List of usage examples for org.lwjgl.opengl GL11 glEnd
public static native void glEnd();
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
private void drawCylinder(float l, float r, float zoffset) { int i;/*from ww w . ja v a 2 s . c o m*/ float tmp, ny, nz, a, ca, sa; final int n = 24; // number of sides to the cylinder (divisible by 4) l *= 0.5; a = (float) (M_PI * 2.0 / n); sa = (float) Math.sin(a); ca = (float) Math.cos(a); // draw cylinder body ny = 1; nz = 0; // normal vector = (0,ny,nz) GL11.glBegin(GL11.GL_TRIANGLE_STRIP); for (i = 0; i <= n; i++) { GL11.glNormal3d(ny, nz, 0); GL11.glVertex3d(ny * r, nz * r, l + zoffset); GL11.glNormal3d(ny, nz, 0); GL11.glVertex3d(ny * r, nz * r, -l + zoffset); // rotate ny,nz tmp = ca * ny - sa * nz; nz = sa * ny + ca * nz; ny = tmp; } GL11.glEnd(); // draw top cap GL11.glShadeModel(GL11.GL_FLAT); ny = 1; nz = 0; // normal vector = (0,ny,nz) GL11.glBegin(GL11.GL_TRIANGLE_FAN); GL11.glNormal3d(0, 0, 1); GL11.glVertex3d(0, 0, l + zoffset); for (i = 0; i <= n; i++) { if (i == 1 || i == n / 2 + 1) setColor(color[0] * 0.75f, color[1] * 0.75f, color[2] * 0.75f, color[3]); GL11.glNormal3d(0, 0, 1); GL11.glVertex3d(ny * r, nz * r, l + zoffset); if (i == 1 || i == n / 2 + 1) setColor(color[0], color[1], color[2], color[3]); // rotate ny,nz tmp = ca * ny - sa * nz; nz = sa * ny + ca * nz; ny = tmp; } GL11.glEnd(); // draw bottom cap ny = 1; nz = 0; // normal vector = (0,ny,nz) GL11.glBegin(GL11.GL_TRIANGLE_FAN); GL11.glNormal3d(0, 0, -1); GL11.glVertex3d(0, 0, -l + zoffset); for (i = 0; i <= n; i++) { if (i == 1 || i == n / 2 + 1) setColor(color[0] * 0.75f, color[1] * 0.75f, color[2] * 0.75f, color[3]); GL11.glNormal3d(0, 0, -1); GL11.glVertex3d(ny * r, nz * r, -l + zoffset); if (i == 1 || i == n / 2 + 1) setColor(color[0], color[1], color[2], color[3]); // rotate ny,nz tmp = ca * ny + sa * nz; nz = -sa * ny + ca * nz; ny = tmp; } GL11.glEnd(); }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
private void drawSky(float[] view_xyz) { GL11.glDisable(GL11.GL_LIGHTING);// w w w . java 2s . c o m if (use_textures) { GL11.glEnable(GL11.GL_TEXTURE_2D); sky_texture.bind(false); } else { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor3f(0f, 0.5f, 1.0f); } // make sure sky depth is as far back as possible GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glDepthRange(1, 1); final float ssize = 1000.0f; float x = ssize * sky_scale; float y = view_xyz[1] + sky_height; GL11.glBegin(GL11.GL_QUADS); GL11.glNormal3f(0, -1, 0); GL11.glTexCoord2f(x + offset, -x + offset); GL11.glVertex3f(ssize + view_xyz[0], y, -ssize + view_xyz[2]); GL11.glTexCoord2f(x + offset, x + offset); GL11.glVertex3f(ssize + view_xyz[0], y, ssize + view_xyz[2]); GL11.glTexCoord2f(-x + offset, x + offset); GL11.glVertex3f(-ssize + view_xyz[0], y, ssize + view_xyz[2]); GL11.glTexCoord2f(-x + offset, -x + offset); GL11.glVertex3f(-ssize + view_xyz[0], y, -ssize + view_xyz[2]); GL11.glEnd(); offset = offset + 0.002f; if (offset > 1) offset -= 1; GL11.glDepthFunc(GL11.GL_LESS); GL11.glDepthRange(0, 1); }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
private void drawGround() { GL11.glDisable(GL11.GL_LIGHTING);/*w w w.ja v a 2 s . co m*/ GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LESS); // GL11.glDepthRange (1,1); if (use_textures) { GL11.glEnable(GL11.GL_TEXTURE_2D); ground_texture.bind(false); } else { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor3f(GROUND_R, GROUND_G, GROUND_B); } // ground fog seems to cause problems with TNT2 under windows /* GLfloat fogColor[4] = {0.5, 0.5, 0.5, 1}; GL11.glEnable (GL_FOG); GL11.glFogi (GL_FOG_MODE, GL_EXP2); GL11.glFogfv (GL_FOG_COLOR, fogColor); GL11.glFogf (GL_FOG_DENSITY, 0.05f); GL11.glHint (GL_FOG_HINT, GL_NICEST); // GL_DONT_CARE); GL11.glFogf (GL_FOG_START, 1.0); GL11.glFogf (GL_FOG_END, 5.0); */ final float gsize = 100.0f; final float offset = 0; // -0.001f; ... polygon offsetting doesn't work well GL11.glBegin(GL11.GL_QUADS); GL11.glNormal3f(0, 1, 0); GL11.glTexCoord2f(-gsize * ground_scale + ground_ofsx, gsize * ground_scale + ground_ofsz); GL11.glVertex3f(-gsize, offset, gsize); GL11.glTexCoord2f(gsize * ground_scale + ground_ofsx, gsize * ground_scale + ground_ofsz); GL11.glVertex3f(gsize, offset, gsize); GL11.glTexCoord2f(gsize * ground_scale + ground_ofsx, -gsize * ground_scale + ground_ofsz); GL11.glVertex3f(gsize, offset, -gsize); GL11.glTexCoord2f(-gsize * ground_scale + ground_ofsx, -gsize * ground_scale + ground_ofsz); GL11.glVertex3f(-gsize, offset, -gsize); GL11.glEnd(); GL11.glDisable(GL11.GL_FOG); }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
private void drawPyramidGrid() { // setup stuff GL11.glEnable(GL11.GL_LIGHTING);//from w w w. j av a2 s . co m GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LESS); // draw the pyramid grid for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { GL11.glPushMatrix(); GL11.glTranslatef(i, 0, j); if (i == 1 && j == 0) setColor(1, 0, 0, 1); else if (i == 0 && j == 1) setColor(0, 0, 1, 1); else setColor(1, 1, 0, 1); final float k = 0.03f; GL11.glBegin(GL11.GL_TRIANGLE_FAN); GL11.glNormal3f(0, 1, -1); GL11.glVertex3f(0, k, 0); GL11.glVertex3f(-k, 0, -k); GL11.glVertex3f(k, 0, -k); GL11.glNormal3f(1, 1, 0); GL11.glVertex3f(k, 0, k); GL11.glNormal3f(0, 1, 1); GL11.glVertex3f(-k, 0, k); GL11.glNormal3f(-1, 1, 0); GL11.glVertex3f(-k, 0, -k); GL11.glEnd(); GL11.glPopMatrix(); } } }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
/** * @see DrawStuffApi#dsDrawLine(float[], float[]) *//* w w w . j av a 2 s. c o m*/ @Override public void dsDrawLine(final float[] pos1, final float[] pos2) { setupDrawingMode(); GL11.glColor3f(color[0], color[1], color[2]); GL11.glDisable(GL11.GL_LIGHTING); GL11.glLineWidth(2); GL11.glShadeModel(GL11.GL_FLAT); GL11.glBegin(GL11.GL_LINES); GL11.glVertex3f(pos1[0], pos1[1], pos1[2]); GL11.glVertex3f(pos2[0], pos2[1], pos2[2]); GL11.glEnd(); }
From source file:org.spout.engine.batcher.GL11SpriteBatch.java
License:Open Source License
public void render() { GL11.glDisable(GL11.GL_DEPTH_TEST);/*from www. ja va2 s. c o m*/ for (int i = 0; i < sprites.size(); i++) { RenderPart rect = sprites.get(i); rect.getRenderMaterial().getShader().setUniform("View", this.view); rect.getRenderMaterial().getShader().setUniform("Projection", this.projection); rect.getRenderMaterial().getShader().setUniform("Model", this.view); //View is always an identity matrix. rect.getRenderMaterial().assign(); GL11.glBegin(GL11.GL_TRIANGLES); float r = (float) rect.getColor().getRed() / 255f; float g = (float) rect.getColor().getGreen() / 255f; float b = (float) rect.getColor().getBlue() / 255f; float a = (float) rect.getColor().getAlpha() / 255f; GL11.glColor4f(r, g, b, a); GL11.glTexCoord2f(rect.getSource().getX(), rect.getSource().getY()); GL11.glVertex3f(rect.getSprite().getX(), rect.getSprite().getY() + rect.getSprite().getHeight(), 0.f); GL11.glColor4f(r, g, b, a); GL11.glTexCoord2f(rect.getSource().getX(), rect.getSource().getY() + rect.getSource().getHeight()); GL11.glVertex3f(rect.getSprite().getX(), rect.getSprite().getY(), 0.f); GL11.glColor4f(r, g, b, a); GL11.glTexCoord2f(rect.getSource().getX() + rect.getSource().getWidth(), rect.getSource().getY() + rect.getSource().getHeight()); GL11.glVertex3f(rect.getSprite().getX() + rect.getSprite().getWidth(), rect.getSprite().getY(), 0.f); GL11.glColor4f(r, g, b, a); GL11.glTexCoord2f(rect.getSource().getX(), rect.getSource().getY()); GL11.glVertex3f(rect.getSprite().getX(), rect.getSprite().getY() + rect.getSprite().getHeight(), 0.f); GL11.glColor4f(r, g, b, a); GL11.glTexCoord2f(rect.getSource().getX() + rect.getSource().getWidth(), rect.getSource().getY() + rect.getSource().getHeight()); GL11.glVertex3f(rect.getSprite().getX() + rect.getSprite().getWidth(), rect.getSprite().getY(), 0.f); GL11.glColor4f(r, g, b, a); GL11.glTexCoord2f(rect.getSource().getX() + rect.getSource().getWidth(), rect.getSource().getY()); GL11.glVertex3f(rect.getSprite().getX() + rect.getSprite().getWidth(), rect.getSprite().getY() + rect.getSprite().getHeight(), 0.f); GL11.glEnd(); } GL11.glEnable(GL11.GL_DEPTH_TEST); }
From source file:org.spoutcraft.api.gui.RenderUtil.java
License:Open Source License
/** * Draws a symmetrical polygon. Large values of segments (>50) approximate a circle. * @param cx x coordinate or the center of the circle * @param cy y coordinate for the center of the circle * @param r radius of the circle//www .j a v a 2 s .c o m * @param numSegments to draw (number of sides to the polygon. Large values > 50 approximate a circle) */ public static void drawSymmetricalPolygon(float cx, float cy, float r, int numSegments) { float theta = 2 * 3.1415926F / ((float) numSegments); float c = (float) Math.cos(theta); // Precalculate the sine and cosine float s = (float) Math.sin(theta); float t; float x = r; // We start at angle = 0 float y = 0; GL11.glBegin(GL11.GL_LINE_LOOP); for (int ii = 0; ii < numSegments; ii++) { GL11.glVertex2f(x + cx, y + cy); // Output vertex // Apply the rotation matrix t = x; x = c * x - s * y; y = s * t + c * y; } GL11.glEnd(); }
From source file:org.spoutcraft.spoutcraftapi.gui.RenderUtil.java
License:Open Source License
/** * Draws a symmetrical polygon. Large values of segments (>50) approximate a circle. * @param cx x coordinate or the center of the circle * @param cy y coordinate for the center of the circle * @param r radius of the circle/*from w w w.j av a 2 s . c om*/ * @param numSegments to draw (number of sides to the polygon. Large values > 50 approximate a circle) */ public static void drawSymmetricalPolygon(float cx, float cy, float r, int numSegments) { float theta = 2 * 3.1415926F / ((float) numSegments); float c = (float) Math.cos(theta);//precalculate the sine and cosine float s = (float) Math.sin(theta); float t; float x = r;//we start at angle = 0 float y = 0; GL11.glBegin(GL11.GL_LINE_LOOP); for (int ii = 0; ii < numSegments; ii++) { GL11.glVertex2f(x + cx, y + cy);//output vertex //apply the rotation matrix t = x; x = c * x - s * y; y = s * t + c * y; } GL11.glEnd(); }
From source file:org.terasology.rendering.gui.components.UIPieChart.java
License:Apache License
public void render() { super.render(); if (_data.size() == 0) return;/* ww w . ja v a 2 s .c o m*/ ArrayList<String> sortedKeys = new ArrayList<String>(_data.keySet()); Collections.sort(sortedKeys); glPushMatrix(); glTranslatef(getSize().x / 2, getSize().y / 2, 0.0f); GL11.glBegin(GL11.GL_TRIANGLE_FAN); GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glVertex3f(0f, 0f, 0f); double stepSize = (Math.PI * 2.0) / SEGMENTS; int segment = 0; double prevValueSum = 0.0f; for (int i = 0; i <= SEGMENTS; i++) { double value = _data.get(sortedKeys.get(segment)); if (((double) i / SEGMENTS) >= value + prevValueSum) { segment++; prevValueSum += value; Vector3f segmentColor = new Vector3f((segment * 0.1f) % 1.0f, (segment * 0.2f) % 1.0f, (segment * 0.4f) % 1.0f); glColor3f(segmentColor.x, segmentColor.y, segmentColor.z); } GL11.glVertex2f((float) Math.sin(stepSize * i) * (getSize().x / 2), (float) Math.cos(stepSize * i) * (getSize().x / 2)); } GL11.glEnd(); glPopMatrix(); }