List of usage examples for org.lwjgl.opengl GL11 glLoadIdentity
public static native void glLoadIdentity();
From source file:com.swinggl.elements.GLFrame.java
License:Open Source License
/** * Sets the size of the window from frame edge to edge. If the window is fullscreen some sizes are limited by graphical capabilities. * * @param width - The width of the window * @param height - The height of the window *//* w w w .java2s.c o m*/ public void setSize(int width, int height) { windowWidth = width; windowHeight = height; if (fullscreen) { GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor()); if (!(windowWidth == vidmode.width() && windowHeight == vidmode.height())) { Debug.println("GLFWVidMode [" + windowWidth + ", " + windowHeight + "] not available, switching to GLFWVidMode [" + vidmode.width() + ", " + vidmode.height() + "]", Debug.ANSI_YELLOW); windowWidth = vidmode.width(); windowHeight = vidmode.height(); } } if (window != 0L) { glfwSetWindowSize(window, windowWidth, windowHeight); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, windowWidth, windowHeight, 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); } }
From source file:com.telinc1.rpjg.Game.java
License:Apache License
public void start() { // Start logging. Configurator.defaultConfig().writer(new ConsoleWriter()) .formatPattern("[{date:yyyy-MM-dd HH:mm:ss}] [{level}] [{class_name}] {message}").activate(); Logger.info("Creating and initializing game."); // Create the display. try {/*ww w. j a v a2 s . c om*/ Display.setTitle(GameOptions.GAME_NAME); Display.setResizable(false); Display.setDisplayMode(new DisplayMode(640, 360)); Display.setVSyncEnabled(true); Display.setFullscreen(false); Display.create(); } catch (LWJGLException e) { e.printStackTrace(); System.exit(ExitCodes.INIT_DISPLAY); } finally { this.isRunning = true; Logger.info("Finished display creation."); } // Initialize OpenGL. GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glClearColor(0f, 0f, 0f, 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, Display.getWidth(), Display.getHeight()); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); // Load all textures. TextureLoader.initialize(); // Initialize the game. this.initialize(); // Load the default map. this.loadMap("dungeon"); ModuleManager.getInstance().openModule(new ModuleMap()); // Main game loop while (this.isRunning() && !Display.isCloseRequested()) { // Clear the screen from the previous frame. GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); this.loop(); this.draw(); this.collectInput(); // Sync and update the display. Display.update(); Display.sync(GameOptions.FRAME_RATE); } // Free up all resources and exit. Logger.info("Close requested!"); TextureLoader.destroy(); Display.destroy(); Logger.info("Resources destroyed - exiting."); System.exit(ExitCodes.CLOSE_REQUESTED); }
From source file:de.codesourcery.flocking.LWJGLRenderer.java
License:Apache License
private void initGL() { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight()); GL11.glOrtho(0, Display.getWidth(), 0, Display.getHeight(), 1, -1); // GL11.glMatrixMode(GL11.GL_MODELVIEW); }
From source file:de.sanandrew.mods.turretmod.client.event.RenderForcefieldHandler.java
License:Creative Commons License
@SubscribeEvent(priority = EventPriority.HIGH) public void onRenderWorldLast(RenderWorldLastEvent event) { Minecraft mc = Minecraft.getMinecraft(); Entity renderEntity = mc.getRenderViewEntity(); if (renderEntity == null) { return;/*w w w. jav a 2 s . c o m*/ } final float partialTicks = event.getPartialTicks(); double renderX = renderEntity.lastTickPosX + (renderEntity.posX - renderEntity.lastTickPosX) * partialTicks; double renderY = renderEntity.lastTickPosY + (renderEntity.posY - renderEntity.lastTickPosY) * partialTicks; double renderZ = renderEntity.lastTickPosZ + (renderEntity.posZ - renderEntity.lastTickPosZ) * partialTicks; List<ForcefieldCube> cubes = new ArrayList<>(); int worldTicks = (int) (mc.world.getTotalWorldTime() % Integer.MAX_VALUE); Iterator<Map.Entry<Integer, Queue<IForcefieldProvider>>> it = this.fieldProviders.entrySet().iterator(); while (it.hasNext()) { Map.Entry<Integer, Queue<IForcefieldProvider>> entry = it.next(); Entity entity = mc.world.getEntityByID(entry.getKey()); if (entity == null || entry.getValue().size() < 1) { it.remove(); continue; } Iterator<IForcefieldProvider> itFF = entry.getValue().iterator(); while (itFF.hasNext()) { IForcefieldProvider ffProvider = itFF.next(); ColorObj color = new ColorObj(ffProvider.getShieldColor()); double entityX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks; double entityY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks; double entityZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks; ForcefieldCube cube = new ForcefieldCube( new Vec3d(entityX - renderX, entityY - renderY, entityZ - renderZ), ffProvider.getShieldBoundingBox(), color); cube.fullRendered = ffProvider.renderFull(); if (entity.isDead || !entity.isEntityAlive() || !ffProvider.isShieldActive() || !mc.world.loadedEntityList.contains(entity)) { if (ffProvider.hasSmoothFadeOut()) { this.fadeOutFields.add(cube); } itFF.remove(); } else { if (TmrConfiguration.calcForcefieldIntf) { for (ForcefieldCube intfCube : cubes) { cube.interfere(intfCube, false); intfCube.interfere(cube, true); } } cubes.add(cube); } } } Iterator<ForcefieldCube> fadeOutIt = this.fadeOutFields.iterator(); while (fadeOutIt.hasNext()) { ForcefieldCube shield = fadeOutIt.next(); if (shield.boxColor.alpha() <= 0) { fadeOutIt.remove(); } else { cubes.add(shield); shield.boxColor.setAlpha(shield.boxColor.alpha() - 3); } } Tessellator tess = Tessellator.getInstance(); for (int pass = 1; pass <= 5; pass++) { float transformTexAmount = worldTicks % 400 + event.getPartialTicks(); float texTranslateX = 0.0F; float texTranslateY = 0.0F; switch (pass) { case 1: texTranslateX = transformTexAmount * -0.01F; texTranslateY = transformTexAmount * 0.01F; mc.renderEngine.bindTexture(Resources.TURRET_FORCEFIELD_P1.getResource()); break; case 2: texTranslateX = transformTexAmount * 0.005F; texTranslateY = transformTexAmount * 0.005F; mc.renderEngine.bindTexture(Resources.TURRET_FORCEFIELD_P2.getResource()); break; case 3: texTranslateX = transformTexAmount * -0.005F; texTranslateY = transformTexAmount * 0.005F; mc.renderEngine.bindTexture(Resources.TURRET_FORCEFIELD_P1.getResource()); break; case 4: texTranslateX = transformTexAmount * 0.0025F; texTranslateY = transformTexAmount * 0.0025F; mc.renderEngine.bindTexture(Resources.TURRET_FORCEFIELD_P2.getResource()); break; case 5: texTranslateX = transformTexAmount * 0.00F; texTranslateY = transformTexAmount * 0.00F; mc.renderEngine.bindTexture(Resources.TURRET_FORCEFIELD_P3.getResource()); break; } GlStateManager.matrixMode(GL11.GL_TEXTURE); GlStateManager.loadIdentity(); GlStateManager.translate(texTranslateX, texTranslateY, 0.0F); GlStateManager.matrixMode(GL11.GL_MODELVIEW); GlStateManager.enableBlend(); GlStateManager.blendFunc(GlStateManager.SourceFactor.CONSTANT_ALPHA, GlStateManager.DestFactor.ONE_MINUS_CONSTANT_ALPHA); for (ForcefieldCube cube : cubes) { tess.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); cube.draw(tess); GL14.glBlendColor(1.0f, 1.0f, 1.0f, cube.boxColor.fAlpha() * 0.5F); GlStateManager.depthMask(false); GlStateManager.disableCull(); tess.draw(); GlStateManager.enableCull(); GlStateManager.depthMask(true); GL14.glBlendColor(1.0F, 1.0F, 1.0F, 1.0F); } GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); GlStateManager.disableBlend(); GlStateManager.matrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity(); GlStateManager.matrixMode(GL11.GL_MODELVIEW); } }
From source file:displayexample.DisplayExample.java
public void start() { x = 15;/*from w ww .ja v a 2s .c o m*/ y = 15; try { Display.setTitle("Exemple de fentre !"); Display.setDisplayMode(new DisplayMode(800, 600)); Display.create(); } catch (LWJGLException e) { e.printStackTrace(); System.exit(0); } box = new Box2D(30.0f, 50.0f, 25.0f); box.setUp(); // init OpenGL here GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, 800, 0, 600, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); while (!Display.isCloseRequested() && !Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { // render OpenGL here box.draw(); pollInput(); Display.update(); Display.sync(60); } Display.destroy(); System.exit(0); }
From source file:dripdisplay.DripDisplayLWJGL.java
protected void initGLLWJGL() { if (!LEVEL_EDITOR) { GL11.glViewport(0, 0, 800, 600); } else {/*from ww w .j a v a 2s . c o m*/ GL11.glViewport(0, 0, 1000, 800); } GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); if (!LEVEL_EDITOR) { GL11.glOrtho(0, 800, 600, 0, 1, -1); } else { GL11.glOrtho(0, 1000, 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:edu.csun.ecs.cs.multitouchj.ui.control.FramedControl.java
License:Apache License
public void render() { // render with no texture Texture texture = getTexture();//from w w w .j a v a 2 s . com setTexture((Texture) null); GL11.glPushMatrix(); GL11.glLoadIdentity(); super.render(); GL11.glPopMatrix(); setTexture(texture); // rendering texture if ((!isVisible()) || (texture == null)) { return; } Size controlSize = getSize(); Size imageSize = texture.getImage().getSize(); float margin = getMargin(); if ((margin >= controlSize.getWidth()) || (margin >= controlSize.getHeight())) { margin = 0.0f; } Color color = getColor(); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(((float) color.getRed() / 255.0f), ((float) color.getGreen() / 255.0f), ((float) color.getBlue() / 255.0f), getOpacity()); Point position = getOpenGlPosition(); float halfWidth = (controlSize.getWidth() / 2.0f); float halfHeight = (controlSize.getHeight() / 2.0f); GL11.glTranslatef(position.getX(), position.getY(), 0.0f); float rotation = OpenGlUtility.getOpenGlRotation(getRotation()); GL11.glRotatef(rotation, 0.0f, 0.0f, 1.0f); // render texture GL11.glEnable(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT); GL11.glBindTexture(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT, texture.getId().intValue()); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex3f(((-1 * halfWidth) + margin), ((-1 * halfHeight) + margin), 0.0f); GL11.glTexCoord2f(imageSize.getWidth(), 0.0f); GL11.glVertex3f((halfWidth - margin), ((-1 * halfHeight) + margin), 0.0f); GL11.glTexCoord2f(imageSize.getWidth(), imageSize.getHeight()); GL11.glVertex3f((halfWidth - margin), (halfHeight - margin), 0.0f); GL11.glTexCoord2f(0.0f, imageSize.getHeight()); GL11.glVertex3f(((-1 * halfWidth) + margin), (halfHeight - margin), 0.0f); GL11.glEnd(); }
From source file:edu.csun.ecs.cs.multitouchj.ui.graphic.WindowManager.java
License:Apache License
protected void renderControl(Control control) { GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glPushMatrix();/*from ww w .ja va 2s .c o m*/ GL11.glLoadIdentity(); control.render(); GL11.glPopMatrix(); GL11.glPopAttrib(); }
From source file:edu.csun.ecs.cs.multitouchj.ui.graphic.WindowManager.java
License:Apache License
protected void initializeOpenGl() { DisplayMode displayMode = displayManager.getCurrentDisplayMode(); GL11.glEnable(GL11.GL_DEPTH_TEST);/*from w w w .j av a 2s . com*/ GL11.glClearDepth(1.0f); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glViewport(0, 0, displayMode.getWidth(), displayMode.getHeight()); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); //GLU.gluPerspective(45.0f, (float)SCREEN_WIDTH/(float)SCREEN_HEIGHT, 4.0f, 4000.0f); GLU.gluPerspective(45.0f, (float) displayMode.getWidth() / (float) displayMode.getHeight(), 1.0f, 100.0f); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); //GL11.glClearDepth(1.0f); //GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); //GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glCullFace(GL11.GL_BACK); }
From source file:edu.csun.ecs.cs.multitouchj.ui.graphic.WindowManager.java
License:Apache License
protected void clearOpenGl() { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glLoadIdentity(); }