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: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) *///ww w . j av a 2 s. c om 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.guillaume.prive.viper.core.graphic.GraphicMotor.java
private static void setupOpenGL() { try {// w ww . ja v a 2 s .c o m PixelFormat pixelFormat = new PixelFormat(); ContextAttribs contextAtrributes = new ContextAttribs(3, 2).withForwardCompatible(true) .withProfileCore(true); Display.setDisplayMode(new DisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT)); Display.setTitle(WINDOW_NAME); Display.create(pixelFormat, contextAtrributes); } catch (LWJGLException e) { throw new IllegalStateException("OpenGL init error", e); } GL11.glClearColor(0f, 0f, 0f, 0f); GL11.glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_BLEND); }
From source file:fr.ign.cogit.geoxygene.appli.render.DisplayableTextRenderer.java
License:Open Source License
private void drawText() throws GLException { if (this.program == null || this.textImage == null) { Logger.getRootLogger().debug("The GeoxGLTextRenderer " + this.hashCode() + "is not ready yet"); return;/* w w w.j a va 2 s . co m*/ } this.textImage.getRGB(0, 0, width, height, this.pixels, 0, width); this.buffer.rewind(); for (int y = height - 1; y >= 0; y--) { for (int x = 0; x < width; x++) { int pixel = this.pixels[y * width + x]; this.buffer.put((byte) (pixel >> 16 & 0xFF)); // Red component this.buffer.put((byte) (pixel >> 8 & 0xFF)); // Green component this.buffer.put((byte) (pixel >> 0 & 0xFF)); // Blue component this.buffer.put((byte) (pixel >> 24 & 0xFF)); // Alpha component } } this.buffer.rewind(); glEnable(GL_TEXTURE_2D); GL13.glActiveTexture(GL13.GL_TEXTURE0 + 2); glBindTexture(GL_TEXTURE_2D, this.getTextTextureId()); // Setup texture scaling filtering GL11.glTexParameteri(GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexImage2D(GL_TEXTURE_2D, 0, GL11.GL_RGBA8, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, this.buffer); Integer fbow = (Integer) GLContext.getActiveGlContext() .getSharedUniform(GeoxygeneConstants.GL_VarName_FboWidth); Integer fboh = (Integer) GLContext.getActiveGlContext() .getSharedUniform(GeoxygeneConstants.GL_VarName_FboHeight); GL11.glViewport(0, 0, fbow, fboh); glDisable(GL11.GL_POLYGON_SMOOTH); GLContext.getActiveGlContext().setCurrentProgram(program); program.setUniform1i("colorTexture2", 2); GLTools.glCheckError("texture binding"); GL11.glDepthMask(false); glDisable(GL11.GL_DEPTH_TEST); GL30.glBindVertexArray(LayerViewGLPanel.getScreenQuad().getVaoId()); GLTools.glCheckError("before drawing textured quad VAO binding"); program.setUniform(GeoxygeneConstants.GL_VarName_ObjectOpacityVarName, 1f); program.setUniform(GeoxygeneConstants.GL_VarName_GlobalOpacityVarName, 1f); glEnable(GL_BLEND); GL11.glBlendFunc(GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); GLTools.glCheckError("blending set for textured quad"); LwjglLayerRenderer.drawComplex(LayerViewGLPanel.getScreenQuad()); GLTools.glCheckError("Drawing textured quad"); GL30.glBindVertexArray(0); // unbind VAO GLTools.glCheckError("exiting Text rendering"); glBindTexture(GL_TEXTURE_2D, 0); // unbind texture }
From source file:fr.veridiangames.client.rendering.Display.java
License:Open Source License
public void update() { closed = glfwWindowShouldClose(window); if (destroy) { destroy();// w w w.j ava 2 s. c o m return; } glfwPollEvents(); glfwSwapBuffers(window); glfwGetWindowSize(window, windowSizeBuffer.asIntBuffer(), null); width = windowSizeBuffer.getInt(0); glfwGetWindowSize(window, null, windowSizeBuffer.asIntBuffer()); height = windowSizeBuffer.getInt(0); resized = false; if (width != lastWidth || height != lastHeight) { lastWidth = width; lastHeight = height; aspect = (float) width / (float) height; resized = true; } if (resized) { GL11.glViewport(0, 0, width, height); } }
From source file:hexagonalminesweeper.HexagonalMinesweeper.java
public static void renderGL() { try {/*from w w w.j a v a 2s . c o m*/ Display.setDisplayMode(new org.lwjgl.opengl.DisplayMode(800, 600)); Display.create(); } catch (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.0f, 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, 800, 600); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, 800, 600, 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); Display.setVSyncEnabled(true); }
From source file:hud.UnitDisplay.java
License:Open Source License
public void draw() { GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_LINE); GL11.glColor4f(0.0f, 0.0f, 0.4f, 1.0f); GL11.glLineWidth(2.0f);//w ww . j a v a 2 s . com GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2i(x, y); GL11.glVertex2i(x, y + height); GL11.glVertex2i(x + width, y + height); GL11.glVertex2i(x + width, y); GL11.glEnd(); GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); GL11.glColor4f(0.0f, 0.5f, 1.0f, 0.8f); GL11.glEnable(GL11.GL_BLEND); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2i(x, y); GL11.glVertex2i(x, y + height); GL11.glVertex2i(x + width, y + height); GL11.glVertex2i(x + width, y); GL11.glEnd(); GL11.glDisable(GL11.GL_BLEND); int[] viewport = GLUtils.getViewport(); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_LIGHTING); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glLoadIdentity(); GLU.gluPerspective(45, 1.0f, 0.001f, 5.0f); GL11.glViewport(getX(), viewport[3] - (getY() + height), width, height); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); GLU.gluLookAt(2.0f * (float) Math.cos(angle), 2.0f * (float) Math.sin(angle), 1.0f, 0, 0, 0, 0, 0, 1); // GL11.glTranslatef(x + width/2, y + height/2,0); currentUnit.draw(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPopMatrix(); GL11.glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); }
From source file:illarion.graphics.lwjgl.RenderDisplayLWJGL.java
License:Open Source License
/** * Setup the openGL render environment. Such as the view port the matrix for * the orthogonal view and so on.//w w w. java 2 s. c o m */ protected void setupOpenGL() { if (!Display.isCreated()) { return; } // set the basic view port of the game. This should be the full size of // the client window GL11.glViewport(0, 0, resWidth, resHeight); // enable alpha blending based on the picture alpha channel GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // disable death test, we work in 2D anyway, there is no depth GL11.glDisable(GL11.GL_DEPTH_TEST); // switch to projection matrix to set up the orthogonal view that we // need GL11.glMatrixMode(GL11.GL_PROJECTION); // load the identity matrix to we have a clean start GL11.glLoadIdentity(); // setup the orthogonal view GLU.gluOrtho2D(0, resWidth, 0, resHeight); // set clear color to black GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // sync frame (only works on windows) if (Graphics.NO_SLOWDOWN) { Display.setVSyncEnabled(false); } else { Display.setVSyncEnabled(true); } // clean up the screen GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // switch to model view matrix, so we can place the sprites correctly GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); }
From source file:im.bci.jnuit.lwjgl.LwjglNuitRenderer.java
License:Open Source License
@Override public void render(Root root) { GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_TRANSFORM_BIT | GL11.GL_HINT_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_SCISSOR_BIT | GL11.GL_LINE_BIT | GL11.GL_TEXTURE_BIT); GL11.glViewport(0, 0, LwjglHelper.getWidth(), LwjglHelper.getHeight()); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix();/* w w w . j a v a2 s . com*/ GL11.glLoadIdentity(); GL11.glOrtho(root.getX(), root.getWidth(), root.getHeight(), root.getY(), -1.0, 1.0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_SCISSOR_TEST); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); GL11.glEnable(GL11.GL_TEXTURE_2D); drawBackgroundAndBorder(root); drawStack(root); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glPopAttrib(); }
From source file:io.root.display.RenderWindow.java
License:Apache License
/** * Updates the RenderWindow, also handles if the window was resized */// w w w . java 2s. co m public static void update() { Display.update(); if (Display.wasResized()) { GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight()); } }
From source file:io.root.gfx.glutils.GL.java
License:Apache License
public static void glViewport(int x, int y, int width, int height) { GL11.glViewport(x, y, width, height); }