List of usage examples for org.lwjgl.opengl GL11 glFlush
public static void glFlush()
From source file:com.aelitis.azureus.plugins.view3d.ViewTest2.java
License:Open Source License
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Composite comp = new Composite(shell, SWT.NONE); comp.setLayout(new FillLayout()); GLData data = new GLData(); data.doubleBuffer = true;/*from w w w . j ava2s . com*/ data.accumAlphaSize = 8; data.accumBlueSize = 8; data.accumGreenSize = 8; data.accumRedSize = 8; final GLCanvas canvas = new GLCanvas(comp, SWT.NONE, data); canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException e) { e.printStackTrace(); } canvas.addListener(SWT.Resize, new Listener() { public void handleEvent(Event event) { Rectangle bounds = canvas.getBounds(); float fAspect = (float) bounds.width / (float) bounds.height; canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException e) { e.printStackTrace(); } GL11.glViewport(0, 0, bounds.width, bounds.height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GLU.gluPerspective(45.0f, fAspect, 0.5f, 400.0f); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); } }); GL11.glLineWidth(1); GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glEnable(GL11.GL_BLEND); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); GL11.glColor3f(1.0f, 0.0f, 0.0f); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glClearDepth(1.0); GL11.glLineWidth(2); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glShadeModel(GL11.GL_FLAT); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClearAccum(0.0f, 0.0f, 0.0f, 0.0f); shell.setText("SWT/LWJGL Example"); shell.setSize(640, 480); shell.open(); final Runnable run = new Runnable() { float rot = 0; public void run() { if (!canvas.isDisposed()) { canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException e) { e.printStackTrace(); } int ACSIZE = 8; int[] viewport = getViewport(); GL11.glClear(GL11.GL_ACCUM_BUFFER_BIT); for (int jitter = 0; jitter < ACSIZE; jitter++) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); double jit_x = jits[jitter][0]; double jit_y = jits[jitter][1]; accPerspective(50.0, (double) viewport[2] / (double) viewport[3], 1.0, 15.0, jit_x, jit_y, 0.0, 0.0, 1.0); { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glClearColor(.3f, .5f, .8f, 1.0f); GL11.glLoadIdentity(); GL11.glTranslatef(0.0f, 0.0f, -10.0f); float frot = rot; GL11.glRotatef(0.15f * rot, 2.0f * frot, 10.0f * frot, 1.0f); GL11.glRotatef(0.3f * rot, 3.0f * frot, 1.0f * frot, 1.0f); GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); GL11.glColor3f(0.9f, 0.9f, 0.9f); drawCylinder(2, 3, 50, 0); drawTorus(1, 1.9f + ((float) Math.sin((0.004f * frot))), 15, 15); } GL11.glAccum(GL11.GL_ACCUM, 1.0f / ACSIZE); } GL11.glAccum(GL11.GL_RETURN, 1.0f); GL11.glFlush(); rot += 0.1; canvas.swapBuffers(); display.asyncExec(this); } } }; canvas.addListener(SWT.Paint, new Listener() { public void handleEvent(Event event) { run.run(); } }); display.asyncExec(run); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:com.ardor3d.renderer.lwjgl.LwjglRenderer.java
License:Open Source License
public void flushFrame(final boolean doSwap) { renderBuckets();/* w w w . ja va 2 s . co m*/ GL11.glFlush(); if (doSwap) { doApplyState(defaultStateList.get(RenderState.StateType.ColorMask)); if (Constants.stats) { StatCollector.startStat(StatType.STAT_DISPLAYSWAP_TIMER); } Display.update(); if (Constants.stats) { StatCollector.endStat(StatType.STAT_DISPLAYSWAP_TIMER); } } if (Constants.stats) { StatCollector.addStat(StatType.STAT_FRAMES, 1); } }
From source file:com.ardor3d.renderer.lwjgl.LwjglRenderer.java
License:Open Source License
public void flushGraphics() { GL11.glFlush(); }
From source file:com.badlogic.gdx.backends.jglfw.JglfwGL20.java
License:Apache License
public void glFlush() { GL11.glFlush(); }
From source file:com.badlogic.gdx.backends.lwjgl.LwjglGL10.java
License:Apache License
public final void glFlush() { GL11.glFlush(); }
From source file:com.dinasgames.engine.graphics.Texture.java
public boolean loadFromImage(Image image, BoundingBox area) { int width = image.getWidth(); int height = image.getHeight(); if (area.width == 0 || area.height == 0 || (area.x <= 0 && area.y <= 0 && area.width >= width && area.height >= height)) { // Load entire image if (create(width, height)) { update(image);/* w w w . j a va 2s. co m*/ GL11.glFlush(); return true; } return false; } else { // Load part of the image BoundingBox r = new BoundingBox(area); if (r.x < 0) { r.x = 0; } if (r.y < 0) { r.y = 0; } if (r.x + r.width > width) { r.width = width - r.x; } if (r.y + r.height > height) { r.height = height - r.y; } if (create((int) r.width, (int) r.height)) { ByteBuffer pixels = image.toByteBuffer(); int pos = 4 * ((int) r.x + (width * (int) r.y)); GL11.glBindTexture(GL11.GL_TEXTURE_2D, mTexture); for (int i = 0; i < r.height; i++) { GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, i, (int) r.width, 1, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, pixels); pos += 4 * width; } GL11.glFlush(); return true; } return false; } }
From source file:com.opengrave.og.light.Depth2DFramebuffer.java
License:Open Source License
@Override public void unbindDraw() { GL11.glFlush(); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0); }
From source file:com.opengrave.og.light.DepthCubeFramebuffer.java
License:Open Source License
public void unbindDraw() { GL11.glFlush(); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0); }
From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java
License:Mozilla Public License
private void doPaint() { if (isDisposed() || mNode == null) { return;//from w w w .j ava2s . co m } setCurrent(); // Clear the color, depth and stencil buffers. GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT); GL11.glLoadIdentity(); GLU.gluLookAt(0.0f, 0.0f, mCamera.z, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); // Transformations happen in the reverse. if (mIsOrtho) { // User's translation. GL11.glTranslatef(mOrthoTranslate.x, mOrthoTranslate.y, 0.0f); // Rotate 180 degrees. GL11.glRotatef(180.0f, 1.0f, 0.0f, 0.0f); // Center the nodes. final Rectangle bounds = getBounds(); final float scaledWidth = mNode.bounds.width * mOrthoScale; final float scaledHeight = mNode.bounds.height * mOrthoScale; GL11.glTranslatef((bounds.width - scaledWidth) / 2, 0.0f, 0.0f); // Scale based on viewport size. GL11.glTranslatef(scaledWidth / 2, -scaledHeight / 2, 0.0f); GL11.glScalef(mOrthoScale, mOrthoScale, 0.0f); GL11.glTranslatef(-scaledWidth / 2, scaledHeight / 2, 0.0f); } else { // Translate all the nodes. GL11.glTranslatef(mTranslate.x, mTranslate.y, 0.0f); // Rotate. GL11.glRotatef(mRotate.x, 1.0f, 0.0f, 0.0f); GL11.glRotatef(mRotate.y, 0.0f, 1.0f, 0.0f); // Center the nodes. GL11.glTranslatef(-mNode.bounds.width / 2, mNode.bounds.height / 2, 0.0f); } final float absX = Math.abs(mRotate.x); final float absY = Math.abs(mRotate.y); mDepth = Math.max(absX, absY) * 5 / 9.0f; drawHierarchy(mNode); if (!mIsPicking && mIsOrtho && mShowOverdraw) { for (int i = 2; i <= 5; i++) { drawOverdraw(i); } } GL11.glFlush(); if (!mIsPicking) { swapBuffers(); } }
From source file:fable.framework.ui.views.chiPlotView.java
License:Open Source License
/** * Build the list to display here/*www. j a va 2s . c o m*/ */ private static void drawReliefList() { if (!reliefListFirst) { GL11.glDeleteLists(reliefList, 1); } reliefListFirst = false; reliefList = GL11.glGenLists(1); GL11.glNewList(reliefList, GL11.GL_COMPILE); GL11.glColor3f(1.0f, 1.0f, 1.0f); // white GL11.glPointSize(pointSize); for (int i = 0; i < imageWidth - 1; i++) { GL11.glBegin(GL11.GL_LINE_STRIP); int j = i + 1; int color_index = (int) image[i]; if (color_index < 0) color_index = 0; if (color_index > COLOR_INDEX_MAX) color_index = COLOR_INDEX_MAX; GL11.glColor3f(red[color_index], green[color_index], blue[color_index]); // temperature lut GL11.glVertex3f(i, image[i], image[j]); // System.out.println("i=" + i + ", j=" + j + " image[i]=" + // image[i] + " image[j]=" + image[j]); GL11.glEnd(); } /* * gl.glBegin(GL.GL_TRIANGLES); * * gl.glVertex3f(-1.0f, -0.5f, 0.0f); // lower left vertex * gl.glVertex3f( 1.0f, -0.5f, 0.0f); // lower right vertex * gl.glVertex3f( 0.0f, 0.5f, 0.0f); // upper vertex * * gl.glEnd(); */ GL11.glEndList(); GL11.glFlush(); }