@Override public void drawTransform(Transform xf) { GL2 gl = panel.getGL().getGL2(); getWorldToScreenToOut(xf.p, temp); temp2.setZero(); float k_axisScale = 0.4f; gl.glBegin(GL2.GL_LINES); gl.glColor3f(1, 0, 0); temp2.x = xf.p.x + k_axisScale * xf.q.c; temp2.y = xf.p.y + k_axisScale * xf.q.s; getWorldToScreenToOut(temp2, temp2); gl.glVertex2f(temp.x, temp.y); gl.glVertex2f(temp2.x, temp2.y); gl.glColor3f(0, 1, 0); temp2.x = xf.p.x + -k_axisScale * xf.q.s; temp2.y = xf.p.y + k_axisScale * xf.q.c; getWorldToScreenToOut(temp2, temp2); gl.glVertex2f(temp.x, temp.y); gl.glVertex2f(temp2.x, temp2.y); gl.glEnd(); }
@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(); }
/** * Creates a single colour mapped vertex. * * @param gl The GL context * @param N The number of points in the X direction * @param M The number of points in the Z direction * @param stepSizeX The size of each quad in the patch * @param stepSizeY The size of each quad in the patch * @param X The index along the X direction * @param Y The index along the Z direction (Y in the data) */ private void createVertex( final GL2 gl, final int N, final int M, final double stepSizeX, final double stepSizeY, final int X, final int Y ) { final double x = X * stepSizeX; final double z = Y * stepSizeY; double y = this.data[Y][X]; if( this.autoScale ) y *= 1d/(this.max-this.min); if( this.renderType == HeightMapType.TEXTURED ) gl.glTexCoord2f( (float)(x / N), (float)(z / M) ); else { final float[] c = this.colour; if( this.colourMap != null ) this.colourMap.apply( (float)(this.data[Y][X] * 1d/(this.max-this.min)), c ); gl.glColor3f( c[0], c[1], c[2] ); } gl.glVertex3d( x, y, z ); }
@Override public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); // get the OpenGL 2 graphics context gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // clear // color // and depth // buffers gl.glLoadIdentity(); // reset the model-view matrix // ----- Your OpenGL rendering code here (Render a white triangle for // testing) ----- gl.glTranslatef(0.0f, 0.0f, -6.0f); // translate into the screen gl.glColor3f(r, g, b); gl.glBegin(GL.GL_TRIANGLES); // draw using triangles long delay = System.currentTimeMillis() - time; double angle = speed * delay * Math.PI / 2000; float c = (float) Math.cos(angle); float s = (float) Math.sin(angle); gl.glVertex3f(c, s, 0.0f); gl.glVertex3f(-s, c, 0.0f); gl.glVertex3f(-c, -s, 0.0f); gl.glEnd(); } @Override
@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.glVertexPointer(2, GL.GL_FLOAT, 0, 0); gl.glColor3f(colors[0], colors[1], colors[2]); gl.glDrawArrays(GL.GL_LINES, 0, p);
gl.glColor3f( config.getRenderingConfig().getMinorTickColour()[0], config.getRenderingConfig().getMinorTickColour()[1], config.getRenderingConfig().getMinorTickColour()[2] );
@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(); }
@Override public void display(GLAutoDrawable glad) { GL2 gl = (GL2)glad.getGL(); gl.glBlendFunc(GL_SRC_ALPHA, blends[iBlend]); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); new GLU().gluOrtho2D(-width / 2 - 1, width / 2 + 1, -height/2 - 1, height/2 + 1); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[0]); if (useOpenGLContext) { queue.finish(); } else { //interleavedColorAndPositionsMem.map(queue, CLMem.MapFlags.Read); interleavedColorAndPositionsMem.read(queue, interleavedColorAndPositionsTemp, true); gl.glBufferSubData(GL_ARRAY_BUFFER, 0, (int)interleavedColorAndPositionsTemp.getValidBytes(), interleavedColorAndPositionsTemp.getByteBuffer()); //interleavedColorAndPositionsMem.unmap(queue, interleavedColorAndPositionsTemp); } gl.glClear(GL_COLOR_BUFFER_BIT); gl.glColor3f(1.0f, 1.0f, 1.0f); //gl.glEnableClientState(GL_VERTEX_ARRAY); //gl.glEnableClientState(GL_COLOR_ARRAY); //gl.glColorPointer(4, GL_UNSIGNED_BYTE, elementSize, gl.glInterleavedArrays(GL2.GL_C4UB_V2F, elementSize, 0); gl.glDrawArrays(GL_POINTS, 0, particlesCount); gl.glBindBuffer(GL_ARRAY_BUFFER, 0); if (!paused) updateKernelArgs(); }
gl.glColor3f( object.object.colour[0], object.object.colour[1], object.object.colour[2] ); else
gl.glColor3f( config.getRenderingConfig().getMinorGridColour()[0], config.getRenderingConfig().getMinorGridColour()[1], config.getRenderingConfig().getMinorGridColour()[2] );