Archived

This topic is now archived and is closed to further replies.

kappa

a problem with pointers

Recommended Posts

kappa    138
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]

Share this post


Link to post
Share on other sites
Evil_Greven    410
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 apparantly
if(TextureImage[x]=this->LoadBMP(mFilename[x].c_str()))


to


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


-Greven

Share this post


Link to post
Share on other sites
PatrickD    122
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]

Share this post


Link to post
Share on other sites