VBO and immediate textures

Started by
8 comments, last by dpadam450 15 years ago
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.
Advertisement
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.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
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?

"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.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

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.


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.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

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?
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).
call glGetString(GL_VENDOR), glGetString(GL_VERSION)
to know what you are running on.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Are your textures powers of 2?

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

This topic is closed to new replies.

Advertisement