Sign in to follow this  
FireViper

Problems with Lesson 6

Recommended Posts

I was trying to compile Lesson 6, (loading textures) in my compiler, DevC++ but got some errors. Can someone look at my source code and tell me how to fix it, or fix it for me. You Can get it form here, http://webvision.xdesignz.com/OpenGLSource.zip thanks,

Share this post


Link to post
Share on other sites
There is a reason that people format code nicely with consistent indenting. When I compile your code I get the following errors:
Error E2108 main.cpp 58: Improper use of typedef 'GLvoid' in function LoadGLTextures()
Error E2379 main.cpp 58: Statement missing ; in function LoadGLTextures()
Error E2451 main.cpp 73: Undefined symbol 'width' in function LoadGLTextures()
Error E2451 main.cpp 73: Undefined symbol 'height' in function LoadGLTextures()
Error E2190 main.cpp 91: Unexpected }
Error E2268 main.cpp 330: Call to undefined function 'ReSizeGLScene' in function CreateGLWindow(char *,int,int,int,bool)
Error E2268 main.cpp 398: Call to undefined function 'ReSizeGLScene' in function __stdcall WndProc(HWND__ *,unsigned int,unsigned int,long)

So I jump to line 58 and find:
35 int LoadGLTextures()
36 {
37 int Status=FALSE;
38 AUX_RGBImageRec *TextureImage[1]; // Create Storage Space For The Texture
39 memset(TextureImage,0,sizeof(void *)*1); //Clears TextureImage
40 // Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
41 if (TextureImage[0]=LoadBMP("Data/NeHe.bmp"))
42 {Status=TRUE; // Set The Status To TRUE
43 glGenTextures(1, &texture[0]); // Create The Texture
44 // Typical Texture Generation Using Data From The Bitmap
45 glBindTexture(GL_TEXTURE_2D, texture[0]);
46 // Generate The Texture
47 glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
48 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // Linear Filtering
49 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtering
50 }
51
52 if (TextureImage[0])
53 {
54 if (TextureImage[0]->data){ free(TextureImage[0]->data); }
55 free(TextureImage[0]);
56 }
57
58 GLvoid ReSizeGLScene(GLsizei width, GLsizei height)
59 {
60 if (height==0)
61 {
62 height=1;
63 }
64 return Status; // Return The Status
65 }
66
67
68 glViewport(0, 0, width, height); // Reset The Current Viewport
69 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
70 glLoadIdentity(); // Reset The Projection Matrix
71
72 // Calculate The Aspect Ratio Of The Window
73 gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
74
75 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
76 glLoadIdentity(); // Reset The Modelview Matrix
77 }




If I rewrite that with proper indenting:
35 int LoadGLTextures()
36 {
37 int Status=FALSE;
38 AUX_RGBImageRec *TextureImage[1]; // Create Storage Space For The Texture
39 memset(TextureImage,0,sizeof(void *)*1); //Clears TextureImage
40 // Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
41 if (TextureImage[0]=LoadBMP("Data/NeHe.bmp"))
42 {
43 Status=TRUE; // Set The Status To TRUE
44 glGenTextures(1, &texture[0]); // Create The Texture
45 // Typical Texture Generation Using Data From The Bitmap
46 glBindTexture(GL_TEXTURE_2D, texture[0]);
47 // Generate The Texture
48 glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
49 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // Linear Filtering
50 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtering
51 }
52
53 if (TextureImage[0])
54 {
55 if (TextureImage[0]->data)
56 {
57 free(TextureImage[0]->data);
58 }
59 free(TextureImage[0]);
60 }
61
62 GLvoid ReSizeGLScene(GLsizei width, GLsizei height)
63 {
64 if (height==0)
65 {
66 height=1;
67 }
68 return Status; // Return The Status
69 }
70
71
72 glViewport(0, 0, width, height); // Reset The Current Viewport
73 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
74 glLoadIdentity(); // Reset The Projection Matrix
75
76 // Calculate The Aspect Ratio Of The Window
77 gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
78
79 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
80 glLoadIdentity(); // Reset The Modelview Matrix
81 }




The error moves to line 62 and the problem is now clear. You have horibly mixed up the functions ReSizeGLScene and LoadGLTextures. Separate them and the errors are reduced to:
Error E2190 main.cpp 95: Unexpected }

Sort out the indentation again and you'll find the function looks like this:
int InitGL(GLvoid)								// All Setup For OpenGL Goes Here
{
// some code
}
}

So get rid of the additional closing brace and everything should compile fine.

Share this post


Link to post
Share on other sites
This is what says Linker:
undefined reference to `auxDIBImageLoadA@4'
undefined reference to `ChoosePixelFormat@8'
undefined reference to `SetPixelFormat@12'
undefined reference to `SwapBuffers@4'

On your first post you said you were able to fix the probem. Can you mail me to source. My screenname is viperblaze01@yahoo.com

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this