Jump to content
  • Advertisement
Sign in to follow this  
DeadlyDan

OpenGL Execessive Lag With Non-Uniform Textures ( Eg. 256x128 )

This topic is 3912 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, i've been programming a sprite class in OpenGL which also has the ability to render specific parts of a sprite. My code works perfectly at the moment except for one problem. With non-uniform textures such as 256x128 when trying to render the CPU usage of my program goes really high and causes windows to respond slowly etc. I've gone through my code and have realized that the bulk of the CPU usage comes from the following code:
	glTexCoord2f ( left, top );	
	glVertex2f ( 0, 0 );

	glTexCoord2f ( right, top ); 
	glVertex2f ( ( offset.w - offset.x ), 0 );

	glTexCoord2f ( right, bottom ); 
	glVertex2f ( ( offset.w - offset.x ), ( offset.h - offset.y ) );

	glTexCoord2f ( left, bottom ); 
	glVertex2f ( 0, ( offset.h - offset.y ) );
When commented out the remaining CPU usage is average 5-6. My code is perfectly fine when using uniform texture sizes but i absolutely need to use non-uniform textures... Any help is GREATLY appreciated. Thanks :)

Share this post


Link to post
Share on other sites
Advertisement

hey ,

1) what kind of gfx do u have it?
2) do u have the latest driver?
3) which Window API are u using?
4) what is the setup code for the device ?
5) how can u setup the texutre in ogl?

Share this post


Link to post
Share on other sites
Hi... Here's what my specifications are:

1) NVidia GeForce 8800 GTX
2) Yes
3) I'm using SDL with OpenGL
4) The device setup code is done through SDL
5) I use SDL_image to load the image into a surface, then set it through opengl using glTexImage2D etc.

Share this post


Link to post
Share on other sites
Hey guys, a few hours of searching and i game up with a solution. I'm now using GL_TEXTURE_RECTANGLE_ARB instead of GL_TEXTURE_2D. The lag is completely gone.

Thanks. :)

Share this post


Link to post
Share on other sites
NVidia GeForce 8800 GTX is a high-end customer product. Most of the recently GPU updates are available. In particular, non-power-of-2 texture is one of them.

You should have no problem to use non-power-of-2 dimension texture with ordinary texture target like GL_TEXTURE_2D on NVidia GeForce 8800 GTX.

For whatever reason, your display card is not functioning correctly. The first thing you should try is to update your display card driver. If it didn't work, you should check whether your computer have other kinds of hardware failures (e.g. having a power supply of not enough power).

Share this post


Link to post
Share on other sites
Quote:
Original post by ma_hty
NVidia GeForce 8800 GTX is a high-end customer product. Most of the recently GPU updates are available. In particular, non-power-of-2 texture is one of them.

You should have no problem to use non-power-of-2 dimension texture with ordinary texture target like GL_TEXTURE_2D on NVidia GeForce 8800 GTX.

For whatever reason, your display card is not functioning correctly. The first thing you should try is to update your display card driver. If it didn't work, you should check whether your computer have other kinds of hardware failures (e.g. having a power supply of not enough power).


2nd'ed

I have a GF8600 GTS and I can load non rectangle textures without lag, using the ordinary texture_2d target. However the same application on my laptop will lag to about 1 FPS (radeon 9600 mobile).
Check your drivers

Share this post


Link to post
Share on other sites
if the same code works heaps faster with GL_TEXTURE_RECTANGLE_ARB instead of GL_TEXTURE_2D on a gf8
i assume its cause youre not setting the texture corrdinates correctly

GL_TEXTURE_2D has normalized texture coords eg 0.0->1.0
GL_TEXTURE_RECTANGLE_ARB does 0->texture width


thus a 256x128 sized texture
glTexCoord2f(256,128) with GL_TEXTURE_RECTANGLE_ARB thats the corner of it, with G_TEXTURE_2D, this is tiling the texture 10000s of times (which is slow)

Share this post


Link to post
Share on other sites
Quote:
With non-uniform textures such as 256x128
What kind of a beast is "Non-Uniform Textures"?
Do you mean "non-power of 2"?
But 256 & 128 are exactly powers 2...

Do you by any chance have automatic mipmap generation enabled?
It can be slow for non-power of 2 textures.

Share this post


Link to post
Share on other sites
Quote:
Original post by bjarniaHowever the same application on my laptop will lag to about 1 FPS (radeon 9600 mobile).

Radeon 9600 has limited support for NPow2 textures - no mipmaping, must be clamped to edge...

Share this post


Link to post
Share on other sites
Quote:
Original post by bjarnia
Quote:
Original post by ma_hty
NVidia GeForce 8800 GTX is a high-end customer product. Most of the recently GPU updates are available. In particular, non-power-of-2 texture is one of them.

You should have no problem to use non-power-of-2 dimension texture with ordinary texture target like GL_TEXTURE_2D on NVidia GeForce 8800 GTX.

For whatever reason, your display card is not functioning correctly. The first thing you should try is to update your display card driver. If it didn't work, you should check whether your computer have other kinds of hardware failures (e.g. having a power supply of not enough power).


2nd'ed

I have a GF8600 GTS and I can load non rectangle textures without lag, using the ordinary texture_2d target. However the same application on my laptop will lag to about 1 FPS (radeon 9600 mobile).
Check your drivers


learning what the hw can do is part of the learning process :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!