Java Code Examples for com.jogamp.opengl.GL2#glDepthFunc()
The following examples show how to use
com.jogamp.opengl.GL2#glDepthFunc() .
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: CubeTexture.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void init(GLAutoDrawable drawable) { final GL2 gl = drawable.getGL().getGL2(); gl.glShadeModel(GL2.GL_SMOOTH); gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); gl.glClearDepth(1.0f); gl.glEnable(GL2.GL_DEPTH_TEST); gl.glDepthFunc(GL2.GL_LEQUAL); gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST); gl.glEnable(GL2.GL_TEXTURE_2D); try { File im = new File("D:\\Temp\\image\\lenna.jpg "); //File im = new File("D:\\Temp\\Map\\GLOBALeb3colshade.jpg"); BufferedImage image = ImageIO.read(im); Texture t = AWTTextureIO.newTexture(gl.getGLProfile(), image, true); //Texture t = TextureIO.newTexture(im, true); texture = t.getTextureObject(gl); } catch (IOException e) { e.printStackTrace(); } }
Example 2
Source File: DelaunayTriangulationExample.java From delaunay-triangulator with MIT License | 6 votes |
public void init(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); gl.glDisable(GL.GL_CULL_FACE); gl.glShadeModel(GL2.GL_SMOOTH); gl.glClearColor(COLOR_BACKGROUND.getRed() / 255.0f, COLOR_BACKGROUND.getGreen() / 255.0f, COLOR_BACKGROUND.getBlue() / 255.0f, 1); gl.glClearDepth(1.0f); gl.glEnable(GL.GL_DEPTH_TEST); gl.glDepthFunc(GL.GL_LEQUAL); gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); gl.setSwapInterval(1); gl.glDisable(GL2.GL_CULL_FACE); delaunayTriangulator = new DelaunayTriangulator(pointSet); }
Example 3
Source File: Cuboid.java From Robot-Overlord-App with GNU General Public License v2.0 | 6 votes |
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: PoseEntity.java From Robot-Overlord-App with GNU General Public License v2.0 | 5 votes |
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 5
Source File: OpenGLHelper.java From Robot-Overlord-App with GNU General Public License v2.0 | 4 votes |
static public int drawAtopEverythingStart(GL2 gl2) { IntBuffer depthFunc = IntBuffer.allocate(1); gl2.glGetIntegerv(GL2.GL_DEPTH_FUNC, depthFunc); gl2.glDepthFunc(GL2.GL_ALWAYS); return depthFunc.get(); }
Example 6
Source File: OpenGLHelper.java From Robot-Overlord-App with GNU General Public License v2.0 | 4 votes |
static public void drawAtopEverythingEnd(GL2 gl2, int previousState) { gl2.glDepthFunc(previousState); }
Example 7
Source File: DHBuilderApp.java From Robot-Overlord-App with GNU General Public License v2.0 | 4 votes |
@Override public void render(GL2 gl2) { gl2.glPushMatrix(); MatrixHelper.applyMatrix(gl2, pose); anchor.render(gl2); if(!inTest) { for( int i=0;i<BONE_NAMES.length;++i) { models[i].render(gl2); } } else { links.get(0).render(gl2); } boolean showBones=false; if(showBones==true) { Vector3d p0 = MatrixHelper.getPosition(this.getPoseWorld()); for( int i=0;i<BONE_NAMES.length;++i) { Matrix4d m = links.get(i).getPoseWorld(); Vector3d p1 = MatrixHelper.getPosition(m); IntBuffer depthFunc = IntBuffer.allocate(1); gl2.glGetIntegerv(GL2.GL_DEPTH_FUNC, depthFunc); gl2.glDepthFunc(GL2.GL_ALWAYS); gl2.glDisable(GL2.GL_TEXTURE_2D); gl2.glDisable(GL2.GL_LIGHTING); gl2.glPushMatrix(); gl2.glColor3d(1, 1, 1); gl2.glBegin(GL2.GL_LINES); gl2.glVertex3d(p0.x,p0.y,p0.z); gl2.glVertex3d(p1.x,p1.y,p1.z); gl2.glEnd(); p0=p1; gl2.glDepthFunc(depthFunc.get()); MatrixHelper.applyMatrix(gl2, m); PrimitiveSolids.drawStar(gl2, 15); gl2.glPopMatrix(); } } gl2.glPopMatrix(); // don't call super.render() }
Example 8
Source File: DragBallEntity.java From Robot-Overlord-App with GNU General Public License v2.0 | 4 votes |
@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(); }