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:org.jogamp.glg2d.GLG2DSimpleEventListener.java
License:Apache License
/** * Defines the viewport to paint into. */ protected void setupViewport() { GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight()); }
From source file:org.jtrfp.mtmx.Engine.java
License:Open Source License
public void start(String title, boolean chooseDisplayMode) throws EngineException { try {// www . ja v a 2 s. com if (chooseDisplayMode) { setupDisplay(); } else { Display.setDisplayMode(new DisplayMode(640, 480)); } Display.setTitle(title); Display.create(); getLogger().log(Level.INFO, "GL_VENDOR: " + GL11.glGetString(GL11.GL_VENDOR)); getLogger().log(Level.INFO, "GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER)); getLogger().log(Level.INFO, "GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION)); engineConfiguration.init(this); engineConfiguration.initResources(); Keyboard.create(); Keyboard.enableRepeatEvents(false); engineConfiguration.initKeyboard(); engineConfiguration.initLight(); DisplayMode displayMode = getDisplayMode(); GL11.glViewport(0, 0, displayMode.getWidth(), displayMode.getHeight()); engineConfiguration.initView(); loop(); destroy(); } catch (LWJGLException e) { destroy(); throw new EngineException("Failed to create display.", e); } }
From source file:org.lwjgl.info.LWJGLTestView.java
License:Open Source License
/** * {@inheritDoc}/*from www . java 2 s. co m*/ * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) */ @Override public void createPartControl(Composite parent) { String strVersion = getFeatureVersion("org.lwjgl"); this.setPartName("org.lwjgl " + strVersion); IStatusLineManager statusLine = this.getViewSite().getActionBars().getStatusLineManager(); fpsstatuslineitem = new FpsStatusLineItem(); statusLine.add(fpsstatuslineitem); GLData data = new GLData(); data.doubleBuffer = true; canvas = new GLCanvas(parent, 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); Display.getCurrent().asyncExec(initRunnable()); }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
@Override // void dsDrawFrame (int width, int height, dsFunctions *fn, int pause) void dsDrawFrame(int width, int height, dsFunctions fn, boolean pause) { if (current_state < 1) dsDebug("internal error"); current_state = 2;/*from w ww .jav a 2 s .co m*/ // setup stuff GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_GEN_S); GL11.glDisable(GL11.GL_TEXTURE_GEN_T); GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LESS); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glCullFace(GL11.GL_BACK); GL11.glFrontFace(GL11.GL_CCW); // setup viewport GL11.glViewport(0, 0, width, height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); final float vnear = 0.1f; final float vfar = 100.0f; final float k = 0.8f; // view scale, 1 = +/- 45 degrees if (width >= height) { float k2 = (float) height / (float) width; GL11.glFrustum(-vnear * k, vnear * k, -vnear * k * k2, vnear * k * k2, vnear, vfar); } else { float k2 = (float) width / (float) height; GL11.glFrustum(-vnear * k * k2, vnear * k * k2, -vnear * k, vnear * k, vnear, vfar); } // setup lights. it makes a difference whether this is done in the // GL_PROJECTION matrix mode (lights are scene relative) or the // GL_MODELVIEW matrix mode (lights are camera relative, bad!). // static GLfloat light_ambient[] = { 0.5, 0.5, 0.5, 1.0 }; // static GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; // static GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, light_ambient); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, light_diffuse); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, light_specular); GL11.glColor3f(1.0f, 1.0f, 1.0f); // clear the window GL11.glClearColor(0.5f, 0.5f, 0.5f, 0); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // snapshot camera position (in MS Windows it is changed by the GUI thread) float[] view2_xyz = view_xyz.clone(); float[] view2_rxyz = view_rxyz.clone(); // memcpy (view2_xyz,view_xyz);//,sizeof(float)*3); // memcpy (view2_hpr,view_hpr);//,sizeof(float)*3); // go to GL_MODELVIEW matrix mode and set the camera GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); setCamera(view2_xyz[0], view2_xyz[1], view2_xyz[2], view2_rxyz[0], view2_rxyz[1], view2_rxyz[2]); // set the light position (for some reason we have to do this in model view. // static GLfloat light_position[] = { LIGHTX, LIGHTY, 1.0, 0.0 }; GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, light_position); // draw the background (ground, sky etc) drawSky(view2_xyz); drawGround(); // draw the little markers on the ground drawPyramidGrid(); // leave openGL in a known state - flat shaded white, no textures GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LESS); GL11.glColor3f(1, 1, 1); setColor(1, 1, 1, 1); // draw the rest of the objects. set drawing state first. color[0] = 1; color[1] = 1; color[2] = 1; color[3] = 1; tnum = DS_TEXTURE_NUMBER.DS_NONE; //if (fn.step) fn.step(pause); }
From source file:org.oscim.gdx.LwjglGL20.java
License:Apache License
public void viewport(int x, int y, int width, int height) { GL11.glViewport(x, y, width, height); }
From source file:org.spout.engine.filesystem.resource.ClientRenderTexture.java
License:Open Source License
public void activate() { if (framebuffer == INVALID_BUFFER) { return; //Can't set this to active if it's not created yet }//from ww w.j av a2s .c om if (useEXT) { EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, framebuffer); } else { GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer); } SpoutRenderer.checkGLError(); GL11.glViewport(0, 0, width, height); SpoutRenderer.checkGLError(); }
From source file:org.spout.engine.filesystem.resource.ClientRenderTexture.java
License:Open Source License
public void release() { if (framebuffer != INVALID_BUFFER) { if (useEXT) { EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, SCREEN_BUFFER); } else {/*from w w w . j ava2s . co m*/ GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, SCREEN_BUFFER); } SpoutRenderer.checkGLError(); GL11.glViewport(0, 0, width, height); SpoutRenderer.checkGLError(); GL11.glDrawBuffer(GL11.GL_BACK); } }
From source file:org.spout.engine.resources.ClientRenderTexture.java
License:Open Source License
public void activate() { if (framebuffer == INVALID_BUFFER) return; //Can't set this to active if it's not created yet if (useEXT)/* w w w . j a va2s . c o m*/ EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, framebuffer); else GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer); GL11.glViewport(0, 0, width, height); }
From source file:org.spout.engine.resources.ClientRenderTexture.java
License:Open Source License
public void release() { if (framebuffer != INVALID_BUFFER) { if (useEXT) EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, SCREEN_BUFFER); else//from w w w. j a va 2 s .co m GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, SCREEN_BUFFER); GL11.glViewport(0, 0, width, height); } }
From source file:org.terasology.rendering.opengl.LwjglFrameBufferObject.java
License:Apache License
@Override public void unbindFrame() { GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0); GL11.glViewport(vp.get(0), vp.get(1), vp.get(2), vp.get(3)); glMatrixMode(GL_TEXTURE);/*from w ww . ja va2s . co m*/ glLoadIdentity(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 0, 2048f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }