Advertisement

How to accelerate texture mapping in OpenGL!!!

Started by March 05, 2003 06:46 AM
10 comments, last by cggm 21 years, 11 months ago
I have a question as follows. While I render the mesh with texture mapping, the Frame rate is always slow down. (I use the OpenGL, Win32 and Visual C++ 6.0) Therefore, I think whether having any technique to accelerate the rendering speed with texture mapping, e.g., using hardware approach or others. If you can tell me any related approach, excluding View Frustum and Occlusion Culling, to slove above question, I will thank you very much. In addition, That is so great if having any example(Source Code) written in OpenGL and C/C++. Sincerely!!!
What are your system specs? Can you be a little more clear about exactly what you''re doing, drawing, etc.

Maybe you can sort your meshes by texture, to reduce state changes... But I''m not really sure what you''re trying to do..
Advertisement
First, thanks for your answer.
My program is executed on WindowsXP and the Code is written by Visual C++ 6.0 with OpenGL.
My drawing code is as follows:
----------------------------------------------
glBindTexture(GL_TEXTURE_2D, Texture No.);
glBegin(GL_TRIANGLES);
glNormal3fv(Normal);
glTexCoord2fv(V1.UV);
glVertex3fv(V1.XYZ);
glTexCoord2fv(V2.UV);
glVertex3fv(V2.XYZ);
glTexCoord2fv(V3.UV);
glVertex3fv(V3.XYZ);
glEnd();
----------------------------------------------
I know when rendering with texture mapping, the speed will decrease. However, now I have to draw a model(scene) with many textures, but a large number of texture cause bad frame rate. Accordingly, I think whether having any technique can accelerate the performance of texture mapping, e.g., maybe use hardware approach etc.
Really thanks for you. ^^
How about drawing using arrays?
Use GL_LINEAR_MIPMAP_NEAREST when creating the texture. It speeds up my programs quite a bit. NeHe has a tut on it too.
batch triangles with same texture and draw them in one call to VA

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
Advertisement
Thanks for everyone to reply my question.

Because I use the "Normal Mask technique", which checks per face every time, to do the backface Culling, I can''t use the Vertex Array to accelerate the rendering.
Therefore, does having any other approach accelerate the render speed?

In another OpenGL news, someone tells me to try the "hardware texture compression", but i don''t know it. ><|||
Who can tell me about it or other approaches.
Thanks very much.
And WHY you can''t use vertex arrays???

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
I hadn''t heard of ''Normal masks'' before, so I spent 5 minutes googling and found this. Which seems to be an old-skool way of doing backface culling back when drawing a single face was expensive. Assuming you''re actually using some sort of 3d hardware (which since you mention OpenGL is pretty much certain) then this is almost certainly a Bad Thing.

Chuck the normal masks in the bin, and use the standard backface culling via vertex winding. Then stick your triangles into a vertex array or display list, sorted by texture.

In general, if you find yourself doing things per face or per vertex, you''re going to have performance problems (unless you can use GF3+ hardware, but we''ll ignore that for now).

(500x7 + 56k == teh suck)
On some hardware set ups its even faster to simply draw the polys rather than check for backfacing! GTA3 on the PC has no backface culling because it was originally coded for the PS2 and on that system backface culling is slower than straight drawing.

To maximise performance sort your vertices by texture to minimise state changes (a google search should explain this if you want to understand more) and render them as vertex arrays.

Doz

This topic is closed to new replies.

Advertisement