Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Lights hav no effect when texture is on

  1. #1
    Intern Contributor uwi2k2's Avatar
    Join Date
    Mar 2011
    Posts
    98

    Lights hav no effect when texture is on

    Hi all,

    sorry i have a really stupid problem here that is killing me today.

    ich have e simple system with lights on and a lot of cubes with normals and texture coordinates
    taking data from a texture atlas.

    when i turn of 'GL_TEXTURE_2D' the lights are shown correctly according to the normals.
    Click image for larger version. 

Name:	Kaisland-2012-11-27-16-32-1.jpg 
Views:	89 
Size:	13.3 KB 
ID:	912

    but as soon as i turn on the texture all the lighteffect is gone:
    Click image for larger version. 

Name:	Kaisland-2012-11-27-16-32-2.jpg 
Views:	108 
Size:	29.8 KB 
ID:	913


    so the only bad guy could be my texture and the 'Modulate / Replace' setting .. but i tryed so mutch ..
    here it is ..

    Code :
    GLuint LoadTexture( const char * filename, int width, int height )
    {
        GLuint texture;
        unsigned char * data;
        FILE * file;
     
        //The following code will read in our RAW file
        file = fopen( filename, "rb" );
        if ( file == NULL ) return 0;
        data = (unsigned char *)malloc( width * height * 3 );
        fread( data, width * height * 3, 1, file );
        fclose( file );
     
        glGenTextures( 1, &texture ); //generate the texture with the loaded data
        glBindTexture( GL_TEXTURE_2D, texture ); //bind the texture to itís array
        glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); //set texture environment parameters
        //glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
        //glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
     
     //   glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); // GL_LINEAR
     //   glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
     
       // glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
       // glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST );
     
        //Here we are setting the parameter to repeat the texture instead of clamping the texture
        //to the edge of our shape. 
        glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
        glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
     
        //Generate the texture
        //glTexImage2D(      GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
        gluBuild2DMipmaps( GL_TEXTURE_2D, 3, width, height, GL_RGB, GL_UNSIGNED_BYTE, data );
     
        free( data ); //free the texture
        return texture; //return whether it was successfull
    }

    you see, i tryed so many setting, mipmap on/off texture_env, min mag filter .. but nothing changes ...

    can someone pls give me the hint ... it must be so simple that i just dont see it ...

    THANX !!!
    uwi
    uwi2k2 - OpenGL Trainer: www.opengl-trainer.com
    ---------------------------------------------------------
    Free Programming Helpline: www.programming-hotline.com
    ---------------------------------------------------------
    A Friday Night Programmer: www.uwiworld.net

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,209
    Check for GL errors:

    * glGetError (or "How do I check for GL errors?)

    And verify that lighting is still enabled, and that you're setting your vertex material properties properly. Failing that, post a short test program that demonstrates the problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •