List of usage examples for org.lwjgl.opengl GL11 glViewport
public static void glViewport(@NativeType("GLint") int x, @NativeType("GLint") int y, @NativeType("GLsizei") int w, @NativeType("GLsizei") int h)
From source file:edu.csun.ecs.cs.multitouchj.ui.graphic.WindowManager.java
License:Apache License
protected void initializeOpenGl() { DisplayMode displayMode = displayManager.getCurrentDisplayMode(); GL11.glEnable(GL11.GL_DEPTH_TEST);/*from w w w. ja va 2s .c o m*/ GL11.glClearDepth(1.0f); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glViewport(0, 0, displayMode.getWidth(), displayMode.getHeight()); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); //GLU.gluPerspective(45.0f, (float)SCREEN_WIDTH/(float)SCREEN_HEIGHT, 4.0f, 4000.0f); GLU.gluPerspective(45.0f, (float) displayMode.getWidth() / (float) displayMode.getHeight(), 1.0f, 100.0f); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); //GL11.glClearDepth(1.0f); //GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); //GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glCullFace(GL11.GL_BACK); }
From source file:espresso3d.engine.window.viewport.E3DViewport.java
License:Open Source License
public void switchToViewport() { // GL11.glMatrixMode(GL11.GL_PROJECTION); // Select The Projection Matrix GL11.glViewport(x, y, width, height); setPerspective(); }
From source file:eu.over9000.veya.gui.Gui.java
License:Open Source License
private static void setUpStates(final int width, final int height) { try {/*from www.j ava 2 s . c o m*/ Display.setDisplayMode(new DisplayMode(width, height)); Display.create(); //Display.create(new PixelFormat().withSamples(4).withDepthBits(24), new ContextAttribs(3, 3)); Display.setVSyncEnabled(true); } catch (final LWJGLException e) { e.printStackTrace(); System.exit(0); } GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glClearColor(0.0f, 0.3f, 0.0f, 0.0f); GL11.glClearDepth(1); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glViewport(0, 0, width, height); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, width, height, 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
From source file:eu.over9000.veya.rendering.Shadow.java
License:Open Source License
public void preRender() { Veya.program_shadow.use(true);/*from w w w .j a v a 2 s .c om*/ updateMatrixLightSpaceMatrixLocation(); GL11.glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, shadowFBO); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GL11.glCullFace(GL11.GL_FRONT); }
From source file:eu.over9000.veya.rendering.Shadow.java
License:Open Source License
public void postRender() { GL11.glCullFace(GL11.GL_BACK); // don't forget to reset original culling face GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0); Veya.program_normal.use(true);//from w w w .ja va 2 s. c om GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight()); GL13.glActiveTexture(GL13.GL_TEXTURE1); GL11.glBindTexture(GL11.GL_TEXTURE_2D, depthMap); }
From source file:eu.over9000.veya.Veya.java
License:Open Source License
private static void init() throws LWJGLException { final Canvas canvas = new Canvas(); frame = new Frame(); frame.add(canvas);//from w w w .java 2 s . c o m frame.setSize(1280, 720); frame.setLocationByPlatform(true); frame.setVisible(true); frame.setExtendedState(Frame.MAXIMIZED_BOTH); frame.setIconImage(loadIcon()); Display.setParent(canvas); Display.create(new PixelFormat().withSamples(4).withDepthBits(24), new ContextAttribs(3, 3)); System.out.println("OpenGL version: " + GL11.glGetString(GL11.GL_VERSION)); System.out.println("Java version: " + System.getProperty("java.version")); System.out.println("graphics adapter: " + Display.getAdapter()); Veya.program_normal = new Program("normal", new String[] { "modelMatrix", "viewMatrix", "projectionMatrix", "lightPosition", "lightColor", "lightFactors", "colorSwitch", "aoSwitch", "cameraPosition", "lightSpaceMatrix", "textureData", "shadowMap" }); Veya.program_shadow = new Program("shadow", new String[] { "modelMatrix", "lightSpaceMatrix" }); Veya.program_debug = new Program("debug", new String[] { "near_plane", "far_plane" }); Util.checkGLError(); Veya.camera = new Camera(-40, 120, -40); Veya.scene = new Scene(1337); Util.checkGLError(); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glLineWidth(2.5f); Util.checkGLError(); GL11.glEnable(GL31.GL_PRIMITIVE_RESTART); GL31.glPrimitiveRestartIndex(Veya.RESTART); GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight()); GL11.glClearColor(124f / 255f, 169f / 255f, 255f / 255f, 1.0f); Mouse.setGrabbed(true); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); Console.start(); }
From source file:eu.over9000.veya.Veya.java
License:Open Source License
private static void checkResize() { if (Display.wasResized()) { Veya.program_normal.use(true);/*w w w. ja v a 2 s . c o m*/ Veya.camera.updateProjectionMatrix(Display.getWidth(), Display.getHeight()); Veya.program_normal.use(false); GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight()); System.out.println("resized"); } }
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./* w w w.j a v a 2 s. c om*/ */ /* * (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);/*from www.j a v a2 s . 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:fi.conf.ae.gl.core.GLCore.java
License:LGPL
public void renderToTexture(int textureID, int width, int height) { GL11.glViewport(0, 0, width, height); glLoop();//from www. java 2s . co m GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); // Bind and copy texture GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, 0, 0, width, height, 0); GL11.glViewport(0, 0, GLValues.screenWidth, GLValues.screenHeight); //GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Clear The Screen And Depth Buffer }