Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7176373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:29:36+00:00 2026-05-28T16:29:36+00:00

I have a function which loads an image/text into my game.I’m using gluBuild2DMipmaps() to

  • 0

I have a function which loads an image/text into my game.I’m using gluBuild2DMipmaps() to make an OpenGL texture from the SDL surface.The problem is that everytime when I call that function, even if I load the same image and bind it on the same texture, gluBuild2DMipmaps allocates 0.5MB of memory which is not released until I close the program.
My function:

void Load_texture(const char * text, SDL_Color clr, int txtNum, const char* file, int ptsize, bool type){
if(type){
         tmpfont = TTF_OpenFont(file, ptsize); 
         sText = TTF_RenderUTF8_Blended( tmpfont, text, clr );
         TTF_CloseFont(tmpfont);
}
if(!type)sText = IMG_Load(file);
area[txtNum].x = 0;area[txtNum].y = 0;area[txtNum].w = sText->w;area[txtNum].h = sText->h;
glGenTextures(1, &texture[txtNum]);
glBindTexture(GL_TEXTURE_2D, texture[txtNum]);
gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGBA, sText->w, sText->h, GL_RGBA, GL_UNSIGNED_BYTE, sText->pixels );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR );
SDL_FreeSurface( sText ); 
}

What can I do to release the memory allocated by gluBuild2DMipmaps, because now my game uses almost 1GB of RAM one minute after it starts.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:29:37+00:00Added an answer on May 28, 2026 at 4:29 pm

    Are you sure you free the texture itself? Do you call

    glDeleteTextures(1, &texture[txtNum]);
    

    …before reusing the txtNum texture?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a simple jQuery.ajax function which loads a user control from the
I have a function A which loads the data from db if the user
I have the following javascript code, which loads without error, however the update function
I have a function which parses one string into two strings. In C# I
I have a function which gets a key from the user and generates a
i have a function which retrieves values from a webservice , then loops through
I have a function which loads some content when executed... IE... function load_product(product_id) {
I have a function Load() in a js file which I added to the
I have a load of php templates which uses a custom translate function __,
I have a function which searches an STL container then returns the iterator when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.