List of usage examples for org.lwjgl.opengl GL11 GL_MODELVIEW
int GL_MODELVIEW
To view the source code for org.lwjgl.opengl GL11 GL_MODELVIEW.
Click Source Link
From source file:itdelatrisu.opsu.render.CurveRenderState.java
License:Open Source License
/** * Restore the old OpenGL state that's backed up in {@code state}. * @param state the old state to restore *//*from w w w . j a v a 2 s . co m*/ private void endRender(RenderState state) { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPopMatrix(); GL11.glEnable(GL11.GL_BLEND); GL20.glUseProgram(state.oldProgram); GL13.glActiveTexture(state.texUnit); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, state.oldArrayBuffer); if (!state.depthWriteEnabled) GL11.glDepthMask(false); if (!state.depthEnabled) GL11.glDisable(GL11.GL_DEPTH_TEST); if (state.texEnabled) GL11.glEnable(GL11.GL_TEXTURE_2D); if (state.smoothedPoly) GL11.glEnable(GL11.GL_POLYGON_SMOOTH); if (!state.blendEnabled) GL11.glDisable(GL11.GL_BLEND); }
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();/*w w w. ja v a2 s. com*/ 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 ww w . ja v a 2 s. c o m*/ 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:itemrender.client.rendering.Renderer.java
License:MIT License
public static void renderEntity(EntityLivingBase entity, FBOHelper fbo, String filenameSuffix, boolean renderPlayer) { Minecraft minecraft = FMLClientHandler.instance().getClient(); float scale = ItemRenderMod.renderScale; fbo.begin();/*from w w w. j a v a 2 s . c o m*/ AxisAlignedBB aabb = entity.getEntityBoundingBox(); double minX = aabb.minX - entity.posX; double maxX = aabb.maxX - entity.posX; double minY = aabb.minY - entity.posY; double maxY = aabb.maxY - entity.posY; double minZ = aabb.minZ - entity.posZ; double maxZ = aabb.maxZ - entity.posZ; double minBound = Math.min(minX, Math.min(minY, minZ)); double maxBound = Math.max(maxX, Math.max(maxY, maxZ)); double boundLimit = Math.max(Math.abs(minBound), Math.abs(maxBound)); GlStateManager.matrixMode(GL11.GL_PROJECTION); GlStateManager.pushMatrix(); GlStateManager.loadIdentity(); GlStateManager.ortho(-boundLimit * 0.75, boundLimit * 0.75, -boundLimit * 1.25, boundLimit * 0.25, -100.0, 100.0); GlStateManager.matrixMode(GL11.GL_MODELVIEW); // Render entity GlStateManager.enableColorMaterial(); GlStateManager.pushMatrix(); GlStateManager.translate(0, 0, 50.0F); if (renderPlayer) GlStateManager.scale(-1F, 1F, 1F); else GlStateManager.scale(-scale, scale, scale); GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F); float f2 = entity.renderYawOffset; float f3 = entity.rotationYaw; float f4 = entity.rotationPitch; float f5 = entity.prevRotationYawHead; float f6 = entity.rotationYawHead; GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F); GlStateManager.rotate((float) Math.toDegrees(Math.asin(Math.tan(Math.toRadians(30)))), 1.0F, 0.0F, 0.0F); GlStateManager.rotate(-45, 0.0F, 1.0F, 0.0F); entity.renderYawOffset = (float) Math.atan((double) (1 / 40.0F)) * 20.0F; entity.rotationYaw = (float) Math.atan((double) (1 / 40.0F)) * 40.0F; entity.rotationPitch = -((float) Math.atan((double) (1 / 40.0F))) * 20.0F; entity.rotationYawHead = entity.rotationYaw; entity.prevRotationYawHead = entity.rotationYaw; GlStateManager.translate(0.0F, 0.0F, 0.0F); RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager(); rendermanager.setPlayerViewY(180.0F); rendermanager.setRenderShadow(false); rendermanager.doRenderEntity(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, true); rendermanager.setRenderShadow(true); entity.renderYawOffset = f2; entity.rotationYaw = f3; entity.rotationPitch = f4; entity.prevRotationYawHead = f5; entity.rotationYawHead = f6; GlStateManager.popMatrix(); RenderHelper.disableStandardItemLighting(); GlStateManager.disableRescaleNormal(); GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit); GlStateManager.disableTexture2D(); GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); GlStateManager.matrixMode(GL11.GL_PROJECTION); GlStateManager.popMatrix(); fbo.end(); String name = EntityList.getEntityString(entity) == null ? entity.getCommandSenderName() : EntityList.getEntityString(entity); fbo.saveToFile(new File(minecraft.mcDataDir, renderPlayer ? "rendered/player.png" : String.format("rendered/entity_%s%s.png", name.replaceAll("[^A-Za-z0-9()\\[\\]]", ""), filenameSuffix))); fbo.restoreTexture(); }
From source file:itemrender.client.rendering.Renderer.java
License:MIT License
public static void renderItem(ItemStack itemStack, FBOHelper fbo, String filenameSuffix, RenderItem itemRenderer) {/*from w ww. j a v a2 s .co m*/ Minecraft minecraft = FMLClientHandler.instance().getClient(); float scale = ItemRenderMod.renderScale; fbo.begin(); GlStateManager.matrixMode(GL11.GL_PROJECTION); GlStateManager.pushMatrix(); GlStateManager.loadIdentity(); GlStateManager.ortho(0, 16, 0, 16, -150.0F, 150.0F); GlStateManager.matrixMode(GL11.GL_MODELVIEW); RenderHelper.enableGUIStandardItemLighting(); GlStateManager.enableRescaleNormal(); GlStateManager.enableColorMaterial(); GlStateManager.enableLighting(); GlStateManager.translate(8 * (1 - scale), 8 * (1 - scale), 0); GlStateManager.scale(scale, scale, scale); itemRenderer.renderItemIntoGUI(itemStack, 0, 0); GlStateManager.disableLighting(); RenderHelper.disableStandardItemLighting(); GlStateManager.matrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); fbo.end(); fbo.saveToFile(new File(minecraft.mcDataDir, String.format("rendered/item_%s_%d%s.png", itemStack.getItem().getUnlocalizedName().replaceAll("[^A-Za-z0-9()\\[\\]]", ""), itemStack.getItemDamage(), filenameSuffix))); fbo.restoreTexture(); }
From source file:itemrender.client.rendering.Renderer.java
License:MIT License
public static String getItemBase64(ItemStack itemStack, FBOHelper fbo, RenderItem itemRenderer) { String base64;/* w w w . jav a 2s . co m*/ float scale = ItemRenderMod.renderScale; fbo.begin(); GlStateManager.matrixMode(GL11.GL_PROJECTION); GlStateManager.pushMatrix(); GlStateManager.loadIdentity(); GlStateManager.ortho(0, 16, 0, 16, -150.0F, 150.0F); GlStateManager.matrixMode(GL11.GL_MODELVIEW); RenderHelper.enableGUIStandardItemLighting(); GlStateManager.enableRescaleNormal(); GlStateManager.enableColorMaterial(); GlStateManager.enableLighting(); GlStateManager.translate(8 * (1 - scale), 8 * (1 - scale), 0); GlStateManager.scale(scale, scale, scale); itemRenderer.renderItemIntoGUI(itemStack, 0, 0); GlStateManager.disableLighting(); RenderHelper.disableStandardItemLighting(); GlStateManager.matrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); fbo.end(); base64 = fbo.getBase64(); fbo.restoreTexture(); return base64; }
From source file:junkdisplay.JunkDisplayLWJGL.java
protected void initGLLWJGL() { if (!LEVEL_EDITOR) { GL11.glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); } else {//from w w w.jav a 2 s . co m 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:kuake2.render.lwjgl.Main.java
License:Open Source License
/** * R_SetupGL/* w w w .jav a2 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 w w . j a va 2s . com */ 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); }
From source file:kuake2.render.lwjgl.Main.java
License:Open Source License
/** * R_BeginFrame//from w w w. j a va2 s .co m */ protected void R_BeginFrame(float camera_separation) { gl_state.camera_separation = camera_separation; /* ** change modes if necessary */ if (gl_mode.modified || vid_fullscreen.modified) { // FIXME: only restart if CDS is required cvar_t ref; ref = Cvar.Get("vid_ref", "lwjgl", 0); ref.modified = true; } if (gl_log.modified) { GLimp_EnableLogging((gl_log.value != 0.0f)); gl_log.modified = false; } if (gl_log.value != 0.0f) { GLimp_LogNewFrame(); } /* ** update 3Dfx gamma -- it is expected that a user will do a vid_restart ** after tweaking this value */ if (vid_gamma.modified) { vid_gamma.modified = false; if ((gl_config.renderer & GL_RENDERER_VOODOO) != 0) { // wird erstmal nicht gebraucht /* char envbuffer[1024]; float g; g = 2.00 * ( 0.8 - ( vid_gamma->value - 0.5 ) ) + 1.0F; Com_sprintf( envbuffer, sizeof(envbuffer), "SSTV2_GAMMA=%f", g ); putenv( envbuffer ); Com_sprintf( envbuffer, sizeof(envbuffer), "SST_GAMMA=%f", g ); putenv( envbuffer ); */ VID.Printf(Defines.PRINT_DEVELOPER, "gamma anpassung fuer VOODOO nicht gesetzt"); } } GLimp_BeginFrame(camera_separation); /* ** go into 2D mode */ 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); /* ** draw buffer stuff */ if (gl_drawbuffer.modified) { gl_drawbuffer.modified = false; if (gl_state.camera_separation == 0 || !gl_state.stereo_enabled) { if (gl_drawbuffer.string.equalsIgnoreCase("GL_FRONT")) GL11.glDrawBuffer(GL11.GL_FRONT); else GL11.glDrawBuffer(GL11.GL_BACK); } } /* ** texturemode stuff */ if (gl_texturemode.modified) { GL_TextureMode(gl_texturemode.string); gl_texturemode.modified = false; } if (gl_texturealphamode.modified) { GL_TextureAlphaMode(gl_texturealphamode.string); gl_texturealphamode.modified = false; } if (gl_texturesolidmode.modified) { GL_TextureSolidMode(gl_texturesolidmode.string); gl_texturesolidmode.modified = false; } /* ** swapinterval stuff */ GL_UpdateSwapInterval(); // // clear screen if desired // R_Clear(); }