GL_LIGHT creates only one light source

I am currently trying to illuminate an object with a light source and change the object color based on GL_COLOR_MATERIAL. For some reason, I can only see one light source that is projected onto the model. I tried different positions and a combination of light sources, and I noticed only the GL_LIGHT0 functions.

I also tried a different combination of ambient / diffuse / materials without success.

static const GLfloat ambient[4] = {0.1f, 0.1f, 0.1f, 1.0f};
static const GLfloat diffuse[4] = {0.5f, 1.0f, 1.0f, 1.0f};
static const GLfloat position0[4] = {0.0f, 0.0f, 20.0f, 0.0f};
static const GLfloat position1[4] = {0.0f, 0.0f, -20.0f, 0.0f};
static const GLfloat front_mat_shininess[1] = {60.0f};
static const GLfloat front_mat_specular[4] = {0.2f, 0.2f, 0.2f, 1.0f};
static const GLfloat front_mat_diffuse[4] = {0.5f, 0.28f, 0.38f, 1.0f};

static const GLfloat lmodel_ambient[4] = {1.0f, 1.0f, 1.0f, 1.0f};
static const GLfloat lmodel_twoside[1] = {GL_FALSE};

glDisable(GL_LIGHTING);
glDisable(GL_COLOR_MATERIAL);

///Enable lighting if item is a solid model
if(wireFlag == 1)
{
    glEnable(GL_LIGHTING);
    glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
    glLightfv(GL_LIGHT0, GL_POSITION, position0);
    glEnable(GL_LIGHT0);

    glLightfv(GL_LIGHT1, GL_AMBIENT, ambient);
    glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse);
    glLightfv(GL_LIGHT1, GL_POSITION, position1);
    glEnable(GL_LIGHT1);

    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
    glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);


    glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, front_mat_shininess);
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, front_mat_specular);
    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, front_mat_diffuse);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_COLOR_MATERIAL);
}

Any help would be greatly appreciated!

+3
source share
1 answer

(, GL_DIFFUSE), 0,0,0,0 GL_LIGHT1.. GL_LIGHT7, - (, 1,1,1,1) GL_LIGHT0. , , , , "" GL_LIGHT1.

+6

Source: https://habr.com/ru/post/1795344/


All Articles