Sign in to follow this  
Sean H

problems with nehe's lesson 6

Recommended Posts

Sean H    122
Im having some problems compiling lesson 6 under vse on my vista machine. I have the platform sdk installed properly and I have already successfully compiled a number of glut and general opengl apps successfully. I also made sure to copy the 'data' folder to the same folder where the new executable is created. Still, whenever I run the program I get a non-descriptive run time error. The precompiled exe that it comes with works fine, but my created executable(which is twice as big for some reason) just refuses to work. Anyone experience this problem with visual studio express? edit: I forgot to mention that I didn't make any changes to the project or code, I just opened it and attempted to compile it. It compiled fine on the first try with no errors. also I'm using the visual c++ version of the lesson, not the .NET version. any help would be appreciated.

Share this post


Link to post
Share on other sites
Sean H    122
I didn't think to try that. I just did it and I got the message:

"Unhandled exception at 0x00401064 in lesson6.exe: 0xC0000005: Access violation reading location 0x00000000."

I'm not sure what this means, but it says it was unable to write out the source code.

Share this post


Link to post
Share on other sites
Durfy    109
Check out the libraries that are included. I believe they are something like glut32.lib etc etc lol. Maybe the version has changed?
-durfy

Share this post


Link to post
Share on other sites
Sean H    122
well this tutorial doesn't use glut. glut.lib isnt one of the files linked into the project so I dont think it's looking for that.

Share this post


Link to post
Share on other sites
cshowe    360
You're dereferencing a NULL pointer. You should check the return of all functions that return a pointer and make sure it's not 0. Also you might wish to enable debugging information in the project settings - this would allow the debugger to give you an exact line of the source code on which the null pointer dereference occurs.

Share this post


Link to post
Share on other sites
cshowe    360
Lets see:

Under project properties look at C/C++->General->Debug Information Format

and make sure that's set to something other than Disabled - Program Database for Edit and Continue is probably best

Also Linker->Debugging->Generate Debug Info should be yes

Then just make sure you run it from the IDE by clicking start debugging rather than start without debugging and you should break to the debugger when the violation occurs

Share this post


Link to post
Share on other sites
Sean H    122
OK I'm getting close to figuring out the problem. thanks to cshowe, I was able to pinpoint the problematic line:

"glBindTexture(GL_TEXTURE_2D, texture[0]);"

I'm not sure why this line is causing an error since it isn't using a pointer. it looks like texture[0] is being set properly:

"glGenTextures(1, texture);"

where texture is being defined as:

"GLuint *texture;"

the funny thing is that this code works fine when compiled under vc6, but vse chokes on it. I'll see if I can figure this out. If I do, I'll post my findings. also it's worthy to note that I've since downloaded other lessons from nehe and they compile and work fine. it looks like it's just this lesson that's causing an error.

Share this post


Link to post
Share on other sites
Sean H    122
OK I was able to get the lesson 6 nehe tutorial to run properly after commenting out two occurences of the same line:

"glBindTexture(GL_TEXTURE_2D, texture[0]);"

after removing all occurences of this line, the program runs fine with correct texture mapping. anyone care to guess what the problem is and why this line causes an error?

Share this post


Link to post
Share on other sites
CrimsonSun    336
glGenTextures only fills an array: it does not create one for you. Your pointer does not point to an array, it points to a GLuint. You're trying to access a part of an array that does not exist (because there is no array) and the texture[0] that you pass is not dereferenced (although fixing this will not fix your program because there is no array). If you're interested in creating only one texture at a time, I'd suggest creating a GLuint on the stack and passing its address to the glGenTextures function using the address-of operator (&).

Share this post


Link to post
Share on other sites
Sean H    122
thanks for the explanation Crimsonsun. this was the problem:

"GLuint *texture;"

this should be an array:

"GLuint texture[1];"

when I loaded the project into vc6, it was kept as an array like it should be. but for some reason when I opened it up in visual studio express, and converted it to the compatible project type, it was converted it to a GLuint pointer. this is what was causing the problem. thanks everyone for the help.

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