0

我的粒子没有发光。我在互联网上搜索它已经完成

glBlendFunc(GL_SRC_ALPHA, GL_ONE);

这段代码改变了我的粒子,但它没有发光。任何人都可以看到我的代码有什么问题吗?以下是相关代码:

void init (void) {
    glEnable (GL_LIGHTING); //enable the lighting
    glEnable (GL_LIGHT0); //enable LIGHT0, our Diffuse Light
    glEnable (GL_LIGHT1); //enable LIGHT1, our Ambient Light
    glEnable(GL_BLEND);
 //   glEnable(GL_DEPTH);

  //  glEnable(GL_COLOR_MATERIAL);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE);

}

void update()
{
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glRotatef(g_orientation, 0.0, 1.0, 0.0); // rotate in y axis
    glTranslatef(-g_posX, -g_posY, -g_posZ);

    glClear(GL_COLOR_BUFFER_BIT);
    glClear(GL_DEPTH_BUFFER_BIT);

    GLfloat DiffuseLight[] = {dlr, dlg, dlb}; //set DiffuseLight[] to the specified values
    GLfloat AmbientLight[] = {alr, alg, alb}; //set AmbientLight[] to the specified values
    glLightfv (GL_LIGHT0, GL_DIFFUSE, DiffuseLight); //change the light accordingly
    glLightfv (GL_LIGHT1, GL_AMBIENT, AmbientLight); //change the light accordingly
    GLfloat LightPosition[] = {lx, ly, lz, lw}; //set the LightPosition to the specified values
    glLightfv (GL_LIGHT0, GL_POSITION, LightPosition); //change the light accordingly
    glColorMaterial(GL_FRONT,GL_DIFFUSE);
    drawRockets();
    if(explosion == true){
        drawParticles();
    }
    drawMolen();
    glutSwapBuffers();
    if(rotate==1)
        angle++;
}

//commonly used material values
GLfloat no_mat[] = { 0.0, 0.0, 0.0, 1.0 };
GLfloat default_ambient[] = {0.2, 0.2, 0.2, 1.0};
GLfloat mat_ambient[] = { 0.7, 0.7, 0.7, 1.0 };
GLfloat mat_ambient_color[] = { 0.8, 0.8, 0.2, 1.0 };
GLfloat mat_diffuse[] = { 0.1, 0.5, 0.8, 1.0 };
GLfloat default_diffuse[] = {0.8, 0.8, 0.8, 1.0};
GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat no_shininess[] = { 0.0 };
GLfloat low_shininess[] = { 5.0 };
GLfloat high_shininess[] = { 100.0 };
GLfloat mat_emission[] = {0.3, 0.5, 0.9, 0.0};
GLfloat mat_emission1[] = {0.0, 1.0, 0.2, 1.0};
GLfloat mat_emission2[] = {0.0, 0.0, 1.0, 0.0};
GLfloat mat_emission3[] = {1.0, 1.0, 0.0, 0.0};

这是我希望我的 glutsolidspheres 成为的另一个示例: 光球(光,材料?) glutsolidsphere

4

0 回答 0