List of usage examples for org.lwjgl.opengl GL11 glMatrixMode
public static native void glMatrixMode(@NativeType("GLenum") int mode);
From source file:com.dyonovan.tcnodetracker.lib.truetyper.FontHelper.java
License:Open Source License
private static void set2DMode(FloatBuffer matrixData) { Minecraft mc = Minecraft.getMinecraft(); ScaledResolution sr = new ScaledResolution(mc.getMinecraft(), mc.displayWidth, mc.displayHeight); mc.entityRenderer.setupOverlayRendering(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix();/*from w ww.j a v a2 s .co m*/ //GL11.glLoadMatrix(matrixData); GL11.glLoadIdentity(); GL11.glOrtho(0, mc.displayWidth, 0, mc.displayHeight, -1, 1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); Matrix4f matrix = new Matrix4f(); matrix.load(matrixData); GL11.glTranslatef(matrix.m30 * sr.getScaleFactor(), -matrix.m31 * sr.getScaleFactor(), 0f); }
From source file:com.dyonovan.tcnodetracker.lib.truetyper.FontHelper.java
License:Open Source License
private static void set3DMode() { GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPopMatrix();//from w w w.ja va 2 s .c om GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); Minecraft mc = Minecraft.getMinecraft(); mc.entityRenderer.setupOverlayRendering(); }
From source file:com.enderville.mod.client.gui.mainmenu.MenuBaseEnderVille.java
License:LGPL
private void drawPanorama(int par1, int par2, float par3) { Tessellator tessellator = Tessellator.instance; GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix();//ww w . jav a2s. c o m GL11.glLoadIdentity(); Project.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDepthMask(false); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); byte b0 = 8; for (int k = 0; k < b0 * b0; ++k) { GL11.glPushMatrix(); float f1 = ((float) (k % b0) / (float) b0 - 0.5F) / 64.0F; float f2 = ((float) (k / b0) / (float) b0 - 0.5F) / 64.0F; float f3 = 0.0F; GL11.glTranslatef(f1, f2, f3); GL11.glRotatef(MathHelper.sin(((float) this.panoramaTimer + par3) / 400.0F) * 25.0F + 20.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(-((float) this.panoramaTimer + par3) * 0.1F, 0.0F, 1.0F, 0.0F); for (int l = 0; l < 6; ++l) { GL11.glPushMatrix(); if (l == 1) { GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); } if (l == 2) { GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); } if (l == 3) { GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); } if (l == 4) { GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); } if (l == 5) { GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); } this.mc.getTextureManager().bindTexture(titlePanoramaPaths[l]); tessellator.startDrawingQuads(); tessellator.setColorRGBA_I(16777215, 255 / (k + 1)); float f4 = 0.0F; tessellator.addVertexWithUV(-1.0D, -1.0D, 1.0D, (double) (0.0F + f4), (double) (0.0F + f4)); tessellator.addVertexWithUV(1.0D, -1.0D, 1.0D, (double) (1.0F - f4), (double) (0.0F + f4)); tessellator.addVertexWithUV(1.0D, 1.0D, 1.0D, (double) (1.0F - f4), (double) (1.0F - f4)); tessellator.addVertexWithUV(-1.0D, 1.0D, 1.0D, (double) (0.0F + f4), (double) (1.0F - f4)); tessellator.draw(); GL11.glPopMatrix(); } GL11.glPopMatrix(); GL11.glColorMask(true, true, true, false); } tessellator.setTranslation(0.0D, 0.0D, 0.0D); GL11.glColorMask(true, true, true, true); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPopMatrix(); GL11.glDepthMask(true); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_DEPTH_TEST); }
From source file:com.gameminers.ethereal.architect.ModelCanvas.java
License:Open Source License
@Override protected void paintGL() { try {// w ww . ja v a 2s. c o m if (getWidth() != current_width || getHeight() != current_height) { current_width = getWidth(); current_height = getHeight(); GL11.glViewport(0, 0, current_width, current_height); } GL11.glClearColor(0.0f, 0.6f, 0.5f, 1.0f); GL11.glClearDepth(1.0); GL11.glColor3f(1, 1, 1); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glLoadIdentity(); GLU.gluPerspective(45.0f, (float) getWidth() / (float) getHeight(), 0.1f, 1000.0f); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glTranslatef(0, 0, zoom); GL11.glRotatef(angle, 0f, 1f, 0f); GL11.glRotatef(tilt, 1f, 0f, 0f); GL11.glTranslatef(-16, -16, -16); if (lit) { GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, lightPosition); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, lightAmbient); } else { GL11.glDisable(GL11.GL_LIGHTING); } if (textured) { GL11.glEnable(GL11.GL_TEXTURE_2D); } else { GL11.glDisable(GL11.GL_TEXTURE_2D); } if (model != null) { if (model.isAmbientOcclusionEnabled()) { GL11.glShadeModel(GL11.GL_SMOOTH); } else { GL11.glShadeModel(GL11.GL_FLAT); } for (ModelElement ele : model.getElements()) { GL11.glPushMatrix(); if (ele.isShade()) { GL11.glEnable(GL11.GL_LIGHTING); } else { GL11.glDisable(GL11.GL_LIGHTING); } float fromX = ele.getFrom()[0]; float fromY = ele.getFrom()[1]; float fromZ = ele.getFrom()[2]; float toX = ele.getTo()[0]; float toY = ele.getTo()[1]; float toZ = ele.getTo()[2]; float fX = (fromX > toX ? fromX : toX); float fY = (fromY > toY ? fromY : toY); float fZ = (fromZ > toZ ? fromZ : toZ); float tX = (fromX > toX ? toX : fromX); float tY = (fromY > toY ? toY : fromY); float tZ = (fromZ > toZ ? toZ : fromZ); GL11.glTranslatef(fX, fY, fZ); float scaleX = tX - fX; float scaleY = tY - fY; float scaleZ = tZ - fZ; GL11.glBegin(GL11.GL_QUADS); GL11.glNormal3f(0, 0, -1f); for (int i = 0; i < vertices.length / 3; i++) { int faceIdx = i / 4; ModelFace face; switch (faceIdx) { case 0: face = ele.getFaces().getNorth(); break; case 1: face = ele.getFaces().getSouth(); break; case 2: face = ele.getFaces().getUp(); break; case 3: face = ele.getFaces().getDown(); break; case 4: face = ele.getFaces().getWest(); break; case 5: face = ele.getFaces().getEast(); break; default: face = null; break; } int idx = i * 3; float vX = vertices[idx] * scaleX; float vY = vertices[idx + 1] * scaleY; float vZ = vertices[idx + 2] * scaleZ; /*float u; float v; GL11.glTexCoord2f(u, v);*/ GL11.glVertex3f(vX, vY, vZ); } GL11.glEnd(); GL11.glPopMatrix(); } } GL11.glPopMatrix(); swapBuffers(); repaint(); } catch (LWJGLException e) { throw new RuntimeException(e); } }
From source file:com.gameminers.mav.render.Rendering.java
License:Open Source License
public static void beforeFrame(int width, int height) { GL11.glViewport(0, 0, width, height); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();/*from w w w .j a v a 2 s . c o m*/ GL11.glOrtho(0, width, height, 0, 100, -100); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
From source file:com.golden.gamedev.engine.lwjgl.LWJGLMode.java
License:Open Source License
private void initGL() { // init GL// w w w .j a va2 s .c om // enable textures since we're going to use these for our sprites GL11.glEnable(GL11.GL_TEXTURE_2D); // disable the OpenGL depth test since we're rendering 2D graphics GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, this.size.width, this.size.height, 0, -1, 1); // enable transparency GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); }
From source file:com.irr310.i3d.scene.I3dCamera.java
License:Open Source License
public void display(float width, float height) { this.currentWidth = width; this.currentHeight = height; GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();/*from w w w . j av a2s. c o m*/ GL11.glOrtho(0, width, 0, height, -2000.0, 2000.0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); backgroundScene.display(this); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); initPerspective(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glPushMatrix(); configureView(glu); if (!configured) { configured = true; if (cameraInitialisation != null) { cameraInitialisation.run(); cameraInitialisation = null; } } GL11.glColor3f(1, 0, 0); GL11.glBegin(GL11.GL_LINES); GL11.glVertex3d(0, 0, 0); GL11.glVertex3d(100, 100, 100); GL11.glEnd(); preDisplayScene(); if (currentScene != null) { currentScene.display(this); } postDisplayScene(); preDisplayGui(); postDisplayGui(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, width, 0, height, -2000.0, 2000.0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); hudScene.display(this); GL11.glPopMatrix(); }
From source file:com.kauridev.lunarfever.Lunar.java
License:Open Source License
private void initOpenGL() { try {/*from w ww. ja v a2s .c o m*/ Display.setDisplayMode(new DisplayMode(TARGET_WIDTH, TARGET_HEIGHT)); Display.setTitle("Lunar Fever"); Display.setFullscreen(false); Display.create(); } catch (LWJGLException e) { e.printStackTrace(); } GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, TARGET_WIDTH, 0, TARGET_HEIGHT, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
From source file:com.kegare.caveworld.client.gui.GuiListSlot.java
License:Minecraft Mod Public
private void drawPanorama(float ticks) { Tessellator tessellator = Tessellator.instance; GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix();/*from w ww .j a va 2s . co m*/ GL11.glLoadIdentity(); Project.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDepthMask(false); OpenGlHelper.glBlendFunc(770, 771, 1, 0); byte b0 = 8; for (int k = 0; k < b0 * b0; ++k) { GL11.glPushMatrix(); float f1 = ((float) (k % b0) / (float) b0 - 0.5F) / 64.0F; float f2 = ((float) (k / b0) / (float) b0 - 0.5F) / 64.0F; float f3 = 0.0F; GL11.glTranslatef(f1, f2, f3); GL11.glRotatef(MathHelper.sin((panoramaTimer + ticks) / 400.0F) * 25.0F + 20.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(-(panoramaTimer + ticks) * 0.1F, 0.0F, 1.0F, 0.0F); for (int l = 0; l < 6; ++l) { GL11.glPushMatrix(); if (l == 1) { GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); } if (l == 2) { GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); } if (l == 3) { GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); } if (l == 4) { GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); } if (l == 5) { GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); } mc.getTextureManager().bindTexture(getPanoramaPaths().getPath(l)); tessellator.startDrawingQuads(); tessellator.setColorRGBA_I(16777215, 255 / (k + 1)); float f4 = 0.0F; tessellator.addVertexWithUV(-1.0D, -1.0D, 1.0D, 0.0F + f4, 0.0F + f4); tessellator.addVertexWithUV(1.0D, -1.0D, 1.0D, 1.0F - f4, 0.0F + f4); tessellator.addVertexWithUV(1.0D, 1.0D, 1.0D, 1.0F - f4, 1.0F - f4); tessellator.addVertexWithUV(-1.0D, 1.0D, 1.0D, 0.0F + f4, 1.0F - f4); tessellator.draw(); GL11.glPopMatrix(); } GL11.glPopMatrix(); GL11.glColorMask(true, true, true, false); } tessellator.setTranslation(0.0D, 0.0D, 0.0D); GL11.glColorMask(true, true, true, true); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPopMatrix(); GL11.glDepthMask(true); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_DEPTH_TEST); }
From source file:com.mtbs3d.minecrift.VRRenderer.java
License:LGPL
/** * sets up projection, view effects, camera position/rotation *//*from w w w. j ava 2s .co m*/ private void setupCameraTransform(float renderPartialTicks, int renderSceneNumber) { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); if (renderSceneNumber == 0) { // Left eye FloatBuffer leftProj = eyeRenderParams.gl_getLeftProjectionMatrix(); GL11.glLoadMatrix(leftProj); //mc.checkGLError("Set left projection"); } else { // Right eye FloatBuffer rightProj = eyeRenderParams.gl_getRightProjectionMatrix(); GL11.glLoadMatrix(rightProj); //mc.checkGLError("Set right projection"); } float var5; if (this.mc.playerController != null && this.mc.playerController.enableEverythingIsScrewedUpMode()) { var5 = 0.6666667F; GL11.glScalef(1.0F, var5, 1.0F); } GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); //First, IPD transformation if (renderSceneNumber == 0) { // Left eye FloatBuffer leftEyeTransform = eyeRenderParams.gl_getLeftViewportTransform(); GL11.glMultMatrix(leftEyeTransform); } else { // Right eye FloatBuffer rightEyeTransform = eyeRenderParams.gl_getRightViewportTransform(); GL11.glMultMatrix(rightEyeTransform); } // Camera height offset float cameraYOffset = 1.62f - (this.mc.vrSettings.getPlayerEyeHeight() - this.mc.vrSettings.neckBaseToEyeHeight); EntityLivingBase entity = this.mc.renderViewEntity; if (entity != null) { //Do in-game camera adjustments if renderViewEntity exists //A few game effects this.hurtCameraEffect(renderPartialTicks); if (this.mc.gameSettings.viewBobbing) { this.setupViewBobbing(renderPartialTicks); } var5 = this.mc.thePlayer.prevTimeInPortal + (this.mc.thePlayer.timeInPortal - this.mc.thePlayer.prevTimeInPortal) * renderPartialTicks; if (var5 > 0.0F) { byte var6 = 20; if (this.mc.thePlayer.isPotionActive(Potion.confusion)) { var6 = 7; } float var7 = 5.0F / (var5 * var5 + 5.0F) - var5 * 0.04F; var7 *= var7; GL11.glRotatef(((float) this.rendererUpdateCount + renderPartialTicks) * (float) var6, 0.0F, 1.0F, 1.0F); GL11.glScalef(1.0F / var7, 1.0F, 1.0F); GL11.glRotatef(-((float) this.rendererUpdateCount + renderPartialTicks) * (float) var6, 0.0F, 1.0F, 1.0F); } if (this.mc.gameSettings.thirdPersonView > 0) { float thirdPersonCameraDist = this.thirdPersonDistanceTemp + (this.thirdPersonDistance - this.thirdPersonDistanceTemp) * renderPartialTicks; float thirdPersonYaw; float thirdPersonPitch; if (this.mc.gameSettings.debugCamEnable) { thirdPersonYaw = this.prevDebugCamYaw + (this.debugCamYaw - this.prevDebugCamYaw) * renderPartialTicks; thirdPersonPitch = this.prevDebugCamPitch + (this.debugCamPitch - this.prevDebugCamPitch) * renderPartialTicks; GL11.glTranslatef(0.0F, 0.0F, (float) (-thirdPersonCameraDist)); GL11.glRotatef(thirdPersonYaw, 1.0F, 0.0F, 0.0F); GL11.glRotatef(thirdPersonPitch, 0.0F, 1.0F, 0.0F); } else { thirdPersonYaw = cameraYaw; thirdPersonPitch = cameraPitch; if (this.mc.gameSettings.thirdPersonView == 2) { thirdPersonPitch += 180.0F; } float PIOVER180 = (float) (Math.PI / 180); //For doing camera collision detection double camX = renderOriginX + camRelX; double camY = renderOriginY + camRelY - cameraYOffset; double camZ = renderOriginZ + camRelZ; float camXOffset = -MathHelper.sin(thirdPersonYaw * PIOVER180) * MathHelper.cos(thirdPersonPitch * PIOVER180) * thirdPersonCameraDist; float camZOffset = MathHelper.cos(thirdPersonYaw * PIOVER180) * MathHelper.cos(thirdPersonPitch * PIOVER180) * thirdPersonCameraDist; float camYOffset = -MathHelper.sin(thirdPersonPitch * PIOVER180) * thirdPersonCameraDist; thirdPersonCameraDist = checkCameraCollision(camX, camY, camZ, camXOffset, camYOffset, camZOffset, thirdPersonCameraDist); if (this.mc.gameSettings.thirdPersonView == 2) { GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); } GL11.glRotatef(cameraPitch - thirdPersonPitch, 1.0F, 0.0F, 0.0F); GL11.glRotatef(cameraYaw - thirdPersonYaw, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(0.0F, 0.0F, (float) (-thirdPersonCameraDist)); GL11.glRotatef(thirdPersonYaw - cameraYaw, 0.0F, 1.0F, 0.0F); GL11.glRotatef(thirdPersonPitch - cameraPitch, 1.0F, 0.0F, 0.0F); } } } if (!this.mc.gameSettings.debugCamEnable) { // if (this.mc.vrSettings.useQuaternions) // { // //GL11.glMultMatrix(cameraMatrix4f); // This doesn't work currently - we still need // // the weird +180... // // // So do this instead... // float[] rawYawPitchRoll = OculusRift.getEulerAngles(orientation.x, // orientation.y, // orientation.z, // orientation.w, // 1f, // OculusRift.HANDED_L, // OculusRift.ROTATE_CCW); // // if (this.mc.gameSettings.thirdPersonView == 2) // GL11.glRotatef(-rawYawPitchRoll[2], 0.0F, 0.0F, 1.0F); // else // GL11.glRotatef(rawYawPitchRoll[2], 0.0F, 0.0F, 1.0F); // // GL11.glRotatef(rawYawPitchRoll[1], 1.0F, 0.0F, 0.0F); // GL11.glRotatef(rawYawPitchRoll[0] + 180.0F, 0.0F, 1.0F, 0.0F); // } // else // { if (this.mc.gameSettings.thirdPersonView == 2) GL11.glRotatef(-this.cameraRoll, 0.0F, 0.0F, 1.0F); else GL11.glRotatef(this.cameraRoll, 0.0F, 0.0F, 1.0F); GL11.glRotatef(this.cameraPitch, 1.0F, 0.0F, 0.0F); GL11.glRotatef(this.cameraYaw + 180.0F, 0.0F, 1.0F, 0.0F); // } } GL11.glTranslated(-camRelX, cameraYOffset - camRelY, -camRelZ); if (this.debugViewDirection > 0) { int var8 = this.debugViewDirection - 1; if (var8 == 1) { GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); } if (var8 == 2) { GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); } if (var8 == 3) { GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); } if (var8 == 4) { GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); } if (var8 == 5) { GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); } } }