List of usage examples for org.lwjgl.opengl GL11 glColorPointer
public static void glColorPointer(@NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") FloatBuffer pointer)
From source file:a1.gui.GUI_Map.java
License:Open Source License
public void DrawTiles() { int x, y, i;/* w w w . j a v a 2 s .c o m*/ int stw, sth; Coord oc, tc, ctc, sc; RenderedTiles = 0; Render2D.ChangeColor(); Sprite.setStaticColor(); // ? ? stw = (TILE_SIZE * 4) - 2; sth = TILE_SIZE * 2; // ? ? Coord sz = scaled_size; oc = viewoffset(sz, mc); // ? ? tc = mc.div(TILE_SIZE); tc.x += -(sz.x / (2 * stw)) - (sz.y / (2 * sth)) - 2; tc.y += (sz.x / (2 * stw)) - (sz.y / (2 * sth)); if (needUpdateView) { needUpdateView = false; for (y = 0; y < (sz.y / sth) + 13; y++) { for (x = 0; x < (sz.x / stw) + 3; x++) { for (i = 0; i < 2; i++) { // ctc = tc.add(new Coord(x + y, y - x + i)); // ? sc = m2s(ctc.mul(TILE_SIZE)).add(oc); sc.x -= TILE_SIZE * 2; // // ? drawtile(ctc, sc); } } } // ? ? if (Config.tile_grid) { for (y = 0; y < (sz.y / sth) + 2; y++) { for (x = 0; x < (sz.x / stw) + 3; x++) { for (i = 0; i < 2; i++) { ctc = tc.add(new Coord(x + y, -x + y + i)); sc = m2s(ctc.mul(TILE_SIZE)).add(oc); drawtile_grid(sc); } } } } if (render_claims) { Color col; for (ClaimPersonal claim : Claims.claims.values()) { if (Player.CharID == claim.owner_id) { col = new Color(0f, 1f, 1f, 0.25f); // if (Claims.expand_claim != null) // continue; } else col = new Color(1f, 0f, 0f, 0.25f); putClaim(claim, oc, col); } if (Claims.expand_claim != null) { col = new Color(0f, 0f, 0.8f, 0.17f); putClaim(Claims.expand_claim, oc, col); } } // updateVBO(); } Color.white.bind(); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, tile_vbo); GL11.glVertexPointer(2, GL11.GL_FLOAT, 16, 0L); GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 16, 8L); Resource.textures.get("tiles").bind(); GL11.glDrawArrays(GL11.GL_QUADS, 0, tile_drawCount); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); if (render_claims) { GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, claim_vbo); GL11.glColorPointer(4, GL11.GL_FLOAT, 24, 0L); GL11.glVertexPointer(2, GL11.GL_FLOAT, 24, 16L); GL11.glDrawArrays(GL11.GL_QUADS, 0, claim_drawCount); GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); } if (Config.tile_grid) { GL11.glColor4f(0.0f, 0.0f, 0.0f, 0.4f); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, tileGrid_vbo); GL11.glVertexPointer(2, GL11.GL_FLOAT, 0, 0L); GL11.glDrawArrays(GL11.GL_LINES, 0, tileGrid_drawCount); } GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); }
From source file:com.ardor3d.renderer.lwjgl.LwjglRenderer.java
License:Open Source License
public void setupColorDataVBO(final FloatBufferData data) { final RenderContext context = ContextManager.getCurrentContext(); final RendererRecord rendRecord = context.getRendererRecord(); final int vboID = setupVBO(data, context); if (vboID != 0) { GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); LwjglRendererUtil.setBoundVBO(rendRecord, vboID); GL11.glColorPointer(data.getValuesPerTuple(), GL11.GL_FLOAT, 0, 0); } else {//from www . j a va 2 s . com GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); } }
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);/* ww w . j av a 2 s . c o m*/ 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.badlogic.gdx.backends.lwjgl.LwjglGL11.java
License:Apache License
public void glColorPointer(int size, int type, int stride, int pointer) { GL11.glColorPointer(size, type, stride, pointer); }
From source file:com.dinasgames.engine.graphics.GL.java
public static void render(Vertex[] verts) { init();// w w 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:game.level.map.TileMap.java
License:Open Source License
public void Render() { GL11.glPushMatrix();/*w w w . j ava2 s . co m*/ GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, VBOVertexHandle); GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, 0L); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, VBOColorHandle); GL11.glColorPointer(3, GL11.GL_FLOAT, 0, 0L); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, VBONormalHandle); GL11.glNormalPointer(GL11.GL_FLOAT, 0, 0L); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); if (DebugMode) { GL11.glDrawArrays(GL11.GL_LINE_LOOP, 0, Quads * 16); } else { GL11.glDrawArrays(GL11.GL_QUADS, 0, Quads * 16); } for (int y = 0; y < tiles.length; y++) { for (int x = 0; x < tiles[0].length; x++) { if (tiles[y][x].IsFloor) { try { tiles[y][x].Render(x, y); } catch (Exception e) { } } } } GL11.glPopMatrix(); // } }
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);/* w w w. j a v a2 s . c o m*/ 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 ava2 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:jake2.desktop.LWJGLAdapter.java
License:Open Source License
@Override public void glColorPointer(int size, boolean b, int stride, ByteBuffer pointer) { GL11.glColorPointer(size, b, stride, pointer); }
From source file:jpcsp.graphics.RE.RenderingEngineLwjgl.java
License:Open Source License
@Override public void setColorPointer(int size, int type, int stride, long offset) { GL11.glColorPointer(size, pointerTypeToGL[type], stride, offset); }