List of usage examples for org.lwjgl.opengl GL20 glDisableVertexAttribArray
public static void glDisableVertexAttribArray(@NativeType("GLuint") int index)
From source file:com.opengrave.og.base.RenderableLines.java
License:Open Source License
@Override public void render(Matrix4f matrix, RenderStyle style) { dealWithChange();//ww w .jav a2 s . c om if (!visible) { return; } if (vertCount == 0) { return; } GL11.glPointSize(3f); int pID = Resources.loadShader("lines.vs", "lines.fs").getProgram(); GL20.glUseProgram(pID); if (pID == 0) { return; } GL30.glBindVertexArray(vaoID); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); Util.checkErr(); getContext().setMatrices(pID, matrix); Util.checkErr(); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDrawArrays(GL11.GL_LINES, 0, vertCount); GL11.glEnable(GL11.GL_DEPTH_TEST); Util.checkErr(); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(0); Util.checkErr(); GL30.glBindVertexArray(0); GL20.glUseProgram(0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); Util.checkErr(); }
From source file:com.opengrave.og.base.RenderableLiquid.java
License:Open Source License
@Override public void render(Matrix4f matrix, RenderStyle style) { dealWithChange();//from ww w. jav a2 s . co m if (vertexList.size() == 0) { return; } int pID = Resources.loadShader("liquid.vs", "liquid.fs").getProgram(); GL20.glUseProgram(pID); int atlas = GL20.glGetUniformLocation(pID, "arraytexture"); int normals = GL20.glGetUniformLocation(pID, "arraytexturedata"); int colours = GL20.glGetUniformLocation(pID, "colours"); int flows = GL20.glGetUniformLocation(pID, "flows"); int shadow = GL20.glGetUniformLocation(pID, "shadowMap"); GL20.glUniform1i(atlas, 0); GL20.glUniform1i(normals, 1); GL20.glUniform1i(colours, 2); GL20.glUniform1i(flows, 3); GL20.glUniform1i(shadow, 4); GL30.glBindVertexArray(vaoID); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); getContext().setMatrices(pID, matrix); textureAtlas.bind(GL13.GL_TEXTURE0); normalAtlas.bind(GL13.GL_TEXTURE1); getColourTexture().bind(GL13.GL_TEXTURE2); getFlowTexture().bind(GL13.GL_TEXTURE3); getContext().bindShadowData(GL13.GL_TEXTURE4); getContext().bindLights(pID, GL13.GL_TEXTURE5); Util.setRenderStyle(pID, style); GL11.glDepthMask(false); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vertexList.size()); GL11.glDepthMask(true); getContext().unbindLights(); getContext().unbindShadowData(); textureAtlas.unbind(); getFlowTexture().unbind(); getColourTexture().unbind(); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); GL30.glBindVertexArray(0); GL20.glUseProgram(0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); }
From source file:com.opengrave.og.base.RenderableMultitex.java
License:Open Source License
@Override public void renderShadows(Matrix4f matrix, Shadow shadow) { dealWithChange();//from w w w . j a v a 2s . c o m if (vertexList.size() == 0) { return; } int pID = Resources.loadShader("terrainshadow.vs", "castshadow.fs").getProgram(); GL20.glUseProgram(pID); GL30.glBindVertexArray(vaoID); GL20.glEnableVertexAttribArray(0); getContext().setShadowMatrices(pID, matrix, shadow); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vertexList.size()); // System.out.println(getClass().getName()+" : "+vertexList.size()+" rendered"); GL20.glDisableVertexAttribArray(0); GL30.glBindVertexArray(0); GL20.glUseProgram(0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); }
From source file:com.opengrave.og.base.RenderableMultitex.java
License:Open Source License
@Override public void render(Matrix4f matrix, RenderStyle style) { dealWithChange();/*from www. j a va 2s . co m*/ if (vertexList.size() == 0) { return; } // GL11.glBindTexture(GL11.GL_TEXTURE_2D, // Resources.loadTexture("tex/blank.png").id); int pID = Resources.loadShader("terrain.vs", "terrain.fs").getProgram(); GL20.glUseProgram(pID); int atlas = GL20.glGetUniformLocation(pID, "arraytexture"); int colours = GL20.glGetUniformLocation(pID, "colours"); int shadow = GL20.glGetUniformLocation(pID, "shadowMap"); int normals = GL20.glGetUniformLocation(pID, "arraytexturedata"); GL20.glUniform1i(atlas, 0); GL20.glUniform1i(colours, 1); GL20.glUniform1i(normals, 2); GL20.glUniform1i(shadow, 3); GL30.glBindVertexArray(vaoID); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); GL20.glEnableVertexAttribArray(3); GL20.glBindAttribLocation(pID, 0, "in_Position"); GL20.glBindAttribLocation(pID, 1, "in_TextureCoord"); GL20.glBindAttribLocation(pID, 2, "in_TexIndex"); GL20.glBindAttribLocation(pID, 3, "in_Normal"); getContext().setMatrices(pID, matrix); GL20.glUniform1i(GL20.glGetUniformLocation(pID, "hidden"), hidden); textureAtlas.bind(GL13.GL_TEXTURE0); getColourTexture().bind(GL13.GL_TEXTURE1); normalAtlas.bind(GL13.GL_TEXTURE2); getContext().bindShadowData(GL13.GL_TEXTURE3); getContext().bindLights(pID, GL13.GL_TEXTURE4); Util.setRenderStyle(pID, style); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vertexList.size()); getContext().unbindLights(); getContext().unbindShadowData(); textureAtlas.unbind(); // HGMainThread.shadowMap.unbind(); getColourTexture().unbind(); // System.out.println(getClass().getName()+" : "+vertexList.size()+" rendered"); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); GL20.glDisableVertexAttribArray(3); GL30.glBindVertexArray(0); GL20.glUseProgram(0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); }
From source file:com.opengrave.og.base.RenderableMultitex.java
License:Open Source License
@Override public void renderForPicking(Matrix4f matrix, Pickable object) { dealWithChange();//w w w .j av a 2 s .co m if (vertexList.size() == 0) { return; } int pID = Resources.loadShader("terrainshadow.vs", "pickingmodel.fs").getProgram(); GL20.glUseProgram(pID); GL30.glBindVertexArray(vaoID); GL20.glEnableVertexAttribArray(0); getContext().setMatrices(pID, matrix); Picking.registerObject(pID, getContext(), object); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vertexList.size()); GL20.glDisableVertexAttribArray(0); GL30.glBindVertexArray(0); GL20.glUseProgram(0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); }
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 va 2 s.com 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();/*from w ww .ja va 2 s . co 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();/*ww w. j av a 2 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// ww w.j av a2 s. c om 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.EntityRenderer.java
License:Apache License
@Override protected void unbindTexturedModel() { Util.enableCulling();// w w w .j av a 2 s. c om GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); GL30.glBindVertexArray(0); }