Archived

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

Help with tut 10 again, this time with code

This topic is 5537 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

Hi This is the attempt of my basic engine on the foundation of Lesson 10. I am trying to make it multi-texturing. It was crashing before so I have rewritten the code. I keep getting tonnes of errors int LoadGLTextures() { int Status=FALSE; AUX_RGBImageRec *texture[100]; memset(texture,0,sizeof(void *)*1); char* string; FILE* TexFile; TexFile=fopen("data\\worldtex.txt", "rt"); char* path; sscanf(string, "%d\n", &NumTexture); for(int i=0;i=LoadBMP(path)) { Status=TRUE; glGenTextures(1, &texture[i]); glBindTexture(GL_TEXTURE_2D, texture[i]); glTexImage2D(GL_TEXTURE_2D, 0, 3, texture[i]->sizeX, texture[i]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, texture[i]->data); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); } if (texture[i]) // If Texture Exists { if (texture[i]->data) // If Texture Image Exists { free(texture[i]->data); // Free The Texture Image Memory } free(texture[i]); // Free The Image Structure } } fclose(TexFile); return Status; } I am getting the errors: ''glGenTextures'' : cannot convert parameter 2 from ''struct _AUX_RGBImageRec ** '' to ''unsigned int *'' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast error C2664: ''glBindTexture'' : cannot convert parameter 2 from ''struct _AUX_RGBImageRec *'' to ''unsigned int'' This conversion requires a reinterpret_cast, a C-style cast or function-style cast Now I know this is due to the fact that the array cannot handle interger data types. However I was wondering if there was a type cast to convert the interger to an AUX_RGBImageRex. Or if someone knew a way round it. Also i was wondering if that code would actually work once I get through this problem... all help is much appreciated DhexB

Share this post


Link to post
Share on other sites
thats not working. you need the image data just for loading the image and building a texture out of it. So you should create it dynamically. Then you need a second array of GLuint. In this array you generate the texture. after your texture was generated you should delete your image data because then the texture is already in the video memory of your card and your image variable worthless.

Share this post


Link to post
Share on other sites