Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 9 of 9

Thread: Free AUX_RGBImageRec ressource impossible

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    5

    Free AUX_RGBImageRec ressource impossible

    Hello,
    I have a huge problem with openGL programs.

    Actually when I get create a AUX_RGBImageRec* with a malloc or thanks a function from OpenGL libraries, it is impossible for removing it with a free.

    So I think you can understand that it is a problem for me especially for memory management and I really don't understand why.

    Has somebody an idea to help me with this problem or is there somebody who has already met that?

    Thanks.
    Livevlad

  2. #2
    Junior Member Newbie
    Join Date
    Jul 2011
    Location
    USA
    Posts
    3

    Re: Free AUX_RGBImageRec ressource impossible

    This isn't even an OpenGL question. Allocating and freeing memory is something you learned when you started programming in C/C++. I'd suggest getting rid of that ancient library Glaux and start using something a little more modern like FreeImage, SOIL, or DeVIL, or write your own loader.

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    5

    Re: Free AUX_RGBImageRec ressource impossible

    Thank you for your answer but I need to use this structure especially and trust me I know how works allocation memory that's why I have a problem.
    Why desallocation does not work with this glaux structure.
    I tried asking solution to some friends very good in programming I I think I have good programming capacities too. So if I ask help to people of this forum it is because I have already searched a solution everywhere.

    So if everybody has another idea.

    Thank you.

  4. #4
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    5

    Re: Free AUX_RGBImageRec ressource impossible

    I would like be more accurate:

    actually I can't free the structure if I use this function:

    AUX_RGBImageRec* example = auxDIBImageLoad(filename);

    free(example); //doesn't work

    I tried too delete although glaux is a C library instead of free but it doesn't work too.

    Thx.

  5. #5
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,732

    Re: Free AUX_RGBImageRec ressource impossible

    I need to use this structure especially
    I'm curious: what circumstances have put you in the position that you need to use GLaux? Because I can't imagine those being good circumstances.

  6. #6
    Member Regular Contributor
    Join Date
    Aug 2008
    Posts
    381

    Re: Free AUX_RGBImageRec ressource impossible

    Looking at http://nehe.gamedev.net/tutorial/texture_mapping/12038/ , they use:

    Code :
    if (TextureImage[0])                       // If Texture Exists
    {
        if (TextureImage[0]->data)             // If Texture Image Exists
        {
            free(TextureImage[0]->data);       // Free The Texture Image Memory
        }
     
        free(TextureImage[0]);                 // Free The Image Structure
    }
    so do you need to free "example->data" before freeing "example"?

  7. #7
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    5

    Re: Free AUX_RGBImageRec ressource impossible

    No very interesting circumstances, I just need to know how to use it perfectly for a project and because I want to know it too^^

    I know that SOIL library is better but glaux is lower level in programmation that's why I prefer it; to get more control if you prefer. But this problem of free will provok memory leak so it is a serious problem if I want to do something very professionnal.

  8. #8
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,732

    Re: Free AUX_RGBImageRec ressource impossible

    but glaux is lower level in programmation that's why I prefer it
    Low level, high level, it doesn't matter; it's trash. It's garbage code that hasn't been updated or even touched in over a decade.

    You shouldn't judge code based on whether it's low level or high level. You should judge code based on whether it's API makes sense, whether it does what it's supposed to, and how well supported it is.

    GLaux has a crappy API, doesn't support many image formats, and hasn't been touched since the phrase "DOT COM" was coined.

    it is a serious problem if I want to do something very professionnal.
    If you wanted to do something "professionnal[sic]", you wouldn't be using GLaux. Professionals use real libraries, libraries that are supported by people.

  9. #9
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    5

    Re: Free AUX_RGBImageRec ressource impossible

    so do you need to free "example->data" before freeing "example"?

    Yes of course I need to free that before but if I free that before it doesn't work too. It seems that compiler thinks the data address was not created thanks to malloc. Why not. But I really don't understand because it seems that only I meet this problem.
    I tried to copied an existing code like NEHE's example but I meet the same problem...

Posting Permissions

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