Jump to content

  • Log In with Google      Sign In   
  • Create Account

Texture unloading


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 ThetaRabbit   Members   -  Reputation: 114

Like
0Likes
Like

Posted 08 March 2012 - 01:30 AM

Hi all. I use SOIL with OpenGL. This is a sample from of code lonesock.net/soil.html :


GLuint tex_2d = SOIL_load_OGL_texture
(
"img.png",
SOIL_LOAD_AUTO,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
);


How can I unload my texture from memory after using this code?

sorry for my bad english.

Sponsor:

#2 RobinsonUK   Members   -  Reputation: 108

Like
1Likes
Like

Posted 08 March 2012 - 02:15 AM

When you say unload, you mean delete the texture?


glDeleteTextures(1, &tex_2d);

The above will delete the texture.

#3 ThetaRabbit   Members   -  Reputation: 114

Like
0Likes
Like

Posted 08 March 2012 - 02:32 AM

I need to delete texture data from memory. glDeleteTextures can do it?

#4 RobinsonUK   Members   -  Reputation: 108

Like
0Likes
Like

Posted 08 March 2012 - 02:36 AM

Yes.



#5 mhagain   Crossbones+   -  Reputation: 7947

Like
1Likes
Like

Posted 08 March 2012 - 06:30 AM

Depends on which memory you want to unload it from. If you want to unload it from video memory then glDeleteTextures is indeed what you want - the texture will be gone (eventually - glDeleteTextures most likely won't remove it immediately and doesn't actually make any promises about the backing memory store (which may e.g. be kept around for potential future reuse) - all it deals with is the texture object name) and you will never be able to use it again in your OpenGL code unless you recreate it.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#6 ThetaRabbit   Members   -  Reputation: 114

Like
0Likes
Like

Posted 08 March 2012 - 10:06 AM

So what, if I want to delete texture from RAM after loading it with SOIL?

#7 mhagain   Crossbones+   -  Reputation: 7947

Like
0Likes
Like

Posted 08 March 2012 - 10:25 AM

I'm not familiar with SOIL but I would be amazed if it didn't already do this for you.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#8 slicer4ever   Crossbones+   -  Reputation: 3883

Like
1Likes
Like

Posted 08 March 2012 - 10:45 AM

looking at the SOIL source, i believe your looking for:

SOIL_free_image_data

look at the header for more information, and i don't claim to be 100% correct, i've never used soil, but i don't see anything else that seems to indicate deleting behavior.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

#9 RobinsonUK   Members   -  Reputation: 108

Like
1Likes
Like

Posted 08 March 2012 - 01:14 PM

looking at the SOIL source, i believe your looking for:

SOIL_free_image_data

look at the header for more information, and i don't claim to be 100% correct, i've never used soil, but i don't see anything else that seems to indicate deleting behavior.


I think that's only if you've loaded the file with SOIL_load_image, because it returns an unsigned char buffer *, not an OpenGL asset ID.

#10 mhagain   Crossbones+   -  Reputation: 7947

Like
1Likes
Like

Posted 08 March 2012 - 05:02 PM

Documented sample code for loading a texture: http://lonesock.net/soil.html and http://libregamewiki...L_Image_Library

SOIL.c, SOIL_load_OGL_texture function, lines 154 and 155:
/*	and nuke the image data	*/
	SOIL_free_image_data( img );

There is no need to do anything yourself to free the data.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#11 slicer4ever   Crossbones+   -  Reputation: 3883

Like
0Likes
Like

Posted 09 March 2012 - 03:21 AM


looking at the SOIL source, i believe your looking for:

SOIL_free_image_data

look at the header for more information, and i don't claim to be 100% correct, i've never used soil, but i don't see anything else that seems to indicate deleting behavior.


I think that's only if you've loaded the file with SOIL_load_image, because it returns an unsigned char buffer *, not an OpenGL asset ID.


you are correct sir, i skimmed over the header file, and saw that, and assumed it was what he was looking for in terms of SOIL consistency.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS