• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

389 Neutral

About fcoelho

  • Rank
  1. SDL 1.2.(14?) on Linux

    [quote name='PrestoChung' timestamp='1334100273' post='4930035'] What does this mean, exactly. How can I run ./configure if I'm not in the SDL directory? [/quote] That usually means something along the lines of: [code]mkdir sdl-build cd sdl-build ../configure[/code] I'm not sure though if it can be a sub-directory of the root SDL folder..
  2. Middle-clicking a link on pretty much any browser will make the link open in a new tab while still focusing the tab you clicked the link from. When in the GDnet front page, clicking any news link will have it open in a new tab and will focus that new tab, which means I can't easily open all the links I'd like to read in new tabs. Also, left-clicking those links will open a new tab, but if I go back to the news page and click on another story, it will "reuse" the previously opened tab.
  3. You can use the following, it will traverse the file tree recursively (won't follow symbolic links) and add the file and directory names to the appropriate vectors. It won't add the base directory (you can add it yourself and check with [font="Courier New"]boost::filesystem::is_directory[/font]) and will throw if "path" isn't a directory. [source lang="cpp"] void GetFiles(const std::string &path, std::vector<std::string> &file, std::vector<std::string> &dir) { try { boost::filesystem::recursive_directory_iterator it(path); boost::filesystem::recursive_directory_iterator end; for ( /**/ ; it != end ; ++it) { if (boost::filesystem::is_regular_file(*it)) { file.push_back(it->path().generic_string()); } else if (boost::filesystem::is_directory(*it)) { dir.push_back(it->path().generic_string()); } } } catch (boost::filesystem::filesystem_error &e) { std::cerr << "Error reading files: '" << e.what() << "'\n"; } } [/source]
  4. If you have any in/out variables in those shaders, make sure each is "shared" with two [b]subsequent[/b] shader stages, i.e.: If your vertex shader has some variable which tou want to send to your fragment shader, say, a [font="Courier New"]out vec2 someVar[/font], be sure to include in your geometry shader too: [source lang="cpp"] //vertex out vec2 someVarToGS; void main() { someVarToGS = ... } //geometry in vec2 someVarToGS[]; out vec2 someVarToFS; void main() { for (each vertex) { someVarToFS = ... EmitVertex(); } ... } //fragment in vec2 someVarToFS; void main() { ... } [/source] Your geometry shader is also empty, which will produce nothing. You have to output your vertices for something to be rendered
  5. Since I couldn't find any reasonable solution, I've modified tolua++ to accept free function operators. In short, tolua++ is already able to correctly generate off-class operator bindings, but doesn't know what to do with them. If the error directive on operator.lua is supressed, [source] if not t:inclass() then --error("#operator can only be defined as class member") end [/source] then generated code for some operator will live in the global namespace. If one opens the generated bindings and moves the lines corresponding to those operators to inside the class module, operator overloading works nicely, i.e., if [source lang="cpp"] tolua_beginmodule(tolua_S,NULL); ... tolua_beginmodule(tolua_S,"b2Vec2"); ... tolua_endmodule(tolua_S); tolua_function(tolua_S,".mul",tolua_lancamento__mul00); tolua_endmodule(tolua_S); [/source] is changed to [source lang="cpp"] tolua_beginmodule(tolua_S,NULL); ... tolua_beginmodule(tolua_S,"b2Vec2"); ... tolua_function(tolua_S,".mul",tolua_lancamento__mul00); tolua_endmodule(tolua_S); tolua_endmodule(tolua_S); [/source] then the custom operator works. Since I didn't want to do this every time the package file changed, I've modified the lua sources to register the function in the right place automatically, relying on the first parameter of the operator argument list to determine who to bind that operator to. So, if there's an [font="Courier New"]operator+(const b2Vec2&, const b2Vec2&)[/font], it gets added to the b2Vec2 class. Pretty lame, but gets the work done, as long as the first parameter is a custom type. It is extremely simple, so there are possibly a lot of corner cases that I didn't test, but it works for me. Some restrictions: [list] [*]Due to the way operator overload works in Lua, no operator+=, operator-= etc. (already considered by tolua++) [*]If the first argument of a certain type isn't a custom type, the binding generation will fail. In these cases, I had to define a "wrapper" operator just for the sake of it, like: [source lang="cpp"] inline b2Vec2 operator*(const b2Vec2 &a, float s) { return operator*(s,a); } [/source] [/list] To be honest, I'm not used to patching, but if anyone's interested, attached is the diff file from my mercurial repository.[attachment=4820:offclassop.zip]
  6. I'm trying to create bindings for Box2D to use within Lua with tolua++. Tolua++ can generate operator bindings when they're defined as members of the given class, but not when they're free functions. In order to properly use Box2D in Lua, I'd like to generate bindings for its vector (b2Vec2) operators, which are defined as free functions. How can I create these bindings? [url="http://www.rasterbar.com/products/luabind/docs.html#operators"]Luabind seems to be able to handle this[/url], but I'd rather do it with tolua++ if there's a (easy) way.
  7. Need help making game - Python

    [quote name='Durakken' timestamp='1309138092' post='4828066'] Sorta what I am talking about. I haven't tried it with the gameIsRunning variable... [source lang="python"] while 1: if GameMode == "StartMenu": pass elif GameMode == "..." ... for event in pygame.event.get(): if event.type == QUIT: pygame.quit() screen.blit(background, (0,0)) pygame.display.flip() [/source] this is what causes it. I don't know why. I'm curious as it should work like that but it doesn't for me. [/quote] The only problem with that code is the use of pygame.quit() in the event loop, causing the screen variable to be invalid. Other than that, it's ok.
  8. Need help making game - Python

    [quote]If I move the for loop out the if...elif structure and put it under it between it and the blit, the #draw everything stuff. And then run it. If I then click on the X instead of closing the window will say "not responding" then go open up a Windows error window.[/quote] From your description, I've came up with: [source lang="python"] while gameIsRunning: if GameMode == "StartMenu": pass elif GameMode == "..." ... for event in pygame.event.get(): if event.type == pygame.QUIT: gameIsRunning = False screen.blit(background, (0,0)) pygame.display.flip() pygame.quit() [/source] Which will run and quit without issues, so I don't think I know what you've done. Care to show some code?
  9. Need help making game - Python

    [quote]Thank you, can you tell me why a simple break doesn't work where you place gameisRunning = False (hit the close button does nothing)?[/quote]That's because [font="Courier New"]break[/font] will put you out of the innermost loop. In this case, the [font="Courier New"]for[/font] loop, not the [font="Courier New"]while[/font] loop. [quote]or why moving the for loop to about the blit it causes the game to stop responding?[/quote] I can't really tell what do you mean with that, or to [i]where[/i] the for loop really goes.
  10. I need help learning to program (python)

    [quote name='Kpyrate' timestamp='1309116110' post='4827974']in the introduction when it is stating that: - print "hello, world!" - will generate the quoted texted, I only get syntax errors. [/quote] If a simple [code]print "Hello, world"[/code] fails with a syntax error, that's most likely because you're running Python version 3 instead of Python 2. In that case, [url="http://openbookproject.net/thinkcs/python/english3e/"]check the link for the third edition of the book, which uses Python 3.[/url]
  11. Need help making game - Python

    [font="Courier New"] pygame.quit()[/font] doesn't quit your game. It just tells Pygame to get rid of it's resources, it's a cleanup method. When [font="Courier New"]pygame.QUIT[/font] is received, your program calls [font="Courier New"]pygame.quit()[/font] and it deletes a few things here and there, but your program keeps running. When you get to the line "[font="Courier New"]screen.blit(background, (0, 0))[/font]", the variable [font="Courier New"]screen[/font] is invalid, causing the [font="Courier New"]blit[/font] to fail. Instead of running everything inside a [font="Courier New"]while 1[/font] loop, keep a variable to tell whether your game is running, and set it in the event loop accordingly: [code] gameIsRunning = True while gameIsRunning: for e in pygame.event.get(): if event.type == QUIT: gameIsRunning = False [/code] After that, place [font="Courier New"]pygame.quit() [/font][font="Arial"]outside the game loop, so you don't run into invalid data.[/font]
  12. Shadow mapping difficulties

    I've tried to change my create_fbo function, especially the texture clamping modes to see if there was a change, but the "replica" of the shadow right above the correct one still appears. Any ideas on how do I fix it? [code]FBO create_fbo(unsigned width, unsigned height) { FBO fbo; glGenFramebuffers(1, &fbo.id); glBindFramebuffer(GL_FRAMEBUFFER, fbo.id); glGenTextures(1, &fbo.zId); glGenTextures(1, &fbo.cId); glBindTexture(GL_TEXTURE_2D, fbo.cId); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); glBindTexture(GL_TEXTURE_2D, fbo.zId); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fbo.cId, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, fbo.zId, 0); GLenum fboStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (fboStatus != GL_FRAMEBUFFER_COMPLETE) std::cerr << "Framebuffer incomplete\n"; return fbo; }[/code]
  13. Shadow mapping difficulties

    In the fragment shader, something is considered shadowed when [code] if (depthFromLight < depthFromCamera) shadow = 0.5;[/code] But this creates the following artifact: [attachment=1626:samplingbehindfrustum.jpg] I've tried to use what's on [url="http://www.fabiensanglard.net/shadowmapping/index.php"]this[/url] site: [code] if (position.w > 0.0)[/code] but it doesn't fix it, it stays the same. I tried to use a "inFrustum" variable to check whether I should check the shadow map for texturing: [code]bool inFrustum = shadowCoord.x > 0.0 && shadowCoord.x < 1.0 && shadowCoord.y > 0.0 && shadowCoord.y < 1.0;[/code] But it creates another problem: [attachment=1625:infrustum.jpg] So, how do I fix this? [list=1][/list]
  14. Shadow mapping difficulties

    The bias matrix is responsible for converting clip coordinates to a "texture coordinate acceptable range", i.e., converting the range [-1,+1] to [0,1]. I solved the problem a few hours ago, it was actually a bug with my math library + compiler version, which caused the bias matrix to be built incorrectly, instead of the expected [code] [.5 0 0 .5] [ 0 .5 0 .5] [ 0 0 .5 .5] [ 0 0 0 1] [/code] it compiled into [code] [ 1 0 0 .5] [ 0 0 0 0] [ 0 0 0 0] [ 0 0 0 0] [/code] It's mostly working now, except for some shadows outside the light frustum which I haven't been able to remove. I'm going to post it back here when I get home.
  15. Shadow mapping difficulties

  • Advertisement