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:com.opengrave.og.base.RenderableParticles.java
License:Open Source License
@Override public void render(Matrix4f matrix, RenderStyle style) { dealWithChange();//from w w w . ja v a 2 s . c om if (matList == null || !matList.valid()) { return; } GL30.glBindVertexArray(idVao); int pID = Resources.loadShader("particle.vs", "particle.fs").getProgram(); GL20.glUseProgram(pID); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); GL20.glBindAttribLocation(pID, 0, "in_Position"); GL20.glBindAttribLocation(pID, 1, "in_Colour"); GL20.glBindAttribLocation(pID, 2, "in_Scale"); Util.checkErr(); int texture = GL20.glGetUniformLocation(pID, "tex"); GL20.glUniform1i(texture, 0); int wSS = GL20.glGetUniformLocation(pID, "windowSizeScale"); GL20.glUniform1f(wSS, getContext().width / 1024f); getContext().setMatrices(pID, matrix); if (matList != null && matList.valid()) { matList.bind(pID, GL13.GL_TEXTURE0); } GL11.glEnable(GL20.GL_POINT_SPRITE); GL11.glEnable(GL20.GL_VERTEX_PROGRAM_POINT_SIZE); GL11.glDepthMask(false); GL11.glDrawArrays(GL11.GL_POINTS, 0, size); GL11.glDepthMask(true); GL11.glDisable(GL20.GL_POINT_SPRITE); GL11.glDisable(GL20.GL_VERTEX_PROGRAM_POINT_SIZE); if (matList != null && matList.valid()) { matList.unbind(); } Util.checkErr(); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); Util.checkErr(); GL20.glUseProgram(0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); Util.checkErr(); }
From source file:com.opengrave.og.base.RenderableParticles.java
License:Open Source License
@Override public void renderForPicking(Matrix4f matrix, Pickable object) { dealWithChange();/* w w w. j ava 2s . c o m*/ GL30.glBindVertexArray(idVao); int pID = Resources.loadShader("particle.vs", "pickingmodel.fs").getProgram(); GL20.glUseProgram(pID); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(2); GL20.glBindAttribLocation(pID, 0, "in_Position"); GL20.glBindAttribLocation(pID, 2, "in_Scale"); Util.checkErr(); int wSS = GL20.glGetUniformLocation(pID, "windowSizeScale"); GL20.glUniform1f(wSS, MainThread.lastW / 1024f); getContext().setMatrices(pID, matrix); GL11.glEnable(GL20.GL_POINT_SPRITE); GL11.glEnable(GL20.GL_VERTEX_PROGRAM_POINT_SIZE); Picking.registerObject(pID, getContext(), object); GL11.glDrawArrays(GL11.GL_POINTS, 0, size); GL11.glDisable(GL20.GL_POINT_SPRITE); GL11.glDisable(GL20.GL_VERTEX_PROGRAM_POINT_SIZE); Util.checkErr(); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(2); Util.checkErr(); GL20.glUseProgram(0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); Util.checkErr(); }
From source file:com.opengrave.og.base.RenderablePoints.java
License:Open Source License
@Override public void render(Matrix4f matrix, RenderStyle style) { Util.checkErr();//from w w w . jav a2 s. c o m dealWithChange(); if (!visible) { return; } if (vertCount == 0) { return; } Util.checkErr(); GL11.glDisable(GL11.GL_DEPTH_TEST); Util.checkErr(); GL11.glPointSize(3f); Util.checkErr(); int pID = Resources.loadShader("particle.vs", "particle.fs").getProgram(); Util.checkErr(); GL20.glUseProgram(pID); Util.checkErr(); if (pID == 0) { return; } Util.checkErr(); GL30.glBindVertexArray(vaoID); Util.checkErr(); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); Util.checkErr(); int wSS = GL20.glGetUniformLocation(pID, "windowSizeScale"); GL20.glUniform1f(wSS, MainThread.lastW / 1024f); getContext().setMatrices(pID, matrix); Util.checkErr(); if (tex != null) { tex.bind(GL13.GL_TEXTURE0); } GL11.glEnable(GL20.GL_POINT_SPRITE); GL11.glEnable(GL20.GL_VERTEX_PROGRAM_POINT_SIZE); GL11.glDrawArrays(GL11.GL_POINTS, 0, vertCount); GL11.glDisable(GL20.GL_POINT_SPRITE); GL11.glDisable(GL20.GL_VERTEX_PROGRAM_POINT_SIZE); if (tex != null) { tex.unbind(); } Util.checkErr(); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); Util.checkErr(); GL30.glBindVertexArray(0); GL20.glUseProgram(0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); Util.checkErr(); GL11.glEnable(GL11.GL_DEPTH_TEST); }
From source file:com.opengrave.og.light.Depth2DFramebuffer.java
License:Open Source License
public void dumpTestingImage() { // TESTING/*w w w. j a v a 2 s . c o m*/ GL11.glDisable(GL11.GL_DEPTH_TEST); int pID = Resources.loadShader("test.vs", "test.fs").getProgram(); GL20.glUseProgram(pID); int shadow = GL20.glGetUniformLocation(pID, "shadowMap"); GL20.glUniform1i(shadow, 0); GL30.glBindVertexArray(vao_ID); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); shadowMap.bind(GL13.GL_TEXTURE0); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, count * 3); shadowMap.unbind(); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glUseProgram(0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); GL11.glEnable(GL11.GL_DEPTH_TEST); // END TESTING }
From source file:com.redthirddivision.quad.rendering.renderers.GuiRenderer.java
License:Apache License
@Override public void render(ArrayList<GuiTexture> elements) { shader.start();// w ww . j a v a 2 s.c o m GL30.glBindVertexArray(quad.getVaoID()); GL20.glEnableVertexAttribArray(0); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_DEPTH_TEST); for (GuiTexture gui : elements) { GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, gui.getTexture()); Matrix4f matrix = MathHelper.createTransformationMatrix(gui.getPosition(), gui.getScale(), new Vector2f(0, 0)); shader.loadTransformation(matrix); GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, quad.getVertexCount()); } GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_DEPTH_TEST); GL20.glDisableVertexAttribArray(0); GL30.glBindVertexArray(0); shader.stop(); }
From source file:com.runescape.client.revised.client.lwjgl.Mesh.java
License:Open Source License
public void draw() { GL20.glEnableVertexAttribArray(0);//from w w w .java 2 s.co m GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.getVbo()); GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, Vertex.getSize() * 4, 0); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, this.getSize()); GL20.glDisableVertexAttribArray(0); }
From source file:com.samrj.devil.gl.DGL.java
License:Open Source License
/** * Draws the given vertex data using the given primitive mode. A shader must * be bound./*from w w w.j a va 2s . c o m*/ * * @param <T> A type of vertex data. * @param data The vertex data to render. * @param mode An OpenGL primitive draw mode. * @return The given vertex data. */ public static <T extends VertexData> T draw(T data, int mode) { if (boundProgram == null) throw new IllegalStateException("No shader program is in use."); int verts = data.numVertices(); int inds = data.numIndices(); VAO.bindFor(data, boundProgram, () -> { if (inds < 0) GL11.glDrawArrays(mode, 0, verts); else GL11.glDrawElements(mode, inds, GL11.GL_UNSIGNED_INT, 0); }); return data; }
From source file:com.timvisee.voxeltex.module.mesh.Mesh.java
License:Open Source License
/** * Render or draw the mesh using OpenGL. *///from ww w . j a v a2 s . co m public void draw(Material material) { // Bind the vertex buffer glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle); GL11.glVertexPointer(this.raw.getVertexAxisCount(), GL11.GL_FLOAT, 0, 0L); // Bind the normal coordinate buffer if available if (hasNormalData()) { glBindBuffer(GL_ARRAY_BUFFER, vboNormalHandle); GL11.glNormalPointer(GL11.GL_FLOAT, 0, 0L); } // Bind the texture coordinate buffer if available if (hasTextureData()) { glBindBuffer(GL_ARRAY_BUFFER, vboTextureHandle); GL11.glTexCoordPointer(this.raw.getTextureAxisCount(), GL11.GL_FLOAT, 0, 0L); } // Enable the client states for the buffers that were bound GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); if (hasNormalData()) GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY); if (hasTextureData()) GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); // Draw the mesh GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, this.vertexCount); // Disable the client used states GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); if (hasNormalData()) GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY); if (hasTextureData()) GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); // Unbind all buffers GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); }
From source file:com.xrbpowered.gl.res.shaders.FeedbackVertices.java
License:Open Source License
public void transform() { GL30.glBindVertexArray(vaoId);/* ww w .ja v a 2 s . c o m*/ GL11.glEnable(GL30.GL_RASTERIZER_DISCARD); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId); transformShader.use(); transformShader.info.initAttribPointers(); transformShader.info.enableAttribs(); GL30.glBindBufferBase(GL30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, vboFeedbackId); GL30.glBeginTransformFeedback(GL11.GL_POINTS); GL11.glDrawArrays(GL11.GL_POINTS, 0, countElements); GL30.glEndTransformFeedback(); transformShader.info.disableAttribs(); transformShader.unuse(); GL11.glDisable(GL30.GL_RASTERIZER_DISCARD); }
From source file:com.xrbpowered.gl.res.shaders.FeedbackVertices.java
License:Open Source License
public void draw() { GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboFeedbackId); renderShader.use();/*from w ww .j ava2s. co m*/ renderShader.info.enableAttribs(); renderShader.info.initAttribPointers(); if (vboiId != GL11.GL_INVALID_VALUE) { GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboiId); GL11.glDrawElements(GL11.GL_POINTS, countElements, GL11.GL_UNSIGNED_INT, 0); } else { GL11.glDrawArrays(GL11.GL_POINTS, 0, countElements); } renderShader.info.disableAttribs(); renderShader.unuse(); GL30.glBindVertexArray(0); }