[QUOTE=menzel;1238379]It’s
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
not
glClear(GL_COLOR_BUFFER_BIT || GL_DEPTH_BUFFER_BIT);
The colormask code is commented out…
Can you explain what object is supposed to be what? How do you get the camera position, ARToolkit? Are you sure the position is correct? Can you render the phantom object visible above the real object? Maybe screenshots will help.[/QUOTE]
Yes, I’m using ARToolkit to get the camera position. I have modified these code and the real scene became black background as I changed glClear(GL_COLOR_BUFFER_BIT || GL_DEPTH_BUFFER_BIT); to glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
here is the picture,
[ATTACH=CONFIG]189[/ATTACH]
here is the code
static void draw( int object, double trans[3][4] )
{
double gl_para[16];
GLfloat mat_ambient[] = {0.0, 0.0, 1.0, 1.0};
GLfloat mat_flash[] = {0.0, 0.0, 1.0, 1.0};
GLfloat mat_flash_shiny[] = {50.0};
GLfloat light_position[] = {100.0,-200.0,200.0,0.0};
GLfloat ambi[] = {0.1, 0.1, 0.1, 0.1};
GLfloat lightZeroColor[] = {0.9, 0.9, 0.9, 0.1};
argDrawMode3D();
argDraw3dCamera( 0, 0 );
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glClearColor(0.0, 0.0, 0.0, 0.0);
glClearDepth(1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* load the camera transformation matrix */
argConvGlpara(trans, gl_para);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixd( gl_para );
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambi);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_flash);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_flash_shiny);
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glMatrixMode(GL_MODELVIEW);
switch( object ) {
case 0:
glTranslatef( 0.0, 0.0, 25.0 );
glutSolidSphere(40.0, 24, 24);
break;
case 1:
// My virtual object
glTranslatef( 0.0, 0.0, 25.0 );
glutSolidCube(50.0);
break;
case 2:
//Supposed to be phantom object
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glCallList(Torus);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
//glDepthFunc(GL_LESS);
//glDepthMask(GL_TRUE);
break;
}
glDisable( GL_LIGHTING );
glDisable( GL_DEPTH_TEST );
}
Here is what I want to do