List of usage examples for org.lwjgl.opengl GL11 glDepthFunc
public static void glDepthFunc(@NativeType("GLenum") int func)
From source file:net.BiggerOnTheInside.Binder.Binder.java
License:Open Source License
/** * <p>Sets up OpenGL.</p>//from www. j a v a 2s. c om */ public void initGL() { int width = displayMode.getWidth(); int height = displayMode.getHeight(); /* Enable 2D texturing. */ GL11.glEnable(GL11.GL_TEXTURE_2D); /* Make all models smoothly textured. */ GL11.glShadeModel(GL11.GL_SMOOTH); /* Set the background color to that signature blue. */ GL11.glClearColor(0.9f, 1.0f, 1.0f, 0.0f); /* Set the clear depth to all-the-way */ GL11.glClearDepth(1.0); /* Enable the depth system. */ GL11.glEnable(GL11.GL_DEPTH_TEST); /* Set the function for depth to GL_LEQUAL. */ GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); /* Enable face culling, basically don't render this face relative to the camera's position. */ GL11.glEnable(GL11.GL_CULL_FACE); /* Set OpenGL to cull the back face of our spatials. */ GL11.glCullFace(GL11.GL_BACK); /* Set the matrix mode to projection. */ GL11.glMatrixMode(GL11.GL_PROJECTION); /* Reset the OpenGL configuration, loading our above prefrences. */ //GL11.glLoadIdentity(); /* Set the perspective. */ GLU.gluPerspective(45.0f, (float) displayMode.getWidth() / (float) displayMode.getHeight(), 0.1f, 100.0f); /* Set the matrix mode to be model view. */ GL11.glMatrixMode(GL11.GL_MODELVIEW); /* Set the perspective correction hint to finest quality. */ GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); }
From source file:net.kubin.world.characters.Player.java
License:Apache License
@Override public void render() { GL11.glEnable(GL11.GL_DEPTH_TEST);/*from w w w .ja v a2 s.c om*/ GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glEnable(GL11.GL_BLEND); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); if (_aimedBlockPosition.y() != -1) { GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GL11.glDisable(GL11.GL_TEXTURE_2D); _aimedBlockAABB.render(0.0f, 0.0f, 0.0f, 0.2f); GL11.glEnable(GL11.GL_TEXTURE_2D); } if (_selectedItem != null) { GL11.glPushMatrix(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_CULL_FACE); _body.transformToRightHand(); /* Prepare the light buffer */ Chunk c = Game.getInstance().getWorld().getChunkManager().getChunkContaining( MathHelper.floor(_position.x()), MathHelper.floor(_position.y()) + 1, MathHelper.floor(_position.z()), false, false, false); if (c != null) { c.getLightBuffer().setReferencePoint(MathHelper.floor(_position.x()), MathHelper.floor(_position.y()) + 1, MathHelper.floor(_position.z())); /* Render the object, with the lightbuffer */ _selectedItem.renderHoldableObject(c.getLightBuffer()); } GL11.glEnable(GL11.GL_CULL_FACE); GL11.glPopMatrix(); } GL11.glDisable(GL11.GL_DEPTH_TEST); }
From source file:net.mechanicalcat.pycode.obj.Model.java
License:Open Source License
public void genList() { this.glList = GL11.glGenLists(1); GL11.glNewList(this.glList, GL11.GL_COMPILE); // if use_texture: glEnable(GL_TEXTURE_2D) GL11.glFrontFace(GL11.GL_CCW);/*from w ww . jav a2s . c o m*/ GL11.glEnable(GL11.GL_CULL_FACE); GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); GL11.glDepthFunc(GL11.GL_LESS); GL11.glCullFace(GL11.GL_BACK); String currentMaterial = ""; Material mtl; for (Face face : this.faces) { if (!face.material.equals(currentMaterial)) { currentMaterial = face.material; mtl = this.materials.get(face.material); if (mtl == null) { GL11.glColor3f(1, 1, 1); } else { // if 'texture_Kd' in mtl: // # use diffuse texmap // glBindTexture(GL_TEXTURE_2D, mtl['texture_Kd']) GL11.glColor3f(mtl.diffuse.x, mtl.diffuse.y, mtl.diffuse.z); } } GL11.glBegin(GL11.GL_POLYGON); for (int i = 0; i < face.vertexes.size(); i++) { if (face.normals.get(i) != 0) { Vector3f n = this.normals.get(face.normals.get(i)); GL11.glNormal3f(n.x, n.y, n.z); } // if texture_coords[i]: // glTexCoord2fv(self.texcoords[texture_coords[i] - 1]) Vector3f v = this.vertices.get(face.vertexes.get(i)); GL11.glVertex3f(v.x, v.y, v.z); } GL11.glEnd(); } GL11.glCullFace(GL11.GL_BACK); GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); GL11.glDisable(GL11.GL_CULL_FACE); // if use_texture: glDisable(GL11.GL_TEXTURE_2D); GL11.glEndList(); }
From source file:net.phatcode.rel.multimedia.Renderer.java
License:Open Source License
Renderer(int screenWidth, int screenHeight) { try {// www. j a v a2 s . c om Display.setDisplayMode(new DisplayMode(screenWidth, screenHeight)); Display.create(); Display.setTitle("AnyaBasic 0.4.0 beta"); } catch (LWJGLException e) { e.printStackTrace(); } this.screenWidth = screenWidth; this.screenHeight = screenHeight; GL11.glViewport(0, 0, screenWidth, screenHeight); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, screenWidth, screenHeight, 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glShadeModel(GL11.GL_SMOOTH); //set shading to smooth(try GL_FLAT) GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); //set Clear color to BLACK GL11.glClearDepth(1.0f); //Set Depth buffer to 1(z-Buffer) GL11.glDisable(GL11.GL_DEPTH_TEST); //Disable Depth Testing so that our z-buffer works GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glAlphaFunc(GL11.GL_GREATER, 0); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glTranslatef(0.375f, 0.375f, 0); // magic trick }
From source file:net.skourti.superhornet.graphics.Model.java
public void render(Camera camera) { shader.bind();//from ww w . j a v a 2s. c o m if (drawMode == SKYBOX) { GL11.glDepthFunc(0); traslationMatrix = new Mat4(1.0f); traslationMatrix = traslationMatrix.translate(camera.position); shader.setUniformMat4f("pr_matrix", camera.combinedMatrix.multiply(getModel())); } else { shader.setUniformMat4f("pr_matrix", camera.combinedMatrix.multiply(getModel())); } for (int i = 0; i < meshes.size(); i++) { meshes.get(i).render(shader, camera, getModel()); } if (drawMode == SKYBOX) { GL11.glDepthFunc(1); } shader.unbind(); }
From source file:net.slimevoid.tmf.client.renderers.ItemRendererToolBelt.java
License:Open Source License
private void renderItem(EntityLivingBase entityliving, ItemStack itemstack, int index, TextureManager texturemanager) { GL11.glPushMatrix();//from w w w . java2s. c om IIcon icon = entityliving.getItemIcon(itemstack, index); if (icon == null) { GL11.glPopMatrix(); return; } texturemanager.bindTexture(texturemanager.getResourceLocation(itemstack.getItemSpriteNumber())); Tessellator tessellator = Tessellator.instance; float f = icon.getMinU(); float f1 = icon.getMaxU(); float f2 = icon.getMinV(); float f3 = icon.getMaxV(); float f4 = 0.0F; float f5 = 0.3F; GL11.glEnable(GL12.GL_RESCALE_NORMAL); /* * GL11.glTranslatef( -f4, -f5, 0.0F); float f6 = 1.5F; GL11.glScalef( * f6, f6, f6); GL11.glRotatef( 50.0F, 0.0F, 1.0F, 0.0F); * GL11.glRotatef( 335.0F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef( * -0.9375F, -0.0625F, 0.0F); */ ItemRenderer.renderItemIn2D(tessellator, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 0.0625F); if (itemstack.hasEffect(index)) { GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_LIGHTING); texturemanager.bindTexture(RES_ITEM_GLINT); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); float f7 = 0.76F; GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glPushMatrix(); float f8 = 0.125F; GL11.glScalef(f8, f8, f8); float f9 = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F; GL11.glTranslatef(f9, 0.0F, 0.0F); GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glScalef(f8, f8, f8); f9 = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F; GL11.glTranslatef(-f9, 0.0F, 0.0F); GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthFunc(GL11.GL_LEQUAL); } GL11.glPopMatrix(); }
From source file:net.smert.frameworkgl.opengl.OpenGL1.java
License:Apache License
public OpenGL1 setDepthFuncAlways() { GL11.glDepthFunc(DepthFunctions.ALWAYS); return this; }
From source file:net.smert.frameworkgl.opengl.OpenGL1.java
License:Apache License
public OpenGL1 setDepthFuncEqual() { GL11.glDepthFunc(DepthFunctions.EQUAL); return this; }
From source file:net.smert.frameworkgl.opengl.OpenGL1.java
License:Apache License
public OpenGL1 setDepthFuncGreater() { GL11.glDepthFunc(DepthFunctions.GREATER); return this; }
From source file:net.smert.frameworkgl.opengl.OpenGL1.java
License:Apache License
public OpenGL1 setDepthFuncGreaterEqual() { GL11.glDepthFunc(DepthFunctions.GEQUAL); return this; }