I am going to write a perfraglighting shader with wireframe covering on mesh surface.
I blend programable pipeline and original pipeline of OpenGL in my code, showed as follow:
glNewList(CallList[2],GL_COMPILE);
glUseProgram(MyShader::Prog);//launch Shader
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.0,1.0);
glCallList(CallList[0]);//Using point array list
glDisable(GL_POLYGON_OFFSET_FILL);
glDisable(GL_LIGHTING);
glUseProgram(0);//shut down the shader
glColor3f(0.0,0.0,0.0);//Setup the line color
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
glCallList(CallList[1]);//Draw Wireframe with
//OpenGL inside pipeline in glvertex3f mode
glEnable(GL_LIGHTING);
glUseProgram(MyShader::Prog);
glEndList();
And in my frag shader, I use following code to produce the final color:
gl_FragColor = gl_FrontLightModelProduct + Iamb + Idiff + Ispec;
Everything is ok when I just use programable pipeline without adding original pipeline to my scene, but when I switch the rendering state to wireframe on solide surface, the color of whole object turn to be the color set by glColor(x,x,x) which is the real reason to this problem I think. Originally, I just set color blue to each vertex in vertex array, and wanna use black to line out the wireframe of the mesh.
I wanna ask are there any drawbacks in my code, and how to manage the correct color state in rendering pipeline.
thanks~