Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: texture/lighting help needed

  1. #1
    Member Newbie
    Join Date
    Sep 2002
    Location
    Cookeville, TN, United States
    Posts
    36

    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
    -Dogcow "moof!"
    Visit The Underground

  2. #2
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Location
    Fort Collins, Colorado
    Posts
    446

    Re: texture/lighting help needed

    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.

  3. #3
    Member Newbie
    Join Date
    Sep 2002
    Location
    Cookeville, TN, United States
    Posts
    36

    Re: texture/lighting help needed

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

    Code :
    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
    -Dogcow "moof!"
    Visit The Underground

  4. #4
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Location
    Fort Collins, Colorado
    Posts
    446

    Re: texture/lighting help needed

    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).]

  5. #5
    Senior Member Regular Contributor
    Join Date
    Oct 2002
    Location
    King George, Virginia
    Posts
    132

    Re: texture/lighting help needed

    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).]

  6. #6
    Member Newbie
    Join Date
    Sep 2002
    Location
    Cookeville, TN, United States
    Posts
    36

    Re: texture/lighting help needed

    Originally posted by jebus:
    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).]
    Damn man, nice call. I totally overlooked that.

    Thanks a lot,
    -Dogcow "moof!"
    Visit The Underground
    -Dogcow "moof!"
    Visit The Underground

  7. #7
    Member Newbie
    Join Date
    Sep 2002
    Location
    Cookeville, TN, United States
    Posts
    36

    Re: texture/lighting help needed

    Originally posted by yakuza:
    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).]
    Yes, I'm using OS X.

    I tried removing my second

    Code :
    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
    -Dogcow "moof!"
    Visit The Underground

  8. #8
    Member Contributor
    Join Date
    Jul 2001
    Location
    Sherbrooke
    Posts
    95

    Re: texture/lighting help needed

    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*
    Let's have a funny day

  9. #9
    Member Newbie
    Join Date
    Sep 2002
    Location
    Cookeville, TN, United States
    Posts
    36

    Re: texture/lighting help needed

    Originally posted by Evil-Dog:
    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

    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!"
    -Dogcow "moof!"
    Visit The Underground

  10. #10
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Location
    Fort Collins, Colorado
    Posts
    446

    Re: texture/lighting help needed

    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.

Page 1 of 2 12 LastLast

Similar Threads

  1. openGL urgent help needed: no texture, no graphic
    By rahulbansalmit in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 03-09-2009, 06:58 AM
  2. PBO Texture update double vram needed?
    By Ingrater in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 04-19-2008, 07:22 AM
  3. Texture compression tutorial needed
    By Benshee in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 08-09-2005, 07:39 AM
  4. Help needed(Texture Mapping)
    By qasim1981 in forum OpenGL ES
    Replies: 12
    Last Post: 01-15-2005, 10:50 AM
  5. Texture Mapping theory needed
    By Nil_z in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 03-26-2001, 06:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean