Java Code Examples for org.lwjgl.opengl.GL11#glVertexPointer()
The following examples show how to use
org.lwjgl.opengl.GL11#glVertexPointer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FloatVBO.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
public final void vertexPointer(int size, int stride, int index) { if (!use_vbo) { saved_buffer.position(index); GL11.glVertexPointer(size, stride, saved_buffer); } else { makeCurrent(); GL11.glVertexPointer(size, GL11.GL_FLOAT, stride, index<<2); } }
Example 2
Source File: LWJGL15DrawContext.java From settlers-remake with MIT License | 5 votes |
protected void specifyFormat(EGeometryFormatType format) { if (format.getTexCoordPos() == -1) { if(tex_coord_on) GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glVertexPointer(2, GL11.GL_FLOAT, 0, 0); } else { if(!tex_coord_on) GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); int stride = format.getBytesPerVertexSize(); GL11.glVertexPointer(2, GL11.GL_FLOAT, stride, 0); GL11.glTexCoordPointer(2, GL11.GL_FLOAT, stride, format.getTexCoordPos()); } tex_coord_on = format.getTexCoordPos() != -1; }
Example 3
Source File: LWJGL15DrawContext.java From settlers-remake with MIT License | 5 votes |
public void drawTrianglesWithTextureColored(TextureHandle textureid, GeometryHandle shapeHandle, GeometryHandle colorHandle, int offset, int lines, int width, int stride, float x, float y) { bindTexture(textureid); int starti = offset < 0 ? (int)Math.ceil(-offset/(float)stride) : 0; if(lsz != -1) GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glTranslatef(x, y, -.1f); GL11.glScalef(1, 1, 0); GL11.glMultMatrixf(heightMatrix); if(!tex_coord_on) { GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); tex_coord_on = true; } bindGeometry(shapeHandle); GL11.glVertexPointer(3, GL11.GL_FLOAT, 5 * 4, 0); GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 5 * 4, 3 * 4); bindGeometry(colorHandle); GL11.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 0, 0); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); for (int i = starti; i != lines; i++) { GL11.glDrawArrays(GL11.GL_TRIANGLES, (offset + stride * i) * 3, width * 3); } GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); GL11.glPopMatrix(); lsz = -1; }
Example 4
Source File: LwjglMesh.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void bind() { if (vertices == null) return; assert (isFinalised); assert (numVertices > 0); org.lwjgl.opengl.Util.checkGLError(); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glVertexPointer(3, 0, vertices); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glColorPointer(4, true, 0, colours); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glTexCoordPointer(2, 0, texCoords); if (texture != null) { GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getId()); } else { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); } org.lwjgl.opengl.Util.checkGLError(); }
Example 5
Source File: VAOGLRenderer.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Flush the currently cached data down to the card */ private void flushBuffer() { if (vertIndex == 0) { return; } if (currentType == NONE) { return; } if (vertIndex < TOLERANCE) { GL11.glBegin(currentType); for (int i=0;i<vertIndex;i++) { GL11.glColor4f(cols[(i*4)+0], cols[(i*4)+1], cols[(i*4)+2], cols[(i*4)+3]); GL11.glTexCoord2f(texs[(i*2)+0], texs[(i*2)+1]); GL11.glVertex3f(verts[(i*3)+0], verts[(i*3)+1], verts[(i*3)+2]); } GL11.glEnd(); currentType = NONE; return; } vertices.clear(); colors.clear(); textures.clear(); vertices.put(verts,0,vertIndex*3); colors.put(cols,0,vertIndex*4); textures.put(texs,0,vertIndex*2); vertices.flip(); colors.flip(); textures.flip(); GL11.glVertexPointer(3,0,vertices); GL11.glColorPointer(4,0,colors); GL11.glTexCoordPointer(2,0,textures); GL11.glDrawArrays(currentType, 0, vertIndex); currentType = NONE; }
Example 6
Source File: FastBlockModelRenderer.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
public static void renderVertexBuffer(VertexBuffer vertexBuffer) { // Check if optifine shaders are currently loaded. final boolean areOptifineShadersEnabled = GibsModelRegistry.isOptifineShadersEnabled(); GlStateManager.pushMatrix(); GlStateManager.resetColor(); GlStateManager.glEnableClientState(GL11.GL_VERTEX_ARRAY); OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit); GlStateManager.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit); GlStateManager.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit); GlStateManager.glEnableClientState(GL11.GL_COLOR_ARRAY); // Extra OpenGL states that must be enabled when shaders are enabled. if (areOptifineShadersEnabled) { GL11.glEnableClientState(32885); GL20.glEnableVertexAttribArray(11); GL20.glEnableVertexAttribArray(12); GL20.glEnableVertexAttribArray(10); } GlStateManager.pushMatrix(); vertexBuffer.bindBuffer(); // Even more OpenGL states that must be enabled when shaders are enabled. if (areOptifineShadersEnabled) { int vertexSizeI = 14; GL11.glVertexPointer(3, 5126, 56, 0L); GL11.glColorPointer(4, 5121, 56, 12L); GL11.glTexCoordPointer(2, 5126, 56, 16L); OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit); GL11.glTexCoordPointer(2, 5122, 56, 24L); OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit); GL11.glNormalPointer(5120, 56, 28L); GL20.glVertexAttribPointer(11, 2, 5126, false, 56, 32L); GL20.glVertexAttribPointer(12, 4, 5122, false, 56, 40L); GL20.glVertexAttribPointer(10, 3, 5122, false, 56, 48L); } else { GlStateManager.glVertexPointer(3, 5126, 28, 0); GlStateManager.glColorPointer(4, 5121, 28, 12); GlStateManager.glTexCoordPointer(2, 5126, 28, 16); OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit); GlStateManager.glTexCoordPointer(2, 5122, 28, 24); OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit); } vertexBuffer.drawArrays(7); GlStateManager.popMatrix(); vertexBuffer.unbindBuffer(); GlStateManager.resetColor(); for (VertexFormatElement vertexformatelement : DefaultVertexFormats.BLOCK.getElements()) { VertexFormatElement.EnumUsage vertexformatelement$enumusage = vertexformatelement .getUsage(); int i = vertexformatelement.getIndex(); switch (vertexformatelement$enumusage) { case POSITION: GlStateManager.glDisableClientState(32884); break; case UV: OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit + i); GlStateManager.glDisableClientState(32888); OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit); break; case COLOR: GlStateManager.glDisableClientState(32886); GlStateManager.resetColor(); } } OpenGlHelper.glBindBuffer(OpenGlHelper.GL_ARRAY_BUFFER, 0); // Finally disable some of those extra OpenGL states that were be enabled due to shaders. if (areOptifineShadersEnabled) { GL11.glDisableClientState(32885); GL20.glDisableVertexAttribArray(11); GL20.glDisableVertexAttribArray(12); GL20.glDisableVertexAttribArray(10); } GlStateManager.resetColor(); GlStateManager.popMatrix(); }
Example 7
Source File: IslandGenerator.java From tribaltrouble with GNU General Public License v2.0 | 4 votes |
private final static Texture[][] blendTextures(OffscreenRendererFactory factory, int chunks_per_colormap, BlendInfo[] blend_infos, int alpha_size, int structure_size, int scale) { boolean use_pbuffer = Settings.getSettings().usePbuffer(); boolean use_fbo = Settings.getSettings().useFBO(); OffscreenRenderer offscreen = factory.createRenderer(TEXELS_PER_CHUNK, TEXELS_PER_CHUNK, new PixelFormat(Globals.VIEW_BIT_DEPTH, 0, 0, 0, 0), Settings.getSettings().use_copyteximage, use_pbuffer, use_fbo); GL11.glColor4f(1f, 1f, 1f, 1f); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0f, TEXELS_PER_CHUNK, 0, TEXELS_PER_CHUNK, -1f, 1f); GL11.glMatrixMode(GL11.GL_TEXTURE); GLState.activeTexture(GL13.GL_TEXTURE1); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE); GL11.glDisable(GL11.GL_TEXTURE_GEN_S); GL11.glDisable(GL11.GL_TEXTURE_GEN_T); GL11.glLoadIdentity(); GLState.activeTexture(GL13.GL_TEXTURE0); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE); GL11.glDisable(GL11.GL_TEXTURE_GEN_S); GL11.glDisable(GL11.GL_TEXTURE_GEN_T); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); float alpha_texel_size = 1f/(alpha_size*scale); float structure_texel_size = 1f/structure_size; float structure_texels_per_chunk_border = Globals.TEXELS_PER_CHUNK_BORDER*structure_texel_size; float structure_offset = TEXELS_PER_CHUNK*structure_texel_size - 2*structure_texels_per_chunk_border; float structure_length = structure_offset + 2*structure_texels_per_chunk_border; float alpha_texels_per_chunk_border = Globals.TEXELS_PER_CHUNK_BORDER*alpha_texel_size; float alpha_offset = TEXELS_PER_CHUNK*alpha_texel_size; float alpha_length = alpha_offset + 2*alpha_texels_per_chunk_border; Texture[][] chunk_maps = new Texture[chunks_per_colormap][chunks_per_colormap]; FloatBuffer coordinates = BufferUtils.createFloatBuffer(4*3); coordinates.put(new float[]{0f, 0f, 0f, TEXELS_PER_CHUNK, 0f, 0f, TEXELS_PER_CHUNK, TEXELS_PER_CHUNK, 0f, 0f, TEXELS_PER_CHUNK, 0f}); coordinates.rewind(); FloatBuffer structure_tex_coords = BufferUtils.createFloatBuffer(4*2); FloatBuffer alpha_tex_coords = BufferUtils.createFloatBuffer(4*2); GLStateStack.switchState(GLState.VERTEX_ARRAY | GLState.TEXCOORD0_ARRAY | GLState.TEXCOORD1_ARRAY); GL11.glVertexPointer(3, 0, coordinates); GL11.glTexCoordPointer(2, 0, structure_tex_coords); GLState.clientActiveTexture(GL13.GL_TEXTURE1); GL11.glTexCoordPointer(2, 0, alpha_tex_coords); GLState.clientActiveTexture(GL13.GL_TEXTURE0); for (int y = 0; y < chunk_maps.length; y++) { for (int x = 0; x < chunk_maps[y].length; x++) { chunk_maps[y][x] = new Texture(TEXELS_PER_CHUNK, TEXELS_PER_CHUNK, GL11.GL_LINEAR_MIPMAP_NEAREST, GL11.GL_LINEAR, GL12.GL_CLAMP_TO_EDGE, GL12.GL_CLAMP_TO_EDGE, Globals.NO_MIPMAP_CUTOFF); int mip_scale = 1; int mip_level = 0; int mip_size = TEXELS_PER_CHUNK; while (mip_size >= 1) { GL11.glLoadIdentity(); GL11.glScalef(1f/mip_scale, 1f/mip_scale, 1f); GL11.glEnable(GL11.GL_BLEND); for (int i = 0; i < blend_infos.length; i++) { blend_infos[i].setup(); float structure_offset_u = x*structure_offset - structure_texels_per_chunk_border; float structure_offset_v = y*structure_offset - structure_texels_per_chunk_border; float alpha_offset_u = x*alpha_offset - alpha_texels_per_chunk_border; float alpha_offset_v = y*alpha_offset - alpha_texels_per_chunk_border; structure_tex_coords.put(0, structure_offset_u).put(1, structure_offset_v); structure_tex_coords.put(2, structure_offset_u + structure_length).put(3, structure_offset_v); structure_tex_coords.put(4, structure_offset_u + structure_length).put(5, structure_offset_v + structure_length); structure_tex_coords.put(6, structure_offset_u).put(7, structure_offset_v + structure_length); alpha_tex_coords.put(0, alpha_offset_u).put(1, alpha_offset_v); alpha_tex_coords.put(2, alpha_offset_u + alpha_length).put(3, alpha_offset_v); alpha_tex_coords.put(4, alpha_offset_u + alpha_length).put(5, alpha_offset_v + alpha_length); alpha_tex_coords.put(6, alpha_offset_u).put(7, alpha_offset_v + alpha_length); GL11.glDrawArrays(GL11.GL_QUADS, 0, 4); blend_infos[i].reset(); } /*if (mip_level == 0) offscreen.dumpToFile("colormap-" + x + "-" + y);*/ offscreen.copyToTexture(chunk_maps[y][x], mip_level, Globals.COMPRESSED_RGB_FORMAT, 0, 0, mip_size, mip_size); mip_scale <<= 1; mip_level++; mip_size >>= 1; } } } boolean succeeded = offscreen.destroy(); if (!succeeded) { /* for (int y = 0; y < chunk_maps.length; y++) for (int x = 0; x < chunk_maps[y].length; x++) chunk_maps[y][x].delete();*/ return null; } else return chunk_maps; }
Example 8
Source File: GearGL20.java From ldparteditor with MIT License | 3 votes |
public void draw(float x, float y, float z) { GL11.glPushMatrix(); GL11.glTranslatef(x, y, z); GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, bvertices); GL11.glDrawElements(GL11.GL_QUADS, bindices); GL11.glPopMatrix(); }
Example 9
Source File: SphereGL20.java From ldparteditor with MIT License | 3 votes |
public void draw(float x, float y, float z) { GL11.glPushMatrix(); GL11.glTranslatef(x, y, z); GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, bvertices); GL11.glDrawElements(GL11.GL_QUADS, bindices); GL11.glPopMatrix(); }