List of usage examples for org.lwjgl.opengl GL11 glVertex3d
public static native void glVertex3d(@NativeType("GLdouble") double x, @NativeType("GLdouble") double y, @NativeType("GLdouble") double z);
From source file:com.wicpar.sinkingsimulatorclassic.Sea.java
License:Open Source License
@Override public void draw() { GL11.glEnable(GL11.GL_DEPTH_TEST);//from w w w .j a va 2s .c om GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_POLYGON_SMOOTH); time = Base.getTimePassed(); GL11.glBegin(GL11.GL_QUAD_STRIP); GL11.glColor4f(SeaColor.r, SeaColor.g, SeaColor.b, SeaColor.a); for (int i = 0; i <= divisions; i++) { double pos = ((double) (i) / (divisions)) * 2 - 1; GL11.glVertex3d(pos, -1, -0.07); GL11.glVertex3d(pos, cam.transformY(getHeight(cam.untransformX(pos), time)), -0.07); } GL11.glEnd(); GL11.glEnable(GL11.GL_POLYGON_SMOOTH); GL11.glLineWidth(2); GL11.glBegin(GL11.GL_LINE_STRIP); GL11.glColor4f(SeaColor.r, SeaColor.g, SeaColor.b, 1); for (int i = 0; i <= divisions; i++) { double pos = ((double) (i) / (divisions)) * 2 - 1; GL11.glVertex3d(pos, cam.transformY(getHeight(cam.untransformX(pos), time)), -0.07); } GL11.glEnd(); GL11.glLineWidth(1); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glLineWidth(1); }
From source file:com.wicpar.sinkingsimulatorclassic.Ship.java
License:Open Source License
@Override public void draw() { final Camera cam = Main.ClassicSinkingSim.getInstance().getCam(); GL11.glEnable(GL11.GL_DEPTH_TEST);/* w ww . ja va 2 s . com*/ GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glPointSize((float) Main.ClassicSinkingSim.getInstance().getCam().scaleSize(0.1)); GL11.glBegin(GL11.GL_POINTS); for (Shipsel[] s : shipsels) { if (s != null) for (Shipsel shipsel : s) { if (shipsel != null) { Color c = shipsel.getColor(); Vector3d pos = shipsel.getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.8); } } } GL11.glEnd(); GL11.glPointSize(1); GL11.glLineWidth((float) Main.ClassicSinkingSim.getInstance().getCam().scaleSize(0.1)); boolean t, b, l, r, e, f; Color c; Vector3d pos; GL11.glBegin(GL11.GL_LINES); for (int y = 0; y < springs[1].length; y++) { for (int x = 0; x < springs[1][y].length; x++) { t = springs[0][y][x]; l = springs[2][y][x]; e = springs[1][y][x]; f = springs[3][y][x]; if (t && (shipsels[y][x] == null || shipsels[y][x + 1] == null)) { springs[0][y][x] = false; } if (l && (shipsels[y][x] == null || shipsels[y + 1][x] == null)) { springs[2][y][x] = false; } if (e && (shipsels[y][x] == null || shipsels[y + 1][x + 1] == null)) { springs[1][y][x] = false; } if (f && (shipsels[y][x + 1] == null || shipsels[y + 1][x] == null)) { springs[3][y][x] = false; } t = springs[0][y][x]; b = springs[0][y + 1][x]; l = springs[2][y][x]; r = springs[2][y][x + 1]; e = springs[1][y][x]; f = springs[3][y][x]; if (t && b && l && r && e && f) continue; if (t && r && e) continue; if (b && l && e) continue; if (t && l && f) continue; if (b && r && f) continue; if (t) { c = shipsels[y][x].getColor(); pos = shipsels[y][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9); c = shipsels[y][x + 1].getColor(); pos = shipsels[y][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9); } if (l) { c = shipsels[y][x].getColor(); pos = shipsels[y][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9); c = shipsels[y + 1][x].getColor(); pos = shipsels[y + 1][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9); } if (e) { c = shipsels[y][x].getColor(); pos = shipsels[y][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9); c = shipsels[y + 1][x + 1].getColor(); pos = shipsels[y + 1][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9); } if (f) { c = shipsels[y][x + 1].getColor(); pos = shipsels[y][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9); c = shipsels[y + 1][x].getColor(); pos = shipsels[y + 1][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9); } } } GL11.glEnd(); GL11.glBegin(GL11.GL_TRIANGLES); for (int y = 0; y < springs[1].length; y++) { for (int x = 0; x < springs[1][y].length; x++) { t = springs[0][y][x]; b = springs[0][y + 1][x]; l = springs[2][y][x]; r = springs[2][y][x + 1]; e = springs[1][y][x]; f = springs[3][y][x]; if (t && b && l && r && e && f) { c = shipsels[y][x].getColor(); pos = shipsels[y][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y][x + 1].getColor(); pos = shipsels[y][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y + 1][x].getColor(); pos = shipsels[y + 1][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y][x + 1].getColor(); pos = shipsels[y][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y + 1][x].getColor(); pos = shipsels[y + 1][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y + 1][x + 1].getColor(); pos = shipsels[y + 1][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); } else { if (t && r && e) { c = shipsels[y][x].getColor(); pos = shipsels[y][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y][x + 1].getColor(); pos = shipsels[y][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y + 1][x + 1].getColor(); pos = shipsels[y + 1][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); } if (b && l && e) { c = shipsels[y][x].getColor(); pos = shipsels[y][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y + 1][x].getColor(); pos = shipsels[y + 1][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y + 1][x + 1].getColor(); pos = shipsels[y + 1][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); } if (t && l && f) { c = shipsels[y][x].getColor(); pos = shipsels[y][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y][x + 1].getColor(); pos = shipsels[y][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y + 1][x].getColor(); pos = shipsels[y + 1][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); } if (b && r && f) { c = shipsels[y + 1][x].getColor(); pos = shipsels[y + 1][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y + 1][x + 1].getColor(); pos = shipsels[y + 1][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y][x + 1].getColor(); pos = shipsels[y][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); } } } } GL11.glEnd(); GL11.glLineWidth(1); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_DEPTH_TEST); }
From source file:com.wicpar.sinkingsimulatorclassic.Sky.java
License:Open Source License
@Override public void draw() { GL11.glEnable(GL11.GL_DEPTH_TEST);/*from w w w .j a va 2s .c o m*/ GL11.glBegin(GL11.GL_QUADS); GL11.glColor4f(SkyColor.r, SkyColor.g, SkyColor.b, SkyColor.a); GL11.glVertex3d(-1, -1, -0.9); GL11.glVertex3d(-1, 1, -0.9); GL11.glVertex3d(1, 1, -0.9); GL11.glVertex3d(1, -1, -0.9); GL11.glEnd(); GL11.glDisable(GL11.GL_DEPTH_TEST); }
From source file:de.kitsunealex.projectx.client.render.RenderTruncatedIcosahedron.java
License:Open Source License
private void renderShape(Vector3[] verts, boolean reverse) { Vector3 center = new Vector3(); for (int i = 0; i < verts.length; i++) { center.add(verts[i]);/*w w w . jav a2 s .c o m*/ } center.multiply(1D / verts.length); Vector3 prev = verts[0]; int start = reverse ? verts.length : 1; int end = reverse ? -1 : verts.length + 1; int step = reverse ? -1 : 1; for (int i = start; i != end; i += step) { GL11.glTexCoord2d(0.5D, 0.5D); GL11.glVertex3d(center.x, center.y, center.z); GL11.glTexCoord2d(0D, 0D); GL11.glVertex3d(prev.x, prev.y, prev.z); GL11.glTexCoord2d(1D, 0D); GL11.glVertex3d(verts[(i % verts.length)].x, verts[(i % verts.length)].y, verts[(i % verts.length)].z); prev = verts[(i % verts.length)]; } }
From source file:fi.conf.ae.gl.GLGraphicRoutines.java
License:LGPL
public static void draw2DRect(float x0, float y0, float x1, float y1, float z) { GL11.glBegin(GL11.GL_QUADS);// ww w . j av a2s. c o m GL11.glNormal3f(0, 0, 1); GL11.glTexCoord2d(0, 0); GL11.glVertex3d(x0, y0, z); GL11.glNormal3f(0, 0, 1); GL11.glTexCoord2d(0, 0.9999999); GL11.glVertex3d(x0, y1, z); GL11.glNormal3f(0, 0, 1); GL11.glTexCoord2d(0.9999999, 0.9999999); GL11.glVertex3d(x1, y1, z); GL11.glNormal3f(0, 0, 1); GL11.glTexCoord2d(0.9999999, 0); GL11.glVertex3d(x1, y0, z); GL11.glEnd(); }
From source file:fi.conf.ae.gl.GLGraphicRoutines.java
License:LGPL
public static void drawRepeatedBackgroundPlane(float rx, float ry, float tx, float ty) { initOrtho();/*from ww w . j a v a 2s.c o m*/ GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2d(tx, ty + ry); GL11.glVertex3d(0, GLValues.glHeight, -GLValues.glDepth); GL11.glTexCoord2d(tx + rx, ty + ry); GL11.glVertex3d(GLValues.glWidth, GLValues.glHeight, -GLValues.glDepth); GL11.glTexCoord2d(tx + rx, ty); GL11.glVertex3d(GLValues.glWidth, 0, -GLValues.glDepth); GL11.glTexCoord2d(tx, ty); GL11.glVertex3d(0, 0, -GLValues.glDepth); GL11.glEnd(); }
From source file:fi.conf.ae.gl.GLGraphicRoutines.java
License:LGPL
public static void drawCircle(float r, float d) { GL11.glBegin(GL11.GL_TRIANGLE_FAN);// w w w . j ava 2 s. c o m for (float a = (float) ((2.0f * Math.PI) / d); a < 2 * Math.PI; a += (2.0f * Math.PI) / (float) d) { GL11.glNormal3f(0, 0, -1.0f); GL11.glTexCoord2d((Math.sin(a) + 1.0f) / 2.0f, (Math.cos(a) + 1.0f) / 2.0f); GL11.glVertex3d(Math.sin(a) * r, Math.cos(a) * r, 0); } GL11.glEnd(); }
From source file:fi.conf.ae.gl.GLGraphicRoutines.java
License:LGPL
public static void drawHexagon(float r) { GL11.glBegin(GL11.GL_TRIANGLE_FAN);//from w w w .j a va 2s . c o m for (float a = (float) ((2.0f * Math.PI) / 6.0f); a < 2 * Math.PI; a += (2.0f * Math.PI) / 6.0f) { GL11.glNormal3f(0, 0, -1.0f); GL11.glTexCoord2d((Math.sin(a) + 1.0f) / 2.0f, (Math.cos(a) + 1.0f) / 2.0f); GL11.glVertex3d(Math.sin(a) * r, Math.cos(a) * r, 0); } GL11.glEnd(); }
From source file:fi.conf.ae.gl.GLGraphicRoutines.java
License:LGPL
public static void drawLineCircle(float radius, float segments, float lineWidth) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, -1); GL11.glLineWidth(lineWidth);/*from ww w. ja v a 2 s. co m*/ GL11.glBegin(GL11.GL_LINE_LOOP); for (float a = 0; a < 2 * Math.PI; a += (2.0f * Math.PI) / segments) { GL11.glVertex3d(Math.sin(a) * radius, Math.cos(a) * radius, 0); } GL11.glEnd(); }
From source file:fi.conf.ae.gl.GLGraphicRoutines.java
License:LGPL
public static void drawLineRect(float w, float x0, float y0, float x1, float y1, float z) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, -1); GL11.glLineWidth(w);/*w ww . ja v a 2 s . c o m*/ GL11.glBegin(GL11.GL_LINE_LOOP); GL11.glVertex3d(x0, y1, z); GL11.glVertex3d(x1, y1, z); GL11.glVertex3d(x1, y0, z); GL11.glVertex3d(x0, y0, z); GL11.glEnd(); }