Java Code Examples for com.jogamp.opengl.GL2#glFlush()
The following examples show how to use
com.jogamp.opengl.GL2#glFlush() .
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: Triangle.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(); //drawing the base gl.glBegin(GL2.GL_LINE_STRIP); gl.glVertex3f(-0.50f, -0.50f, 0); gl.glVertex3f(0.50f, -0.50f, 0); gl.glVertex3f(0f, 0.50f, 0); gl.glVertex3f(-0.50f, -0.50f, 0); gl.glEnd(); gl.glFlush(); }
Example 4
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 5
Source File: Tessellation.java From MeteoInfo with GNU Lesser General Public License v3.0 | 4 votes |
public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); gl.glClear(GL2.GL_COLOR_BUFFER_BIT); gl.glColor3f(1.0f, 1.0f, 1.0f); /* * jogl specific addition for tessellation */ tessellCallBack tessCallback = new tessellCallBack(gl, glu); double rect[][] = new double[][]{ // [4][3] in C; reverse here {50.0, 50.0, 0.0}, {200.0, 50.0, 0.0}, {200.0, 200.0, 0.0}, {50.0, 200.0, 0.0}}; double tri[][] = new double[][]{// [3][3] {75.0, 75.0, 0.0}, {125.0, 175.0, 0.0}, {175.0, 75.0, 0.0}}; double star[][] = new double[][]{// [5][6]; 6x5 in java {250.0, 50.0, 0.0, 1.0, 0.0, 1.0}, {325.0, 200.0, 0.0, 1.0, 1.0, 0.0}, {400.0, 50.0, 0.0, 0.0, 1.0, 1.0}, {250.0, 150.0, 0.0, 1.0, 0.0, 0.0}, {400.0, 150.0, 0.0, 0.0, 1.0, 0.0}}; gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); startList = gl.glGenLists(2); GLUtessellator tobj = glu.gluNewTess(); glu.gluTessCallback(tobj, GLU.GLU_TESS_VERTEX, tessCallback);// glVertex3dv); glu.gluTessCallback(tobj, GLU.GLU_TESS_BEGIN, tessCallback);// beginCallback); glu.gluTessCallback(tobj, GLU.GLU_TESS_END, tessCallback);// endCallback); glu.gluTessCallback(tobj, GLU.GLU_TESS_ERROR, tessCallback);// errorCallback); /* rectangle with triangular hole inside */ gl.glNewList(startList, GL2.GL_COMPILE); gl.glShadeModel(GL2.GL_FLAT); glu.gluTessBeginPolygon(tobj, null); glu.gluTessBeginContour(tobj); glu.gluTessVertex(tobj, rect[0], 0, rect[0]); glu.gluTessVertex(tobj, rect[1], 0, rect[1]); glu.gluTessVertex(tobj, rect[2], 0, rect[2]); glu.gluTessVertex(tobj, rect[3], 0, rect[3]); glu.gluTessEndContour(tobj); glu.gluTessBeginContour(tobj); glu.gluTessVertex(tobj, tri[0], 0, tri[0]); glu.gluTessVertex(tobj, tri[1], 0, tri[1]); glu.gluTessVertex(tobj, tri[2], 0, tri[2]); glu.gluTessEndContour(tobj); glu.gluTessEndPolygon(tobj); gl.glEndList(); glu.gluTessCallback(tobj, GLU.GLU_TESS_VERTEX, tessCallback);// vertexCallback); glu.gluTessCallback(tobj, GLU.GLU_TESS_BEGIN, tessCallback);// beginCallback); glu.gluTessCallback(tobj, GLU.GLU_TESS_END, tessCallback);// endCallback); glu.gluTessCallback(tobj, GLU.GLU_TESS_ERROR, tessCallback);// errorCallback); glu.gluTessCallback(tobj, GLU.GLU_TESS_COMBINE, tessCallback);// combineCallback); /* smooth shaded, self-intersecting star */ gl.glNewList(startList + 1, GL2.GL_COMPILE); gl.glShadeModel(GL2.GL_SMOOTH); glu.gluTessProperty(tobj, // GLU.GLU_TESS_WINDING_RULE, // GLU.GLU_TESS_WINDING_POSITIVE); glu.gluTessBeginPolygon(tobj, null); glu.gluTessBeginContour(tobj); glu.gluTessVertex(tobj, star[0], 0, star[0]); glu.gluTessVertex(tobj, star[1], 0, star[1]); glu.gluTessVertex(tobj, star[2], 0, star[2]); glu.gluTessVertex(tobj, star[3], 0, star[3]); glu.gluTessVertex(tobj, star[4], 0, star[4]); glu.gluTessEndContour(tobj); glu.gluTessEndPolygon(tobj); gl.glEndList(); glu.gluDeleteTess(tobj); gl.glCallList(startList); gl.glCallList(startList + 1); gl.glFlush(); }
Example 6
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 7
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 8
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 9
Source File: OpenGLVideoRenderer.java From sagetv with Apache License 2.0 | 4 votes |
private void updateVideo(int frametype) { if(owner.isInFrame() || (owner.getPbuffer().getContext().makeCurrent()==GLContext.CONTEXT_NOT_CURRENT)) { if(!owner.isInFrame()) { System.out.println("Couldn't make pbuffer current?"); return; } else { System.out.println("update video while already in frame"); } } GL2 gl = owner.getPbuffer().getGL().getGL2(); if(pureNativeMode) { try { updateVideo0(); } catch(Throwable t) {} } else { //System.out.println("20,20 pixel: "+videobuffer.get(20*720+20)); //System.out.println(" width: "+videowidth+" height: "+videoheight); gl.glEnable(gl.GL_TEXTURE_RECTANGLE); gl.glBindTexture(gl.GL_TEXTURE_RECTANGLE, videot[0]); gl.glPixelStorei(gl.GL_UNPACK_SKIP_PIXELS, videoy); gl.glTexSubImage2D(gl.GL_TEXTURE_RECTANGLE, 0, 0, 0, videowidth, videoheight, gl.GL_LUMINANCE, gl.GL_UNSIGNED_BYTE, videobuffer); gl.glBindTexture(gl.GL_TEXTURE_RECTANGLE, videot[1]); gl.glPixelStorei(gl.GL_UNPACK_SKIP_PIXELS, videou); gl.glTexSubImage2D(gl.GL_TEXTURE_RECTANGLE, 0, 0, 0, videowidth/2, videoheight/2, gl.GL_LUMINANCE, gl.GL_UNSIGNED_BYTE, videobuffer); gl.glBindTexture(gl.GL_TEXTURE_RECTANGLE, videot[2]); gl.glPixelStorei(gl.GL_UNPACK_SKIP_PIXELS, videov); gl.glTexSubImage2D(gl.GL_TEXTURE_RECTANGLE, 0, 0, 0, videowidth/2, videoheight/2, gl.GL_LUMINANCE, gl.GL_UNSIGNED_BYTE, videobuffer); gl.glPixelStorei(gl.GL_UNPACK_SKIP_PIXELS, 0); gl.glDisable(gl.GL_TEXTURE_RECTANGLE); gl.glFlush(); } if(!owner.isInFrame()) owner.getPbuffer().getContext().release(); }
Example 10
Source File: RobotOverlord.java From Robot-Overlord-App with GNU General Public License v2.0 | 4 votes |
/** * Use glRenderMode(GL_SELECT) to ray pick the item under the cursor. * https://github.com/sgothel/jogl-demos/blob/master/src/demos/misc/Picking.java * http://web.engr.oregonstate.edu/~mjb/cs553/Handouts/Picking/picking.pdf * @param gl2 the openGL render context */ protected int findItemUnderCursor(GL2 gl2) { // select buffer IntBuffer pickBuffer = Buffers.newDirectIntBuffer(SELECT_BUFFER_SIZE); // set up the buffer that will hold the names found under the cursor in furthest to closest. gl2.glSelectBuffer(SELECT_BUFFER_SIZE, pickBuffer); // change the render mode gl2.glRenderMode( GL2.GL_SELECT ); // wipe the select buffer gl2.glInitNames(); viewport.renderPick(gl2,pickX,pickY); gl2.glPushName(0); // render in selection mode, without advancing time in the simulation. scene.render(gl2); gl2.glPopName(); gl2.glFlush(); // get the picking results and return the render mode to the default int hits = gl2.glRenderMode( GL2.GL_RENDER ); boolean verbose=false; if(verbose) Log.message("\n"+hits+" PICKS @ "+pickX+","+pickY); float z1,z2; float zMinBest = Float.MAX_VALUE; int i, j, index=0, nameCount, pickName=0, bestPickName=0; for(i=0;i<hits;++i) { nameCount=pickBuffer.get(index++); z1 = (float) (pickBuffer.get(index++) & 0xffffffffL) / (float)0x7fffffff; z2 = (float) (pickBuffer.get(index++) & 0xffffffffL) / (float)0x7fffffff; if(verbose) { Log.message(" names="+nameCount+" zMin="+z1+" zMax="+z2); } String add=": "; for(j=0;j<nameCount;++j) { pickName = pickBuffer.get(index++); if(verbose) { Log.message(add+pickName); add=", "; } } if(nameCount>0) { //pickName = pickBuffer.get(index++); if(verbose) Log.message(add+" BEST="+pickName); if(zMinBest > z1) { zMinBest = z1; bestPickName = pickName; } } } return bestPickName; }