A Question about glTexImage2D() and using memory

hi.

When I call this code over again.

glBindTexture(GL_TEXTURE_2D,m_texIDText);

glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,m_nWidth,m_nHeight,0,GL_RGBA,GL_UNSIGNED_BYTE,(GLvoid*)m_bits);

I know that the increase of memory is occurred irregularly untill my program is over.
Although I change texture Data, I use same Texture ID.

I guess, This is a abnormal phenomenon. right?

I tested PC using PowerVR libraries before porting mx31 board.

Hi Daniel,

The code looks fine. You can call glTexImage2D on the same texture name as often as you want. That’s perfectly legal.

Looks like there is a bug in that OpenGL implementation.

As a workaround you might call glDeleteTextures followed by glBindTexture on the texture name before calling glTexImage2D. This will - if exist - remove the texture from memory prior to reloading or better said reallocating it.

I know that it is a bit strange to do this since you use texture names that have been deleted, but according to the spec that’s ok. (Also it works in practice - at least on desktop OpenGL).

Nils

I think I’m seeing the same behavior…

I’m trying to copy a video frame to a texture during each RenderView() call. Basically, I create a texture initially…


//:::INIT:::
glGenTextures(1, &m_textureID);
glBindTexture(GL_TEXTURE_2D, m_textureID);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

Then for each frame, I do something like the following to update the texture…


//Render
glBindTexture(GL_TEXTURE_2D, m_textureID);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,m_nWidth,m_nHeight,0,
                     GL_RGB,GL_UNSIGNED_BYTE,(GLvoid*)m_pBuffer);

Where my buffer is the new video frame. I’m totally new to OpenGL, but it seems pretty obvious that the repeating call to glTexImage2D is the problem b/c if I comment it out, my app won’t just hang after ~2 seconds but instead I’ll get a white square on the screen. I have checked and double checked the height/width and I’m pretty sure the format and everything of the buffer is correct b/c I get a video to play on the quad for a little while.

I too am using the i.mx31. I have tried doing


//Render
glDeleteTextures(1, &m_textureID);
glGenTextures(1, &m_textureID);
glBindTexture(GL_TEXTURE_2D, m_textureID);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,m_nWidth,m_nHeight,0,
                     GL_RGB,GL_UNSIGNED_BYTE,(GLvoid*)m_pBuffer);

with no luck. Am I doing something terribly wrong? I have also tried glSubTexImage2D, but the same thing happens. Is there a way to track how much memory is being used by OGLES? My entire Init and Render functions are probably no more than 2 pages worth of text.

Thanks for all answers.
I don’t call glDeleteTexture(); I just reuse same texture Id.
Even the RGBA data size is same.
But…
As I just said. My memory increased 4Kb memory unsteadily continuously
untill my program is over.

It isn’t clear to me whether this happens on PC emulation, i.MX31, or both?

This problem only happends on PC emulation.
I haven’t tested MBX lite based on OMAP2430 untill now. Not i.MX31.

Is this only pc emulation bug?

This happens directly on my i.mx31 board running Linux 2.6.19.2 and the respective GL drivers.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.