OpenGL ES reloading textures

Started by
1 comment, last by cdcastro 14 years, 5 months ago
Hi there! I'm working with OpenGL ES and my system does not have enough VRAM so what I am doing is keeping the textures in RAM and unloading/reloading as necessary. The problem is that it does not work. When I unload, reloading gives me a blank texture. It renders the quads white. I added glGetError after all opengl calls of the process and did not find any errors. And I'm getting desperate. Here's a streamlined version of what I'm doing. I kept only the opengl calls, from deleting the textures to loading them again. Before deleting they work fine. After, blank square: // deleting glDeleteTextures(m_uiTextures, (GLuint*)m_pTexture); sdelete [] m_pTexture; m_pTexture = 0; // reloading m_pTexture = (void**)snew GLuint[m_uiTextures]; glGenTextures(m_uiTextures, (GLuint*)m_pTexture); glBindTexture(GL_TEXTURE_2D,m_pTexture[0]); glTexImage2D(GL_TEXTURE_2D, whole_bunch_of_parameters); I then set the filter mode and the wrap mode. Can you see something wrong? Any help would be appreciated. Cheers, Cesar
Advertisement
I'm not a GL ES expert but you probably have this problem
http://www.opengl.org/wiki/Common_Mistakes#Creating_a_Texture

Because getting a white quad means that your texture is invalid.
Are you setting the filter modes to GL_LINEAR or GL_NEAREST?
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);
I looked at that page, went through my algorithms and everything seemed fine. I then noticed because I was saving the texture state locally, my system thought the texture was already with the correct filter mode. I reset the filter mode at unload, just to force the update on load, and it worked.

Thanks for the help!

This topic is closed to new replies.

Advertisement