Skip to main content
gamedev.net
🔒 Locked

CTexture Problems

Started by CtrlAltDel 3 replies 300+ views
Original Post
CtrlAltDel
CtrlAltDel
I am trying to write a small class file that will represent Textures in my programs, however, I am by no means a good programer and am having trouble resolving some link errors und MSVC++ 6. Here is my CTexture Class where I beleive my problem lies: class CTexture { public: GLuint texture; //Where the texture is stored. this->texture int LoadGLTextures(char path[256]) // Load Bitmaps And Convert To Textures { int Status=FALSE; // Status Indicator AUX_RGBImageRec *TextureImage= NULL; // Create Storage Space For The Texture memset(TextureImage,0,sizeof(void *)*1); // Set The Pointer To NULL // Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit if (TextureImage=LoadBMP(path)) { Status=TRUE; // Set The Status To TRUE glGenTextures(1, &this->texture); // Create The Texture // Typical Texture Generation Using Data From The Bitmap glBindTexture(GL_TEXTURE_2D, this->texture); glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage->sizeX, TextureImage->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage->data); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); } if (TextureImage) // If Texture Exists { if (TextureImage->data) // If Texture Image Exists { free(TextureImage->data); // Free The Texture Image Memory } free(TextureImage); // Free The Image Structure } return Status; // Return The Status } private: AUX_RGBImageRec *LoadBMP(char *Filename) // Loads A Bitmap Image { FILE *File=NULL; // File Handle if (!Filename) // Make Sure A Filename Was Given { return NULL; // If Not Return NULL } File=fopen(Filename,"r"); // Check To See If The File Exists if (File) // Does The File Exist? { fclose(File); // Close The Handle return auxDIBImageLoad(Filename); // Load The Bitmap And Return A Pointer } return NULL; // If Load Failed Return NULL } }; And here is an implementation of that class(most of it): CTexture text; if (!text.LoadGLTextures("Data/text.bmp")) // Jump To Texture Loading Routine ( NEW ) { return FALSE; // If Texture Didn't Load Return FALSE } glBindTexture(GL_TEXTURE_2D, text.texture); glBegin(GL_QUADS); // Front Face glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Back Face glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Top Face glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); // Bottom Face glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Right face glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Left Face glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); glEnd(); After debuging I finally condensed my errors down to the nice number of 26 They are all link errors and have me stumped. They all look like: main.obj : error LNK2001: unresolved external symbol _gluPerspective@32 main.obj : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0 main.obj : error LNK2001: unresolved external symbol __imp__glMatrixMode@4 main.obj : error LNK2001: unresolved external symbol __imp__glViewport@16 If 1the code looks familiar it is because it is based of Nehe's Tutorial 6,7,8. Any Ideas? [edited by - CtrlAltDel on December 8, 2002 8:29:31 PM] [edited by - CtrlAltDel on December 8, 2002 8:41:12 PM]
CtrlAltDel
CtrlAltDel
No I added opengl32.lib to the wrong project.

However I still error when the program runs:

First-chance exception in Cube.exe: 0xC0000005: Access Violation.


I have no idea how to use MSVC++ built in debugging...
niyaw
niyaw
some of the following may help.

http://www.gamedev.net/community/forums/topic.asp?topic_id=98522
http://www.gamedev.net/community/forums/topic.asp?topic_id=98664
http://www.gamedev.net/community/forums/topic.asp?topic_id=100019

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.