List of usage examples for org.lwjgl.opengl GL11 GL_VERTEX_ARRAY
int GL_VERTEX_ARRAY
To view the source code for org.lwjgl.opengl GL11 GL_VERTEX_ARRAY.
Click Source Link
From source file:ion2d.INDirector.java
License:Open Source License
protected void enableDefaultGLStates() { if (Display.isCreated() == false) return;//from www . j a v a 2s .c o m GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glEnable(GL11.GL_TEXTURE_2D); }
From source file:ion2d.INDirector.java
License:Open Source License
protected void disableDefaultGLStates() { if (Display.isCreated() == false) return;/*from w w w .ja va 2 s .c o m*/ GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glDisable(GL11.GL_TEXTURE_2D); }
From source file:kuake2.render.lwjgl.Misc.java
License:Open Source License
void GL_SetDefaultState() { GL11.glClearColor(1f, 0f, 0.5f, 0.5f); // original quake2 //GL11.glClearColor(0, 0, 0, 0); // replaced with black GL11.glCullFace(GL11.GL_FRONT);// w w w. j a va 2 s . c o m GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glAlphaFunc(GL11.GL_GREATER, 0.666f); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_BLEND); GL11.glColor4f(1, 1, 1, 1); GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); GL11.glShadeModel(GL11.GL_FLAT); GL_TextureMode(gl_texturemode.string); GL_TextureAlphaMode(gl_texturealphamode.string); GL_TextureSolidMode(gl_texturesolidmode.string); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, gl_filter_min); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, gl_filter_max); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL_TexEnv(GL11.GL_REPLACE); if (qglPointParameterfEXT) { // float[] attenuations = { gl_particle_att_a.value, gl_particle_att_b.value, gl_particle_att_c.value }; FloatBuffer att_buffer = BufferUtils.createFloatBuffer(4); att_buffer.put(0, gl_particle_att_a.value); att_buffer.put(1, gl_particle_att_b.value); att_buffer.put(2, gl_particle_att_c.value); GL11.glEnable(GL11.GL_POINT_SMOOTH); EXTPointParameters.glPointParameterfEXT(EXTPointParameters.GL_POINT_SIZE_MIN_EXT, gl_particle_min_size.value); EXTPointParameters.glPointParameterfEXT(EXTPointParameters.GL_POINT_SIZE_MAX_EXT, gl_particle_max_size.value); EXTPointParameters.glPointParameterEXT(EXTPointParameters.GL_DISTANCE_ATTENUATION_EXT, att_buffer); } if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f) { GL11.glEnable(EXTSharedTexturePalette.GL_SHARED_TEXTURE_PALETTE_EXT); GL_SetTexturePalette(d_8to24table); } GL_UpdateSwapInterval(); /* * vertex array extension */ GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); ARBMultitexture.glClientActiveTextureARB(GL_TEXTURE0); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); }
From source file:lwjglapp.Renderer.java
void drawVBO() { FloatBuffer cBuffer = BufferUtils.createFloatBuffer(9); cBuffer.put(1).put(0).put(0);// w w w . j av a 2s.c om cBuffer.put(0).put(1).put(0); cBuffer.put(0).put(0).put(1); cBuffer.flip(); FloatBuffer vBuffer = BufferUtils.createFloatBuffer(9); vBuffer.put(-0.5f).put(-0.5f).put(0.0f); vBuffer.put(+0.5f).put(-0.5f).put(0.0f); vBuffer.put(+0.5f).put(+0.5f).put(0.0f); vBuffer.flip(); IntBuffer ib = BufferUtils.createIntBuffer(2); glGenBuffersARB(ib); int vHandle = ib.get(0); int cHandle = ib.get(1); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); glBindBufferARB(GL_ARRAY_BUFFER_ARB, vHandle); glBufferDataARB(GL_ARRAY_BUFFER_ARB, vBuffer, GL_STATIC_DRAW_ARB); GL11.glVertexPointer(3, GL11.GL_FLOAT, /* stride */ 3 << 2, 0L); glBindBufferARB(GL_ARRAY_BUFFER_ARB, cHandle); glBufferDataARB(GL_ARRAY_BUFFER_ARB, cBuffer, GL_STATIC_DRAW_ARB); GL11.glColorPointer(3, GL11.GL_FLOAT, /* stride */ 3 << 2, 0L); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, 3 /* elements */); glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); // cleanup VBO handles ib.put(0, vHandle); ib.put(1, cHandle); glDeleteBuffersARB(ib); }
From source file:net.adam_keenan.voxel.world.BlockVBO.java
License:Creative Commons License
public void render(BlockType type, float x, float y, float z) { TextureLoader.bind(Textures.SHEET);/*from w ww.j a v a2 s . c o m*/ int vertID = this.blockVertexBufferID, texID; switch (type) { case DIRT: texID = dirtTextureID; break; case STONE: texID = stoneTextureID; break; case GRASS: texID = grassTextureID; break; case AIR: texID = 0; break; case FIRE: texID = grassTextureID; vertID = this.projectileVBOID; break; default: texID = stoneTextureID; break; } if (texID == 0) return; GL11.glPushMatrix(); GL11.glTranslatef(x, y, z); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); // Vertex array ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, vertID); GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, 0); // Texture array ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, texID); GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0); // Index array ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, indexBufferID); // Draw 'em up GL12.glDrawRangeElements(GL11.GL_QUADS, 0, 6 * 4, 6 * 4, GL11.GL_UNSIGNED_INT, 0); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glPopMatrix(); TextureLoader.unbind(); }
From source file:net.kubin.rendering.ChunkMeshRenderer.java
License:Apache License
public static void renderChunkMesh(Chunk chunk, MeshType meshType) { if (chunk.getMesh().getVBO(meshType) <= 0) { return;// w w w . j a v a2 s .c o m } /* Bind the correct texture */ GL11.glEnable(GL11.GL_TEXTURE_2D); TextureStorage.getTexture("blocks").bind(); if (meshType == MeshType.OPAQUE) { GL11.glDisable(GL11.GL_BLEND); } else if (meshType == MeshType.TRANSLUCENT) { GL11.glDisable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glAlphaFunc(GL11.GL_GREATER, 0.0f); } ChunkMesh mesh = chunk.getMesh(); /* Bind the buffer */ ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, mesh.getVBO(meshType)); /* Enable the different kinds of data in the buffer */ GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); // System.out.println("Chunk Vertices = " + mesh.getVertexCount()); /* Define the starting positions */ GL11.glVertexPointer(POSITION_SIZE, GL11.GL_FLOAT, STRIDE * FLOAT_SIZE, POSITION_OFFSET * FLOAT_SIZE); GL11.glTexCoordPointer(TEX_COORD_SIZE, GL11.GL_FLOAT, STRIDE * FLOAT_SIZE, TEX_COORD_OFFSET * FLOAT_SIZE); GL11.glColorPointer(COLOR_SIZE, GL11.GL_FLOAT, STRIDE * FLOAT_SIZE, COLOR_OFFSET * FLOAT_SIZE); /* Draw the buffer */ GL11.glDrawArrays(GL11.GL_QUADS, 0, mesh.getVertexCount(meshType)); /* Unbind the buffer */ ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, 0); /* Disable the different kindds of data */ GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); if (meshType == MeshType.TRANSLUCENT) { GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_ALPHA_TEST); } }
From source file:net.minecraftforge.client.CloudRenderer.java
License:Open Source License
public boolean render(int cloudTicks, float partialTicks) { if (!isBuilt()) return false; Entity entity = mc.getRenderViewEntity(); double totalOffset = cloudTicks + partialTicks; double x = entity.prevPosX + (entity.posX - entity.prevPosX) * partialTicks + totalOffset * 0.03; double y = mc.world.provider.getCloudHeight() - (entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks) + 0.33; double z = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * partialTicks; int scale = getScale(); if (cloudMode == 2) z += 0.33 * scale;//from w w w . j a va2 s . c om // Integer UVs to translate the texture matrix by. int offU = fullCoord(x, scale); int offV = fullCoord(z, scale); GlStateManager.pushMatrix(); // Translate by the remainder after the UV offset. GlStateManager.translate((offU * scale) - x, y, (offV * scale) - z); // Modulo to prevent texture samples becoming inaccurate at extreme offsets. offU = offU % texW; offV = offV % texH; // Translate the texture. GlStateManager.matrixMode(GL11.GL_TEXTURE); GlStateManager.translate(offU * PX_SIZE, offV * PX_SIZE, 0); GlStateManager.matrixMode(GL11.GL_MODELVIEW); GlStateManager.disableCull(); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); // Color multiplier. Vec3d color = mc.world.getCloudColour(partialTicks); float r = (float) color.x; float g = (float) color.y; float b = (float) color.z; if (mc.gameSettings.anaglyph) { float tempR = r * 0.3F + g * 0.59F + b * 0.11F; float tempG = r * 0.3F + g * 0.7F; float tempB = r * 0.3F + b * 0.7F; r = tempR; g = tempG; b = tempB; } if (COLOR_TEX == null) COLOR_TEX = new DynamicTexture(1, 1); // Apply a color multiplier through a texture upload if shaders aren't supported. COLOR_TEX.getTextureData()[0] = 255 << 24 | ((int) (r * 255)) << 16 | ((int) (g * 255)) << 8 | (int) (b * 255); COLOR_TEX.updateDynamicTexture(); GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit); GlStateManager.bindTexture(COLOR_TEX.getGlTextureId()); GlStateManager.enableTexture2D(); // Bind the clouds texture last so the shader's sampler2D is correct. GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); mc.renderEngine.bindTexture(texture); ByteBuffer buffer = Tessellator.getInstance().getBuffer().getByteBuffer(); // Set up pointers for the display list/VBO. if (OpenGlHelper.useVbo()) { vbo.bindBuffer(); int stride = FORMAT.getNextOffset(); GlStateManager.glVertexPointer(3, GL11.GL_FLOAT, stride, 0); GlStateManager.glEnableClientState(GL11.GL_VERTEX_ARRAY); GlStateManager.glTexCoordPointer(2, GL11.GL_FLOAT, stride, 12); GlStateManager.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GlStateManager.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, stride, 20); GlStateManager.glEnableClientState(GL11.GL_COLOR_ARRAY); } else { buffer.limit(FORMAT.getNextOffset()); for (int i = 0; i < FORMAT.getElementCount(); i++) FORMAT.getElements().get(i).getUsage().preDraw(FORMAT, i, FORMAT.getNextOffset(), buffer); buffer.position(0); } // Depth pass to prevent insides rendering from the outside. GlStateManager.colorMask(false, false, false, false); if (OpenGlHelper.useVbo()) vbo.drawArrays(GL11.GL_QUADS); else GlStateManager.callList(displayList); // Full render. if (!mc.gameSettings.anaglyph) { GlStateManager.colorMask(true, true, true, true); } else { switch (EntityRenderer.anaglyphField) { case 0: GlStateManager.colorMask(false, true, true, true); break; case 1: GlStateManager.colorMask(true, false, false, true); break; } } // Wireframe for debug. if (WIREFRAME) { GlStateManager.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); GlStateManager.glLineWidth(2.0F); GlStateManager.disableTexture2D(); GlStateManager.depthMask(false); GlStateManager.disableFog(); if (OpenGlHelper.useVbo()) vbo.drawArrays(GL11.GL_QUADS); else GlStateManager.callList(displayList); GlStateManager.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); GlStateManager.depthMask(true); GlStateManager.enableTexture2D(); GlStateManager.enableFog(); } if (OpenGlHelper.useVbo()) { vbo.drawArrays(GL11.GL_QUADS); vbo.unbindBuffer(); // Unbind buffer and disable pointers. } else { GlStateManager.callList(displayList); } buffer.limit(0); for (int i = 0; i < FORMAT.getElementCount(); i++) FORMAT.getElements().get(i).getUsage().postDraw(FORMAT, i, FORMAT.getNextOffset(), buffer); buffer.position(0); // Disable our coloring. GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit); GlStateManager.disableTexture2D(); GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); // Reset texture matrix. GlStateManager.matrixMode(GL11.GL_TEXTURE); GlStateManager.loadIdentity(); GlStateManager.matrixMode(GL11.GL_MODELVIEW); GlStateManager.disableBlend(); GlStateManager.enableCull(); GlStateManager.popMatrix(); return true; }
From source file:net.smert.frameworkgl.opengl.helpers.VertexArrayHelper.java
License:Apache License
public void disableVertices() { GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); }
From source file:net.smert.frameworkgl.opengl.helpers.VertexArrayHelper.java
License:Apache License
public void enableVertices() { GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); }
From source file:opengl.Map.java
public void Draw() { float[] vertices = { -1.0f, -1.0f, -1.0f, -0.8f, 0.7f, -0.8f, 0.7f, -1.0f, 1.0f, -1.0f, 1.0f, -0.2f, 10000.7f, -0.97f, 10000.7f, -1.0f }; FloatBuffer triangle = BufferUtils.createFloatBuffer(vertices.length); triangle.put(vertices);/*from w w w .j a va 2s .c o m*/ triangle.flip(); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); // GL11.glColorPointer(3, GL11.GL_FLOAT, 0, triangleVertexBuffer); GL11.glVertexPointer(2, 0, triangle); GL11.glDrawArrays(GL11.GL_QUADS, 0, vertices.length / 2); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); }