Java Code Examples for com.jogamp.opengl.GL2#glMaterialfv()

The following examples show how to use com.jogamp.opengl.GL2#glMaterialfv() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Lighting.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Start the lighting
 *
 * @param gl GL2
 */
public void start(GL2 gl) {
    //gl.glShadeModel(GL2.GL_SMOOTH);

    gl.glEnable(GL2.GL_LIGHTING);
    gl.glEnable(this.light);
    gl.glEnable(GL2.GL_DEPTH_TEST);

    gl.glLightModelfv(GL2.GL_LIGHT_MODEL_AMBIENT, ambient, 0);
    //gl.glLightfv(this.light, GL2.GL_AMBIENT, ambient, 0);
    gl.glLightfv(this.light, GL2.GL_SPECULAR, specular, 0);
    gl.glLightfv(this.light, GL2.GL_DIFFUSE, diffuse, 0);
    gl.glLightfv(this.light, GL2.GL_POSITION, position, 0);
    
    //Material
    gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_AMBIENT, mat_ambient, 0);
    gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_DIFFUSE, mat_diffuse, 0);
    gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_SPECULAR, mat_specular, 0);
    gl.glMaterialf(GL2.GL_FRONT, GL2.GL_SHININESS, mat_shininess);
}
 
Example 2
Source File: MaterialEntity.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
public void render(GL2 gl2) {
	gl2.glColor4d(diffuse.getR(),diffuse.getG(),diffuse.getB(),diffuse.getA());
	gl2.glMaterialfv(GL2.GL_FRONT, GL2.GL_DIFFUSE, diffuse.getFloatArray(),0);
    gl2.glMaterialfv(GL2.GL_FRONT, GL2.GL_SPECULAR, specular.getFloatArray(),0);
    gl2.glMaterialfv(GL2.GL_FRONT, GL2.GL_EMISSION, emission.getFloatArray(),0);
    gl2.glMaterialfv(GL2.GL_FRONT, GL2.GL_AMBIENT, ambient.getFloatArray(),0);
    gl2.glMaterialf(GL2.GL_FRONT, GL2.GL_SHININESS, shininess.get().floatValue());
    gl2.glColorMaterial(GL2.GL_FRONT,GL2.GL_AMBIENT_AND_DIFFUSE );
    
    boolean isColorEnabled = gl2.glIsEnabled(GL2.GL_COLOR_MATERIAL);
	gl2.glDisable(GL2.GL_COLOR_MATERIAL);
	
	gl2.glShadeModel(GL2.GL_SMOOTH);
	
    if(isLit()) gl2.glEnable(GL2.GL_LIGHTING);
    else gl2.glDisable(GL2.GL_LIGHTING);

    texture.render(gl2);
    
    if(isColorEnabled) gl2.glEnable(GL2.GL_COLOR_MATERIAL);
}
 
Example 3
Source File: DeltaRobot3.java    From Robot-Overlord-App with GNU General Public License v2.0 5 votes vote down vote up
protected void setColor(GL2 gl2,float r,float g,float b,float a) {
	float [] diffuse = {r,g,b,a};
	gl2.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_AMBIENT_AND_DIFFUSE, diffuse,0);
	float[] specular={0.85f,0.85f,0.85f,1.0f};
    gl2.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_SPECULAR, specular,0);
    float[] emission={0.01f,0.01f,0.01f,1f};
    gl2.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_EMISSION, emission,0);
    
    gl2.glMaterialf(GL2.GL_FRONT_AND_BACK, GL2.GL_SHININESS, 50.0f);

    gl2.glColor4f(r,g,b,a);
}