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:ion2d.INDirector.java
License:Open Source License
public static void setProjection(ProjectionFormat format) { if (Display.isCreated() == false) return;// w w w . ja v a2 s . co m Dimension screen = getScreenSize(); switch (format) { case DirectorProjection2D: GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, screen.width, 0, screen.height, -1000, 1000); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); break; case DirectorProjection3D: GL11.glViewport(0, 0, screen.width, screen.height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); float aspect = (screen.width * 1.0f) / (screen.height * 1.0f); GLU.gluPerspective(55, aspect, 0, screen.height + screen.width); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GLU.gluLookAt(screen.width / 2, screen.height / 2, getZEye(), screen.width / 2, screen.height / 2, 0.0f, 0.0f, 1.0f, 0.0f); break; } instance.currentProjection = format; }
From source file:itdelatrisu.opsu.render.CurveRenderState.java
License:Open Source License
/** * Draw a curve to the screen that's tinted with `color`. The first time * this is called this caches the image result of the curve and on subsequent * runs it just draws the cached copy to the screen. * @param color tint of the curve/*from w ww. j a v a 2 s .c om*/ * @param borderColor the curve border color * @param curve the points along the curve to be drawn */ public void draw(Color color, Color borderColor, Vec2f[] curve) { float alpha = color.a; // if this curve hasn't been drawn, draw it and cache the result if (fbo == null) { FrameBufferCache cache = FrameBufferCache.getInstance(); Rendertarget mapping = cache.get(hitObject); if (mapping == null) mapping = cache.insert(hitObject); fbo = mapping; int oldFb = GL11.glGetInteger(EXTFramebufferObject.GL_FRAMEBUFFER_BINDING_EXT); int oldTex = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); //glGetInteger requires a buffer of size 16, even though just 4 //values are returned in this specific case IntBuffer oldViewport = BufferUtils.createIntBuffer(16); GL11.glGetInteger(GL11.GL_VIEWPORT, oldViewport); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, fbo.getID()); GL11.glViewport(0, 0, fbo.width, fbo.height); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); Colors.WHITE_FADE.a = 1.0f; this.draw_curve(color, borderColor, curve); color.a = 1f; GL11.glBindTexture(GL11.GL_TEXTURE_2D, oldTex); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, oldFb); GL11.glViewport(oldViewport.get(0), oldViewport.get(1), oldViewport.get(2), oldViewport.get(3)); Colors.WHITE_FADE.a = alpha; } // draw a fullscreen quad with the texture that contains the curve GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_1D); GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo.getTextureID()); GL11.glBegin(GL11.GL_QUADS); GL11.glColor4f(1.0f, 1.0f, 1.0f, alpha); GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex2i(fbo.width, 0); GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex2i(0, 0); GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex2i(0, fbo.height); GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex2i(fbo.width, fbo.height); GL11.glEnd(); }
From source file:itemrender.client.rendering.FBOHelper.java
License:MIT License
public void begin() { checkGlErrors("FBO Begin Init"); // Remember current framebuffer. lastFramebuffer = GL11.glGetInteger(EXTFramebufferObject.GL_FRAMEBUFFER_BINDING_EXT); // Render to our texture EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, framebufferID); // Remember viewport info. lastViewport = GLAllocation.createDirectIntBuffer(16); GL11.glGetInteger(GL11.GL_VIEWPORT, lastViewport); GL11.glViewport(0, 0, renderTextureSize, renderTextureSize); GlStateManager.matrixMode(GL11.GL_MODELVIEW); GlStateManager.pushMatrix();// ww w . j a v a2 s . c om GlStateManager.loadIdentity(); // Remember current texture. lastTexture = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); GlStateManager.clearColor(0, 0, 0, 0); GlStateManager.clear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GlStateManager.cullFace(GL11.GL_FRONT); GlStateManager.enableDepth(); GlStateManager.enableLighting(); GlStateManager.enableRescaleNormal(); checkGlErrors("FBO Begin Final"); }
From source file:itemrender.client.rendering.FBOHelper.java
License:MIT License
public void end() { checkGlErrors("FBO End Init"); GlStateManager.cullFace(GL11.GL_BACK); GlStateManager.disableDepth();//from w w w.j a v a 2s . com GlStateManager.disableRescaleNormal(); GlStateManager.disableLighting(); GlStateManager.matrixMode(GL11.GL_MODELVIEW); GlStateManager.popMatrix(); // Revert to last viewport GL11.glViewport(lastViewport.get(0), lastViewport.get(1), lastViewport.get(2), lastViewport.get(3)); // Revert to default framebuffer EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, lastFramebuffer); // Revert to last texture GlStateManager.bindTexture(lastTexture); checkGlErrors("FBO End Final"); }
From source file:jake2.desktop.LWJGLAdapter.java
License:Open Source License
@Override public void glViewport(int x, int y, int w, int h) { GL11.glViewport(x, y, w, h); }
From source file:jpcsp.graphics.RE.RenderingEngineLwjgl.java
License:Open Source License
@Override public void setViewport(int x, int y, int width, int height) { GL11.glViewport(x, y, width, height); }
From source file:junkdisplay.JunkDisplayLWJGL.java
protected void initGLLWJGL() { if (!LEVEL_EDITOR) { GL11.glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); } else {//from www .j a v a 2 s . c om GL11.glViewport(0, 0, 1500, 800); } GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); if (!LEVEL_EDITOR) { GL11.glOrtho(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 1, -1); } else { GL11.glOrtho(0, 1500, 800, 0, 1, -1); } GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); initTextures(); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); createModel(); }
From source file:junkdisplay.JunkDisplayLWJGL.java
protected void resetGL() { GL11.glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); }
From source file:kuake2.render.lwjgl.Main.java
License:Open Source License
/** * R_SetupGL// w w w .j a v a 2 s . c o m */ void R_SetupGL() { // // set up viewport // //int x = (int) Math.floor(r_newrefdef.x * vid.width / vid.width); int x = r_newrefdef.x; //int x2 = (int) Math.ceil((r_newrefdef.x + r_newrefdef.width) * vid.width / vid.width); int x2 = r_newrefdef.x + r_newrefdef.width; //int y = (int) Math.floor(vid.height - r_newrefdef.y * vid.height / vid.height); int y = vid.height - r_newrefdef.y; //int y2 = (int) Math.ceil(vid.height - (r_newrefdef.y + r_newrefdef.height) * vid.height / vid.height); int y2 = vid.height - (r_newrefdef.y + r_newrefdef.height); int w = x2 - x; int h = y - y2; GL11.glViewport(x, y2, w, h); // // set up projection matrix // float screenaspect = (float) r_newrefdef.width / r_newrefdef.height; GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); MYgluPerspective(r_newrefdef.fov_y, screenaspect, 4, 4096); GL11.glCullFace(GL11.GL_FRONT); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glRotatef(-90, 1, 0, 0); // put Z going up GL11.glRotatef(90, 0, 0, 1); // put Z going up GL11.glRotatef(-r_newrefdef.viewangles[2], 1, 0, 0); GL11.glRotatef(-r_newrefdef.viewangles[0], 0, 1, 0); GL11.glRotatef(-r_newrefdef.viewangles[1], 0, 0, 1); GL11.glTranslatef(-r_newrefdef.vieworg[0], -r_newrefdef.vieworg[1], -r_newrefdef.vieworg[2]); GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, r_world_matrix); r_world_matrix.clear(); // // set drawing parms // if (gl_cull.value != 0.0f) GL11.glEnable(GL11.GL_CULL_FACE); else GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_DEPTH_TEST); }
From source file:kuake2.render.lwjgl.Main.java
License:Open Source License
/** * R_SetGL2D/*from w ww . j ava 2 s . c o m*/ */ void R_SetGL2D() { // set 2D virtual screen size GL11.glViewport(0, 0, vid.width, vid.height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, vid.width, vid.height, 0, -99999, 99999); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glColor4f(1, 1, 1, 1); }