texture/lighting help needed

I’ve spent the past week and a half working on an OpenGL program for a class. It took me three days just to find a texture loader that would compile, but whenf I attempt to run my program using the texture loader, it exits out. Also, once I added just a few lines of lighting code, my program started not liking the glLookAt function.

Any help would be appreciated. The texture loader code (which opens an image file and places its contents inside a texture) is way beyond my skill level. I have no idea where to start to fix it… The lighting code is very simple and I’m rather confused that it doesn’t work.

main.cpp
glass.tga
floor.tga

Thanks in advance,
-Dogcow “moof!”
Visit The Underground

Does it give any error messages when it exits out? Have you debugged to find where it exits? How can you know if the lighting changes aren’t working correctly if the program just exits?

What I’m seeing is you’re only allocating space for one texture object, yet attempting to load 2 textures. You’re also loading each texture every time you need to use it. You should be loading the texture once, in the Init part of your code, then just binding each texture object as you need to use it.

I’d suggest more closely examining Nehe’s texture tutorial (since you use his tga code), and ask specific questions if you need help.

The errors that the lighting code is producing in the glLookAt Function are:

main.cpp:431: request for member `x' in `position', which is of non-aggregate type `float[4]'
main.cpp:431: request for member `y' in `position', which is of non-aggregate type `float[4]'
main.cpp:431: request for member `z' in `position', which is of non-aggregate type `float[4]'

When I comment out the lighting lines (including the declarations of the arrays), the program will compile and run, but will instantly quit with “Program 2 has exited due to signal 10 (SIGBUS).”

I have no idea how to debug, or where to start to fix this… The code I used for the texture loading is from the mac os example (the windows example used specific windows libraries and the mac os x example used objective c, rather than c.) I’m also somewhat confused of how I could get it to load multiple textures rather than just one. I assume I’d make a larger texture array, but the image loading code is much more complex than any other c code I’ve dealt with and I’m not sure how to proceed.

Thanks,
-Dogcow “moof!”
Visit The Underground

That signal 10 error is a memory error, if I’m not mistaken. This makes sense since you are using one texture object, and trying to use 2 textures with it.

What OS are you using?

Edit: I take it you’re using a Mac, is it OSX?

[This message has been edited by yakuza (edited 10-31-2002).]

simple…you’ve got a global vector structure called ‘position’ and you declare a local float array also named ‘position’ in your main func. bad practice. in main, rename the local, or refer to the global as : osition

EDIT: that needs to be ‘:: position’ w/o the space, forum changed it to a smiley.

jebus

[This message has been edited by jebus (edited 10-31-2002).]

Originally posted by jebus:
[b]simple…you’ve got a global vector structure called ‘position’ and you declare a local float array also named ‘position’ in your main func. bad practice. in main, rename the local, or refer to the global as : osition

EDIT: that needs to be ‘:: position’ w/o the space, forum changed it to a smiley.

jebus

[This message has been edited by jebus (edited 10-31-2002).][/b]

Damn man, nice call. I totally overlooked that.

Thanks a lot,
-Dogcow “moof!”
Visit The Underground

Originally posted by yakuza:
[b]That signal 10 error is a memory error, if I’m not mistaken. This makes sense since you are using one texture object, and trying to use 2 textures with it.

What OS are you using?

Edit: I take it you’re using a Mac, is it OSX?

[This message has been edited by yakuza (edited 10-31-2002).][/b]

Yes, I’m using OS X.

I tried removing my second

loadGLTextures(textureTwo);
    glBindTexture(GL_TEXTURE_2D, texture[0].texID);

And having it just use the same texture for those, but it still exited with the same error. “Program 2 has exited due to signal 10 (SIGBUS).” Any suggestions would be greatly appreciated.

-Dogcow “moof!”
Visit The Underground

Take some time to do a couple of NEHE tutorials at http://nehe.gamedev.net

do the targa loader tutorial and the texturing and lighting ones…
you should be able to do what you want to do
Good luck


Evil-Dog
Let’s have a funny day

Originally posted by Evil-Dog:
[b]Take some time to do a couple of NEHE tutorials at http://nehe.gamedev.net

do the targa loader tutorial and the texturing and lighting ones…
you should be able to do what you want to do
Good luck

[/b]

Unfortunately he uses proprietary win libraries for his texture loader. The loader I used in my program is the only non-platform specific one I could find, and though it will compile, it won’t run.

-Dogcow “moof!”

At the bottom of the tutorial at Nehe is Mac OS X port of the tutorial source code.
http://nehe.gamedev.net/tutorials/lesson.asp?l=24

Hope that helps.

He used the glaux.lib in his first ones, but also has at the bottom of each tutor versions for Max, linux and GLUT.

On my website I have a TGA loader that is very simple to use, the code is used in my blackjack program. It will work on any platform.
http://www.angelfire.com/linux/nexusone/

Originally posted by Dogcow:
[b] Unfortunately he uses proprietary win libraries for his texture loader. The loader I used in my program is the only non-platform specific one I could find, and though it will compile, it won’t run.

-Dogcow “moof!”[/b]