Java Code Examples for javax.media.opengl.GL2#glVertex3f()
The following examples show how to use
javax.media.opengl.GL2#glVertex3f() .
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: JoglDebugDraw.java From jbox2d with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void drawCircle(Vec2 center, float radius, Color3f color) { GL2 gl = panel.getGL().getGL2(); gl.glPushMatrix(); transformViewport(gl, zero); float theta = 2 * MathUtils.PI / NUM_CIRCLE_POINTS; float c = MathUtils.cos(theta); float s = MathUtils.sin(theta); float x = radius; float y = 0; float cx = center.x; float cy = center.y; gl.glBegin(GL2.GL_LINE_LOOP); gl.glColor4f(color.x, color.y, color.z, 1); for (int i = 0; i < NUM_CIRCLE_POINTS; i++) { gl.glVertex3f(x + cx, y + cy, 0); // apply the rotation matrix float temp = x; x = c * x - s * y; y = s * temp + c * y; } gl.glEnd(); gl.glPopMatrix(); }
Example 2
Source File: JoglDebugDraw.java From jbox2d with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void drawCircle(Vec2 center, float radius, Vec2 axis, Color3f color) { GL2 gl = panel.getGL().getGL2(); gl.glPushMatrix(); transformViewport(gl, zero); float theta = 2 * MathUtils.PI / NUM_CIRCLE_POINTS; float c = MathUtils.cos(theta); float s = MathUtils.sin(theta); float x = radius; float y = 0; float cx = center.x; float cy = center.y; gl.glBegin(GL2.GL_LINE_LOOP); gl.glColor4f(color.x, color.y, color.z, 1); for (int i = 0; i < NUM_CIRCLE_POINTS; i++) { gl.glVertex3f(x + cx, y + cy, 0); // apply the rotation matrix float temp = x; x = c * x - s * y; y = s * temp + c * y; } gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(cx, cy, 0); gl.glVertex3f(cx + axis.x * radius, cy + axis.y * radius, 0); gl.glEnd(); gl.glPopMatrix(); }
Example 3
Source File: JoglDebugDraw.java From jbox2d with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void drawSegment(Vec2 p1, Vec2 p2, Color3f color) { GL2 gl = panel.getGL().getGL2(); gl.glPushMatrix(); transformViewport(gl, zero); gl.glBegin(GL2.GL_LINES); gl.glColor3f(color.x, color.y, color.z); gl.glVertex3f(p1.x, p1.y, 0); gl.glVertex3f(p2.x, p2.y, 0); gl.glEnd(); gl.glPopMatrix(); }
Example 4
Source File: JoglDebugDraw.java From jbox2d with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void drawParticles(Vec2[] centers, float radius, ParticleColor[] colors, int count) { GL2 gl = panel.getGL().getGL2(); gl.glPushMatrix(); transformViewport(gl, zero); float theta = 2 * MathUtils.PI / NUM_CIRCLE_POINTS; float c = MathUtils.cos(theta); float s = MathUtils.sin(theta); float x = radius; float y = 0; for (int i = 0; i < count; i++) { Vec2 center = centers[i]; float cx = center.x; float cy = center.y; gl.glBegin(GL2.GL_TRIANGLE_FAN); if (colors == null) { gl.glColor4f(1, 1, 1, .4f); } else { ParticleColor color = colors[i]; gl.glColor4b(color.r, color.g, color.b, color.a); } for (int j = 0; j < NUM_CIRCLE_POINTS; j++) { gl.glVertex3f(x + cx, y + cy, 0); float temp = x; x = c * x - s * y; y = s * temp + c * y; } gl.glEnd(); } gl.glPopMatrix(); }
Example 5
Source File: JoglDebugDraw.java From jbox2d with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void drawParticlesWireframe(Vec2[] centers, float radius, ParticleColor[] colors, int count) { GL2 gl = panel.getGL().getGL2(); gl.glPushMatrix(); transformViewport(gl, zero); float theta = 2 * MathUtils.PI / NUM_CIRCLE_POINTS; float c = MathUtils.cos(theta); float s = MathUtils.sin(theta); float x = radius; float y = 0; for (int i = 0; i < count; i++) { Vec2 center = centers[i]; float cx = center.x; float cy = center.y; gl.glBegin(GL2.GL_LINE_LOOP); if (colors == null) { gl.glColor4f(1, 1, 1, 1); } else { ParticleColor color = colors[i]; gl.glColor4b(color.r, color.g, color.b, (byte) 127); } for (int j = 0; j < NUM_CIRCLE_POINTS; j++) { gl.glVertex3f(x + cx, y + cy, 0); float temp = x; x = c * x - s * y; y = s * temp + c * y; } gl.glEnd(); } gl.glPopMatrix(); }
Example 6
Source File: Rhombus.java From MeteoInfo with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void display(GLAutoDrawable drawable) { final GL2 gl = drawable.getGL().getGL2(); gl.glTranslatef(0f, 0f, -2.5f); //drawing edge1..... gl.glBegin(GL2.GL_LINES); gl.glVertex3f(-0.75f, 0f, 0); gl.glVertex3f(0f, -0.75f, 0); gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(-0.75f, 0f, 3f); // 3 units into the window gl.glVertex3f(0f, -0.75f, 3f); gl.glEnd(); //top gl.glBegin(GL2.GL_LINES); gl.glVertex3f(-0.75f, 0f, 0); gl.glVertex3f(-0.75f, 0f, 3f); gl.glEnd(); // bottom gl.glBegin(GL2.GL_LINES); gl.glVertex3f(0f, -0.75f, 0); gl.glVertex3f(0f, -0.75f, 3f); gl.glEnd(); // edge 2.... gl.glBegin(GL2.GL_LINES); gl.glVertex3f(0f, -0.75f, 0); gl.glVertex3f(0.75f, 0f, 0); gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(0f, -0.75f, 3f); gl.glVertex3f(0.75f, 0f, 3f); gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(0f, -0.75f, 0); gl.glVertex3f(0f, -0.75f, 3f); gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(0.75f, 0f, 0); gl.glVertex3f(0.75f, 0f, 3f); gl.glEnd(); //Edge 3............. gl.glBegin(GL2.GL_LINES); gl.glVertex3f(0.0f, 0.75f, 0); gl.glVertex3f(-0.75f, 0f, 0); gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(0.0f, 0.75f, 3f); gl.glVertex3f(-0.75f, 0f, 3f); gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(0.0f, 0.75f, 0); gl.glVertex3f(0.0f, 0.75f, 3f); gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(-0.75f, 0f, 0); gl.glVertex3f(-0.75f, 0f, 3f); gl.glEnd(); //final edge gl.glBegin(GL2.GL_LINES); gl.glVertex3f(0.75f, 0f, 0); gl.glVertex3f(0.0f, 0.75f, 0); gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(0.75f, 0f, 3f); gl.glVertex3f(0.0f, 0.75f, 3f); gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(0.75f, 0f, 0); gl.glVertex3f(0.75f, 0f, 3f); gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(0.0f, 0.75f, 0); gl.glVertex3f(0.0f, 0.75f, 3f); gl.glEnd(); }