Jump to content
  • Advertisement

archaos90

Member
  • Content Count

    32
  • Joined

  • Last visited

Community Reputation

122 Neutral

About archaos90

  • Rank
    Member
  1. archaos90

    Quad Rotation Problem

    Doesn't work. All that happened when I did as you said was that the sprites got scaled by a factor of 0.5.
  2. I'm having problems with rotating a sprite in OpenGL. The graphics is set to 2D and I have my own coordinate system management (for several good reasons), which is why I am not translating. The problem is that while rotating, the very z-axis it rotates around itself seems to be located at (0,0). What I want is that it should rotate around the middle of the sprite, meaning it should only rotate and not move from the upper-right corner down to the lower-left corner and then continue rotating outside of the screen the rest of the 270 degrees. Here's the OpenGL code: glBindTexture(GL_TEXTURE_2D, *texture->getGLTexture()); glPushMatrix(); glRotatef(angle, 0, 0, 1); glBegin(GL_QUADS); glTexCoord2i(0, 0); glVertex3f(x1, y1, 0.0f); glTexCoord2i(1, 0); glVertex3f(x2, y1, 0); glTexCoord2i(1, 1); glVertex3f(x2, y2, 0); glTexCoord2i(0, 1); glVertex3f(x1, y2, 0); glEnd(); glPopMatrix(); if(angle < 360) { angle++; } else { angle = 0; } Help would be appreciated.
  3. If it works and if performance meets your expectations, then there's nothing wrong with it. That's rule <insert number here> of programming.
  4. archaos90

    VBO and immediate textures

    And something else that might be worth adding. What I am rendering for now is mainly text, rendered by the SDL_ttf library. The SDL_Surface's that TTF_RenderText_Solid returns, I convert into an OpenGL texture. I only do this once or every time I want to set a new text to the menuitem, not every time a frame is drawn. Some time ago I thought the performance lacked because there was color format differences that's being spooky, but then I made sure that I convert the SDL_Surface's to the same format as the screen surface. In short words; I render text into OpenGL textures by using SDL_ttf and converting SDL_Surface's into OpenGL textures. With the texture in the computer memory, I render the texture every frame. To me, this should be an effective way and shouldn't impact my framerate as much as it does (~120 fps with nothing to draw, ~15-25 fps when drawing 4-5 textures).
  5. archaos90

    VBO and immediate textures

    Quote:Original post by dpadam450 Alright, what you mean by immediate mode is that the drawing is in immediate mode. Two things: 1.) Sending 4 texcoords, and 4 positions every frame to display a texture each frame is negligable. How many textured quads are you planning on drawing? 2.) The only other code you can put at "Insert code here" is either a VBO or a display list. Just google those. Like I said though, unless your rendering high poly terrain or a ton of quads, dont worry about it. Okey, I trust you. But that doesn't explain the HUGE fps drop I get everytime I render stuff. Any other explanation?
  6. archaos90

    VBO and immediate textures

    Quote:Original post by dpadam450 "What I want to do is to have a OpenGL texture and render it using vertex and color arrays" Huh. Well VBO's are strictly for models. It is fast cuz the models are stored on the GPU. Textures are by default put on the GPU. So if you just want to render a texture, then the only way it to render a quad, and set the texture on it. Other than that, I don't know what you mean. I understand why you don't understand what I was asking about earlier. I just didn't know the question itself. I've done some studying now and I think I can ask the right question now. To clarify my problem I'll give you some samples code. Here is the method I am currently using. The function is called every time a frame is drawn which makes the method unsuitable. void UMenuitem::Refresh() { VTexture *texture; if(active) { texture = texture_active; } else { texture = texture_normal; } int w = texture->width(); int h = texture->height(); glBindTexture(GL_TEXTURE_2D, *texture->getGLTexture()); glBegin(GL_QUADS); glTexCoord2i(0, 0); glVertex3f(x, y, 0.0f); glTexCoord2i(1, 0); glVertex3f(x + w, y, 0); glTexCoord2i(1, 1); glVertex3f(x + w, y + h, 0); glTexCoord2i(0, 1); glVertex3f(x, y + h, 0); glEnd(); } What I want to do is to render it with an intermediate method as opposed to the immediate one I am currently using. If someone knows what I should do, please qoute the following code and fill in the missing code. I know there are other methods for rendering textures than with immediate rendering. void UMenuitem::Refresh() { VTexture *texture; if(active) { texture = texture_active; } else { texture = texture_normal; } int w = texture->width(); int h = texture->height(); glBindTexture(GL_TEXTURE_2D, *texture->getGLTexture()); // ... insert your code here } I hope I have made my self clear now. If not, please tell me. Otherwise, please help.
  7. archaos90

    OpenGL problems

    Quote:Original post by jyk The Red Book would be a good place to look for examples (I may be wrong, but I think it's freely available online). If after that you're still running into problems, post your code here or in the OpenGL forum, and someone will most likely be able to help. I've looked through it already. The book is also mainly using immediate rendering too instead of the intermediate one I am looking for. Also, there isn't much "code" I am having problem with. It's just I don't know what to do, really. This is as much code you can elaborate on: void UMenuitem::Refresh() { VTexture *texture; if(active) { texture = texture_active; } else { texture = texture_normal; } int w = texture->width(); int h = texture->height(); glBindTexture(GL_TEXTURE_2D, *texture->getGLTexture()); // ... now what? } Now, it looks like this: void UMenuitem::Refresh() { VTexture *texture; if(active) { texture = texture_active; } else { texture = texture_normal; } int w = texture->width(); int h = texture->height(); glBindTexture(GL_TEXTURE_2D, *texture->getGLTexture()); glBegin(GL_QUADS); glTexCoord2i(0, 0); glVertex3f(x, y, 0.0f); glTexCoord2i(1, 0); glVertex3f(x + w, y, 0); glTexCoord2i(1, 1); glVertex3f(x + w, y + h, 0); glTexCoord2i(0, 1); glVertex3f(x, y + h, 0); glEnd(); } This last one which I am currently using is very, very slow which is not good because the function is called every time a frame is drawn in my game. It's wellknown that this method of rendering in OpenGL is slow and not designed for realtime rendering. That's why I am looking for another way to render my textures. x and y are members of the UMenuitem class. texture is by the way an object of the class VTexture which is a managing class that manages OpenGL textures and other information relevant to the texture (e.g width, height etc). Because glBindTexture takes a reference instead of a pointer to a OpenGL texture, I dereference the return value from the getGLTexture() which happens to be a pointer to a GLuint variable which is a name of sorts which OpenGL uses to handle my texture which is loaded in memory already. That should explain my code fairly good.
  8. archaos90

    OpenGL problems

    Hey I'm trying to learn OpenGL and I'm beginning with using it in 2D since that's what's most relevant to me right now. I've read some theory about how computer graphics works and all that. What I am trying to do is to simply draw an OpenGL texture. I am NOT going to resort to immediate(glBegin()/glEnd()) rendering since that's way too slow (really, I have tried it already). So I heard about these vertex arrays and I thought I had found the ultimate answer, but unfortunatly there are absolutely ZERO tutorials or examples of how to render a texture using that. Every single tutorial or example uses the immediate methods. Since my question is probably too stupid for the OpenGL forum (which I might really understand) I ask here. Google can't find the answers for me, but maybe you could. Try the challenge! Know what Google does not! Help me!
  9. archaos90

    VBO and immediate textures

    Quote:Original post by V-man If you are making a lot of calls to glVertex, glTexCoord, glNormal, then that would explain the slow down. In that case, VBO will help. This is not a tutorial site. It is for technical info http://www.opengl.org/wiki/General_OpenGL and then there is nehe.gamedev.net for tutorials. There is developer.nvidia.com SDK for examples. Thanks for the answer! I had to read a bit more about OpenGL in theory to really understand what to ask to get answer to want I really want to do. So here goes. What I want to do is to have a OpenGL texture and render it using vertex and color arrays. I have no idea how to do that and I can't find any tutorial or anything covering that topic. I've checked everything among NeHe's stuff too. Any known method for converting OpenGL textures into vertex and color arrays?
  10. Hey I read this tutorial(http://gpwiki.org/index.php/SDL:Tutorials:Using_SDL_with_OpenGL) and I got a question. Can I use the textures I create the way the tutorial describes with VBO rendering? My current project recieves major drops in the framerate (around 25 fps with only ~7 textures onscreen). Since I use immediate rendering in realtime I suspect that's the problem, and that's why I want to use VBO instead. Since I am pretty new to OpenGL I'd prefer tutorials or other resources. Any ideas or other tutorials that covers 2D textures and VBO? Help would be appreciated.
  11. archaos90

    Box2D problem

    Quote:Original post by Colin Jeanne I just set up a project to use Box2D (in VC++ 2008 Express but this should apply anywhere) - here's how to get started: 1. Unzip Box2D 2. Build Box2D using either the provided VS solution files or the makefiles 3. Add the Libraries directory (I believe that is what it was called) from the directory containing Source and Includes directories to the list of places for you linker to look for libraries in 4. Link Box2d.lib or Box2d.a 5. Add the Includes directory to your compiler's places to search for included files 6. Include box2d.h into your files Your project should build and you should be on your way with Box2D. Well, not really. For MinGW-based compilers you'll need to manually patch the b2Math.h file in the "Source/Common"-directory. The first path to do is #include <cmath> to #include <math.h> The second thing to change is inline bool b2IsValid(float32 x) { #ifdef _MSC_VER return _finite(x) != 0; #else return finite(x) != 0; #endif } which should be patched into this: inline bool b2IsValid(float32 x) { #ifdef _MSC_VER return _finite(x) != 0; #else return isfinite(x) != 0; #endif } With those changes done plus what you said will have it work. At least it did for me.
  12. archaos90

    Box2D problem

    Nevermind. I solved the problem. Now I have the basis for a platform Super Mario Bros.-kind of game I'm making, but with realistic physics. I'm having a story and everything planned. Just need someone good at drawing sprites now. The game is called 'The Scientist' and is about, suprisingly, a scientist. He's intentionally unnamed, but not mute. The adventure will start with him creating a Time Machine which he wants to use to save his son who was killed a few years before the game starts. The device does not work as intended and he ends up in various periods of time. In contrast to many other games there is no villain who will play some sort of the last boss. It's an adventurous puzzle-solving game with a few RPG-elements. Time to time dialogs (in text) will occur where the scientist will give some humuorus comments, especially math- and science-oriented jokes. If you remember the first Lost Vikings game? Well, something in the style of that. The gameplay will mainly be about solving puzzles but enemies will come in your way. Your only weapon is physics. Well actually, not the theory of physics. I mean the real deal. Throwing boxes, rocks.. make trees fall down on your enemies etc. You will have use of your brain, trust on that. I'll come back again when I have some alpha version ready - or whenever I run into some seemingly unsolvable problem and ask you for help.
  13. archaos90

    Box2D problem

    Okey, but now the compile complains about some undeclared variable in the Box2D library. I went to check it out and I found these lines: inline bool b2IsValid(float32 x) { #ifdef _MSC_VER return _finite(x) != 0; #else return finite(x) != 0; #endif } These lines leads me to believe that the preprocessor checks if I am trying to compile with VC++, which is not the case, so it defaults to the other of its two supported compiler enviroments (Xcode and CodeBlocks). This should be fixable, but how? Any ideas? p.s This is what the compile said: In file included from include/Box2D/include/../Source/Collision/Shapes/b2Shape.h:22, from include/Box2D/include/../Source/Collision/Shapes/b2CircleShape.h:22, from include/Box2D/include/Box2D.h:36, from main.cpp:16: include/Box2D/include/../Source/Collision/Shapes/../../Common/b2Math.h: In function `bool b2IsValid(float32)': include/Box2D/include/../Source/Collision/Shapes/../../Common/b2Math.h:63: error: `finite' undeclared (first use this function) include/Box2D/include/../Source/Collision/Shapes/../../Common/b2Math.h:63: error: (Each undeclared identifier is reported only once for each function it appears in.) make.exe: *** [obj/main.o] Error 1 Execution terminated
  14. archaos90

    Box2D problem

    Hey, I have ran into this problem surely so many others have, yet I can't find any answers elsewhere so I turn to you now. I want to use Box2D in my project and I'm using the latest Bloodshed Dev-C++ version. All tutorials say nothing about that I can't use that so I'll stick to my favorite IDE. I had a hard time building Box2D itself, but I had to resort to using Visual C++ 2008 Express. Then, I have the library built and all and now I want to be building stuff with it too. I assume I'm supposed to use the lonely Box2D.h include file that came with the source of the library. When I did, it wanted a lot of other header files which led to me having to use the whole source to the library just to compile mine. I know this isn't right, since I just built a static library earlier with the source, so I now realize I'm doing something wrong. Question is, what am I doing wrong and what am I supposed to do? P.s. please don't come with the simple answer "use vc++, it rocks". I love my current IDE and I actually hate VC++. It's bloated and tries to write its own rules regarding how to program. Again, help would be appreciated! D.s
  15. archaos90

    SDL window locking up [SOLVED]

    Quote: Hopefully someone else learns from my mistakes. Oh, and don't code when you're tired. :P Hehe, funny enough, I always solve all bugs I encounter when coding during the day at night when I'm extremely tired. I also find it easier to think. It's like drinking alcohol while coding: http://xkcd.com/323/, it might be the same phenomenon.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!