Java Code Examples for com.jogamp.opengl.GL2#glLoadIdentity()
The following examples show how to use
com.jogamp.opengl.GL2#glLoadIdentity() .
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: J3DBasic.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { GL2 gl = drawable.getGL().getGL2(); if (height <= 0) { height = 1; } final float h = (float) width / (float) height; gl.glViewport(0, 0, width, height); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective(40.0f, h, 1.5, 18.0); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); }
Example 2
Source File: JCuboid.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { final GL2 gl = drawable.getGL().getGL2(); if (height <= 0) { height = 1; } final float h = (float) width / (float) height; gl.glViewport(0, 0, width, height); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective(45.0f, h, 1.0, 20.0); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); }
Example 3
Source File: JRotation.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void display(GLAutoDrawable drawable) { final GL2 gl = drawable.getGL().getGL2(); gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer gl.glLoadIdentity(); // Reset The View //triangle rotation gl.glRotatef(rotation, 0.0f, 1.0f, 0.0f); gl.glBegin(GL2.GL_TRIANGLES); //Green Color gl.glColor3f(0.0f, 1.0f, 0.0f); gl.glVertex2d(0, 0.5); gl.glVertex2d(-0.5, -0.5); gl.glVertex2d(0.5, -0.5); gl.glEnd(); gl.glFlush(); //Assign the angle rotation += 0.6f; }
Example 4
Source File: CubeSample2.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { GL2 gl = drawable.getGL().getGL2(); // gl.glViewport(0f, 0f, width, height); //(3) Jogl内部で実行済みなので,不要.(APIDOCに書いてある) // gl.glOrtho(-2.0, 2.0, -2.0, 2.0, -2.0, 2.0); gl.glMatrixMode(GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective(30.0, (double)width / (double)height, 1.0, 300.0); // gl.glTranslatef(0.0f, 0.0f, -5.0f); glu.gluLookAt(3.0f, 4.0f, 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); // System.out.printf("x:%d, y:%d, w:%d, h:%d, %n", x, y, width, height); //これによりウィンドウをリサイズしても中の図形は大きさが維持される. //また,第3,第4引数を入れ替えることによりGLWindowの座標系(左上隅が原点)とデバイス座標系(左下隅が原点)の違いを吸収している. // gl.glOrthof(x, x + width, y + height, y, -1.0f, 1.0f); //(4) // gl.glOrthof(x/300f, (x + width)/300f, (y + height)/300f, y/300f, -1.0f, 1.0f); //(4) // gl.glOrthof(x/400f, (x + width)/400f, (y + height)/400f, y/400f, -1.0f, 1.0f); //(4) // gl.glOrthof(x/400f, (x + width)/400f, (y + height)/400f, y/400f, -1.0f, 1.0f); //(4) // gl.glOrthof(x/300f, (x/300) + width, (y/300) + height, y/300f, -1.0f, 1.0f); //(4) // gl.glOrthof(x , x + width/300f, y + height/300f, y, -1.0f, 1.0f); //(4) gl.glMatrixMode(GL_MODELVIEW); // gl.glLoadIdentity(); }
Example 5
Source File: OpenGLGFXCMD.java From sagetv with Apache License 2.0 | 6 votes |
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { GL2 gl; System.out.println("reshape "+x+","+y+" "+width+","+height); gl = drawable.getGL().getGL2(); newosdwidth=width; newosdheight=height; gl.glViewport(0, 0, newosdwidth, newosdheight); gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrtho(0,newosdwidth,newosdheight,0,-1.0,1.0); gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glLoadIdentity(); gl.glClearColor( 0.0f, 0.0f, 0.0f, 0.0f); gl.glClear( gl.GL_COLOR_BUFFER_BIT); synchronized(newpbufferlock) { newpbuffer=true; } myConn.postResizeEvent(new java.awt.Dimension(c.getWidth(), c.getHeight())); }
Example 6
Source File: ViewportEntity.java From Robot-Overlord-App with GNU General Public License v2.0 | 6 votes |
public void renderPick(GL2 gl2,double pickX,double pickY) { gl2.glMatrixMode(GL2.GL_PROJECTION); gl2.glLoadIdentity(); // get the current viewport dimensions to set up the projection matrix int[] viewportDimensions = new int[4]; gl2.glGetIntegerv(GL2.GL_VIEWPORT,viewportDimensions,0); GLU glu = GLU.createGLU(gl2); // Set up a tiny viewport that only covers the area behind the cursor. // Tiny viewports are faster. glu.gluPickMatrix(pickX, canvasHeight-pickY, 5.0, 5.0, viewportDimensions,0); if(drawOrtho.get()) { renderOrtho(gl2); } else { renderPerspective(gl2); } renderShared(gl2); }
Example 7
Source File: OneTriangle.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
protected static void setup( GL2 gl2, int width, int height ) { gl2.glMatrixMode( GL2.GL_PROJECTION ); gl2.glLoadIdentity(); // coordinate system origin at lower left with width and height same as the window GLU glu = new GLU(); glu.gluOrtho2D( 0.0f, width, 0.0f, height ); gl2.glMatrixMode( GL2.GL_MODELVIEW ); gl2.glLoadIdentity(); gl2.glViewport( 0, 0, width, height ); }
Example 8
Source File: ViewportEntity.java From Robot-Overlord-App with GNU General Public License v2.0 | 5 votes |
public void renderPerspective(GL2 gl2) { gl2.glMatrixMode(GL2.GL_PROJECTION); gl2.glLoadIdentity(); double zNear = nearZ.get(); double zFar = farZ.get(); double fH = Math.tan( Math.toRadians(fieldOfView.get()/2) ) * zNear; double aspect = (double)canvasWidth / (double)canvasHeight; double fW = fH * aspect; gl2.glFrustum(-fW,fW,-fH,fH,zNear,zFar); }
Example 9
Source File: ViewportEntity.java From Robot-Overlord-App with GNU General Public License v2.0 | 5 votes |
public void renderShared(GL2 gl2) { // store the projection matrix for later double [] m = new double[16]; gl2.glGetDoublev(GL2.GL_PROJECTION_MATRIX, m, 0); projectionMatrix.set(m); gl2.glMatrixMode(GL2.GL_MODELVIEW); gl2.glLoadIdentity(); PoseEntity camera = getAttachedTo(); Matrix4d mFinal = camera.getPoseWorld(); mFinal.invert(); MatrixHelper.applyMatrix(gl2, mFinal); }
Example 10
Source File: OneTriangle.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
protected static void render( GL2 gl2, int width, int height ) { gl2.glClear( GL.GL_COLOR_BUFFER_BIT ); // draw a triangle filling the window gl2.glLoadIdentity(); gl2.glBegin( GL.GL_TRIANGLES ); gl2.glColor3f( 1, 0, 0 ); gl2.glVertex2f( 0, 0 ); gl2.glColor3f( 0, 1, 0 ); gl2.glVertex2f( width, 0 ); gl2.glColor3f( 0, 0, 1 ); gl2.glVertex2f( width / 2, height ); gl2.glEnd(); }
Example 11
Source File: JLight.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void display(GLAutoDrawable drawable) { final GL2 gl = drawable.getGL().getGL2(); gl.glColor3f(1f, 0f, 0f); gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); gl.glLoadIdentity(); gl.glRotatef(rotation, 1.0f, 1.0f, 0.0f); gl.glBegin(GL2.GL_TRIANGLES); gl.glVertex2d(0, 0.5); gl.glVertex2d(-0.5, -0.5); gl.glVertex2d(0.5, -0.5); gl.glEnd(); gl.glFlush(); //Angle rotation += 0.6f; gl.glEnable(GL2.GL_LIGHTING); gl.glEnable(GL2.GL_LIGHT0); gl.glEnable(GL2.GL_DEPTH_TEST); float[] ambientLight = {0f, 0f, 1f, 0f}; gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_AMBIENT, ambientLight, 0); float[] specularLight = {1f, 0f, 0f, 0f}; gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_SPECULAR, specularLight, 0); float[] diffuseLight = {1f, 0f, 0f, 0f}; gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, diffuseLight, 0); }
Example 12
Source File: CubeTexture.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { final GL2 gl = drawable.getGL().getGL2(); if (height <= 0) { height = 1; } final float h = (float) width / (float) height; gl.glViewport(0, 0, width, height); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective(45.0f, h, 1.0, 20.0); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); }
Example 13
Source File: ViewportEntity.java From Robot-Overlord-App with GNU General Public License v2.0 | 5 votes |
public void renderOrtho(GL2 gl2,double zoom) { gl2.glMatrixMode(GL2.GL_PROJECTION); gl2.glLoadIdentity(); double w = canvasWidth/10; double h = canvasHeight/10; gl2.glOrtho(-w/zoom, w/zoom, -h/zoom, h/zoom, nearZ.get(), farZ.get()); }
Example 14
Source File: DelaunayTriangulationExample.java From delaunay-triangulator with MIT License | 5 votes |
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { GL2 gl = drawable.getGL().getGL2(); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrtho(0, DIMENSION.getWidth(), DIMENSION.getHeight(), 0, 1.0, -1.0); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); }
Example 15
Source File: BasicLine1.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { final GL2 gl = drawable.getGL().getGL2(); gl.glViewport(0, 0, width, height); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrthof(-2f, 2f, -2f, 2f, 0.0f, 1.0f); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); }
Example 16
Source File: OpenGLGFXCMD.java From sagetv with Apache License 2.0 | 4 votes |
private void initpbuffer() { GL2 gl; System.out.println("initpbuffer"); osdwidth=newosdwidth; osdheight=newosdheight; GLCapabilities caps = new GLCapabilities(null); caps.setHardwareAccelerated(true); caps.setDoubleBuffered(false); caps.setAlphaBits(8); caps.setRedBits(8); caps.setGreenBits(8); caps.setBlueBits(8); caps.setDepthBits(0); caps.setFBO(false); System.out.println("initpbuffer2"); if (!GLDrawableFactory.getFactory(caps.getGLProfile()).canCreateGLPbuffer(null, caps.getGLProfile())) { throw new GLException("pbuffers unsupported"); } if(pbuffer!=null) pbuffer.destroy(); System.out.println("initpbuffer3"); pbuffer = GLDrawableFactory.getFactory(caps.getGLProfile()).createOffscreenAutoDrawable(null, caps, null, osdwidth, osdheight ); pbuffer.setContext(pbuffer.createContext(c.getContext()), true); //pbuffer.setContext(c.getContext(), false); System.out.println("initpbuffer4: pbuffers is null? " + (pbuffer==null)); if(pbuffer.getContext().makeCurrent()==GLContext.CONTEXT_NOT_CURRENT) { System.out.println("Couldn't make pbuffer current?"); return; } System.out.println("initpbuffer5"); gl = pbuffer.getGL().getGL2(); gl.glClearColor( 0.0f, 0.0f, 0.0f, 0.0f); gl.glClear( gl.GL_COLOR_BUFFER_BIT); gl.glViewport(0, 0, osdwidth, osdheight); gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrtho(0,osdwidth,0,osdheight,-1.0,1.0); gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glLoadIdentity(); // TODO: look into reusing same texture like OSX version... if(osdt!=null) gl.glDeleteTextures(1, osdt, 0); osdt = new int[1]; byte img[] = new byte[osdwidth*osdheight*4]; gl.glGenTextures(1, osdt, 0); gl.glEnable(gl.GL_TEXTURE_RECTANGLE); gl.glBindTexture(gl.GL_TEXTURE_RECTANGLE,osdt[0]); gl.glTexParameteri(gl.GL_TEXTURE_RECTANGLE, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR); gl.glTexParameteri(gl.GL_TEXTURE_RECTANGLE, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR); gl.glTexImage2D(gl.GL_TEXTURE_RECTANGLE, 0, 4, osdwidth, osdheight, 0, gl.GL_BGRA, bigendian ? gl.GL_UNSIGNED_INT_8_8_8_8_REV : gl.GL_UNSIGNED_BYTE, java.nio.ByteBuffer.wrap(img)); gl.glEnable(gl.GL_TEXTURE_RECTANGLE); gl.glBindTexture(gl.GL_TEXTURE_RECTANGLE, osdt[0]); gl.glCopyTexSubImage2D(gl.GL_TEXTURE_RECTANGLE, 0, 0, 0, 0, 0, osdwidth, osdheight); gl.glDisable(gl.GL_TEXTURE_RECTANGLE); System.out.println("initpbuffer6"); pbuffer.getContext().release(); System.out.println("initpbuffer7"); }
Example 17
Source File: JCudaDriverVolumeRendererJOGL.java From jcuda-samples with MIT License | 4 votes |
@Override public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); // Use OpenGL to build view matrix float modelView[] = new float[16]; gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glRotatef(-simpleInteraction.getRotationDegX(), 1.0f, 0.0f, 0.0f); gl.glRotatef(-simpleInteraction.getRotationDegY(), 0.0f, 1.0f, 0.0f); gl.glTranslatef( -simpleInteraction.getTranslationX(), -simpleInteraction.getTranslationY(), -simpleInteraction.getTranslationZ()); gl.glGetFloatv(GL2.GL_MODELVIEW_MATRIX, modelView, 0); gl.glPopMatrix(); // Build the inverted view matrix invViewMatrix[0] = modelView[0]; invViewMatrix[1] = modelView[4]; invViewMatrix[2] = modelView[8]; invViewMatrix[3] = modelView[12]; invViewMatrix[4] = modelView[1]; invViewMatrix[5] = modelView[5]; invViewMatrix[6] = modelView[9]; invViewMatrix[7] = modelView[13]; invViewMatrix[8] = modelView[2]; invViewMatrix[9] = modelView[6]; invViewMatrix[10] = modelView[10]; invViewMatrix[11] = modelView[14]; // Copy the inverted view matrix to the global variable that // was obtained from the module. The inverted view matrix // will be used by the kernel during rendering. cuMemcpyHtoD(c_invViewMatrix, Pointer.to(invViewMatrix), invViewMatrix.length * Sizeof.FLOAT); // Render and fill the PBO with pixel data render(); // Draw the image from the PBO gl.glClear(GL.GL_COLOR_BUFFER_BIT); gl.glDisable(GL.GL_DEPTH_TEST); gl.glRasterPos2i(0, 0); gl.glBindBuffer(GL2.GL_PIXEL_UNPACK_BUFFER, pbo); gl.glDrawPixels(width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, 0); gl.glBindBuffer(GL2.GL_PIXEL_UNPACK_BUFFER, 0); // Update FPS information in main frame title step++; long currentTime = System.nanoTime(); if (prevTimeNS == -1) { prevTimeNS = currentTime; } long diff = currentTime - prevTimeNS; if (diff > 1e9) { double fps = (diff / 1e9) * step; String t = "JCuda 3D texture volume rendering sample - "; t += String.format("%.2f", fps)+" FPS"; frame.setTitle(t); prevTimeNS = currentTime; step = 0; } }
Example 18
Source File: J3DTriangle.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.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); gl.glLoadIdentity(); // Move triangle gl.glTranslatef(-0.5f, 0.0f, -6.0f); gl.glRotatef(rotation, 0.0f, 1.0f, 0.0f); gl.glBegin(GL2.GL_TRIANGLES); // Front gl.glColor3f(1.0f, 1.0f, 0.0f); // Yellow gl.glVertex3f(1.5f, 2f, 0.0f); // Top Of Triangle gl.glColor3f(0.0f, 1.5f, 0.0f); // Green gl.glVertex3f(-1.5f, -1.5f, 1.5f); // Left Of Triangle gl.glColor3f(1.0f, 0.0f, 1.0f); // Purple gl.glVertex3f(1.5f, -1.5f, 1.5f); // Right Of Triangle // Right gl.glColor3f(1.0f, 1.0f, 0.0f); // Yellow gl.glVertex3f(1.5f, 2.0f, 0.0f); // Top Of Triangle gl.glColor3f(1.0f, 0.0f, 1.0f); // Purple gl.glVertex3f(1.5f, -1.5f, 1.5f); // Left Of Triangle gl.glColor3f(0.0f, 1.0f, 0.0f); // Green gl.glVertex3f(1.5f, -1.5f, -1.5f); // Right Of Triangle // Back gl.glColor3f(1.0f, 1.0f, 0.0f); // Yellow gl.glVertex3f(1.5f, 2.0f, 0.0f); // Top Of Triangle gl.glColor3f(0.0f, 1.0f, 0.0f); // Green gl.glVertex3f(1.5f, -1.5f, -1.5f); // Left Of Triangle gl.glColor3f(1.0f, 0.0f, 1.0f); // Purple gl.glVertex3f(-1.5f, -1.5f, -1.5f); // Right Of Triangle //left gl.glColor3f(1.0f, 1.0f, 0.0f); // Yellow gl.glVertex3f(1.5f, 2.0f, 0.0f); // Top Of Triangle gl.glColor3f(1.0f, 0.0f, 1.0f); // Purple gl.glVertex3f(-1.5f, -1.5f, -1.5f); // Left Of Triangle gl.glColor3f(0.0f, 1.0f, 0.0f); // Green gl.glVertex3f(-1.5f, -1.5f, 1.5f); // Right Of Triangle gl.glEnd(); gl.glFlush(); rotation += 0.6f; }
Example 19
Source File: J3DCube.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.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); gl.glLoadIdentity(); gl.glTranslatef(0f, 0f, -2.0f); gl.glRotatef(rotation, 1.0f, 1.0f, 1.0f); gl.glBegin(GL2.GL_QUADS); gl.glColor3f(0f, 0f, 1f); //Blue color //Top Quadrilateral gl.glVertex3f(0.5f, 0.5f, -0.5f); //Upper Right gl.glVertex3f(-0.5f, 0.5f, -0.5f); // Upper Left gl.glVertex3f(-0.5f, 0.5f, 0.5f); // Bottom Left gl.glVertex3f(0.5f, 0.5f, 0.5f); // Bottom Right //Below Quadrilateral gl.glColor3f(1f, 0f, 0f); //Red color gl.glVertex3f(0.5f, -0.5f, 0.5f); // Upper Right gl.glVertex3f(-0.5f, -0.5f, 0.5f); // Upper Left gl.glVertex3f(-0.5f, -0.5f, -0.5f); // Bottom Left gl.glVertex3f(0.5f, -0.5f, -0.5f); // Bottom Right //Front Quadrilateral gl.glColor3f(0f, 1f, 0f); //Green color gl.glVertex3f(0.5f, 0.5f, 0.5f); // Upper Right gl.glVertex3f(-0.5f, 0.5f, 0.5f); // Upper Left gl.glVertex3f(-0.5f, -0.5f, 0.5f); // Bottom Left gl.glVertex3f(0.5f, -0.5f, 0.5f); // Bottom Right //Back Quadrilateral gl.glColor3f(1f, 1f, 0f); //Yellow gl.glVertex3f(0.5f, -0.5f, -0.5f); // Bottom Left gl.glVertex3f(-0.5f, -0.5f, -0.5f); // Bottom Right gl.glVertex3f(-0.5f, 0.5f, -0.5f); // Upper Right gl.glVertex3f(0.5f, 0.5f, -0.5f); // Upper Left //Left Quadrilateral gl.glColor3f(1f, 0f, 1f); //Purple gl.glVertex3f(-0.5f, 0.5f, 0.5f); // Upper Right gl.glVertex3f(-0.5f, 0.5f, -0.5f); // Upper Left gl.glVertex3f(-0.5f, -0.5f, -0.5f); // Bottom Left gl.glVertex3f(-0.5f, -0.5f, 0.5f); // Bottom Right //Right Quadrilateral gl.glColor3f(0f, 1f, 1f); //Cyan gl.glVertex3f(0.5f, 0.5f, -0.5f); // Upper Right gl.glVertex3f(0.5f, 0.5f, 0.5f); // Upper Left gl.glVertex3f(0.5f, -0.5f, 0.5f); // Bottom Left gl.glVertex3f(0.5f, -0.5f, -0.5f); // Bottom Right gl.glEnd(); gl.glFlush(); rotation += 0.6f; }
Example 20
Source File: JCuboid.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.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); gl.glLoadIdentity(); gl.glTranslatef(0f, 0f, -5.0f); gl.glRotatef(rotation, 1.0f, 1.0f, 1.0f); gl.glBegin(GL2.GL_QUADS); gl.glColor3f(1f, 0f, 0f); //red color //Top gl.glVertex3f(-1f, 0.8f, 0.5f); gl.glVertex3f(-0.5f, 0.8f, 0.5f); gl.glVertex3f(-1f, 0.5f, 0.5f); gl.glVertex3f(-0.5f, 0.5f, 0.5f); //Bottom gl.glVertex3f(-1f, 0.8f, 0.9f); gl.glVertex3f(-1f, 0.5f, 0.9f); gl.glVertex3f(-0.5f, 0.5f, 0.9f); gl.glVertex3f(-0.5f, 0.8f, 0.9f); //Front gl.glVertex3f(-0.5f, 0.8f, 0.5f); gl.glVertex3f(-1f, 0.8f, 0.5f); gl.glVertex3f(-1f, 0.8f, 0.9f); gl.glVertex3f(-0.5f, 0.8f, 0.9f); //Back gl.glVertex3f(-0.5f, 0.5f, 0.5f); gl.glVertex3f(-1f, 0.5f, 0.5f); gl.glVertex3f(-1f, 0.5f, 0.9f); gl.glVertex3f(-0.5f, 0.5f, 0.9f); //Left gl.glVertex3f(-0.5f, 0.8f, 0.9f); gl.glVertex3f(-0.5f, 0.8f, 0.5f); gl.glVertex3f(-0.5f, 0.5f, 0.9f); gl.glVertex3f(-0.5f, 0.5f, 0.5f); //Right gl.glVertex3f(-1f, 0.8f, 0.9f); gl.glVertex3f(-1f, 0.8f, 0.5f); gl.glVertex3f(-1f, 0.5f, 0.5f); gl.glVertex3f(-1f, 0.5f, 0.9f); gl.glEnd(); gl.glFlush(); rotation -= 0.15f; }