Jump to content
  • Advertisement
Sign in to follow this  
virtualpaul

Problem uploading textures

This topic is 1736 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

I am using the following code to upload my textures on the GPU in a loop before starting to render but I get some 'random' out of memory (1285) error returned by glTexStorage2D.  I also got similar results using glTexImage2D.

 

Sometimes a smaller texture (128x128) returns out of memory but the next one, a bigger one (256x256) returns ok. I checked with GPU-Z and only 180MB of the video card memory (1GB) is used. I also used Gdebugger and there is not much memory used (VBOs, Front/Back buffers, Textures, Shaders). The textures are between 32x32 to 2048x2048. I never succeeded loading a 4096x4096 for some reason.  The textures that do load are displaying correctly.

glGenTextures(1, &TextureID);
showGlError();
glBindTexture(GL_TEXTURE_2D, TextureID);
showGlError();

Nof_MipMap = 2;

glTexStorage2D(
GL_TEXTURE_2D,
Nof_MipMap,
GL_RGBA8,
Image_Width, Image_Height);
glError = showGlError();

glTexSubImage2D(
GL_TEXTURE_2D,
0,
0, 0,
Image_Width, Image_Height,
GL_RGB,
GL_UNSIGNED_SHORT_5_6_5_REV,
Image_Address);
glError = showGlError();

glGenerateMipmap(GL_TEXTURE_2D); //Generate num_mipmaps number of mipmaps here.
glError = showGlError();

glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
showGlError();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
showGlError();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
showGlError();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
showGlError();

Share this post


Link to post
Share on other sites
Advertisement
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!