@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(); }
@Override public void drawPolygon(Vec2[] vertices, int vertexCount, Color3f color) { GL2 gl = panel.getGL().getGL2(); gl.glPushMatrix(); transformViewport(gl, zero); gl.glBegin(GL2.GL_LINE_LOOP); gl.glColor4f(color.x, color.y, color.z, 1f); for (int i = 0; i < vertexCount; i++) { Vec2 v = vertices[i]; gl.glVertex2f(v.x, v.y); } gl.glEnd(); gl.glPopMatrix(); }
@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(); }
@Override public void drawSolidPolygon(Vec2[] vertices, int vertexCount, Color3f color) { GL2 gl = panel.getGL().getGL2(); gl.glPushMatrix(); transformViewport(gl, zero); gl.glBegin(GL2.GL_TRIANGLE_FAN); gl.glColor4f(color.x, color.y, color.z, .4f); for (int i = 0; i < vertexCount; i++) { Vec2 v = vertices[i]; gl.glVertex2f(v.x, v.y); } gl.glEnd(); gl.glBegin(GL2.GL_LINE_LOOP); gl.glColor4f(color.x, color.y, color.z, 1f); for (int i = 0; i < vertexCount; i++) { Vec2 v = vertices[i]; gl.glVertex2f(v.x, v.y); } gl.glEnd(); gl.glPopMatrix(); }
@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(); }
gl.glVertex3f(cx + axis.x * radius, cy + axis.y * radius, 0); gl.glEnd(); gl.glPopMatrix();
private void endRendering(final boolean ortho) { final GL2 gl = GLContext.getCurrentGL().getGL2(); final Texture texture = getTexture(); texture.disable(gl); if (ortho) { gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glPopMatrix(); gl.glMatrixMode(GL.GL_TEXTURE); gl.glPopMatrix(); } gl.glPopAttrib(); }
@Override protected void renderVis( final GLAutoDrawable drawable ) { if( drawable == null || this.axesRenderer == null ) return; final GL2 gl = drawable.getGL().getGL2(); this.axesRenderer.renderAxis( drawable ); final List<LocatedObject3D<D>> x = new ArrayList<XYZVisualisation3D.LocatedObject3D<D>>(); x.addAll( this.data ); for( final LocatedObject3D<D> d : x ) { gl.glPushMatrix(); this.plotter.plotObject( drawable, d, this.axesRenderer ); gl.glPopMatrix(); } }
/** * Main render method * * @param gl GL context */ public final void render(GL2 gl) { gl.glMatrixMode(GL2.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glOrtho(0, width, 0, height, -1, +1); gl.glColor4f(0f, 0f, 0f, .5f); // Fade background: gl.glBegin(GL2.GL_QUADS); gl.glVertex2f(0f, 0f); gl.glVertex2f(width, 0f); gl.glVertex2f(width, height); gl.glVertex2f(0f, height); gl.glEnd(); renderContents(gl); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPopMatrix(); }
@Override public void drawAxis( final AxisConfig<float[]> config ) { final GL2 gl = this.glad.getGL().getGL2(); gl.glPushMatrix(); this.orient( gl ); final float zero = 0.001f; gl.glBegin( GL.GL_LINE_STRIP ); { gl.glLineWidth( (float)config.getRenderingConfig().getThickness() ); gl.glColor3f( config.getRenderingConfig().getColour()[0], config.getRenderingConfig().getColour()[1], config.getRenderingConfig().getColour()[2] ); final float n1 = this.calculatePosition( config.getMinValue() ).floatValue(); final float n2 = this.calculatePosition( config.getMaxValue() ).floatValue(); // We draw in the x axis, so the orientation has to be set appropriately gl.glVertex3f( n1, zero, zero ); gl.glVertex3f( n2, zero, zero ); } gl.glEnd(); gl.glPopMatrix(); }
gl.glEnd(); gl.glPopMatrix(); gl.glVertex3d( p2[0], p2[1], p2[2] ); gl.glEnd(); gl.glPopMatrix();
@Override public void drawMajorTickGridline( final double location, final AxisConfig<float[]> config ) { final GL2 gl = this.glad.getGL().getGL2(); gl.glPushMatrix(); this.orient( gl ); gl.glLineWidth( (float)config.getRenderingConfig().getMajorGridThickness() ); gl.glColor3f( config.getRenderingConfig().getMajorGridColour()[0], config.getRenderingConfig().getMajorGridColour()[1], config.getRenderingConfig().getMajorGridColour()[2] ); final float ll = this.calculatePosition( location ).floatValue(); final float zero = 0.001f; gl.glBegin( GL.GL_LINE_STRIP ); { // We draw in the x axis, so the orientation has to be set appropriately gl.glVertex3f( ll, zero, zero ); gl.glVertex3f( ll, 1, zero ); } gl.glEnd(); gl.glBegin( GL.GL_LINE_STRIP ); { // We draw in the x axis, so the orientation has to be set appropriately gl.glVertex3f( ll, zero, zero ); gl.glVertex3f( ll, zero, 1*this.gridDirection ); } gl.glEnd(); gl.glPopMatrix(); }
@Override public void drawMajorTick( final double location, final AxisConfig<float[]> config ) { final GL2 gl = this.glad.getGL().getGL2(); gl.glPushMatrix(); this.orient( gl ); gl.glLineWidth( (float)config.getRenderingConfig().getMajorTickThickness() ); gl.glColor3f( config.getRenderingConfig().getMajorTickColour()[0], config.getRenderingConfig().getMajorTickColour()[1], config.getRenderingConfig().getMajorTickColour()[2] ); final float l = (float)config.getRenderingConfig().getMajorTickLength(); final float l2 = -l; final float ll = this.calculatePosition( location ).floatValue(); final float zero = 0.001f; gl.glBegin( GL.GL_LINE_STRIP ); { // We draw in the x axis, so the orientation has to be set appropriately gl.glVertex3f( ll, l, zero ); gl.glVertex3f( ll, l2, zero ); } gl.glEnd(); gl.glBegin( GL.GL_LINE_STRIP ); { // We draw in the x axis, so the orientation has to be set appropriately gl.glVertex3f( ll, zero, l ); gl.glVertex3f( ll, zero, l2 ); } gl.glEnd(); gl.glPopMatrix(); }
this.glu.gluDeleteQuadric( qobj0 ); gl.glPopMatrix();
gl.glTranslated(r.x, r.y, r.z); this.drawOutline(dc, a, b, c, d); gl.glPopMatrix(); gl.glPushMatrix(); this.drawOutline(dc, a, e, f, d);