List of usage examples for org.lwjgl.opengl GL11 glDrawArrays
public static void glDrawArrays(@NativeType("GLenum") int mode, @NativeType("GLint") int first, @NativeType("GLsizei") int count)
From source file:a1.gui.GUI_Map.java
License:Open Source License
public void DrawTiles() { int x, y, i;/* w w w . ja va 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:ar.com.quark.backend.lwjgl.opengl.DesktopGLES20.java
License:Apache License
/** * {@inheritDoc}/*from w w w .j a va 2 s .c om*/ */ @Override public void glDrawArrays(int primitive, int offset, int count) { GL11.glDrawArrays(primitive, offset, count); }
From source file:bd.ac.seu.lwjgldemo.Renderer.java
private void drawSomething() { GL11.glClearColor(0, 0, 0, 1);/*from w ww .j av a 2 s.c o m*/ GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); GL11.glColor3f(1, 1, 0); GL11.glPushMatrix(); GL11.glRotatef(angle, 0, 0, 1); /* GL11.glBegin(GL11.GL_QUADS); for (int row = 0; row < vertices.length; row = row + 3) { double x = vertices[row]; double y = vertices[row + 1]; double z = vertices[row + 2]; GL11.glVertex3d(x, y, z); } GL11.glEnd(); */ GL30.glBindVertexArray(vaoId); GL20.glEnableVertexAttribArray(0); // Draw the vertices GL11.glDrawArrays(GL11.GL_QUADS, 0, vertices.length / 3); // Put everything back to default (deselect) GL20.glDisableVertexAttribArray(0); GL30.glBindVertexArray(0); GL11.glPopMatrix(); angle = angle + .10f; frameCounter++; long currentTime = System.nanoTime(); long timeDifference = currentTime - lastTime; double fps = 1000000000.0 / timeDifference; System.out.printf("FPS: %.3f\n", fps); lastTime = currentTime; }
From source file:com.ardor3d.renderer.lwjgl.LwjglRenderer.java
License:Open Source License
@Override public void drawArrays(final FloatBufferData vertices, final int[] indexLengths, final IndexMode[] indexModes, final int primcount) { if (indexLengths == null) { final int glIndexMode = getGLIndexMode(indexModes[0]); if (primcount < 0) { GL11.glDrawArrays(glIndexMode, 0, vertices.getTupleCount()); } else {/*from w w w .j a v a2 s .co m*/ GL31.glDrawArraysInstanced(glIndexMode, 0, vertices.getTupleCount(), primcount); } if (Constants.stats) { addStats(indexModes[0], vertices.getTupleCount()); } } else { int offset = 0; int indexModeCounter = 0; for (int i = 0; i < indexLengths.length; i++) { final int count = indexLengths[i]; final int glIndexMode = getGLIndexMode(indexModes[indexModeCounter]); if (primcount < 0) { GL11.glDrawArrays(glIndexMode, offset, count); } else { GL31.glDrawArraysInstanced(glIndexMode, offset, count, primcount); } if (Constants.stats) { addStats(indexModes[indexModeCounter], count); } offset += count; if (indexModeCounter < indexModes.length - 1) { indexModeCounter++; } } } }
From source file:com.badlogic.gdx.backends.jglfw.JglfwGL20.java
License:Apache License
public void glDrawArrays(int mode, int first, int count) { GL11.glDrawArrays(mode, first, count); }
From source file:com.badlogic.gdx.backends.lwjgl.LwjglGL10.java
License:Apache License
public final void glDrawArrays(int mode, int first, int count) { GL11.glDrawArrays(mode, first, count); }
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 va 2 s .c om*/ 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.RenderTarget.java
public void draw(VertexCache verts, PrimitiveType type, RenderStates states) { if (verts == null) { return;//from www .j a v a2 s . c o m } if (verts.getSize() <= 0) { return; } FloatBuffer v, c, t; v = verts.getVertexBuffer(); c = verts.getColorBuffer(); t = verts.getTexcoordsBuffer(); if (v == null || c == null || t == null) { return; } //if(true) {return;} if (!activate(true)) { return; } if (!mCache.glStatesSet) { resetGLStates(); } View oldView = null; if (states.gui) { oldView = mView; setView(new View(0.f, 0.f, mView.mSizeX, mView.mSizeY)); } applyTransform(states.transform); if (mCache.viewChanged) { applyCurrentView(); } if (mCache.lastBlendMode != states.blendMode) { applyBlendMode(states.blendMode); } int textureId = (states.texture != null ? states.texture.getTextureID() : 0); if (textureId != mCache.lastTextureId) { applyTexture(states.texture); } // 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, v); GL11.glColorPointer(4, 0, c); GL11.glTexCoordPointer(2, 0, t); 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; } // Draw the verticies GL11.glDrawArrays(mode, 0, verts.getSize()); if (oldView != null) { setView(oldView); } }
From source file:com.dinasgames.engine.graphics.RenderTarget.java
public void draw(Vertex[] verts, PrimitiveType type, RenderStates states) { if (verts == null) { return;/*from www . jav a 2 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.google.gapid.glviewer.gl.Renderer.java
License:Apache License
/** Draws primitives using the vertex data bound to the given shader. */ public static void draw(Shader shader, int primitive, int vertexCount) { shader.bind();/*from w w w . j av a 2 s. com*/ GL11.glDrawArrays(primitive, 0, vertexCount); }