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

The following examples show how to use com.jogamp.opengl.GL2#glIsEnabled() . 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: MatrixHelper.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
/**
 * See drawMatrix(gl2,p,u,v,w,1)
 * @param gl2
 * @param m
 * @param scale
 */
public static void drawMatrix(GL2 gl2,Matrix4d m,double scale) {
	boolean depthWasOn = gl2.glIsEnabled(GL2.GL_DEPTH_TEST);
	gl2.glDisable(GL2.GL_DEPTH_TEST);
	boolean lightWasOn = gl2.glIsEnabled(GL2.GL_LIGHTING);
	gl2.glDisable(GL2.GL_LIGHTING);
	
	gl2.glPushMatrix();
		gl2.glTranslated(m.m03,m.m13,m.m23);
		gl2.glScaled(scale, scale, scale);
		
		gl2.glBegin(GL2.GL_LINES);
		gl2.glColor3f(1,0,0);		gl2.glVertex3f(0,0,0);		gl2.glVertex3d(m.m00,m.m10,m.m20);  // 1,0,0 = red
		gl2.glColor3f(0,1,0);		gl2.glVertex3f(0,0,0);		gl2.glVertex3d(m.m01,m.m11,m.m21);  // 0,1,0 = green 
		gl2.glColor3f(0,0,1);		gl2.glVertex3f(0,0,0);		gl2.glVertex3d(m.m02,m.m12,m.m22);  // 0,0,1 = blue
		gl2.glEnd();

	gl2.glPopMatrix();
	if(lightWasOn) gl2.glEnable(GL2.GL_LIGHTING);
	if(depthWasOn) gl2.glEnable(GL2.GL_DEPTH_TEST);
}
 
Example 2
Source File: MatrixHelper.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
/**
 * See drawMatrix(gl2,p,u,v,w,1)
 * @param gl2
 * @param m
 * @param scale
 */
public static void drawMatrix2(GL2 gl2,Matrix4d m,double scale) {
	boolean depthWasOn = gl2.glIsEnabled(GL2.GL_DEPTH_TEST);
	gl2.glDisable(GL2.GL_DEPTH_TEST);
	boolean lightWasOn = gl2.glIsEnabled(GL2.GL_LIGHTING);
	gl2.glDisable(GL2.GL_LIGHTING);
	
	gl2.glPushMatrix();
		gl2.glTranslated(m.m03,m.m13,m.m23);
		gl2.glScaled(scale, scale, scale);
		
		gl2.glBegin(GL2.GL_LINES);
		gl2.glColor3f(1,1,0);		gl2.glVertex3f(0,0,0);		gl2.glVertex3d(m.m00,m.m10,m.m20);  // 1,1,0 = yellow
		gl2.glColor3f(0,1,1);		gl2.glVertex3f(0,0,0);		gl2.glVertex3d(m.m01,m.m11,m.m21);  // 0,1,1 = teal 
		gl2.glColor3f(1,0,1);		gl2.glVertex3f(0,0,0);		gl2.glVertex3d(m.m02,m.m12,m.m22);  // 1,0,1 = magenta
		gl2.glEnd();

	gl2.glPopMatrix();
	if(lightWasOn) gl2.glEnable(GL2.GL_LIGHTING);
	if(depthWasOn) gl2.glEnable(GL2.GL_DEPTH_TEST);
}
 
Example 3
Source File: Cuboid.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
public void render(GL2 gl2) {
	gl2.glPushMatrix();
		//MatrixHelper.applyMatrix(gl2, poseWorld);

		IntBuffer depthFunc = IntBuffer.allocate(1);
		gl2.glGetIntegerv(GL2.GL_DEPTH_FUNC, depthFunc);
		gl2.glDepthFunc(GL2.GL_ALWAYS);
		
		boolean isLit = gl2.glIsEnabled(GL2.GL_LIGHTING);
		gl2.glDisable(GL2.GL_LIGHTING);
		
		gl2.glColor3d(255,255,255);
		PrimitiveSolids.drawBoxWireframe(gl2, getBoundsBottom(),getBoundsTop());

		if (isLit) gl2.glEnable(GL2.GL_LIGHTING);
		
		gl2.glDepthFunc(depthFunc.get());
	gl2.glPopMatrix();
}
 
Example 4
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 5
Source File: Bezier3ControlPoint.java    From Robot-Overlord-App with GNU General Public License v2.0 5 votes vote down vote up
/**
 * visualize the line in opengl
 * @param gl2
 */
public void render(GL2 gl2) {
	//Vector3f u,v,w;
	
	//MatrixHelper.drawMatrix(gl2, position.interpolate(0), u, v, w);
	//MatrixHelper.drawMatrix(gl2, position.interpolate(1), u, v, w);
	boolean isLit = gl2.glIsEnabled(GL2.GL_LIGHTING);
	boolean isCM =  gl2.glIsEnabled(GL2.GL_COLOR_MATERIAL);
	boolean isDepth =  gl2.glIsEnabled(GL2.GL_DEPTH_TEST);

	gl2.glEnable(GL2.GL_DEPTH_TEST);
	gl2.glDisable(GL2.GL_LIGHTING);
	gl2.glDisable(GL2.GL_COLOR_MATERIAL);
	
	//*
	gl2.glColor4f(0, 0, 1, 1);
	gl2.glBegin(GL2.GL_LINES);
	gl2.glVertex3f(position.p0.x,position.p0.y,position.p0.z);
	gl2.glVertex3f(position.p1.x,position.p1.y,position.p1.z);
	
	gl2.glVertex3f(position.p2.x,position.p2.y,position.p2.z);
	gl2.glVertex3f(position.p3.x,position.p3.y,position.p3.z);
	gl2.glEnd();
	//*/
	
	gl2.glColor4f(0, 1, 0, 1);
	gl2.glBegin(GL2.GL_LINE_STRIP);
	final float NUM_STEPS=20;
	for(float i=0;i<=NUM_STEPS;++i) {
		Vector3f ipos = position.interpolate(i/NUM_STEPS);
		gl2.glVertex3f(ipos.x,ipos.y,ipos.z);
	}
	gl2.glEnd();
	
	if(isLit) gl2.glEnable(GL2.GL_LIGHTING);
	if(isCM) gl2.glEnable(GL2.GL_COLOR_MATERIAL);
	if(!isDepth) gl2.glDisable(GL2.GL_DEPTH_TEST);
}
 
