• Advertisement
Sign in to follow this  

ok, don't groan.. lesson 6 problems, yes..

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

Hello peoples, I did fine with lessons 1-5 and the tutorials are excellent (ok, so lesson 1 was a bit boring, but 2-5 were a good time!) So yep, I've started Lesson 6 today and when I compile and run it, I get this initialization error? Anyway, so I downloaded the glAux Replacement.cpp and included it in the file like this: #include "glAux Replacement.cpp" Furthermore, I commented out the int LoadGLTextures() and the InitGL() functions in Lesson 6. I'm not sure if I am commenting out the right functions... are they? Ok, so I get these errors now: undeclared identifier \glaux replacement.cpp(42) : error C2065: 'window' : undeclared identifier \glaux replacement.cpp(42) : error C2065: 'Keys' : undeclared identifier \glaux replacement.cpp(42) : error C2065: 'keys' : undeclared identifier \glaux replacement.cpp(43) : error C2448: 'Initialize' : function-style initializer appears to be a function definition \lesson1.cpp(21) : error C2040: 'keys' : 'bool [256]' differs in levels of indirection from ''unknown-type'' The first four errors are related to the glAux Replacement.cpp's Initialize function:
BOOL Initialize (GL_Window* window, Keys* keys)				
{
	g_window	= window;
	g_keys		= keys;

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


I know most people are sick of this one questions, but as I beginner, I do need the help. Someone vaguely touched on this in my first post, but that's too vague for me. If someone can give me step-by-step directions about how to overcome these errors and successfully compile lesson 6, I will REALLY APPRECIATE IT! I really need those specifics, as a beginner, or I get too frustrated, which doesn't lead to good things :( Plus, if any one of you can help me, this post can help other n00bs who will inevitably run into this problem. ---Edit---- glAux Replacement.cpp is from NeHe main page on the left side. I can try the bmp.h and bmp.cpp suggestions. I just want to be able to compile lesson 6 successfully.. btw, has someone here done so already? [Edited by - sspeedy on July 7, 2006 1:30:04 AM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by sspeedy

Anyway, so I downloaded the glAux Replacement.cpp and included it in the file like this:
#include "glAux Replacement.cpp"



#include cpp files in your project is a terrible idea. If you are referring to the post that has the bmp.cpp and bmp.h source code, then you should add the bmp.cpp file to your project and add #include "bmp.h" instead of #include <glaux.h>.

Share this post


Link to post
Share on other sites
im not too sure about all your other errors, but your 'keys' one looks fairly simple. you have a variable defined as:

bool keys[256];

whereas your using it as Keys, just look at your error.
so instead of putting in Keys, put in keys so its not capital K anymore.

hope that helps,
--nathan

Share this post


Link to post
Share on other sites
I had a look trough the replacement code on the main Nehe page, and i now know why it didn't work..

1. it's written to work on the nehe basecode and not lesson 6.

2. you should not include the "glAux Replacement.cpp" in the project, you should instead cut and paste the code into the basecode.

So to get it to work you have to replace the LoadGLTextures() function with the NeHeLoadBitmap() function.
Secondly in InitGL() you have to replace the first if statement

if (!LoadGLTextures())
{
return FALSE;
}

with

if (!NeHeLoadBitmap("Data/NeHe.bmp", texture[0]))
return FALSE;

the way this and the replacement code i posted works is simmilar (i even think the original source of the code is the same), exept mine replaces the specific glAux function in question and Nehe's the whole texture loading function.

Share this post


Link to post
Share on other sites
Quote:
Original post by lc_overlord
I had a look trough the replacement code on the main Nehe page, and i now know why it didn't work..

1. it's written to work on the nehe basecode and not lesson 6.

2. you should not include the "glAux Replacement.cpp" in the project, you should instead cut and paste the code into the basecode.

So to get it to work you have to replace the LoadGLTextures() function with the NeHeLoadBitmap() function.
Secondly in InitGL() you have to replace the first if statement

if (!LoadGLTextures())
{
return FALSE;
}

with

if (!NeHeLoadBitmap("Data/NeHe.bmp", texture[0]))
return FALSE;

the way this and the replacement code i posted works is simmilar (i even think the original source of the code is the same), exept mine replaces the specific glAux function in question and Nehe's the whole texture loading function.



hey thanks lc_overlord! How come there are no official, clear instructions on how to fix stuff for lesson 6? That would definitely help n00bs like me out. Plus, with the replacement code, there was an Initialize function. What was that for?

After I made the changes you mentioned, I ran it and got the same initialization error.... and then i realized why.. i don't have a Nehe.bmp! heh, so I just took an image, resized it, and voilah! I stared at my rotating cube in admiration for a min. and a half.

this forum has been so helpful so far. here i go on to lesson 7 tonight!

Share this post


Link to post
Share on other sites
Quote:
Original post by sspeedy
hey thanks lc_overlord! How come there are no official, clear instructions on how to fix stuff for lesson 6? That would definitely help n00bs like me out. Plus, with the replacement code, there was an Initialize function. What was that for?


Trust me, it is going to be rewritten soon, lesson 6 is one of the reasons we are rewriting the lessons instead of just adding to them.
So, yay no more glAux stuff. :)

As i said before, it was written for the nehe basecode and that has BOOL Initialize (GL_Window* window, Keys* keys) instead of InitGL(), and your supposed to replace the top part of it, i have to admit that the documentation is a bit thin, this is why we are working on this.

Share this post


Link to post
Share on other sites
hey lc, since you've helped me out, I'll ask more questions here. I would've created a new thread, but don't want to look like an attention whore. It's to do with lesson 7, and I'm making mistakes but can't catch 'em. Here they are (if I don't get any responses, guess i'll make a new thread then).

For lesson 7, Nehe modifies the LoadGLTextures() function. I'm using the NeHeLoadBitmap(LPTSTR szFileName, GLuint &texid) function. I tried to do the best I could with the changes he made. For instance, in LoadGLTextures, he uses:

glGenTextures(3, &texture[0]);

So, I modified glGenTextures(1, &texid); in NeHeLoadBitmap to glGenTextures(3, &texid[0]);

Can the argument GLuint &texid be an array? Assuming yes, wherever NeHe used glBindTexture(GL_TEXTURE_2D, texture[0]); I used glBindTexture(GL_TEXTURE_2D, texid[0]); ...and so on (basically substituted texid for texture within the function). Hope ya get the point. When I do this, I get these errors:


C4996: 'fopen' was declared deprecated
error C2109: subscript requires array or pointer type
error C2109: subscript requires array or pointer type
error C2109: subscript requires array or pointer type
error C2109: subscript requires array or pointer type



The errors correspond to these exact lines (I know this is getting repetitive, but can't hurt to show loc):

glGenTextures(3, &texid[0]);
glBindTexture(GL_TEXTURE_2D, texid[0]);
glBindTexture(GL_TEXTURE_2D, texid[1]);
glBindTexture(GL_TEXTURE_2D, texid[2]);

Share this post


Link to post
Share on other sites
Did you convert texid to an array, because that error souldn't pop up unless you didn't do that.

GLuint texid[3]; <- it should look like this
GLuint texid; <- and not like this

Share this post


Link to post
Share on other sites
Quote:
Original post by lc_overlord
Did you convert texid to an array, because that error souldn't pop up unless you didn't do that.

GLuint texid[3]; <- it should look like this
GLuint texid; <- and not like this


I remember changing it to GLuint textid[] (w/o the 3). Why should it be
NeHeLoadBitmap(LPTSTR szFileName, GLuint texid[3]) and not
NeHeLoadBitmap(LPTSTR szFileName, GLuint &texid[3])?

forgetting the little things obviously, argh.

Share this post


Link to post
Share on other sites
actuarly now that i think about it it should perhaps be
bool NeHeLoadBitmap(LPTSTR szFileName, GLuint *texid)
and texture should be an array, it depends a little on how you are solving this.

Share this post


Link to post
Share on other sites
Quote:
Original post by lc_overlord
actuarly now that i think about it it should perhaps be
bool NeHeLoadBitmap(LPTSTR szFileName, GLuint *texid)
and texture should be an array, it depends a little on how you are solving this.


yes sir, you're right. I changed it to GLuint *texid and most errors went away. It only had a problem with these two lines from InitGL(GLvoid) function:
if (!NeHeLoadBitmap("crate.bmp", texture[0]))
return FALSE;

The error was something like 'can't convert GLuint to *GLuint. I simply took away the [0] from texture, and it compiled and runs now.

it's amazing how I can't remember the basics of working with chars, arrays etc. anyone wanna offer an easy to follow explanation here?

I feel like I'm the only one who gets overwhelmed by programming. Lessons 6 and 7, I need to review as I'm not sure I understand filters. Otherwise, these tutorials are quite exciting! And I appreciate your patience with me, lc_overlord. definitely makes it easy to learn when you're not getting criticized!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement