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:kuake2.render.lwjgl.Surf.java
License:Open Source License
/** * DrawGLPoly */ void DrawGLPoly(glpoly_t p) { GL11.glDrawArrays(GL11.GL_POLYGON, p.pos, p.numverts); }
From source file:kuake2.render.lwjgl.Surf.java
License:Open Source License
/** * DrawGLFlowingPoly//w w w . j ava2 s . c o m * version that handles scrolling texture */ void DrawGLFlowingPoly(glpoly_t p) { float scroll = -64 * ((r_newrefdef.time / 40.0f) - (int) (r_newrefdef.time / 40.0f)); if (scroll == 0.0f) scroll = -64.0f; p.beginScrolling(scroll); GL11.glDrawArrays(GL11.GL_POLYGON, p.pos, p.numverts); p.endScrolling(); }
From source file:kuake2.render.lwjgl.Surf.java
License:Open Source License
/** * GL_RenderLightmappedPoly/*www . j av a 2s. c o m*/ * * @param surf */ void GL_RenderLightmappedPoly(msurface_t surf) { // ersetzt goto boolean gotoDynamic = false; int map; for (map = 0; map < Defines.MAXLIGHTMAPS && (surf.styles[map] != (byte) 255); map++) { if (r_newrefdef.lightstyles[surf.styles[map] & 0xFF].white != surf.cached_light[map]) { gotoDynamic = true; break; } } // this is a hack from cwei if (map == 4) map--; // dynamic this frame or dynamic previously boolean is_dynamic = false; if (gotoDynamic || (surf.dlightframe == r_framecount)) { // label dynamic: if (gl_dynamic.value != 0) { if ((surf.texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 | Defines.SURF_TRANS66 | Defines.SURF_WARP)) == 0) { is_dynamic = true; } } } glpoly_t p; image_t image = R_TextureAnimation(surf.texinfo); int lmtex = surf.lightmaptexturenum; if (is_dynamic) { // ist raus gezogen worden int[] temp = new int[128*128]; int smax, tmax; if (((surf.styles[map] & 0xFF) >= 32 || surf.styles[map] == 0) && (surf.dlightframe != r_framecount)) { smax = (surf.extents[0] >> 4) + 1; tmax = (surf.extents[1] >> 4) + 1; R_BuildLightMap(surf, temp, smax); R_SetCacheState(surf); GL_MBind(GL_TEXTURE1, gl_state.lightmap_textures + surf.lightmaptexturenum); lmtex = surf.lightmaptexturenum; GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, surf.light_s, surf.light_t, smax, tmax, GL_LIGHTMAP_FORMAT, GL11.GL_UNSIGNED_BYTE, temp); } else { smax = (surf.extents[0] >> 4) + 1; tmax = (surf.extents[1] >> 4) + 1; R_BuildLightMap(surf, temp, smax); GL_MBind(GL_TEXTURE1, gl_state.lightmap_textures + 0); lmtex = 0; GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, surf.light_s, surf.light_t, smax, tmax, GL_LIGHTMAP_FORMAT, GL11.GL_UNSIGNED_BYTE, temp); } c_brush_polys++; GL_MBind(GL_TEXTURE0, image.texnum); GL_MBind(GL_TEXTURE1, gl_state.lightmap_textures + lmtex); // ========== // PGM if ((surf.texinfo.flags & Defines.SURF_FLOWING) != 0) { float scroll; scroll = -64 * ((r_newrefdef.time / 40.0f) - (int) (r_newrefdef.time / 40.0f)); if (scroll == 0.0f) scroll = -64.0f; for (p = surf.polys; p != null; p = p.chain) { p.beginScrolling(scroll); GL11.glDrawArrays(GL11.GL_POLYGON, p.pos, p.numverts); p.endScrolling(); } } else { for (p = surf.polys; p != null; p = p.chain) { GL11.glDrawArrays(GL11.GL_POLYGON, p.pos, p.numverts); } } // PGM // ========== } else { c_brush_polys++; GL_MBind(GL_TEXTURE0, image.texnum); GL_MBind(GL_TEXTURE1, gl_state.lightmap_textures + lmtex); // ========== // PGM if ((surf.texinfo.flags & Defines.SURF_FLOWING) != 0) { float scroll; scroll = -64 * ((r_newrefdef.time / 40.0f) - (int) (r_newrefdef.time / 40.0f)); if (scroll == 0.0) scroll = -64.0f; for (p = surf.polys; p != null; p = p.chain) { p.beginScrolling(scroll); GL11.glDrawArrays(GL11.GL_POLYGON, p.pos, p.numverts); p.endScrolling(); } } else { // PGM // ========== for (p = surf.polys; p != null; p = p.chain) { GL11.glDrawArrays(GL11.GL_POLYGON, p.pos, p.numverts); } // ========== // PGM } // PGM // ========== } }
From source file:lwjglapp.Renderer.java
void drawVBO() { FloatBuffer cBuffer = BufferUtils.createFloatBuffer(9); cBuffer.put(1).put(0).put(0);//from w w w . j ava 2 s . c o m 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:model.ModelMD2.java
@Override public void draw(float frame, float[] vpMatrix, float[] matrix, RenderEngine engine) { if (frame < 0 || frame > header.num_frames - 1) return;//from w w w . j ava 2 s. c o m //Select current frame and next int frame_0 = frame_ids[(int) Math.floor(frame)]; int frame_1 = frame_ids[(int) Math.min(Math.ceil(frame), header.num_frames - 1)]; //Upload frame interpolation GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex_id); ShaderUtils.useProgram(shader_id); { //Upload uniform values ShaderUtils.setUniformMatrix4(shader_id, "viewprojMatrix", vpMatrix); ShaderUtils.setUniformMatrix4(shader_id, "modelMatrix", matrix); ShaderUtils.setUniformVar(shader_id, "frame_interpolated", (float) (frame - Math.floor(frame))); //ShaderUtils.setUniformVar(shader_id, "cameraDir", engine.camera.yaw, engine.camera.pitch, engine.camera.roll); //Bind frames to VAO GL30.glBindVertexArray(vao_id); { GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, frame_0);//Bind frame 0 { GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 32, 0); GL20.glVertexAttribPointer(1, 2, GL11.GL_FLOAT, false, 32, 12); GL20.glVertexAttribPointer(2, 3, GL11.GL_FLOAT, false, 32, 20); } GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, frame_1);//Bind frame 1 { GL20.glVertexAttribPointer(3, 3, GL11.GL_FLOAT, false, 32, 0); GL20.glVertexAttribPointer(4, 2, GL11.GL_FLOAT, false, 32, 12); GL20.glVertexAttribPointer(5, 3, GL11.GL_FLOAT, false, 32, 20); } GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); //Enable attribs and render for (int i = 0; i < 6; i++) { GL20.glEnableVertexAttribArray(i); } { GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, header.num_tris * 3); } for (int i = 0; i < 6; i++) { GL20.glDisableVertexAttribArray(i); } } GL30.glBindVertexArray(0); } ShaderUtils.useProgram(0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); }
From source file:Model.Render.java
public void render(Model model) { GL30.glBindVertexArray(model.getVaoID()); GL20.glEnableVertexAttribArray(0);/*from ww w . ja va 2 s.co m*/ GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, model.getVertexCount()); GL20.glDisableVertexAttribArray(0); GL30.glBindVertexArray(0); }
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;//from www .j a va2 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.neilcsmith.praxis.video.opengl.internal.Mesh.java
License:Apache License
/** <p> * Renders the mesh using the given primitive type. offset specifies the offset into either the vertex buffer or the index * buffer depending on whether indices are defined. count specifies the number of vertices or indices to use thus count / * #vertices per primitive primitives are rendered. * </p>//from w ww. j a va 2s. co m * * <p> * This method will automatically bind each vertex attribute as specified at construction time via {@link VertexAttributes} to * the respective shader attributes. The binding is based on the alias defined for each VertexAttribute. * </p> * * <p> * This method must only be called after the {@link ShaderProgram#begin()} method has been called! * </p> * * <p> * This method is intended for use with OpenGL ES 2.0 and will throw an IllegalStateException when OpenGL ES 1.x is used. * </p> * * @param shader the shader to be used * @param primitiveType the primitive type * @param offset the offset into the vertex or index buffer * @param count number of vertices or indices to use */ public void render(ShaderProgram shader, int primitiveType, int offset, int count) { if (autoBind) { bind(shader); } if (indices.getNumIndices() > 0) { GL11.glDrawElements(primitiveType, count, GL11.GL_UNSIGNED_SHORT, offset * 2); } else { GL11.glDrawArrays(primitiveType, offset, count); } if (autoBind) { unbind(shader); } }
From source file:net.smert.frameworkgl.opengl.helpers.VertexArrayHelper.java
License:Apache License
public void drawArrays(int mode, int first, int count) { GL11.glDrawArrays(mode, first, count); }
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 v a 2 s. 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); }