glDeleteTextures problem [Solved]

Recommended Posts

darren_mfuk    148
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
}


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 on other sites
Agony    3452
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 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 on other sites
darren_mfuk    148
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 !!

Create an account

Register a new account