Archived

This topic is now archived and is closed to further replies.

cggm

How to accelerate texture mapping in OpenGL!!!

Recommended Posts

cggm    122
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!!!

Share this post


Link to post
Share on other sites
James Trotter    432
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..

Share this post


Link to post
Share on other sites
cggm    122
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. ^^

Share this post


Link to post
Share on other sites
xiros    122
Use GL_LINEAR_MIPMAP_NEAREST when creating the texture. It speeds up my programs quite a bit. NeHe has a tut on it too.

Share this post


Link to post
Share on other sites
cggm    122
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.

Share this post


Link to post
Share on other sites
OrangyTang    1298
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)

Share this post


Link to post
Share on other sites
Doz    122
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.

Share this post


Link to post
Share on other sites
ChookMaster    138
If you find that the more textures you have, the slower you go, then textures are your limiting factor. Solve this problem before trying vertex arrays etc.

Make sure you only do 1 glTexImage2D per image - ie. make sure it is not in your display list.

Again, since textures are you limiting factor, try to bind each texture only once per frame (ie, draw everything with the same texture at the same time as suggested earlier).

The problem might simply be that the total of your required image memory is greater that the memory on your card - this will cause the images to "churn" through your memory. The symptom of this would be that you load a couple of images ok, and then suddenly you load one more and the performance drops.

You can use glAreTexturesResident to check to see how well things are going - and consider dropping to a lower res version of your textures if they start going AWOL. (or buy a new graphics card !). Texture compression, or palette texture extensions, should also help here, giving you a "virtual factor of 4" extra graphics memory if you card supports it.

Since you are using OGL, you should already be using hardware acceleration (if your card supports it).

Share this post


Link to post
Share on other sites