/** * @param gl * */ private void setupLighting( GL gl ) { gl.glPushAttrib( GL.GL_CURRENT_BIT | GL.GL_LIGHTING_BIT ); gl.glMaterialfv( GL.GL_FRONT, GL.GL_AMBIENT, ambientColor, 0 ); gl.glMaterialfv( GL.GL_FRONT, GL.GL_DIFFUSE, diffuseColor, 0 ); gl.glMaterialfv( GL.GL_FRONT, GL.GL_SPECULAR, specularColor, 0 ); gl.glMaterialf( GL.GL_FRONT, GL.GL_SHININESS, shininess ); }
public void renderPrepared( RenderContext glRenderContext, DirectGeometryBuffer geomBuffer ) { enableArrays( glRenderContext, geomBuffer ); GL context = glRenderContext.getContext(); normalBuffer.rewind(); context.glPushAttrib( GL.GL_CURRENT_BIT | GL.GL_LIGHTING_BIT ); // context.glMaterialfv( GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, ambientColor, 0 ); context.glMaterialfv( GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE, diffuseColor, 0 ); context.glMaterialfv( GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR, specularColor, 0 ); context.glMaterialfv( GL.GL_FRONT_AND_BACK, GL.GL_EMISSION, emmisiveColor, 0 ); context.glMaterialf( GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, style.getShininess() ); context.glDrawArrays( openGLType, 0, vertexCount ); context.glPopAttrib(); disableArrays( glRenderContext ); }
private void debug( RenderContext context ) { GL gl = context.getContext(); gl.glPushAttrib( GL.GL_CURRENT_BIT | GL.GL_LIGHTING_BIT ); gl.glMaterialfv( GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, new float[] { 1, 0, 0 }, 0 ); gl.glMaterialfv( GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE, new float[] { 1, 0, 0 }, 0 ); float[] bbox = getModelBBox(); gl.glBegin( GL.GL_QUADS ); // Front face gl.glNormal3f( 0, 0, 1 ); gl.glVertex3f( bbox[0], bbox[1], bbox[2] ); gl.glVertex3f( bbox[3], bbox[4], bbox[2] ); gl.glVertex3f( bbox[3], bbox[4], bbox[5] ); gl.glVertex3f( bbox[0], bbox[1], bbox[5] ); gl.glEnd(); gl.glPopAttrib(); } }
context.glMaterialfv( GL.GL_FRONT, GL.GL_DIFFUSE, new float[] { 1, 1, 1, 1 }, 0 ); context.glMaterialfv( GL.GL_FRONT, GL.GL_SPECULAR, new float[] { 0.3f, 0.3f, 0.3f, 1 }, 0 );
private void init( GL gl ) { float[] cc = JOGLUtils.convertColorFloats( request.getBackgroundColor() ); gl.glClearColor( cc[0], cc[1], cc[2], 0.0f ); SunInfo pos = request.getSceneParameters().getSunPosition(); float[] light_position = pos.getEucledianPosition( sceneLatitude ); Vectors3f.scale( -1, light_position ); float[] ambientAndDiffuse = pos.calculateSunlight( sceneLatitude ); // float intens = pos.calcSunlightIntensity( ambientAndDiffuse, 0.5f ); gl.glLightfv( GL.GL_LIGHT0, GL.GL_POSITION, new float[] { light_position[0], light_position[1], light_position[2], 0 }, 0 ); gl.glLightfv( GL.GL_LIGHT0, GL.GL_AMBIENT, new float[] { ambientAndDiffuse[0], ambientAndDiffuse[1], ambientAndDiffuse[2], 1 }, 0 ); gl.glMaterialfv( GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, new float[] { ambientAndDiffuse[0], ambientAndDiffuse[1], ambientAndDiffuse[2], 1 }, 0 ); gl.glLightfv( GL.GL_LIGHT0, GL.GL_DIFFUSE, new float[] { ambientAndDiffuse[0], ambientAndDiffuse[1], ambientAndDiffuse[2], 1 }, 0 ); }
ambientAndDiffuse[2], 1 }, 0 ); gl.glMaterialfv( GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, new float[] { ambientAndDiffuse[0], ambientAndDiffuse[1], ambientAndDiffuse[2], 1 }, 0 );
gl.glMaterialfv( GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE, color, 0 ); gl.glEnd(); gl.glMaterialfv( GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE, color, 0 ); gl.glEnd(); gl.glMaterialfv( GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE, color, 0 ); gl.glBegin( GL.GL_QUADS );
gl.glDisable( GL.GL_BLEND ); float[] color = new float[] { 1, 0, 0 }; gl.glMaterialfv( GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE, color, 0 ); gl.glMaterialfv( GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE, color, 0 ); gl.glMaterialfv( GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE, color, 0 ); gl.glBegin( GL.GL_QUADS );