List of usage examples for org.lwjgl.opengl GL11 GL_VERTEX_ARRAY
int GL_VERTEX_ARRAY
To view the source code for org.lwjgl.opengl GL11 GL_VERTEX_ARRAY.
Click Source Link
From source file:opengl.Player.java
public void Draw() { float[] vertices = { (0.0f * ScaleX) + x, (0.0f * ScaleY) + y, (0.0f * ScaleX) + x, (1.0f * ScaleY) + y, (1.0f * ScaleX) + x, (1.0f * ScaleY) + y, (1.0f * ScaleX) + x, (0.0f * ScaleY) + y }; FloatBuffer triangle = BufferUtils.createFloatBuffer(vertices.length); triangle.put(vertices);/*from ww w. ja va 2s. co 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); }
From source file:org.craftmania.rendering.ChunkMeshRenderer.java
License:Apache License
public static void renderChunkMesh(Chunk chunk, MeshType meshType) { if (chunk.getMesh().getVBO(meshType) <= 0) { return;/* ww w .java2 s. com*/ } /* Bind the correct texture */ GL11.glEnable(GL11.GL_TEXTURE_2D); TextureStorage.getTexture("terrain").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:org.free.jake2.render.lwjgl.Misc.java
License:Open Source License
void GL_SetDefaultState() { GL11.glClearColor(1f, 0f, 0.5f, 0.5f); // original quake2 //GL11.glClearColor(0, 0, 0, 0); // replaced with black GL11.glCullFace(GL11.GL_FRONT);//from ww w . j a v a2 s .c om GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glAlphaFunc(GL11.GL_GREATER, 0.666f); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_BLEND); GL11.glColor4f(1, 1, 1, 1); GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); GL11.glShadeModel(GL11.GL_FLAT); GL_TextureMode(gl_texturemode.string); GL_TextureAlphaMode(gl_texturealphamode.string); GL_TextureSolidMode(gl_texturesolidmode.string); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, gl_filter_min); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, gl_filter_max); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL_TexEnv(GL11.GL_REPLACE); if (qglPointParameterfEXT) { // float[] attenuations = { gl_particle_att_a.value, gl_particle_att_b.value, gl_particle_att_c.value }; FloatBuffer att_buffer = BufferUtils.createFloatBuffer(4); att_buffer.put(0, gl_particle_att_a.value); att_buffer.put(1, gl_particle_att_b.value); att_buffer.put(2, gl_particle_att_c.value); GL11.glEnable(GL11.GL_POINT_SMOOTH); GL14.glPointParameterf(EXTPointParameters.GL_POINT_SIZE_MIN_EXT, gl_particle_min_size.value); GL14.glPointParameterf(EXTPointParameters.GL_POINT_SIZE_MAX_EXT, gl_particle_max_size.value); GL14.glPointParameter(EXTPointParameters.GL_DISTANCE_ATTENUATION_EXT, att_buffer); } if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f) { GL11.glEnable(EXTSharedTexturePalette.GL_SHARED_TEXTURE_PALETTE_EXT); GL_SetTexturePalette(d_8to24table); } GL_UpdateSwapInterval(); /* * vertex array extension */ GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL13.glClientActiveTexture(GL_TEXTURE0); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); }
From source file:org.jogamp.glg2d.VertexBuffer.java
License:Apache License
/** * Draws the vertices and rewinds the buffer to be ready to draw next time. * //ww w . j ava 2s.c o m * @param gl * The graphics context to use to draw * @param mode * The mode, e.g. {@code GL#GL_LINE_STRIP} */ public void drawBuffer(int mode) { if (buffer.position() == 0) { return; } int count = buffer.position(); buffer.rewind(); GL11.glVertexPointer(2, 0, buffer); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glDrawArrays(mode, 0, count / 2); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); buffer.position(count); }
From source file:org.obsidianbox.obsidian.renderer.GuiRenderer.java
License:MIT License
@Override public void render() { // Snapshot Minecraft rendering final int mcProgId = GL11.glGetInteger(GL20.GL_CURRENT_PROGRAM); final int mcVAID = GL11.glGetInteger(GL11.GL_VERTEX_ARRAY); updateScaledAttributes();/*from w ww .ja va2 s . c o m*/ LWJGLUtil.checkForGLError(); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); pipeline.run(context); GL11.glDisable(GL11.GL_BLEND); LWJGLUtil.checkForGLError(); GL20.glUseProgram(mcProgId); GL30.glBindVertexArray(mcVAID); LWJGLUtil.checkForGLError(); }
From source file:org.spout.engine.renderer.GL11BatchVertexRenderer.java
License:Open Source License
@Override protected void doFlush() { GL11.glNewList(displayList, GL11.GL_COMPILE); FloatBuffer vBuffer = BufferUtils.createFloatBuffer(vertexBuffer.size()); vBuffer.clear();/*w ww . ja v a 2 s . c o m*/ vBuffer.put(vertexBuffer.toArray()); vBuffer.flip(); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glVertexPointer(4, 0, vBuffer); /*if (useColors) { vBuffer.clear(); vBuffer.put(colorBuffer.toArray()); vBuffer.flip(); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glColorPointer(4, 0, vBuffer); }*/ if (useNormals) { vBuffer.clear(); vBuffer.put(normalBuffer.toArray()); vBuffer.flip(); GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY); GL11.glNormalPointer(0, vBuffer); } if (useTextures) { FloatBuffer temp = BufferUtils.createFloatBuffer(uvBuffer.size()); temp.put(uvBuffer.toArray()); temp.flip(); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glTexCoordPointer(2, 0, temp); } GL11.glDrawArrays(renderMode, 0, numVertices); GL11.glEndList(); }
From source file:org.terasology.rendering.nui.internal.Line.java
License:Apache License
public void draw(float x1, float y1, float x2, float y2, float width, Color color, Color background, float alpha) { GL20.glUseProgram(0);//from w ww. j a v a 2s . c o m GL11.glDisable(GL11.GL_CULL_FACE); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); float t = 0; float r = 0; float f = width - (int) width; float a; boolean alphaBlend = alpha > 0; float cRed = color.rf(); float cGreen = color.gf(); float cBlue = color.bf(); float bRed = background.rf(); float bGreen = background.gf(); float bBlue = background.bf(); if (alphaBlend) { a = alpha; } else { a = 1.f; } if (width >= 0.0 && width < 1.0) { t = 0.05f; r = 0.48f + 0.32f * f; if (!alphaBlend) { cRed += 0.88 * (1 - f); cGreen += 0.88 * (1 - f); cBlue += 0.88 * (1 - f); if (cRed > 1.0f) { cRed = 1.0f; } if (cGreen > 1.0f) { cGreen = 1.0f; } if (cBlue > 1.0f) { cBlue = 1.0f; } } else { a *= f; } } else if (width >= 1.0 && width < 2.0) { t = 0.05f + f * 0.33f; r = 0.768f + 0.312f * f; } else if (width >= 2.0 && width < 3.0) { t = 0.38f + f * 0.58f; r = 1.08f; } else if (width >= 3.0 && width < 4.0) { t = 0.96f + f * 0.48f; r = 1.08f; } else if (width >= 4.0 && width < 5.0) { t = 1.44f + f * 0.46f; r = 1.08f; } else if (width >= 5.0 && width < 6.0) { t = 1.9f + f * 0.6f; r = 1.08f; } else if (width >= 6.0) { float ff = width - 6.0f; t = 2.5f + ff * 0.50f; r = 1.08f; } //determine angle of the line to horizontal float tx = 0; //core thinkness of a line float ty = 0; float rx = 0; //fading edge of a line float ry = 0; float cx = 0; //cap of a line float cy = 0; float epsilon = 0.01f; float dx = x2 - x1; float dy = y2 - y1; if (Math.abs(dx) < epsilon) { //vertical tx = t; ty = 0; rx = r; ry = 0; if (width > 0.0 && width < 1.0) { tx *= 8; } else if (width == 1.0) { tx *= 10; } } else if (Math.abs(dy) < epsilon) { //horizontal tx = 0; ty = t; rx = 0; ry = r; if (width > 0.0 && width < 1.0) { ty *= 8; } else if (width == 1.0) { ty *= 10; } } else { if (width < 3) { //approximate to make things even faster float m = dy / dx; //and calculate tx,ty,rx,ry if (m > -0.4142 && m <= 0.4142) { // -22.5< angle <= 22.5, approximate to 0 (degree) tx = t * 0.1f; ty = t; rx = r * 0.6f; ry = r; } else if (m > 0.4142 && m <= 2.4142) { // 22.5< angle <= 67.5, approximate to 45 (degree) tx = t * -0.7071f; ty = t * 0.7071f; rx = r * -0.7071f; ry = r * 0.7071f; } else if (m > 2.4142 || m <= -2.4142) { // 67.5 < angle <=112.5, approximate to 90 (degree) tx = t; ty = t * 0.1f; rx = r; ry = r * 0.6f; } else if (m > -2.4142 && m < -0.4142) { // 112.5 < angle < 157.5, approximate to 135 (degree) tx = t * 0.7071f; ty = t * 0.7071f; rx = r * 0.7071f; ry = r * 0.7071f; } } else { //calculate to exact dx = y1 - y2; dy = x2 - x1; float len = (float) Math.sqrt(dx * dx + dy * dy); dx /= len; dy /= len; cx = -0.6f * dy; cy = 0.6f * dx; tx = t * dx; ty = t * dy; rx = r * dx; ry = r * dy; } } //draw the line by triangle strip float[] lineVertex = { x1 - tx - rx, y1 - ty - ry, //fading edge1 x2 - tx - rx, y2 - ty - ry, x1 - tx, y1 - ty, //core x2 - tx, y2 - ty, x1 + tx, y1 + ty, x2 + tx, y2 + ty, x1 + tx + rx, y1 + ty + ry, //fading edge2 x2 + tx + rx, y2 + ty + ry }; GL11.glVertexPointer(2, 0, wrap(lineVertex)); if (!alphaBlend) { float[] lineColor = { bRed, bGreen, bBlue, bRed, bGreen, bBlue, cRed, cGreen, cBlue, cRed, cGreen, cBlue, cRed, cGreen, cBlue, cRed, cGreen, cBlue, bRed, bGreen, bBlue, bRed, bGreen, bBlue }; GL11.glColorPointer(3, 0, wrap(lineColor)); } else { float[] lineColor = { cRed, cGreen, cBlue, 0, cRed, cGreen, cBlue, 0, cRed, cGreen, cBlue, a, cRed, cGreen, cBlue, a, cRed, cGreen, cBlue, a, cRed, cGreen, cBlue, a, cRed, cGreen, cBlue, 0, cRed, cGreen, cBlue, 0 }; GL11.glColorPointer(4, 0, wrap(lineColor)); } if ((Math.abs(dx) < epsilon || Math.abs(dy) < epsilon) && width <= 1.0) { GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, 6); } else { GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, 8); } //cap (do not draw if too thin) if (width >= 3) { //draw cap lineVertex = new float[] { x1 - rx + cx, y1 - ry + cy, //cap1 x1 + rx + cx, y1 + ry + cy, x1 - tx - rx, y1 - ty - ry, x1 + tx + rx, y1 + ty + ry, x2 - rx - cx, y2 - ry - cy, //cap2 x2 + rx - cx, y2 + ry - cy, x2 - tx - rx, y2 - ty - ry, x2 + tx + rx, y2 + ty + ry }; GL11.glVertexPointer(2, 0, wrap(lineVertex)); if (!alphaBlend) { float[] lineColor = { bRed, bGreen, bBlue, //cap1 bRed, bGreen, bBlue, cRed, cGreen, cBlue, cRed, cGreen, cBlue, bRed, bGreen, bBlue, //cap2 bRed, bGreen, bBlue, cRed, cGreen, cBlue, cRed, cGreen, cBlue }; GL11.glColorPointer(3, 0, wrap(lineColor)); } else { float[] lineColor = { cRed, cGreen, cBlue, 0, //cap1 cRed, cGreen, cBlue, 0, cRed, cGreen, cBlue, a, cRed, cGreen, cBlue, a, cRed, cGreen, cBlue, 0, //cap2 cRed, cGreen, cBlue, 0, cRed, cGreen, cBlue, a, cRed, cGreen, cBlue, a }; GL11.glColorPointer(4, 0, wrap(lineColor)); } GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, 4); GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 4, 4); } GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); GL11.glEnable(GL11.GL_CULL_FACE); }
From source file:org.voxels.platform.LWJGLOpenGLAdapter.java
License:Open Source License
@Override public int GL_VERTEX_ARRAY() { return GL11.GL_VERTEX_ARRAY; }
From source file:src.graphics.common.Rendering.java
License:Open Source License
/** A generalised interface for stuff that wants to be rendered- *//*from w w w.jav a 2 s.com*/ void initSettings() { GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glEnable(GL11.GL_NORMALIZE); // IF MISSING, COLOURS ARE TOO BRIGHT. GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glDepthMask(true); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glCullFace(GL11.GL_BACK); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glAlphaFunc(GL11.GL_GREATER, 0.1f); GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glColorMaterial(GL11.GL_FRONT_AND_BACK, GL11.GL_AMBIENT_AND_DIFFUSE); }
From source file:taiga.code.opengl.ColoredDrawable.java
License:Open Source License
@Override public void draw(int x, int y, int w, int h) { GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glVertexPointer(2, 0, createVertices(x, y, w, h)); GL11.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 0, colors); GL11.glDrawElements(GL11.GL_QUADS, indices); }