• Advertisement
Sign in to follow this  

glLightModel and Forceware 80

This topic is 4294 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Sorry to post some nVIDIA specific problem but I created a bug report for that problem some month ago at nvidia registered developer (Bug ID: 212152) but I have no answer. Well I have a small glut program that reproduces the problem (ask me I you want an exe). Using 70 Forceware drivers (and for years), that program draws 2 white triangles. With Forceware 80 series (and FSAA 4X on the driver config), that program gives a white and a black triangle. Does someone see any reason ?
#include <GL/glut.h>
#include <stdlib.h>
#include <math.h>
#include <iostream.h>


bool vDraw2Triangles = true ;

void display(void)
{
	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glFrontFace(GL_CCW) ;
	glNormal3f(0,0,1.000000) ;
	glColor4f(1.000000,1.000000,1.000000,1.000000) ;

	// First face: 
	if (vDraw2Triangles)
	{
		glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,1) ;
		glEnable(GL_CULL_FACE) ;


		glBegin(GL_TRIANGLE_STRIP) ; 
			glVertex3f(0,1,0) ;
			glVertex3f(-1,1,0) ;
			glVertex3f(-1,0,0) ;
		glEnd() ;
	}

	// Second face: back face is visible but we disable back face culling
	// not correctly drawn (black instead of white)
	glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,0) ;
	glDisable(GL_CULL_FACE) ;

	glBegin(GL_TRIANGLES) ; 
		glVertex3f(0,0,0) ;
		glVertex3f(0,1,0) ;
		glVertex3f(1,1,0) ;
	glEnd() ;


	glutSwapBuffers() ;
	glutPostRedisplay() ;
}

void reshape (int w, int h)
{
	glViewport (0, 0, (GLsizei) w, (GLsizei) h);
	glMatrixMode (GL_PROJECTION);
	glLoadIdentity();
	if (w <= h)
	  glOrtho (-1.5, 1.5, -1.5*(GLfloat)h/(GLfloat)w,
		 1.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0);
	else
	  glOrtho (-1.5*(GLfloat)w/(GLfloat)h,
		 1.5*(GLfloat)w/(GLfloat)h, -1.5, 1.5, -10.0, 10.0);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
}

void keyboard(unsigned char key, int x, int y)
{
	switch (key) {
		case 27:
			exit(0);
		break;
		case 'b': case 'B' :
			vDraw2Triangles = !vDraw2Triangles ;
		break ;
	}
}



void Initialization()
{
	glClearColor (0.5, 0.6, 0.8, 0.0);

	glShadeModel(GL_SMOOTH) ;

	glEnable(GL_LIGHTING);

	glEnable(GL_LIGHT0);
	GLfloat specular[] = { 0.0, 0.0, 0.0, 0.0 };
	GLfloat ambiant[] = { 0.7, 0.7, 0.7, 1.0 };

	GLfloat lig_pos[] = { 0.0, 10., 1. };
	glLightfv(GL_LIGHT0,GL_POSITION,lig_pos) ;
	glLightfv(GL_LIGHT0,GL_AMBIENT,ambiant) ;
	glLightfv(GL_LIGHT0,GL_DIFFUSE,ambiant) ;
	glLightfv(GL_LIGHT0,GL_SPECULAR,specular) ;


	glEnable(GL_COLOR_MATERIAL) ;
	glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE) ;

}

int main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
	glutInitWindowSize (1024, 768); 
	glutInitWindowPosition (0, 0);
	glutCreateWindow (argv[0]);

	Initialization() ;

	glutDisplayFunc(display); 
	glutReshapeFunc(reshape);
	glutKeyboardFunc(keyboard);
	glutMainLoop();
	return 0;
}




Share this post


Link to post
Share on other sites
Advertisement
im pretty tired but i think a white + black tri is thr right result

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement