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 5 of 5

Thread: Material (specular and shininess) not working with GL_FRONT_AND_BACK (under Linux)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member Newbie
    Join Date
    Mar 2017
    Posts
    5

    Material (specular and shininess) not working with GL_FRONT_AND_BACK (under Linux)

    Hi,

    i try to draw a polygon mesh that has to be visible from both sides. Therefore i have set
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
    glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);

    With GL_FRONT or GL_BACK it works fine for one side, however with both it doesn't at all (everything looks white without shading or color. When i compile the same code under Windows it looks as it should. Any ideas?

    Here is the complete init function:

    Code cpp:
    void initializeGL()
    {
        //qglClearColor(Qt::black);
        glEnable(GL_DEPTH_TEST);
        glShadeModel(GL_SMOOTH);
        glEnable(GL_POLYGON_SMOOTH);
        glEnable(GL_LINE_SMOOTH);
     
    #ifdef TRANSPARENCY
        glEnable(GL_BLEND); // Transparency
        glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    #endif
     
    #ifdef LIGHTING
        glEnable(GL_LIGHTING);
        glEnable(GL_LIGHT0);
        glEnable(GL_RESCALE_NORMAL);
        glEnable(GL_COLOR_MATERIAL);
     
        GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0};
        GLfloat mat_shininess[] = {1000.0};
        GLfloat light_position[] = {0, 0.5, 1.0, 0.0};
        //glClearColor (0.0, 0.0, 0.0, 0.0);
     
        glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
        glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);
        glLightfv(GL_LIGHT0, GL_POSITION, light_position);
        GLfloat lmodel_ambient[]={0.2, 0.2, 0.2, 1.0};
        glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
        glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_ambient);
    #endif
     
        glDisable(GL_CULL_FACE);
        //glCullFace(GL_NONE);
    }
    Last edited by Dark Photon; 12-18-2017 at 05:33 PM.

Posting Permissions

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