Results 1 to 7 of 7

Thread: A Question about glTexImage2D() and using memory.

  1. #1
    Junior Member
    Join Date
    Oct 2006
    Posts
    28

    A Question about glTexImage2D() and using memory.

    hi.

    When I call this code over again.

    Code :
    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.

  2. #2
    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

  3. #3
    Junior Member
    Join Date
    Oct 2007
    Posts
    2
    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...

    Code :
    //:::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...

    Code :
    //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

    Code :
    //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.

  4. #4
    Junior Member
    Join Date
    Oct 2006
    Posts
    28
    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.

  5. #5
    Senior Member
    Join Date
    May 2006
    Posts
    353

    Re: A Question about glTexImage2D() and using memory.

    Quote Originally Posted by danielkim
    I tested PC using PowerVR libraries before porting mx31 board.
    It isn't clear to me whether this happens on PC emulation, i.MX31, or both?
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  6. #6
    Junior Member
    Join Date
    Oct 2006
    Posts
    28

    Re: A Question about glTexImage2D() and using memory.

    Quote Originally Posted by Xmas
    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?

  7. #7
    Junior Member
    Join Date
    Oct 2007
    Posts
    2
    This happens directly on my i.mx31 board running Linux 2.6.19.2 and the respective GL drivers.

Similar Threads

  1. a question about glTexImage2D
    By wycwang in forum OpenGL ES general technical discussions
    Replies: 1
    Last Post: 03-31-2008, 04:00 AM
  2. a question about glTexImage2D
    By wycwang in forum OpenGL ES general technical discussions
    Replies: 1
    Last Post: 11-13-2007, 12:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •