Results 1 to 4 of 4

Thread: glBindTexture and memory

  1. #1
    Member Contributor
    Join Date
    Feb 2001
    Location
    Hungary
    Posts
    60

    glBindTexture and memory

    Under C++Builder I wrote the following code:


    FILE *ff;
    textureim = new unsigned char [512*512*4];

    ff=fopen("d:\\000.bma","rb");
    fread(textureim,128*128*4,1,ff);
    fclose(ff);


    glGenTextures(1, &backgr[0]);
    glBindTexture(GL_TEXTURE_2D, backgr[0]);

    I use GeneralMemoryStatus to watch how much memory I have left, like that:

    GlobalMemoryStatus(&ms);
    Edit1->Text=ms.dwAvailPhys;

    When I reach the "glBindTexture" line, I see, that something eats up my memory. I tested all lines, but the memory 'runs away' only, if I use glBingTexture. If I make an 'X-thousand-times' loop, my prog will surely crash.
    Is there a possibility to free the memory, allocated by glBindTexture, or is GlobalMemoryStatus wrong, or did I missed out something?

  2. #2
    Senior Member Regular Contributor
    Join Date
    Apr 2003
    Location
    Toulouse, France
    Posts
    133

    Re: glBindTexture and memory

    do you mean that if you do:
    while(1) glBindTexture(GL_TEXTURE_2D, texid);
    the memory run away ???

    or the textureim = new unsigned char [512*512*4]; is included in the loop ???????????????????????????

  3. #3
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: glBindTexture and memory

    glGenTextures(); will allocate memory to store the texture object's informations (not the teximage, yet).
    glBindTexture() only switches between those texture objects and shouldn't increase the memory, well, except for the first usage in case the necessary few control informations like filter, priority etc. are allocated lazily in the driver or when you're downloading the teximages for the first time.
    Of course your memory will run out if you generate too many texture objects. Virtual address space is only 2 GB on Win32, so the possible ids itself would exceed that.
    Use glDeleteTextures to cleanup unused texture objects. (Was that your question?)

    [This message has been edited by Relic (edited 07-02-2003).]

  4. #4
    Member Contributor
    Join Date
    Feb 2001
    Location
    Hungary
    Posts
    60

    Re: glBindTexture and memory

    So, You mean, if I use glDeleteTextures each time I have a glGenTextures, I will have the same quantity of memory? (if yes: right, that was my question!)
    Thanx!

Similar Threads

  1. GlBindTexture?
    By Bagoj in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-09-2004, 10:19 PM
  2. Need help with glBindTexture
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 12-01-2002, 01:31 PM
  3. Can I get texture address in memory from glBindTexture?
    By LangFox in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 11-02-2002, 03:25 AM
  4. glBindTexture...
    By RandyU in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-17-2001, 01:12 PM
  5. glbindtexture
    By wavey do in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-07-2000, 11:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean