Java Code Examples for com.jogamp.opengl.GL2#glRotatef()
The following examples show how to use
com.jogamp.opengl.GL2#glRotatef() .
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: 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 2
Source File: CubeTexture.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); gl.glLoadIdentity(); // Reset The View gl.glTranslatef(0f, 0f, -5.0f); gl.glRotatef(xrot, 1.0f, 1.0f, 1.0f); gl.glRotatef(yrot, 0.0f, 1.0f, 0.0f); gl.glRotatef(zrot, 0.0f, 0.0f, 1.0f); //drawImage(gl); this.drawBoxGridsTicksLabels(gl); drawImage(gl); gl.glFlush(); //change the speeds here xrot += .1f; yrot += .1f; zrot += .1f; }
Example 3
Source File: Spidee.java From Robot-Overlord-App with GNU General Public License v2.0 | 6 votes |
void Draw_Body(GL2 gl2) { gl2.glPushMatrix(); DoubleBuffer m=DoubleBuffer.allocate(16); m.put( 0,-body.left.x); m.put( 1,-body.left.y); m.put( 2,-body.left.z); m.put( 4,body.forward.x); m.put( 5,body.forward.y); m.put( 6,body.forward.z); m.put( 8,body.up.x); m.put( 9,body.up.y); m.put(10,body.up.z); m.put(15,1); matBody.render(gl2); gl2.glTranslated(body.pos.x + 7.5f * body.up.x, body.pos.y + 7.5f * body.up.y, body.pos.z + 7.5f * body.up.z ); gl2.glMultMatrixd(m); gl2.glRotatef(180,0,1,0); modelBody.render(gl2); gl2.glPopMatrix(); }
Example 4
Source File: JPaddle.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); gl.glClear(GL2.GL_COLOR_BUFFER_BIT); gl.glLoadIdentity(); gl.glTranslatef(0f, 0f, -2.0f); gl.glRotatef(rotation, 1f, 0f, 0f); gl.glColor3f(1f, 0f, 0f); gl.glBegin(GL2.GL_POLYGON); gl.glVertex3d(-0.5, 0.3, 0.8); gl.glVertex3d(0.5, 0.3, 0.8); gl.glVertex3d(0.8, 0.7, 0.8); gl.glVertex3d(-0.8, 0.7, 0.8); gl.glEnd(); int paddles = 40; for (int i = 0; i < paddles; i++) { gl.glRotated(360.0 / paddles, 1, 0, 0); gl.glBegin(GL2.GL_POLYGON); gl.glVertex3d(-0.5, 0.3, 0.8); gl.glVertex3d(0.5, 0.3, 0.8); gl.glVertex3d(0.8, 0.7, 0.8); gl.glVertex3d(-0.8, 0.7, 0.8); gl.glEnd(); } rotation -= 0.2f; }
Example 5
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 6
Source File: CubeSample2.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); gl.glClear(GL.GL_COLOR_BUFFER_BIT); gl.glLoadIdentity(); // 視点位置と視線方向 // glu.gluLookAt(3.0, 4.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); // 図形の回転 gl.glTranslatef(0.5f, 0.5f, 0.5f); gl.glRotatef(r, 0.0f, 1.0f, 0.0f); gl.glTranslatef(-0.5f, -0.5f, -0.5f); // 図形の描画 gl.glColor3f(0.0f, 0.0f, 0.0f); gl.glBegin(GL_LINES); for (int i = 0; i < 12; i++) { gl.glVertex3fv(vertex[edge[i][0]], 0); gl.glVertex3fv(vertex[edge[i][1]], 0); } gl.glEnd(); //一周回ったら回転角を 0 に戻す if (r++ >= 360.0f) r = 0; System.out.println("anim:" + animator.isAnimating() + ", r:" + r); if(willAnimatorPause) { animator.pause(); System.out.println("animoator paused:"); willAnimatorPause = false; } drawable.swapBuffers(); }
Example 7
Source File: Sixi2LinearGripper.java From Robot-Overlord-App with GNU General Public License v2.0 | 5 votes |
@Override public void render(GL2 gl2) { gl2.glPushMatrix(); gl2.glRotatef(180-45,0,0,1); super.render(gl2); gl2.glPopMatrix(); }
Example 8
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; }
Example 9
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 10
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 11
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; } }