Sign in to follow this  
tieungao35

Lesson 6 help

Recommended Posts

hi all, I could follow all first 5 lessons. Once i move to lesson 6, i got stuck. First of all, i comment out # include <gl\glaux.h>, I have errors. If i # include "glAux Replacement.cpp" and place "glAux Replacement.cpp" in the same directory with the source code, I still have errors. Please help me. PS: i use visual studio 2008.

Share this post


Link to post
Share on other sites
You should never #include a .cpp file, only header files. If there is an associated "glAux Replacement.h" file, include that instead.

If you still get errors after that, post them in their exact form, as well as the code causing them.

Share this post


Link to post
Share on other sites
on the homepage, I see there is only one "glaux replacement.cpp" on the left side.

I just rename it to "glaux replacement.h" and add to the project. After compiling, i have those errors.

1>e:\opengl_t\firstprogram\firstprogram\firstsource.cpp(32) : error C2143: syntax error : missing ';' before '*'
1>e:\opengl_t\firstprogram\firstprogram\firstsource.cpp(32) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\opengl_t\firstprogram\firstprogram\firstsource.cpp(33) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\opengl_t\firstprogram\firstprogram\firstsource.cpp(46) : error C3861: 'auxDIBImageLoad': identifier not found
1>e:\opengl_t\firstprogram\firstprogram\firstsource.cpp(56) : error C2065: 'TextureImage' : undeclared identifier
1>e:\opengl_t\firstprogram\firstprogram\firstsource.cpp(58) : error C2065: 'TextureImage' : undeclared identifier
1>e:\opengl_t\firstprogram\firstprogram\firstsource.cpp(61) : error C2065: 'TextureImage' : undeclared identifier
1>e:\opengl_t\firstprogram\firstprogram\firstsource.cpp(69) : error C2065: 'TextureImage' : undeclared identifier
1>e:\opengl_t\firstprogram\firstprogram\firstsource.cpp(69) : error C2227: left of '->sizeX' must point to class/struct/union/generic type
1>e:\opengl_t\firstprogram\firstprogram\firstsource.cpp(69) : error C2065: 'TextureImage' : undeclared identifier
1>e:\opengl_t\firstprogram\firstprogram\firstsource.cpp(69) : error C2227: left of '->sizeY' must point to class/struct/union/generic type
1>e:\opengl_t\firstprogram\firstprogram\firstsource.cpp(69) : error C2065: 'TextureImage' : undeclared identifier
1>e:\opengl_t\firstprogram\firstprogram\firstsource.cpp(69) : error C2227: left of '->data' must point to class/struct/union/generic type
1>e:\opengl_t\firstprogram\firstprogram\firstsource.cpp(74) : error C2065: 'TextureImage' : undeclared identifier
1>e:\opengl_t\firstprogram\firstprogram\firstsource.cpp(76) : error C2065: 'TextureImage' : undeclared identifier
1>e:\opengl_t\firstprogram\firstprogram\firstsource.cpp(76) : error C2227: left of '->data' must point to class/struct/union/generic type
1>e:\opengl_t\firstprogram\firstprogram\firstsource.cpp(78) : error C2065: 'TextureImage' : undeclared identifier
1>e:\opengl_t\firstprogram\firstprogram\firstsource.cpp(78) : error C2227: left of '->data' must point to class/struct/union/generic type
1>e:\opengl_t\firstprogram\firstprogram\firstsource.cpp(81) : error C2065: 'TextureImage' : undeclared identifier
1>Build log was saved at "file://e:\openGL_t\firstProgram\firstProgram\Debug\BuildLog.htm"
1>firstProgram - 19 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Share this post


Link to post
Share on other sites
Instead of #include "glAux Replacement.cpp", add this line to your main file:

bool NeHeLoadBitmap(LPTSTR szFileName, GLuint &texid);

And in your main file, use the following code instead of the old LoadGLTextures:

GLuint	texture[1];	
...
int LoadGLTextures( ){
if (!NeHeLoadBitmap("Data/NeHe.bmp", texture[0])) // Load The Bitmap
return FALSE;
}


And add glAux Replacement.cpp to your project. (And if you haven't done allready, remove this from the file:

BOOL Initialize (GL_Window* window, Keys* keys)							// Any GL Init Code & User Initialiazation Goes Here
{
g_window = window;
g_keys = keys;

// Start Of User Initialization
if (!NeHeLoadBitmap("Data/NeHe.bmp", texture[0])) // Load The Bitmap
return FALSE;

This piece is only an example usage. So your glAux Replacement.cpp should be like this:

#include <windows.h>
#include <GL/gl.h>

/************************************************************************
REPLACEMENT FOR GLAUX
************************************************************************
This is not a full blown bitmap loader. It is a quick and easy
way to replace the glAux dependant code in my older tutorials
with code that does not depend on the glAux library!

This code only loads Truecolor Bitmap Images. It will not load
8-bit bitmaps. If you encounter a bitmap that will not load
use a program such as Irfanview to convert the bitmap to 24 bits.
************************************************************************/


bool NeHeLoadBitmap(LPTSTR szFileName, GLuint &texid) // Creates Texture From A Bitmap File
{
HBITMAP hBMP; // Handle Of The Bitmap
BITMAP BMP; // Bitmap Structure

glGenTextures(1, &texid); // Create The Texture
hBMP=(HBITMAP)LoadImage(GetModuleHandle(NULL), szFileName, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE );

if (!hBMP) // Does The Bitmap Exist?
return FALSE; // If Not Return False

GetObject(hBMP, sizeof(BMP), &BMP); // Get The Object
// hBMP: Handle To Graphics Object
// sizeof(BMP): Size Of Buffer For Object Information
// &BMP: Buffer For Object Information

glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // Pixel Storage Mode (Word Alignment / 4 Bytes)

// Typical Texture Generation Using Data From The Bitmap
glBindTexture(GL_TEXTURE_2D, texid); // Bind To The Texture ID
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Linear Min Filter
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Mag Filter
glTexImage2D(GL_TEXTURE_2D, 0, 3, BMP.bmWidth, BMP.bmHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, BMP.bmBits);

DeleteObject(hBMP); // Delete The Object

return TRUE; // Loading Was Successful
}

Share this post


Link to post
Share on other sites
well,
I found another way how to fix that kind of compatible bug. Just download the project and open dsw file with visual studio 2008. Then Visual studio 2008 automatically convert the project without any errors. However, if I compile from source the file , then I will have bug due to library compatible. TKs.

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