• Advertisement
Sign in to follow this  

glDeleteTextures problem [Solved]

This topic is 3963 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey guys ... I am having trouble deleting texture, as it seems to need a constant, what have I missed here.
// card structure
typedef struct cardStruct
{
   // shortened
	GLuint	Texture;	// texture for face of card
   // shortened
} 

const int sizeOfCardDeck = 20;

cardStruct *cards = new cardStruct[sizeOfCardDeck];


This is how I load textures:
  for (int i = 1; i < sizeOfCardDeck + 1; i++) 
  {
   // shortened
    Load_Texture(&cards[i].Texture, filename); 
  }




And I have trouble trying to delete them when finished: glDeleteTextures(sizeOfCardDeck, cards->Texture); OR for (int i = 0; i < sizeOfCardDeck; i++) { glDeleteTextures(1, cards[i].Texture); } Both ways tell me i need a constant (cannot convert parameter 2 from 'GLuint' to 'const GLuint *') [Edited by - darren_mfuk on March 16, 2007 11:09:27 AM]

Share this post


Link to post
Share on other sites
Advertisement
The important thing is not the constant (C/C++ can convert a non-const variable to a const variable no problem, if a function is asking for a const version). The problem is the '*'. I'm no OGL person, but as far as C/C++ goes, it's asking for a pointer to a GLuint, while you're passing an actual instance. Since I'm not familiar enough with OGL, I don't know if the solution is just attach an ampersand (&) to the beginning of "cards[i].Texture", (like you did with Load_Texture()), but it would give you the correct data type.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Agony is correct. Pass the texture id to the glDeleteTextures function as a reference (using the & operator). The reason glDeleteTextures works this way is to allow you to delete an array of texture ids, and is why you need to pass in the size value as the first parameter. The glGenTextures function basically works the same way.

Share this post


Link to post
Share on other sites
Thanks 'Agony' & Anonymous Poster

You know when ya just having one of those blonde days !

Agony, you just got yourself a 'bonus point' on your rating ;-)

Anonymous Poster, you missed out sorry !!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement