a problem with pointers

Started by
2 comments, last by kappa 20 years ago
I am trying to do a class wich I can use to load my textures in OpenGL, I got everthing working exept when I whant to store the bitmap in AUX_RGBImageRec *TextureImage wich I have used new on to create an array of those. how would I do this?

//..code	

	AUX_RGBImageRec *TextureImage;

	TextureImage = new AUX_RGBImageRec [n];


	memset(TextureImage, 0, sizeof(void *)*n);
	
	for(int x = 0; x<n; x++)
	{
                //This does not work apparantly

		if(TextureImage[x]=this->LoadBMP(mFilename[x].c_str()))
		{
			status=true;

			glGenTextures(1, &mTexture[x]);
			
//..code

[edited by - kappa on March 27, 2004 11:42:49 AM]
Advertisement
I don''t have but a moment to look at it but I think you have to do this... try changing this:

AUX_RGBImageRec *TextureImage;...//This does not work apparantlyif(TextureImage[x]=this->LoadBMP(mFilename[x].c_str())) 


to

AUX_RGBImageRec *TextureImage;...//This does not work apparantlyif(TextureImage[x]=(*AUX_RGBImageRec)this->LoadBMP(mFilename[x].c_str())) 


-Greven
Ok...TextureImage should be a pointer right? so you need a pointer to a pointer instead so you want this...

AUX_RGBImageRec **TextureImage;

TextureImage = new AUX_RGBImageRec*[n];

You should keep in mind OpenGL doesn't store the actual pointer you are using, it keeps an identifier to the image



[edited by - PatrickD on March 27, 2004 12:55:17 PM]
Thank you, that did it.

This topic is closed to new replies.

Advertisement