Example 6
Source File: PoseEntity.java    From Robot-Overlord-App with GNU General Public License v2.0 5 votes vote down vote up
public void renderLineage(GL2 gl2) {
	boolean isTex = gl2.glIsEnabled(GL2.GL_TEXTURE_2D);
	gl2.glDisable(GL2.GL_TEXTURE_2D);

	// save the lighting mode
	boolean lightWasOn = gl2.glIsEnabled(GL2.GL_LIGHTING);
	gl2.glDisable(GL2.GL_LIGHTING);

	IntBuffer depthFunc = IntBuffer.allocate(1);
	gl2.glGetIntegerv(GL2.GL_DEPTH_FUNC, depthFunc);
	gl2.glDepthFunc(GL2.GL_ALWAYS);
	//boolean depthWasOn = gl2.glIsEnabled(GL2.GL_DEPTH_TEST);
	//gl2.glDisable(GL2.GL_DEPTH_TEST);

	gl2.glColor4d(1,1,1,1);
	gl2.glBegin(GL2.GL_LINES);
	// connection to children
	for(Entity e : children ) {
		if(e instanceof PoseEntity) {					
			Vector3d p = ((PoseEntity)e).getPosition();
			gl2.glVertex3d(0, 0, 0);
			gl2.glVertex3d(p.x,p.y,p.z);
		}
	}
	gl2.glEnd();

	//if(depthWasOn) gl2.glEnable(GL2.GL_DEPTH_TEST);
	gl2.glDepthFunc(depthFunc.get());
	// restore lighting
	if(lightWasOn) gl2.glEnable(GL2.GL_LIGHTING);
	if(isTex) gl2.glDisable(GL2.GL_TEXTURE_2D);
}
 
Example 7
Source File: OpenGLHelper.java    From Robot-Overlord-App with GNU General Public License v2.0 4 votes vote down vote up
static public boolean disableLightingStart(GL2 gl2) {
	boolean lightWasOn = gl2.glIsEnabled(GL2.GL_LIGHTING);
	gl2.glDisable(GL2.GL_LIGHTING);
	return lightWasOn;
}
 
Example 8
Source File: DragBallEntity.java    From Robot-Overlord-App with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void render(GL2 gl2) {
	if(subject==null) return;

	gl2.glDisable(GL2.GL_TEXTURE_2D);

	RobotOverlord ro = (RobotOverlord)getRoot();
	ro.viewport.renderChosenProjection(gl2);

	gl2.glPushMatrix();
	
		/*if(isBallHit) {
			Vector3d dp = this.getPosition();
			
			ViewportEntity cameraView = ro.viewport;
			Ray ray = cameraView.rayPick();
			Vector3d dr = ray.getPoint(100);

			gl2.glBegin(GL2.GL_LINES);
			gl2.glColor3d(1, 1, 1);
			gl2.glVertex3d(ray.start.x, ray.start.y, ray.start.z);
			gl2.glVertex3d(dr.x, dr.y, dr.z);

			gl2.glVertex3d(dp.x,dp.y,dp.z);
			gl2.glVertex3d(pickPointOnBall.x, pickPointOnBall.y, pickPointOnBall.z);
			gl2.glEnd();
			
			PrimitiveSolids.drawStar(gl2, dp,10);
			PrimitiveSolids.drawStar(gl2, pickPointOnBall,10);
		}//*/
		
		IntBuffer depthFunc = IntBuffer.allocate(1);
		gl2.glGetIntegerv(GL2.GL_DEPTH_FUNC, depthFunc);
		gl2.glDepthFunc(GL2.GL_ALWAYS);
		//boolean isDepth=gl2.glIsEnabled(GL2.GL_DEPTH_TEST);
		//gl2.glDisable(GL2.GL_DEPTH_TEST);

		boolean isLit = gl2.glIsEnabled(GL2.GL_LIGHTING);
		gl2.glDisable(GL2.GL_LIGHTING);


		IntBuffer lineWidth = IntBuffer.allocate(1);
		gl2.glGetIntegerv(GL2.GL_LINE_WIDTH, lineWidth);
		gl2.glLineWidth(2);

		gl2.glPushMatrix();

			renderOutsideCircle(gl2);

			MatrixHelper.applyMatrix(gl2, FOR);
			gl2.glScaled(ballSize.get(),ballSize.get(),ballSize.get());

			if(isRotateMode()) {
				renderRotation(gl2);
			} else {
				renderTranslation(gl2);
			}
			
		gl2.glPopMatrix();

		// set previous line width
		gl2.glLineWidth(lineWidth.get());
		
		if (isLit) gl2.glEnable(GL2.GL_LIGHTING);

		//if(isDepth) gl2.glEnable(GL2.GL_DEPTH_TEST);
		gl2.glDepthFunc(depthFunc.get());
		
	gl2.glPopMatrix();
}