List of usage examples for org.lwjgl.opengl GL11 GL_MODELVIEW
int GL_MODELVIEW
To view the source code for org.lwjgl.opengl GL11 GL_MODELVIEW.
Click Source Link
From source file:org.agpu.oc.common.tileentity.AdvancedMonitor.java
public void startDrawing2D(int x, int y, int width, int height) { if (worldObj.isRemote) { GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, frameBufferID); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glViewport(x, y, width, height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix();//from w ww . ja v a 2 s. com GL11.glLoadIdentity(); GL11.glOrtho(0, width, height, 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glClearColor(cr, cg, cb, ca); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); } }
From source file:org.agpu.oc.common.tileentity.AdvancedMonitor.java
public void swapBuffers(NBTTagCompound tag) { if (worldObj.isRemote) { for (int i = 0; i < tag.getInteger("commands"); i++) { NBTTagCompound t = tag.getCompoundTag(String.valueOf(i)); String type = t.getString("type"); if (type.equals("startDrawing3D")) { startDrawing3D(t.getInteger("x"), t.getInteger("y"), t.getInteger("width"), t.getInteger("height"), t.getFloat("fov"), t.getFloat("zNear"), t.getFloat("zFar")); } else if (type.equals("startDrawing2D")) { startDrawing2D(t.getInteger("x"), t.getInteger("y"), t.getInteger("width"), t.getInteger("height")); } else if (type.equals("setColor")) { GL11.glColor4f(t.getFloat("r"), t.getFloat("g"), t.getFloat("b"), t.getFloat("a")); } else if (type.equals("vertex3f")) { GL11.glVertex3f(t.getFloat("x"), t.getFloat("y"), t.getFloat("z")); } else if (type.equals("vertex2i")) { GL11.glVertex2i(t.getInteger("x"), t.getInteger("y")); } else if (type.equals("translate")) { GL11.glTranslatef(t.getFloat("x"), t.getFloat("y"), t.getFloat("z")); } else if (type.equals("rotate")) { GL11.glRotatef(t.getFloat("angle"), t.getFloat("x"), t.getFloat("y"), t.getFloat("z")); } else if (type.equals("scale")) { GL11.glScalef(t.getFloat("x"), t.getFloat("y"), t.getFloat("z")); } else if (type.equals("begin")) { GL11.glBegin(t.getInteger("m")); } else if (type.equals("end")) { GL11.glEnd();//from w w w .j ava 2 s .c o m } else if (type.equals("string")) { Minecraft.getMinecraft().fontRendererObj.drawString(t.getString("string"), t.getInteger("x"), t.getInteger("y"), t.getInteger("color")); } else if (type.equals("enable")) { GL11.glEnable(t.getInteger("v")); } else if (type.equals("disable")) { GL11.glDisable(t.getInteger("v")); } else { System.out.println("Unknown packet type received: " + type); } } GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPopMatrix(); GL11.glPopAttrib(); } }
From source file:org.cogaen.lwjgl.scene.Camera.java
License:Open Source License
void applyTransform() { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();/*from www . j a v a 2s . c o m*/ GL11.glOrtho(0, this.width, 0, this.height, 1, -1); GL11.glTranslated(this.width / 2, this.height / 2, 0.0); GL11.glScaled(this.zoom, this.zoom, 0.0); GL11.glRotatef((float) -this.angle, 0, 0, 1); GL11.glTranslated(-this.posX, -this.posY, 0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glViewport(this.viewport.getX(), this.viewport.getY(), this.viewport.getWidth(), this.viewport.getHeight()); }
From source file:org.cogaen.lwjgl.scene.SceneService.java
License:Open Source License
public void renderScene() { // quite and dirty frame counter this.clock.tick(); this.fpsSum += this.clock.getDelta(); if (++this.fpsCnt >= this.fpsAvg) { this.fpsCnt = 0; this.fps = String.format("FPS: %2.2f", (1.0 / (this.fpsSum / this.fpsAvg))); this.fpsSum = 0.0; }/*from w ww .j a v a2 s . c om*/ // Clear the screen and depth buffer GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); // render layers in each camera for (Camera camera : cameras) { if (!camera.isActive()) { continue; } camera.applyTransform(); for (int i = this.layers.size() - 1; i >= 0; --i) { this.layers.get(i).render(camera.getMask()); } for (RenderSubsystem rs : this.subSystems) { rs.render(camera.getMask()); } } // draw overlays GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, 1.0, 0, 1.0 / getAspectRatio(), 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glViewport(0, 0, this.config.getWidth(), this.config.getHeight()); this.overlayRoot.renderWithAspectRatio(0xFFFFFFFF, getAspectRatio()); // this.overlayRoot.render(0xFFFFFFFF); // render frame counter GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, this.config.getWidth(), this.config.getHeight(), 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4d(1, 0, 1, 1); font.drawString(5, this.config.getHeight() - 20, this.fps); Display.update(); if (Display.isCloseRequested()) { this.evtSrv.dispatchEvent(new SimpleEvent(WINDOW_CLOSE_REQUEST)); } }
From source file:org.eclipse.swt.opengl.examples.LWJGLExample.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 ww w . ja v a 2 s .c om 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.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); shell.setText("SWT/LWJGL Example"); shell.setSize(640, 480); shell.open(); display.asyncExec(new Runnable() { int rot = 0; public void run() { if (!canvas.isDisposed()) { canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException e) { e.printStackTrace(); } 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); rot++; GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); GL11.glColor3f(0.9f, 0.9f, 0.9f); drawTorus(1, 1.9f + ((float) Math.sin((0.004f * frot))), 15, 15); canvas.swapBuffers(); display.asyncExec(this); } } }); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet195.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. ja v a2 s.c o m 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() { @Override 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.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); shell.setText("SWT/LWJGL Example"); shell.setSize(640, 480); shell.open(); final Runnable run = new Runnable() { int rot = 0; @Override public void run() { if (!canvas.isDisposed()) { canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException e) { e.printStackTrace(); } 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); rot++; GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); GL11.glColor3f(0.9f, 0.9f, 0.9f); drawTorus(1, 1.9f + ((float) Math.sin((0.004f * frot))), 15, 15); canvas.swapBuffers(); display.asyncExec(this); } } }; canvas.addListener(SWT.Paint, new Listener() { @Override public void handleEvent(Event event) { run.run(); } }); display.asyncExec(run); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet341.java
License:Open Source License
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout()); GLData data = new GLData(); data.doubleBuffer = true;//from w w w .j av a 2s. co m final GLCanvas canvas = new GLCanvas(shell, SWT.NONE, data); canvas.setLayoutData(new GridData(640, 480)); canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException e) { e.printStackTrace(); } canvas.addListener(SWT.Resize, new Listener() { @Override 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.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); Button button = new Button(shell, SWT.PUSH); button.setText("Capture"); button.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { capture(canvas); } }); shell.pack(); shell.open(); display.asyncExec(new Runnable() { int rot = 0; @Override public void run() { if (!canvas.isDisposed()) { canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException e) { e.printStackTrace(); } 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); rot++; GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); GL11.glColor3f(0.9f, 0.9f, 0.9f); drawTorus(1, 1.9f + ((float) Math.sin((0.004f * frot))), 15, 15); canvas.swapBuffers(); display.asyncExec(this); } } }); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.evilco.emulator.core.graphic.matrix.MonochromeMatrixScreen.java
License:Apache License
/** * {@inheritDoc}/* w ww. j a v a 2 s . c o m*/ */ @Override public void initialize() { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, this.getWidth(), this.getHeight(), 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
From source file:org.fenggui.binding.render.lwjgl.LWJGLOpenGL.java
License:Open Source License
public void setModelMatrixMode() { GL11.glMatrixMode(GL11.GL_MODELVIEW); }
From source file:org.fenggui.example.ExampleBasisLWJGL.java
License:Open Source License
private void glInit(int width, int height) { // Go into orthographic projection mode. GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();/*from w w w.ja v a 2s. c o m*/ GLU.gluOrtho2D(0, width, 0, height); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glViewport(0, 0, width, height); //set clear color to ... ugly GL11.glClearColor(0.1f, 0.5f, 0.2f, 0.0f); //sync frame (only works on windows ) => THAT IS NOT TRUE (ask Rainer) Display.setVSyncEnabled(false); }