List of usage examples for org.lwjgl.opengl GL11 glDisableClientState
public static native void glDisableClientState(@NativeType("GLenum") int cap);
From source file:com.timvisee.voxeltex.module.mesh.Mesh.java
License:Open Source License
/** * Render or draw the mesh using OpenGL. *///from w ww .ja v a2 s . c o m public void draw(Material material) { // Bind the vertex buffer glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle); GL11.glVertexPointer(this.raw.getVertexAxisCount(), GL11.GL_FLOAT, 0, 0L); // Bind the normal coordinate buffer if available if (hasNormalData()) { glBindBuffer(GL_ARRAY_BUFFER, vboNormalHandle); GL11.glNormalPointer(GL11.GL_FLOAT, 0, 0L); } // Bind the texture coordinate buffer if available if (hasTextureData()) { glBindBuffer(GL_ARRAY_BUFFER, vboTextureHandle); GL11.glTexCoordPointer(this.raw.getTextureAxisCount(), GL11.GL_FLOAT, 0, 0L); } // Enable the client states for the buffers that were bound GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); if (hasNormalData()) GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY); if (hasTextureData()) GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); // Draw the mesh GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, this.vertexCount); // Disable the client used states GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); if (hasNormalData()) GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY); if (hasTextureData()) GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); // Unbind all buffers GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); }
From source file:de.codesourcery.flocking.LWJGLRenderer.java
License:Apache License
private void renderWorld(World world) { final double modelMax = world.getSimulationParameters().modelMax; xInc = Display.getWidth() / modelMax; yInc = Display.getHeight() / modelMax; GL11.glEnable(GL11.GL_DEPTH_TEST);//from ww w .java 2 s . c om GL11.glDepthMask(true); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(false); GL11.glColor3f(0.5f, 0.5f, 1.0f); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); final int triangleCount = world.getPopulationCount(); // setup vertex data final int vertexArrayLen = triangleCount * 3 * 2; // one triangle = 3 vertices * 2 int's per vertex final MyIntBuffer vertexBuffer = getVertexBuffer(vertexArrayLen); final IntBuffer vertexIntBuffer = vertexBuffer.getBuffer(); final IBoidVisitor visitor = new IBoidVisitor() { @Override public void visit(Boid boid) { drawBoid(boid, vertexIntBuffer); } }; world.visitAllBoids(visitor); vertexBuffer.rewind(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertexBuffer.getHandle()); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertexBuffer.getBuffer(), GL15.GL_DYNAMIC_DRAW); GL11.glVertexPointer(2, GL11.GL_INT, 0, 0); // setup index data MyIntBuffer indexBuffer = getIndexBuffer(triangleCount * 3); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, indexBuffer.getHandle()); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indexBuffer.getBuffer(), GL15.GL_STATIC_DRAW); GL11.glDrawElements(GL11.GL_TRIANGLES, triangleCount * 3, GL11.GL_UNSIGNED_INT, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(true); }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
/** * Sets the OGL environment up to render points * /*from w w w . j a va2 s.c o m*/ * Disables textures, and vertex arrays * */ public void initPointRenderer() { // if(currentRenderMode == RENDERMODE_POINT) // return; /* GL11.glDepthMask(true); GL11.glEnable(GL11.GL_DEPTH_TEST); // Enables Depth Testing GL11.glDepthFunc(GL11.GL_LEQUAL); // The Type Of Depth Testing To Do GL11.glHint (GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); // Set Perspective Calculations To Most Accurate */ disableAllTextureUnits(); GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
public void initSolidAndLineRendering() { GL11.glDepthMask(true);//from www.ja v a 2s . c o m GL11.glEnable(GL11.GL_DEPTH_TEST); // Enables Depth Testing GL11.glDepthFunc(GL11.GL_LEQUAL); // The Type Of Depth Testing To Do GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); // Set Perspective Calculations To Most Accurate disableAllTextureUnits(); GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); }
From source file:go.graphics.swing.opengl.LWJGLDrawContext.java
License:Open Source License
@Override public void fillQuad(float x1, float y1, float x2, float y2) { ByteBuffer quadPoints = ByteBuffer.allocateDirect(4 * 2 * 4); quadPoints.order(ByteOrder.nativeOrder()); FloatBuffer floatBuff = quadPoints.asFloatBuffer(); floatBuff.put(x1);/*from w w w .j av a2 s . c om*/ floatBuff.put(y1); floatBuff.put(x1); floatBuff.put(y2); floatBuff.put(x2); floatBuff.put(y2); floatBuff.put(x2); floatBuff.put(y1); floatBuff.position(0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glVertexPointer(2, GL11.GL_FLOAT, 0, floatBuff); GL11.glDrawArrays(GL11.GL_QUADS, 0, 4); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); }
From source file:go.graphics.swing.opengl.LWJGLDrawContext.java
License:Open Source License
@Override public void drawLine(float[] points, boolean loop) { if (points.length % 3 != 0) { throw new IllegalArgumentException("Point array length needs to be multiple of 3."); }/*from ww w .j a va 2 s . c o m*/ ByteBuffer floatBuff = generateTemporaryFloatBuffer(points); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, floatBuff); GL11.glDrawArrays(loop ? GL11.GL_LINE_LOOP : GL11.GL_LINE_STRIP, 0, points.length / 3); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); }
From source file:go.graphics.swing.opengl.LWJGLDrawContext.java
License:Open Source License
@Override public void drawTrianglesWithTextureColored(TextureHandle texture, ByteBuffer buffer, int triangles) throws IllegalBufferException { bindTexture(texture);/*from w ww . j ava2s. c om*/ GL11.glVertexPointer(3, GL11.GL_FLOAT, 6 * 4, buffer); buffer.position(3 * 4); GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 6 * 4, buffer); buffer.position(5 * 4); GL11.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 6 * 4, buffer); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, triangles * 3); GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); }
From source file:go.graphics.swing.opengl.LWJGLDrawContext.java
License:Open Source License
@Override public void drawTrianglesWithTextureColored(TextureHandle texture, GeometryHandle geometry, int triangleCount) throws IllegalBufferException { if (canUseVBOs) { bindTexture(texture);/*from w w w.j a v a 2 s.c o m*/ bindArrayBuffer(geometry); GL11.glVertexPointer(3, GL11.GL_FLOAT, 6 * 4, 0); GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 6 * 4, 3 * 4); GL11.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 6 * 4, 5 * 4); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, triangleCount * 3); GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); bindArrayBuffer(null); } else { ByteBuffer buffer = getGeometryBuffer(geometry); drawTrianglesWithTextureColored(texture, buffer, buffer.remaining() / 4 / 5); } }
From source file:hellfirepvp.astralsorcery.client.sky.RenderDefaultSkybox.java
License:Open Source License
private static void renderDefaultSkybox(float partialTicks) { GlStateManager.disableTexture2D();/* w w w . j av a 2 s .c o m*/ Vec3d vec3 = Minecraft.getMinecraft().world.getSkyColor(Minecraft.getMinecraft().getRenderViewEntity(), partialTicks); float f = (float) vec3.xCoord; float f1 = (float) vec3.yCoord; float f2 = (float) vec3.zCoord; if (Minecraft.getMinecraft().gameSettings.anaglyph) { float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F; float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F; float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F; f = f3; f1 = f4; f2 = f5; } GlStateManager.color(f, f1, f2); Tessellator tessellator = Tessellator.getInstance(); net.minecraft.client.renderer.VertexBuffer vb = tessellator.getBuffer(); GlStateManager.depthMask(false); GlStateManager.enableFog(); GlStateManager.color(f, f1, f2); if (OpenGlHelper.useVbo()) { skyVBO.bindBuffer(); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0L); skyVBO.drawArrays(7); skyVBO.unbindBuffer(); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); } else { GlStateManager.callList(glSkyList); } GlStateManager.disableFog(); GlStateManager.disableAlpha(); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); RenderHelper.disableStandardItemLighting(); float[] afloat = Minecraft.getMinecraft().world.provider.calcSunriseSunsetColors( Minecraft.getMinecraft().world.getCelestialAngle(partialTicks), partialTicks); if (afloat != null) { GlStateManager.disableTexture2D(); GlStateManager.shadeModel(7425); GlStateManager.pushMatrix(); GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); GlStateManager.rotate( MathHelper.sin(Minecraft.getMinecraft().world.getCelestialAngleRadians(partialTicks)) < 0.0F ? 180.0F : 0.0F, 0.0F, 0.0F, 1.0F); GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F); float f6 = afloat[0]; float f7 = afloat[1]; float f8 = afloat[2]; if (Minecraft.getMinecraft().gameSettings.anaglyph) { float f9 = (f6 * 30.0F + f7 * 59.0F + f8 * 11.0F) / 100.0F; float f10 = (f6 * 30.0F + f7 * 70.0F) / 100.0F; float f11 = (f6 * 30.0F + f8 * 70.0F) / 100.0F; f6 = f9; f7 = f10; f8 = f11; } vb.begin(6, DefaultVertexFormats.POSITION_COLOR); vb.pos(0.0D, 100.0D, 0.0D).color(f6, f7, f8, afloat[3]).endVertex(); //int j = 16; for (int l = 0; l <= 16; ++l) { float f21 = (float) l * (float) Math.PI * 2.0F / 16.0F; float f12 = MathHelper.sin(f21); float f13 = MathHelper.cos(f21); vb.pos((double) (f12 * 120.0F), (double) (f13 * 120.0F), (double) (-f13 * 40.0F * afloat[3])) .color(afloat[0], afloat[1], afloat[2], 0.0F).endVertex(); } tessellator.draw(); GlStateManager.popMatrix(); GlStateManager.shadeModel(7424); } GlStateManager.enableTexture2D(); GlStateManager.tryBlendFuncSeparate(770, 1, 1, 0); GlStateManager.pushMatrix(); float f16 = 1.0F - Minecraft.getMinecraft().world.getRainStrength(partialTicks); GlStateManager.color(1.0F, 1.0F, 1.0F, f16); GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(Minecraft.getMinecraft().world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F); float f17 = 30.0F; Minecraft.getMinecraft().renderEngine.bindTexture(MC_DEF_SUN_PNG); vb.begin(7, DefaultVertexFormats.POSITION_TEX); vb.pos((double) (-f17), 100.0D, (double) (-f17)).tex(0.0D, 0.0D).endVertex(); vb.pos((double) f17, 100.0D, (double) (-f17)).tex(1.0D, 0.0D).endVertex(); vb.pos((double) f17, 100.0D, (double) f17).tex(1.0D, 1.0D).endVertex(); vb.pos((double) (-f17), 100.0D, (double) f17).tex(0.0D, 1.0D).endVertex(); tessellator.draw(); f17 = 20.0F; Minecraft.getMinecraft().renderEngine.bindTexture(MC_DEF_MOON_PHASES_PNG); int i = Minecraft.getMinecraft().world.getMoonPhase(); int k = i % 4; int i1 = i / 4 % 2; float f22 = (float) (k) / 4.0F; float f23 = (float) (i1) / 2.0F; float f24 = (float) (k + 1) / 4.0F; float f14 = (float) (i1 + 1) / 2.0F; vb.begin(7, DefaultVertexFormats.POSITION_TEX); vb.pos((double) (-f17), -100.0D, (double) f17).tex((double) f24, (double) f14).endVertex(); vb.pos((double) f17, -100.0D, (double) f17).tex((double) f22, (double) f14).endVertex(); vb.pos((double) f17, -100.0D, (double) (-f17)).tex((double) f22, (double) f23).endVertex(); vb.pos((double) (-f17), -100.0D, (double) (-f17)).tex((double) f24, (double) f23).endVertex(); tessellator.draw(); GlStateManager.disableTexture2D(); float f15 = Minecraft.getMinecraft().world.getStarBrightness(partialTicks) * f16; if (f15 > 0.0F) { GlStateManager.color(f15, f15, f15, f15); if (OpenGlHelper.useVbo()) { starVBO.bindBuffer(); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0L); starVBO.drawArrays(7); starVBO.unbindBuffer(); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); } else { GlStateManager.callList(starGLCallList); } } GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.disableBlend(); GlStateManager.enableAlpha(); GlStateManager.enableFog(); GlStateManager.popMatrix(); GlStateManager.disableTexture2D(); GlStateManager.color(0.0F, 0.0F, 0.0F); double d0 = Minecraft.getMinecraft().player.getPositionEyes(partialTicks).yCoord - Minecraft.getMinecraft().world.getHorizon(); if (d0 < 0.0D) { GlStateManager.pushMatrix(); GlStateManager.translate(0.0F, 12.0F, 0.0F); if (OpenGlHelper.useVbo()) { sky2VBO.bindBuffer(); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0L); sky2VBO.drawArrays(7); sky2VBO.unbindBuffer(); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); } else { GlStateManager.callList(glSkyList2); } GlStateManager.popMatrix(); //float f18 = 1.0F; float f19 = -((float) (d0 + 65.0D)); //float f20 = -1.0F; vb.begin(7, DefaultVertexFormats.POSITION_COLOR); vb.pos(-1.0D, (double) f19, 1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(1.0D, (double) f19, 1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(-1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(-1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(1.0D, (double) f19, -1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(-1.0D, (double) f19, -1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(1.0D, (double) f19, 1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(1.0D, (double) f19, -1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(-1.0D, (double) f19, -1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(-1.0D, (double) f19, 1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(-1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(-1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(-1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(-1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex(); tessellator.draw(); } if (Minecraft.getMinecraft().world.provider.isSkyColored()) { GlStateManager.color(f * 0.2F + 0.04F, f1 * 0.2F + 0.04F, f2 * 0.6F + 0.1F); } else { GlStateManager.color(f, f1, f2); } GlStateManager.pushMatrix(); GlStateManager.translate(0.0F, -((float) (d0 - 16.0D)), 0.0F); GlStateManager.callList(glSkyList2); GlStateManager.popMatrix(); GlStateManager.enableTexture2D(); GlStateManager.depthMask(true); }
From source file:illarion.graphics.lwjgl.DriverSettingsLWJGL.java
License:Open Source License
/** * Disable the last activated mode./*from w ww .j ava2 s . co m*/ */ private void disableLast() { if (currentMode == MODE_TEXTURE) { GL11.glDisable(GL11.GL_TEXTURE_2D); } else if (currentMode == MODE_TEXTUREPOINTER) { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); } else if (currentMode == MODE_DRAWDOT) { GL11.glDisable(GL11.GL_POINT_SMOOTH); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); } else if (currentMode == MODE_DRAWLINE) { GL11.glDisable(GL11.GL_LINE_SMOOTH); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); } else if (currentMode == MODE_DRAWPOLY) { GL11.glDisable(GL11.GL_POLYGON_SMOOTH); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); } else if (currentMode == MODE_DRAWPOLY) { GL11.glDisable(GL11.GL_POLYGON_SMOOTH); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); } }