List of usage examples for org.lwjgl.opengl GL11 glMatrixMode
public static native void glMatrixMode(@NativeType("GLenum") int mode);
From source file:fable.framework.ui.views.chiPlotView.java
License:Open Source License
/** * This is a callback that will allow us to create the viewer and initialize * it.//from w ww.j a v a 2 s. c o m */ /* * (non-Javadoc) * * @see * org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets * .Composite) */ /* * (non-Javadoc) * * @see * org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets * .Composite) */ public void createPartControl(Composite parent) { // logger = FableLogger.getLogger(); console = new FableMessageConsole("Peaksearch console"); ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { console }); console.displayOut("Welcome to chiplotview " + ToolBox.getPluginVersion(Activator.PLUGIN_ID)); IOConsoleOutputStream stream = console.newOutputStream(); // console_debug = new ConsoleLineTracker(); System.setOut(new PrintStream(stream, true)); System.setErr(new PrintStream(stream)); thisView = this; parent.setLayout(new GridLayout()); Composite controlPanelComposite = new Composite(parent, SWT.NULL); GridLayout controlGridLayout = new GridLayout(); controlGridLayout.numColumns = 8; controlPanelComposite.setLayout(controlGridLayout); controlPanelComposite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false)); freezeButton = new Button(controlPanelComposite, SWT.CHECK); freezeButton.setText("Freeze"); freezeButton.setToolTipText("freeze 3d relief, disable rotation"); freezeButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (freezeButton.getSelection()) freeze = true; else freeze = false; } }); resetButton = new Button(controlPanelComposite, SWT.NULL); resetButton.setText("Reset"); resetButton.setToolTipText("reset 3d projection to be flat and fill the canvas"); resetButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { grip.init(); } }); autoscaleButton = new Button(controlPanelComposite, SWT.CHECK); autoscaleButton.setText("Autoscale"); autoscaleButton.setToolTipText("autoscale 3d relief between minimum and mean"); autoscaleButton.setSelection(true); autoscaleButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (autoscaleButton.getSelection()) { if (!autoscale) { autoscale = true; scaleImage(); drawReliefList(); } minimumSpinner.setEnabled(false); maximumSpinner.setEnabled(false); } else { if (autoscale) { autoscale = false; scaleImage(); drawReliefList(); } minimumSpinner.setEnabled(true); maximumSpinner.setEnabled(true); } } }); Label minLabel = new Label(controlPanelComposite, SWT.NULL); minLabel.setText("Minimum"); minimumSpinner = new Spinner(controlPanelComposite, SWT.NULL); minimumSpinner.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false)); minimumSpinner.setMinimum(0); minimumSpinner.setMaximum(Integer.MAX_VALUE); minimumSpinner.setEnabled(false); Label maxLabel = new Label(controlPanelComposite, SWT.NULL); maxLabel.setText("Maximum"); maximumSpinner = new Spinner(controlPanelComposite, SWT.NULL); maximumSpinner.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false)); maximumSpinner.setMinimum(0); maximumSpinner.setMaximum(Integer.MAX_VALUE); maximumSpinner.setEnabled(false); updateButton = new Button(controlPanelComposite, SWT.NULL); updateButton.setText("Update"); updateButton.setToolTipText("redraw 3d relief plot"); updateButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { scaleImage(); drawReliefList(); drawRelief(); } }); Composite comp = new Composite(parent, SWT.NONE); comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); comp.setLayout(new FillLayout()); GLData data = new GLData(); data.doubleBuffer = true; canvas = new GLCanvas(comp, SWT.NONE, data); canvas.setSize(comp.getSize()); canvas.setCurrent(); // context = // GL11.GLDrawableFactory.getFactory().createExternalGLContext(); canvas.addListener(SWT.Resize, new Listener() { public void handleEvent(Event event) { Rectangle bounds = canvas.getBounds(); 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 glu = new GLU(); // aspect = (float) imageWidth / (float) imageHeight; // gl.glMatrixMode(GL.GL_MODELVIEW); // gl.glLoadIdentity(); drawRelief(); canvas.swapBuffers(); } }); try { GLContext.useContext(canvas); } catch (LWJGLException e) { e.printStackTrace(); } GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glColor3f(1.0f, 0.0f, 0.0f); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); // gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); // gl.glClearDepth(1.0); // gl.glLineWidth(2); // / gl.glEnable(GL.GL_DEPTH_TEST); GL11.glOrtho(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f); // create the grip for users to change the orientation, translation and // zoom grip = new SceneGrip(); canvas.addMouseListener(grip); canvas.addMouseMoveListener(grip); canvas.addListener(SWT.MouseWheel, grip); canvas.addKeyListener(grip); // apparently opengl has to be redrawn constantly (why ?) Display.getCurrent().asyncExec(new Runnable() { public void run() { if (!canvas.isDisposed()) { canvas.setCurrent(); // Rectangle bounds = canvas.getBounds(); /* * canvasWidth = bounds.width; canvasHeight = bounds.height; */ // context.makeCurrent(); // GL gl = context.getGL (); // gl.glClear(GL.GL_COLOR_BUFFER_BIT | // GL.GL_DEPTH_BUFFER_BIT); // gl.glClearColor(.0f, .0f, .0f, 1.0f); // black // background*/ drawRelief(); canvas.swapBuffers(); } } }); }
From source file:fable.imageviewer.views.ReliefView.java
License:Open Source License
@Override public void createPartControl(Composite parent) { thisView = this; parent.setLayout(new GridLayout(1, false)); GridUtils.removeMargins(parent);//w w w. j av a2s . c o m createActions(); Composite comp = new Composite(parent, SWT.NONE); comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); comp.setLayout(new FillLayout()); GLData data = new GLData(); data.doubleBuffer = true; canvas = new GLCanvas(comp, SWT.NONE, data); canvas.setSize(comp.getSize()); canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException ex) { FableUtils.excMsg(ReliefView.class, "Error in createPartControl using GLContext.useContext", ex); } // context = GLDrawableFactory.getFactory().createExternalGLContext(); 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 ex) { FableUtils.excMsg(ReliefView.class, "Error in resize listener using GLContext.useContext", ex); } // context.makeCurrent(); // GL11 gl = context.getGL (); GL11.glViewport(0, 0, bounds.width, bounds.height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); // GLU glu = new GLU(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); drawRelief(); canvas.swapBuffers(); // context.release(); } }); canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException ex) { FableUtils.excMsg(ReliefView.class, "Error in createPartControl using GLContext.useContext", ex); } // GL11 gl = context.getGL (); 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); // context.release(); // create the grip for users to change the orientation, translation and // zoom grip = new SceneGrip(canvas, this); canvas.addMouseListener(grip); canvas.addMouseMoveListener(grip); canvas.addListener(SWT.MouseWheel, grip); canvas.addKeyListener(grip); // apparently opengl has to be redrawn constantly (why ?) Display.getCurrent().asyncExec(new Runnable() { // int rot = 0; public void run() { if (canvas == null) return; if (!canvas.isDisposed()) { canvas.setCurrent(); Rectangle bounds = canvas.getBounds(); grip.setBounds(bounds); canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException ex) { FableUtils.excMsg(ReliefView.class, "Error in createPartControl using " + "GLContext.useContext", ex); } // GL11 gl = context.getGL (); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glClearColor(.0f, .0f, .0f, 1.0f); // black background drawRelief(); canvas.swapBuffers(); // context.release(); Display.getCurrent().timerExec(200, this); } } }); createImageInformationPanel(parent); }
From source file:fable.imageviewer.views.SceneGrip.java
License:Open Source License
/** * Warning called constantly in display loop - change with care. *//*from ww w .ja va2 s . co m*/ public void adjust() { canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException ex) { FableUtils.excMsg(ReliefView.class, "Error in adjust using GLContext.useContext", ex); } // gl = context.getGL (); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); /* set the orthogonal projection to the size of the window */ GL11.glOrtho(0, canvasWidth, canvasHeight, 0, -1.0e5f, 1.0e5f); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glTranslatef(canvasWidth / 2 + this.xoff, canvasHeight / 2 + this.yoff, 0); GL11.glScalef(zoff, zoff, zoff); /* * zoff has no effect on the orthogonal projection therefore zoom by * passing zoff to scale */ GL11.glRotatef(this.xrot, 1f, 0.0f, 0.0f); GL11.glRotatef(this.yrot, 0.0f, 1f, 0.0f); GL11.glTranslatef(-prov.getImageWidth() / 2, -prov.getImageHeight() / 2, 0); }
From source file:fi.conf.ae.gl.GLGraphicRoutines.java
License:LGPL
public static void initPerspective(float angle) { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();/*from w ww. ja v a2 s. co m*/ //GL11.glPixelZoom( 1.0f, 1.0f ); //GL11.glViewport(0, 0, GLValues.screenWidth, GLValues.screenHeight); GLU.gluPerspective(angle, GLValues.glRatio, 0.001f, GLValues.glDepth); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
From source file:fi.conf.ae.gl.GLGraphicRoutines.java
License:LGPL
public static void initOrtho() { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();/*from w w w. j a v a 2 s.c o m*/ //GL11.glPixelZoom( 1.0f, 1.0f ); //GL11.glViewport(0, 0, GLValues.screenWidth, GLValues.screenHeight); GL11.glOrtho(0, GLValues.glWidth, GLValues.glHeight, 0, -GLValues.glDepth, GLValues.glDepth); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
From source file:flash.display.DisplayObject.java
License:Open Source License
public final void JITB$renderDisplayObject() { if (!visible()) { return;/*from w w w. j a v a 2 s .co m*/ } GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); transform().matrix().JITB$toDoubleBuffer(modelViewMatrix); GL11.glLoadMatrix(modelViewMatrix); //GL11.glTranslated(x(), y(), 0.0); //GL11.glRotatef(_rotationRad, 0.0f, 0.0f, 1.0f); //GL11.glScaled(_scaleX, _scaleY, 1.0); GL11.glColor4d(_transform.colorTransform().redMultiplier, _transform.colorTransform().greenMultiplier, _transform.colorTransform().blueMultiplier, _transform.colorTransform().alphaMultiplier); final String blendMode = blendMode(); boolean disableDepthTest = false; if (blendMode.equals(BlendMode.ADD)) { GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); disableDepthTest = true; } try { JITB$render(); } finally { if (disableDepthTest) { GL11.glDisable(GL11.GL_BLEND); } GL11.glPopMatrix(); } }
From source file:forestry.core.render.CrateRenderingHandler.java
License:Open Source License
private void renderIn3D(ItemStack stack) { GL11.glPushMatrix();//from w w w . j a va2 s . c om Tessellator tessellator = Tessellator.instance; if (RenderManager.instance.renderEngine == null) { return; } int meta = stack.getItemDamage(); for (int pass = 0; pass < stack.getItem().getRenderPasses(meta); ++pass) { IIcon icon = stack.getItem().getIconFromDamageForRenderPass(meta, pass); if (icon == null) { continue; } if (renderItem.renderWithColor) { int color = stack.getItem().getColorFromItemStack(stack, pass); float c1 = (float) (color >> 16 & 255) / 255.0F; float c2 = (float) (color >> 8 & 255) / 255.0F; float c3 = (float) (color & 255) / 255.0F; GL11.glColor4f(c1, c2, c3, 1.0F); } float minU = icon.getMinU(); float maxU = icon.getMaxU(); float minV = icon.getMinV(); float maxV = icon.getMaxV(); if (stack.getItemSpriteNumber() == 0) { RenderManager.instance.renderEngine.bindTexture(BLOCK_TEXTURE); } else { RenderManager.instance.renderEngine.bindTexture(ITEM_TEXTURE); } ItemRenderer.renderItemIn2D(tessellator, maxU, minV, minU, maxV, icon.getIconWidth(), icon.getIconHeight(), PIXEL); if (stack.hasEffect(pass)) { GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_LIGHTING); RenderManager.instance.renderEngine.bindTexture(GLINT_TEXTURE); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); float f13 = 0.76F; GL11.glColor4f(0.5F * f13, 0.25F * f13, 0.8F * f13, 1.0F); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glPushMatrix(); float f14 = 0.125F; GL11.glScalef(f14, f14, f14); float f15 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; GL11.glTranslatef(f15, 0.0F, 0.0F); GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, PIXEL); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glScalef(f14, f14, f14); f15 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; GL11.glTranslatef(-f15, 0.0F, 0.0F); GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, PIXEL); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthFunc(GL11.GL_LEQUAL); } } GL11.glPopMatrix(); }
From source file:fr.def.iss.vd2.lib_v3d.camera.V3DCamera.java
License:Open Source License
public void display(float width, float height) { this.currentWidth = width; this.currentHeight = height; GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();//from ww w . j a v a 2 s.co m GL11.glOrtho(0, width, 0, height, -2000.0, 2000.0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); backgroundScene.display(this); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); initPerspective(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glPushMatrix(); configureView(glu); if (!configured) { configured = true; if (cameraInitialisation != null) { cameraInitialisation.run(); cameraInitialisation = null; } } preDisplayScene(); if (currentScene != null) { currentScene.display(this); } postDisplayScene(); preDisplayGui(); postDisplayGui(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, width, 0, height, -2000.0, 2000.0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); hudScene.display(this); GL11.glPopMatrix(); }
From source file:fr.def.iss.vd2.lib_v3d.V3DCanvas.java
License:Open Source License
/** * The only method that you should implement by yourself. * * @see javax.media.openGL11.GLEventListener#display(javax.media.openGL11.GLAutoDrawable) *//*from ww w . ja va 2 s . c o m*/ public void display() { GL11.glClear(GL11.GL_ACCUM_BUFFER_BIT); for (V3DCameraBinding binding : cameraList) { GL11.glViewport(binding.x, binding.y, binding.width, binding.height); //Clean Background I3dColor color = binding.camera.getBackgroundColor(); GL11.glClearColor(color.r, color.g, color.b, color.a); GL11.glScissor(binding.x, binding.y, binding.width, binding.height); GL11.glEnable(GL11.GL_SCISSOR_TEST); if (color.a == 1.0f) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); } else { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glOrtho(0, binding.width, 0, binding.height, -2000.0, 2000.0); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glColor4f(color.r, color.g, color.b, color.a); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex3f(0, 0, 0); GL11.glVertex3f(binding.width, 0, 0); GL11.glVertex3f(binding.width, binding.height, 0); GL11.glVertex3f(0, binding.height, 0); GL11.glEnd(); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); } GL11.glDisable(GL11.GL_SCISSOR_TEST); binding.camera.display(binding.width, binding.height); GL11.glDisable(GL11.GL_DEPTH_TEST); // binding.getGui().display(); GL11.glEnable(GL11.GL_DEPTH_TEST); if (select && binding == focusCamera) { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); //glu.gluPerspective(45.0f, h, 0.1, 2000.0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); binding.camera.select(mouseX, mouseY); context.setMouseOverCameraBinding(binding); } } GL11.glFlush(); select = false; }
From source file:fr.mcnanotech.kevin_68.nanotechmod.main.client.renderer.RenderCreeperDriller.java
License:Creative Commons License
protected int renderMobCreeperDrillerPassModel(MobCreeperDriller mob, int par2, float par3) { if (mob.getPowered()) { if (par2 == 1) { float var4 = (float) mob.ticksExisted + par3; this.bindTexture(new ResourceLocation("textures/entity/creeper/creeper_armor.png")); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity();/*from w w w. j a v a 2 s. c om*/ float var5 = var4 * 0.01F; float var6 = var4 * 0.01F; GL11.glTranslatef(var5, var6, 0.0F); this.setRenderPassModel(this.model); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_BLEND); float var7 = 0.5F; GL11.glColor4f(var7, var7, var7, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); return 1; } if (par2 == 2) { GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); } } return -1; }