• What Do You Need Help With? V6
    7,544 replies, posted
Does anyone here have experience with Gtk# ? I've made a widget that inherits Gtk.Image, but I want to add a click event for it. The main problem is that Gtk.Image doesn't have a click event by default and I don't know Gtk# well enough to add it myself. Has somebody here done this before or know how I should approach the task?
I got around this issue by placing the image widget inside an eventbox widget which allowed me to track click events.
I'm trying to learn about ray-tracing, and i've looked at a lot of resources and got some notes taken down, but what kills me is the maths of it. I've never been great at maths, but i'm pretty determined to get a ray-tracer done - I feel like it'd be a good learning experience. How do I suck less at understanding the maths of ray-tracing? What are the mathematic fundamentals I need to go and learn before I can fully understand how to implement a ray-tracer? I know a couple people in WAYWO have worked on ray-tracers before, so hopefully I could get some informative replies.
[QUOTE=Hng;45307098]I'm trying to learn about ray-tracing, and i've looked at a lot of resources and got some notes taken down, but what kills me is the maths of it. I've never been great at maths, but i'm pretty determined to get a ray-tracer done - I feel like it'd be a good learning experience. How do I suck less at understanding the maths of ray-tracing? What are the mathematic fundamentals I need to go and learn before I can fully understand how to implement a ray-tracer? I know a couple people in WAYWO have worked on ray-tracers before, so hopefully I could get some informative replies.[/QUOTE] Afaik having a good understanding of linear algebra is fundamental to doing anything with computer graphic, because pretty much all computer graphics is based on that field.
Was reading some random articles about computer graphics just now and this guy gives a pretty good summerization of the math behind ray-tracing: [url]http://fabiensanglard.net/RayTracing/freeDirectionTunnel.txt[/url] He also includes an example with a lot of math involved so if you're interested in an example showing the math-skills you need you should definitely read it. Edit: You can double post now?
I am making a platformer in C++, this is my system for storing and drawing tiles: [code] class Tile { public: Tile(); Tile(string path); void draw(int x, int y, int w, int h); void add(int x, int y, int sx, int sy, int w, int h); SDL_Texture* image; int width = ROOM_WIDTH, height = ROOM_HEIGHT; vector<SDL_Rect> tiles; }; Tile::Tile(string path) { //Load tileset image file SDL_Surface* temp = IMG_Load(path.c_str()); //Create a texture from the image SDL_Texture* temp2 = SDL_CreateTextureFromSurface(renderer, temp); //store the texture for later use image = temp2; //Resize the tiles vector tiles.resize(width * height, { -1, -1, -1, -1 }); } // Add a tile void Tile::add(int x, int y, int sx, int sy, int w, int h) { tiles[x + y * width].x = sx; // From X tiles[x + y * width].y = sy; // From Y tiles[x + y * width].w = w; // With width tiles[x + y * width].h = h; // With height } void Tile::draw(int x, int y, int w, int h) { // Set up drawing boundaries int xx = x - 32; if (xx < 0) xx = 0; int yy = y - 32; if (yy < 0) yy = 0; int ww = w + 32; if (ww > ROOM_WIDTH) ww = ROOM_WIDTH; int hh = h + 32; if (hh > ROOM_HEIGHT) hh = ROOM_HEIGHT; // Loop through the X and Y within the boundary for (int dy = yy; dy < hh; dy++) { for (int dx = xx; dx < ww; dx++) { if (tiles[dx + dy * width] .x > -1) { SDL_Rect src = tiles[dx + dy * width] ; SDL_Rect dst = { dx, dy, src.w, src.h }; SDL_RenderCopy(renderer, image, &src, &dst); } } } }[/code] Is this an efficient way of doing it, what can I change so I don't run into issues down the line? [editline]7th July 2014[/editline] The tiles are stored in a vector of SDL_Rects that is resized to room width * room height, the default value is {-1, -1, -1, -1}. Tiles are added using the add function, and drawn with draw. Draw takes a rectangle from the tiles from x, y to w, h. Tiles within 32 pixels outside this region or tiles within this region are drawn. If the tile has the default value (x = -1) then it is not drawn.
Can someone explain to me how winsock2 works? I'm not understanding a few things. For example, why do most of these examples seem to always have two socket calls in their server programs? Why can the following slew of crap not handle more than one client connection? Are the other socket calls in most of these examples client connections themselves? How does one save memory by not opening a dozen sockets before they're needed then? Why can the following slew of crap not handle more than one client connection? (edit: I mean besides the obvious 'the while loop ends as soon as a connection is made') [code] WSADATA wsa; SOCKADDR_IN addr; SOCKET listener; int addrSize = sizeof(SOCKADDR_IN); if (WSAStartup(MAKEWORD(2,2), &wsa)) { cout << "WSAStartup as failed for some dumb reason.\n"; } addr.sin_addr.s_addr = inet_addr("127.0.0.1"); addr.sin_family = AF_INET; addr.sin_port = htons(2220); listener = socket(AF_INET, SOCK_STREAM, NULL); bind(listener, (SOCKADDR*)&addr, sizeof(SOCKADDR_IN)); listen(listener, 10); while (1) { if (connection = accept(listener, (SOCKADDR*)&addr, &addrSize)) { cout << "some shit"; break; } }[/code]
[QUOTE=Pat.Lithium;45314878] [code] class Tile { public: Tile(); Tile(string path); void draw(int x, int y, int w, int h); void add(int x, int y, int sx, int sy, int w, int h); SDL_Texture* image; int width = ROOM_WIDTH, height = ROOM_HEIGHT; vector<SDL_Rect> tiles; }; Tile::Tile(string path) { //Load tileset image file SDL_Surface* temp = IMG_Load(path.c_str()); //Create a texture from the image SDL_Texture* temp2 = SDL_CreateTextureFromSurface(renderer, temp); //store the texture for later use image = temp2; //Resize the tiles vector tiles.resize(width * height, { -1, -1, -1, -1 }); } // Add a tile void Tile::add(int x, int y, int sx, int sy, int w, int h) { tiles[x + y * width].x = sx; // From X tiles[x + y * width].y = sy; // From Y tiles[x + y * width].w = w; // With width tiles[x + y * width].h = h; // With height } void Tile::draw(int x, int y, int w, int h) { // Set up drawing boundaries int xx = x - 32; if (xx < 0) xx = 0; int yy = y - 32; if (yy < 0) yy = 0; int ww = w + 32; if (ww > ROOM_WIDTH) ww = ROOM_WIDTH; int hh = h + 32; if (hh > ROOM_HEIGHT) hh = ROOM_HEIGHT; // Loop through the X and Y within the boundary for (int dy = yy; dy < hh; dy++) { for (int dx = xx; dx < ww; dx++) { if (tiles[dx + dy * width] .x > -1) { SDL_Rect src = tiles[dx + dy * width] ; SDL_Rect dst = { dx, dy, src.w, src.h }; SDL_RenderCopy(renderer, image, &src, &dst); } } } } [/code] [/QUOTE] Not that familiar with SDL but does IMG_Load() load a new copy of the image even if another is already in memory? If not you will be loading a new copy of that image for every tile sharing that same image which is very inefficient. If possible I would implement a resource manager that store all the images for your game with associated path and only load the image from disc if it isn't already in stored by the resource manager. This is just preference but I prefer to have all the code for drawing in it's own renderer class further up the hierarchy and keep the Tile class to a simple structure storing position and texture pointer. This way all the drawing code is collected in that class and only called once per drawing cycle, instead of once in every Tile class.
I have a change I want to make to a repo on Github (not mine). This change is literally a single character fix -- it's for a regexp for syntax highlighting in a ST3 package. Is making a pull request for this tiny change going overboard? Should I just open an issue?
[QUOTE=FPSMango;45316726]Not that familiar with SDL but does IMG_Load() load a new copy of the image even if another is already in memory? If not you will be loading a new copy of that image for every tile sharing that same image which is very inefficient. If possible I would implement a resource manager that store all the images for your game with associated path and only load the image from disc if it isn't already in stored by the resource manager. [/QUOTE] thanks I'll wanted to implement a resource manager at some point, but I was just focused on getting the tiles to work in the first place.
[QUOTE=fauxpark;45324582]I have a change I want to make to a repo on Github (not mine). This change is literally a single character fix -- it's for a regexp for syntax highlighting in a ST3 package. Is making a pull request for this tiny change going overboard? Should I just open an issue?[/QUOTE] Merging the pull request is likely less work for them, I think it automatically creates and closes an issue too. I think you can just click "edit" at that file on GitHub and it will do everything else automatically. If you created an issue they'd have to look up and edit everything manually.
[QUOTE=Tamschi;45325220]Merging the pull request is likely less work for them, I think it automatically creates and closes an issue too. .[/QUOTE] Just confirming it does
Is there any good icon pack for an (human resources) application? The silk icon pack are to small and go ugly if they're stretched bigger than 24 pixels.
Any preference on style? Here are some flat icons: [url]http://www.flaticon.com/packs/[/url] This pack isn't as flat: [url]http://icomoon.io/icons.html[/url] Maybe have a look around conformist/deviantart, there are a good amount of icon authors there.
[QUOTE=Tamschi;45325220]Merging the pull request is likely less work for them, I think it automatically creates and closes an issue too.[/QUOTE] I guess so. I just wondered whether I was worthy of having my name added to the list of contributors for making a single keystroke. I kind of answered my own question when I looked at it and saw a few others had committed one-liners as well. I suppose it's not that rare to see typos fixed in this way.
[QUOTE=fauxpark;45326104]I guess so. I just wondered whether I was worthy of having my name added to the list of contributors for making a single keystroke. I kind of answered my own question when I looked at it and saw a few others had committed one-liners as well. I suppose it's not that rare to see typos fixed in this way.[/QUOTE] The most important thing is that it's fixed. A fix shouldn't take a huge amount of time. A single keystroke fix is also a fix. Think about ; Also a single keystroke, but one that makes the difference between it working and just falling appart.
What's a good way to pack a texture atlas? I was thinking of placing from largest to smallest and just going left to right and scanning for unused space, but are there any better algorithms. Not that it really matters the packer is run in development.
[QUOTE=reevezy67;45334730]What's a good way to pack a texture atlas? I was thinking of placing from largest to smallest and just going left to right and scanning for unused space, but are there any better algorithms. Not that it really matters the packer is run in development.[/QUOTE] This is what I use: [URL]http://www.blackpawn.com/texts/lightmaps/[/URL] [editline]sdf[/editline] Oh and here I made a somewhat modular C++/SFML implementation of a texture atlas using the above method: [URL]https://github.com/naelstrof/invictus/blob/master/src/texture_atlas.cpp[/URL]
Hey everyone I have this snippet of code : [code] foreach (Excel.Worksheet sheet in m_WorkBook.Sheets) { //This adds a new checkbox AddListButton(sheet.Name); //Can this be done easier ? bool found = false; foreach(string str in tabExclude) { if(str == sheet.Name) { found = true; break; } } //Checks the newest added checkbox if (!found) m_CheckBoxes[m_CheckBoxes.Count - 1].Checked = true; } [/code] Wondering if this can be done in a more sane / more readable way (Lambda's? Linq ?) and if so how to do it, I am not really comfortable yet with lambda's or linq
[QUOTE=quincy18;45335762]Hey everyone I have this snippet of code : [code] foreach (Excel.Worksheet sheet in m_WorkBook.Sheets) { //This adds a new checkbox AddListButton(sheet.Name); //Can this be done easier ? bool found = false; foreach(string str in tabExclude) { if(str == sheet.Name) { found = true; break; } } //Checks the newest added checkbox if (!found) m_CheckBoxes[m_CheckBoxes.Count - 1].Checked = true; } [/code] Wondering if this can be done in a more sane / more readable way (Lambda's? Linq ?) and if so how to do it, I am not really comfortable yet with lambda's or linq[/QUOTE] Yep [code] bool found = tabExclude.Any(str => str == sheet.Name); [/code] .Any() returns true if anything in the enumerable satisfies the specified condition.
Can somebody tell me what the reasoning is for the naming convention of mVariable or m_variable for member variables in C++? Do they really need to be distinguished more?
[QUOTE=Duskling;45336573]Can somebody tell me what the reasoning is for the naming convention of mVariable or m_variable for member variables in C++? Do they really need to be distinguished more?[/QUOTE] It's nice to not accidentally be able to make a local assignment, which is very reliably prevented by removing the namespace collision. That's about it.
Does anybody know any ethical hacking websites or general hacking websites? All of the ones I can find are "HACK ANY FB ACCOUNT WITH THESE FIVE TIPS* *must complete survey" I'm just wanting to get a bit of wider reading before I study it at uni.
How do I combine text and a variable in one printf statement in C? [code] printf("%d", age, " years old."); [/code] Only prints the age but not my string.
I'm not well versed in C, but wouldn't you want to do something like this? [code]printf("%d years old.", age);[/code] At least, that's my thought after looking [url=http://www.cprogramming.com/tutorial/printf-format-strings.html]at this C printf tutorial[/url].
How can I do something like this in android, but for checkboxes? [CODE] layout.removeViewAt(x + 2); layout.removeViewAt(x + 1); [/CODE] I have a TextView and a RadioGroup (or EditText), I can remove them by using the code above. If I have say a TextView and 3 CheckBoxes how can I make sure that i remove all 3 checkboxes and not just the first one, is there some kind of way to group them? Or will I have to have some external key:count that keeps track of how many checkboxes there are for that area? This is probably not the 'correct' way of doing it since I probably should remove the view themselves and not whichever view is at the index, but that would mean rewriting a lot of code. The reason i'm not using radiobuttons with multi-choice is to make it more intuitive for the end user. (radiobutton circles for single and checkbox squares for multiple choice) [editline]10th July 2014[/editline] Solved it, while posting it I was searching for some way to check the type of a view so I did it like this. [CODE] while (layout.getChildAt(layout.indexOfChild(rg) + 1) instanceof CheckBox) { layout.removeViewAt(layout.indexOfChild(rg) + 1) } [/CODE]
[QUOTE=Erasus;45339329]Does anybody know any ethical hacking websites or general hacking websites? All of the ones I can find are "HACK ANY FB ACCOUNT WITH THESE FIVE TIPS* *must complete survey" I'm just wanting to get a bit of wider reading before I study it at uni.[/QUOTE] There's [URL="http://hak5.org/"]Hak5[/URL], but it's far from only hacking, more a general security and niche tech show... which may actually be just what you since first and foremost you need extensive general knowledge to discover new vulnerabilities. Then you just have to tests against some service's API or check the source code and hope that you find something. Either that or you stumble into (or in this case be stumbled into) [URL="https://play.google.com/store/apps/details?id=com.ubisoft.watchdogs.hide"]a completely insecure program[/URL] just by accident :v:
I am making application where I am generating files that are later to be analyzed by me on my server. I also want these files that are generated to be encrypted so that the user cannot tamper with them. Anyone know what I can do?
In what language are you doing it? .NET for example has a cryptography library built in. Depending on how secure you want it, you could scramble it yourself.
I'm using C# and net 4.0
Sorry, you need to Log In to post a reply to this thread.