List of usage examples for org.lwjgl.opengl GL11 glEnableClientState
public static native void glEnableClientState(@NativeType("GLenum") int cap);
From source file:com.ardor3d.renderer.lwjgl.LwjglRenderer.java
License:Open Source License
public void setupTextureDataVBO(final List<FloatBufferData> textureCoords) { final RenderContext context = ContextManager.getCurrentContext(); final RendererRecord rendRecord = context.getRendererRecord(); final ContextCapabilities caps = context.getCapabilities(); final TextureState ts = (TextureState) context.getCurrentState(RenderState.StateType.Texture); int enabledTextures = rendRecord.getEnabledTextures(); final boolean valid = rendRecord.isTexturesValid(); boolean exists, wasOn; if (ts != null) { final int max = caps.isMultitextureSupported() ? Math.min(caps.getNumberOfFragmentTexCoordUnits(), TextureState.MAX_TEXTURES) : 1;/*from w w w. j a va2 s . co m*/ for (int i = 0; i < max; i++) { wasOn = (enabledTextures & (2 << i)) != 0; exists = textureCoords != null && i < textureCoords.size(); if (!exists) { if (valid && !wasOn) { continue; } else { checkAndSetTextureArrayUnit(i, rendRecord, caps); // disable bit in tracking int enabledTextures &= ~(2 << i); // disable state GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); continue; } } else { checkAndSetTextureArrayUnit(i, rendRecord, caps); // grab a vboID and make sure it exists and is up to date. final FloatBufferData data = textureCoords.get(i); final int vboID = setupVBO(data, context); // Found good vbo if (vboID != 0) { if (!valid || !wasOn) { // enable bit in tracking int enabledTextures |= (2 << i); // enable state GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); } // set our active vbo LwjglRendererUtil.setBoundVBO(rendRecord, vboID); // send data GL11.glTexCoordPointer(data.getValuesPerTuple(), GL11.GL_FLOAT, 0, 0); } // Not a good vbo, disable it. else { if (!valid || wasOn) { // disable bit in tracking int enabledTextures &= ~(2 << i); // disable state GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); } } } } } rendRecord.setEnabledTextures(enabledTextures); rendRecord.setTexturesValid(true); }
From source file:com.ardor3d.renderer.lwjgl.LwjglRenderer.java
License:Open Source License
public void setupInterleavedDataVBO(final FloatBufferData interleaved, final FloatBufferData vertexCoords, final FloatBufferData normalCoords, final FloatBufferData colorCoords, final List<FloatBufferData> textureCoords) { final RenderContext context = ContextManager.getCurrentContext(); final RendererRecord rendRecord = context.getRendererRecord(); final ContextCapabilities caps = context.getCapabilities(); final int lengthBytes = getTotalInterleavedSize(context, vertexCoords, normalCoords, colorCoords, textureCoords);//from w ww. j a va 2s .c om int currLengthBytes = 0; if (interleaved.getBufferLimit() > 0) { interleaved.getBuffer().rewind(); currLengthBytes = Math.round(interleaved.getBuffer().get()); } if (lengthBytes != currLengthBytes || interleaved.getVBOID(context.getGlContextRep()) == 0 || interleaved.isNeedsRefresh()) { initializeInterleavedVBO(context, interleaved, vertexCoords, normalCoords, colorCoords, textureCoords, lengthBytes); } final int vboID = interleaved.getVBOID(context.getGlContextRep()); LwjglRendererUtil.setBoundVBO(rendRecord, vboID); int offsetBytes = 0; if (normalCoords != null) { updateVBO(normalCoords, rendRecord, vboID, offsetBytes); GL11.glNormalPointer(GL11.GL_FLOAT, 0, offsetBytes); GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY); offsetBytes += normalCoords.getBufferLimit() * 4; } else { GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY); } if (colorCoords != null) { updateVBO(colorCoords, rendRecord, vboID, offsetBytes); GL11.glColorPointer(colorCoords.getValuesPerTuple(), GL11.GL_FLOAT, 0, offsetBytes); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); offsetBytes += colorCoords.getBufferLimit() * 4; } else { GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); } if (textureCoords != null) { final TextureState ts = (TextureState) context.getCurrentState(RenderState.StateType.Texture); int enabledTextures = rendRecord.getEnabledTextures(); final boolean valid = rendRecord.isTexturesValid(); boolean exists, wasOn; if (ts != null) { final int max = caps.isMultitextureSupported() ? Math.min(caps.getNumberOfFragmentTexCoordUnits(), TextureState.MAX_TEXTURES) : 1; for (int i = 0; i < max; i++) { wasOn = (enabledTextures & (2 << i)) != 0; exists = textureCoords != null && i < textureCoords.size() && textureCoords.get(i) != null && i <= ts.getMaxTextureIndexUsed(); if (!exists) { if (valid && !wasOn) { continue; } else { checkAndSetTextureArrayUnit(i, rendRecord, caps); // disable bit in tracking int enabledTextures &= ~(2 << i); // disable state GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); continue; } } else { checkAndSetTextureArrayUnit(i, rendRecord, caps); // grab a vboID and make sure it exists and is up to date. final FloatBufferData textureBufferData = textureCoords.get(i); updateVBO(textureBufferData, rendRecord, vboID, offsetBytes); if (!valid || !wasOn) { // enable bit in tracking int enabledTextures |= (2 << i); // enable state GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); } // send data GL11.glTexCoordPointer(textureBufferData.getValuesPerTuple(), GL11.GL_FLOAT, 0, offsetBytes); offsetBytes += textureBufferData.getBufferLimit() * 4; } } } rendRecord.setEnabledTextures(enabledTextures); rendRecord.setTexturesValid(true); } if (vertexCoords != null) { updateVBO(vertexCoords, rendRecord, vboID, offsetBytes); GL11.glVertexPointer(vertexCoords.getValuesPerTuple(), GL11.GL_FLOAT, 0, offsetBytes); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); } else { GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); } }
From source file:com.auroraengine.opengl.model.CreatureVertexFormat.java
License:Open Source License
@Override public void enable() { GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); }
From source file:com.auroraengine.opengl.model.ModifiableVertexFormat.java
License:Open Source License
@Override public void enable() { GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); if (usage_normal != null) { GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY); }/*w w w . ja v a 2s.c o m*/ if (usage_colour != null) { GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); } for (BufferUsage usage_tex_coord : usage_tex_coords) { if (usage_tex_coord != null) { GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); break; } } }
From source file:com.auroraengine.opengl.model.VertexBuffer.java
License:Open Source License
public void enableClientState() { // Bindings should be based on the nvidia general requirements GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); }
From source file:com.badlogic.gdx.backends.lwjgl.LwjglGL10.java
License:Apache License
public final void glEnableClientState(int array) { GL11.glEnableClientState(array); }
From source file:com.colonycraft.rendering.world.ChunkMeshRenderer.java
License:Apache License
public static void renderChunkMesh(World world, Chunk chunk, int meshType) { /* Bind the correct texture */ GL11.glEnable(GL11.GL_TEXTURE_2D);// w w w . j a v a2 s .c o m TextureStorage.getTexture("terrain").bind(); if (meshType == ChunkMesh.MESH_OPAQUE) { GL11.glDisable(GL11.GL_BLEND); } else if (meshType == ChunkMesh.MESH_TRANSLUCENT || meshType == ChunkMesh.MESH_GRASS) { 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 cmesh = chunk.getMesh(); Mesh mesh = cmesh.getMesh(meshType); if (mesh == null) return; /* Bind the buffer */ GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, mesh.getVertexBufferHandle()); /* Enable the different kinds of data in the buffer */ GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); if (meshType == ChunkMesh.MESH_GRASS) { GL20.glEnableVertexAttribArray(GRASS_ATTRIBUTE_LIGHT); } else { GL20.glEnableVertexAttribArray(CHUNK_ATTRIBUTE_LIGHT); } /* 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); GL20.glVertexAttribPointer(CHUNK_ATTRIBUTE_LIGHT, 2, GL11.GL_FLOAT, false, STRIDE * FLOAT_SIZE, LIGHT_OFFSET * FLOAT_SIZE); /* Draw the buffer */ GL11.glDrawArrays(GL11.GL_QUADS, 0, mesh.vertices()); /* Unbind the buffer */ GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); /* Disable the different kinds of data */ GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); if (meshType == ChunkMesh.MESH_GRASS) { GL20.glDisableVertexAttribArray(GRASS_ATTRIBUTE_LIGHT); } else { GL20.glDisableVertexAttribArray(CHUNK_ATTRIBUTE_LIGHT); } if (meshType == ChunkMesh.MESH_TRANSLUCENT || meshType == ChunkMesh.MESH_GRASS) { GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_ALPHA_TEST); } }
From source file:com.dinasgames.engine.graphics.GL.java
public static void render(Vertex[] verts) { init();// ww w . j a v a 2 s . c o m int numberIndices = verts.length / 3; vertexBuffer = BufferUtils.createFloatBuffer(verts.length * 2); colorBuffer = BufferUtils.createFloatBuffer(verts.length); indexBuffer = BufferUtils.createFloatBuffer(verts.length); vertexBuffer.clear(); colorBuffer.clear(); indexBuffer.clear(); for (Vertex vert : verts) { vertexBuffer.put(vert.x); vertexBuffer.put(vert.y); GLColor c = vert.color.toGLColor(); colorBuffer.put(c.getRed()); colorBuffer.put(c.getGreen()); colorBuffer.put(c.getBlue()); colorBuffer.put(c.getAlpha()); } vertexBufferData(vertexBufferID, vertexBuffer); colorBufferData(colorBufferID, colorBuffer); // Push verticies to OpenGL GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertexBufferID); GL11.glVertexPointer(2, GL11.GL_FLOAT, 0, 0); // Push color values to OpenGL GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, colorBufferID); GL11.glColorPointer(4, GL11.GL_FLOAT, 0, 0); // Draw the shape GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, indexBufferID); GL11.glDrawElements(GL11.GL_TRIANGLES, numberIndices, GL11.GL_UNSIGNED_INT, 0); // Disalble client state for vertex and color GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); }
From source file:com.dinasgames.engine.graphics.RenderTarget.java
public void draw(Vertex[] verts, PrimitiveType type, RenderStates states) { if (verts == null) { return;// w w w . j a va2 s . c o m } if (verts.length == 0) { return; } if (activate(true)) { if (!mCache.glStatesSet) { resetGLStates(); } boolean useVertexCache = (verts.length <= StatusCache.VertexCacheSize); if (useVertexCache) { for (int i = 0; i < verts.length; i++) { Vertex v = mCache.vertexCache[i]; Vector2f p = Transform.multiply(states.transform, new Vector2f(verts[i].x, verts[i].y)); v.x = p.x; v.y = p.y; v.color = verts[i].color; v.tx = verts[i].tx; v.ty = verts[i].ty; } if (!mCache.useVertexCache) { applyTransform(Transform.Identity); } } else { applyTransform(states.transform); } if (mCache.viewChanged) { applyCurrentView(); } if (!mCache.lastBlendMode.equals(states.blendMode)) { applyBlendMode(states.blendMode); } int textureId = (states.texture != null ? states.texture.getTextureID() : 0); if (textureId != mCache.lastTextureId) { applyTexture(states.texture); } if (useVertexCache) { if (!mCache.useVertexCache) { verts = new Vertex[mCache.vertexCache.length]; for (int i = 0; i < mCache.vertexCache.length; i++) { verts[i] = new Vertex(mCache.vertexCache[i]); } } else { //verts = null; return; } } if (verts != null) { // Create some buffers to store vertex and color data FloatBuffer vertexBuffer = BufferUtils.createFloatBuffer(verts.length * 2); FloatBuffer colorBuffer = BufferUtils.createFloatBuffer(verts.length * 4); FloatBuffer tcBuffer = BufferUtils.createFloatBuffer(verts.length * 2); // Copy the vertex and color data to the buffers for (Vertex vert : verts) { // Write vertex coordinate (XY) vertexBuffer.put(vert.x); vertexBuffer.put(vert.y); tcBuffer.put(vert.tx); tcBuffer.put(vert.ty); // Write Color (RGBA) GLColor c = vert.color.toGLColor(); colorBuffer.put(c.getRed()); colorBuffer.put(c.getGreen()); colorBuffer.put(c.getBlue()); colorBuffer.put(c.getAlpha()); } // Flip the buffer so it can be used vertexBuffer.flip(); colorBuffer.flip(); tcBuffer.flip(); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); // Give the buffers to OpenGL GL11.glVertexPointer(2, 0, vertexBuffer); GL11.glColorPointer(4, 0, colorBuffer); GL11.glTexCoordPointer(2, 0, tcBuffer); } int mode = -1; switch (type) { case Points: mode = GL11.GL_POINTS; break; case Lines: mode = GL11.GL_LINES; break; case LinesStrip: mode = GL11.GL_LINE_STRIP; break; case Triangles: mode = GL11.GL_TRIANGLES; break; case TrianglesStrip: mode = GL11.GL_TRIANGLE_STRIP; break; case TrianglesFan: mode = GL11.GL_TRIANGLE_FAN; break; case Quads: mode = GL11.GL_QUADS; break; } if (mode == -1) { return; } if (verts != null) { GL11.glDrawArrays(mode, 0, verts.length); } mCache.useVertexCache = useVertexCache; } }
From source file:com.dinasgames.engine.graphics.RenderTarget.java
public void resetGLStates() { //if(true){return;} if (activate(true)) { //GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND);//w ww.jav a2 s. co m GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); //GL11.glEnable(GL13.GL_MULTISAMPLE); mCache.glStatesSet = true; applyBlendMode(BlendMode.BlendAlpha); applyTransform(Transform.Identity); applyTexture(null); mCache.useVertexCache = false; setView(new View(getView())); } }