@Override
  public void main(int delta) {

    GameData.render();

    GL11.glLoadIdentity();
    GL11.glOrtho(0, GameSettings.getScreenX(), 0, GameSettings.getScreenY(), -1, 1);

    GL11.glColor4d(0, 0, 0, .7);
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GL11.glVertex2d(0, 0);
    GL11.glVertex2d(GameSettings.getScreenX(), 0);
    GL11.glVertex2d(GameSettings.getScreenX(), GameSettings.getScreenY());
    GL11.glVertex2d(0, GameSettings.getScreenY());
    GL11.glEnd();

    float ratio = ((float) (GameSettings.getScreenY()) / GameSettings.getScreenX());
    GL11.glLoadIdentity();
    GL11.glOrtho(
        -GameData.zoom,
        GameSettings.getScreenX() + GameData.zoom,
        -GameData.zoom * (ratio),
        GameSettings.getScreenY() + GameData.zoom * (ratio),
        -1,
        1);

    for (Button b : buttons) {
      b.render();
    }
  }
Пример #2
0
  private void init(boolean absolutePixels, boolean testModes) {
    // find out what the current bits per pixel of the desktop is
    int currentBpp = Display.getDisplayMode().getBitsPerPixel();

    try {
      DisplayMode mode;
      if (testModes) mode = findDisplayMode(WINDOW_WIDTH, WINDOW_HEIGHT, currentBpp);
      else mode = new DisplayMode(WINDOW_WIDTH, WINDOW_HEIGHT);

      Display.setDisplayMode(mode);
      Display.setFullscreen(false);
      Display.setTitle("src");
      Display.create();
    } catch (LWJGLException e) {
      e.printStackTrace();
    }

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    double aspectRatio = (double) WINDOW_WIDTH / WINDOW_HEIGHT;

    if (absolutePixels) {
      glOrtho(0.0d, WINDOW_WIDTH, 0.0d, WINDOW_HEIGHT, 1.0d, -1.0d);
    } else {
      glOrtho(aspectRatio, -aspectRatio, -1.0d, 1.0d, 1.0d, -1.0d);
    }

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
  }
Пример #3
0
  public void render() {
    glPushMatrix();
    glLoadIdentity();
    glOrtho(0, Juego.obtenerAnchura(), Juego.obtenerAltura(), 0, 1, -1);
    uFont.drawString(x, y, texto);

    glLoadIdentity();
    glOrtho(0, Juego.obtenerAnchura(), 0, Juego.obtenerAltura(), 1, -1);
    glPopMatrix();
  }
Пример #4
0
  public void start() {
    try {
      Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
      Display.create();
      Display.setFullscreen(true);
    } catch (LWJGLException e) {
      e.printStackTrace();
      System.exit(0);
    }

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glClearAccum(0f, 0f, 0f, 1f);
    GL11.glClear(GL11.GL_ACCUM_BUFFER_BIT);

    while (!Display.isCloseRequested() && !finished) {
      if (System.currentTimeMillis() - time > 1000) {
        System.out.println(framecount + " FPS");
        time = System.currentTimeMillis();
        framecount = 0;
      }

      GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

      GL11.glColor3f(1, 1, 1);

      GL11.glMatrixMode(GL11.GL_MODELVIEW);
      GL11.glLoadIdentity();
      GL11.glOrtho(0, WIDTH, HEIGHT, 0, -10, 10);
      Manager.DrawBackground();

      GL11.glMatrixMode(GL11.GL_MODELVIEW);
      GL11.glLoadIdentity();
      GL11.glOrtho(0, WIDTH, HEIGHT, 0, -10, 10);

      GL11.glTranslatef(-Camera.x, -Camera.y, 0);
      Display.sync(60);

      Manager.Draw();
      Manager.Update();

      GL11.glMatrixMode(GL11.GL_MODELVIEW);
      GL11.glLoadIdentity();
      GL11.glOrtho(0, WIDTH, HEIGHT, 0, -10, 10);
      Manager.DrawForeground();

      Display.update();

      framecount++;
    }
  }
Пример #5
0
  public void start() {
    System.out.println("SplitMan starting...");
    try {
      Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
      Display.setResizable(false);
      Display.setVSyncEnabled(true);
      Display.setTitle("SplitMan");
      Display.create();
    } catch (Exception e) {
      e.printStackTrace();
      Display.destroy();
      System.exit(1);
    }
    WIDTH = Display.getWidth();
    HEIGHT = Display.getHeight();
    System.out.println("Display: " + WIDTH + " x " + HEIGHT);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, WIDTH, HEIGHT, 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    Resources.load();

    setScreen(new GuiGame());
    System.out.println("SplitMan started");
  }
Пример #6
0
 public static void resizedRefresh() {
   GL11.glMatrixMode(GL11.GL_PROJECTION);
   GL11.glLoadIdentity(); // Resets any previous projection matrices
   GL11.glOrtho(0, Display.getWidth(), 0, Display.getHeight(), 1000, -1000);
   GL11.glMatrixMode(GL11.GL_MODELVIEW);
   GL11.glLoadIdentity();
 }
Пример #7
0
 /** Update the display of the achievement window to match the game window. */
 private void updateAchievementWindowScale() {
   GL11.glViewport(0, 0, this.theGame.displayWidth, this.theGame.displayHeight);
   GL11.glMatrixMode(GL11.GL_PROJECTION);
   GL11.glLoadIdentity();
   GL11.glMatrixMode(GL11.GL_MODELVIEW);
   GL11.glLoadIdentity();
   this.achievementWindowWidth = this.theGame.displayWidth;
   this.achievementWindowHeight = this.theGame.displayHeight;
   ScaledResolution var1 =
       new ScaledResolution(
           this.theGame.gameSettings, this.theGame.displayWidth, this.theGame.displayHeight);
   this.achievementWindowWidth = var1.getScaledWidth();
   this.achievementWindowHeight = var1.getScaledHeight();
   GL11.glClear(256);
   GL11.glMatrixMode(GL11.GL_PROJECTION);
   GL11.glLoadIdentity();
   GL11.glOrtho(
       0.0D,
       (double) this.achievementWindowWidth,
       (double) this.achievementWindowHeight,
       0.0D,
       1000.0D,
       3000.0D);
   GL11.glMatrixMode(GL11.GL_MODELVIEW);
   GL11.glLoadIdentity();
   GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
 }
Пример #8
0
  public static void initOrtho(int width, int height) {
    glEnable(GL_TEXTURE_2D);

    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

    glEnable(GL_BLEND);
    //		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glBlendFunc(GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    //		glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE_MINUS_CONSTANT_COLOR);
    //		GL11.glDisable(GL_BLEND);
    //		GL11.glDepthMask(true);

    glEnable(GL_ALPHA_TEST);
    glAlphaFunc(GL_GREATER, 0.1f);

    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do

    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
    glLoadIdentity(); // Reset The Projection Matrix

    // Calculate The Aspect Ratio Of The Window
    glOrtho(0, width, 0, height, -99999, 99999);
    glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  }
Пример #9
0
  /**
   * Initialise the game
   *
   * @throws Exception if init fails
   */
  private static void init() throws Exception {
    // Create a fullscreen window with 1:1 orthographic 2D projection, and with
    // mouse, keyboard, and gamepad inputs.
    Display.setTitle(GAME_TITLE);
    Display.setFullscreen(true);

    // Enable vsync if we can
    Display.setVSyncEnabled(true);

    Display.create();

    // Start up the sound system
    AL.create();

    // TODO: Load in your textures etc here

    // Put the window into orthographic projection mode with 1:1 pixel ratio.
    // We haven't used GLU here to do this to avoid an unnecessary dependency.
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(
        0.0,
        Display.getDisplayMode().getWidth(),
        0.0,
        Display.getDisplayMode().getHeight(),
        -1.0,
        1.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
  }
Пример #10
0
 protected void setupGLState() {
   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.glMatrixMode(GL11.GL_PROJECTION);
   GL11.glPushMatrix();
   GL11.glLoadIdentity();
   GL11.glOrtho(0, width, height, 0, -1.0, 1.0);
   GL11.glMatrixMode(GL11.GL_MODELVIEW);
   GL11.glPushMatrix();
   GL11.glLoadIdentity();
   GL11.glEnable(GL11.GL_TEXTURE_2D);
   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);
 }
Пример #11
0
  public Render(Level level) {
    this.level = level;
    try {
      Display.setFullscreen(true);
    } catch (LWJGLException e) {
      e.printStackTrace();
    }

    // Enable vsync if we can
    Display.setVSyncEnabled(true);

    try {
      Display.create();
    } catch (LWJGLException e) {
      e.printStackTrace();
    }

    // Put the window into orthographic projection mode with 1:1 pixel
    // ratio.
    // We haven't used GLU here to do this to avoid an unnecessary
    // dependency.

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(
        0.0,
        Display.getDisplayMode().getWidth(),
        0.0,
        Display.getDisplayMode().getHeight(),
        -1.0,
        1.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
  }
Пример #12
0
 private void initGL() {
   try {
     Display.setDisplayMode(new DisplayMode(GS.FRAMEWIDTH, GS.FRAMEHEIGHT));
     Display.setFullscreen(true);
     Display.create();
     Display.setVSyncEnabled(true);
   } catch (LWJGLException e) {
     e.printStackTrace();
     Display.destroy();
     System.exit(1);
   }
   GL11.glEnable(GL11.GL_TEXTURE_2D);
   // GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
   GL11.glClearDepth(1.0f);
   // GL11.glEnable(GL11.GL_DEPTH_TEST);
   // GL11.glDepthFunc(GL11.GL_ADD); //Wenn nicht auskommentiert führt es zu Exception
   GL11.glMatrixMode(GL11.GL_PROJECTION);
   GL11.glViewport(0, 0, GS.FRAMEWIDTH, GS.FRAMEHEIGHT);
   GL11.glOrtho(0, GS.FRAMEWIDTH, GS.FRAMEHEIGHT, 0, 0, 128);
   GL11.glEnable(GL11.GL_BLEND);
   GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
   // GL11.glBlendEquation( BLENDING_EQUATIONS[blendingEquationIndex]);
   GL11.glShadeModel(GL11.GL_FLAT);
   GL11.glMatrixMode(GL11.GL_MODELVIEW);
   GL11.glEnable(GL11.GL_ALPHA_TEST);
   GL11.glAlphaFunc(GL11.GL_GREATER, 0);
   GL11.glCullFace(GL11.GL_BACK);
   glEnable(GL_CULL_FACE);
   glCullFace(GL_BACK);
   GL11.glLoadIdentity();
 }
Пример #13
0
  /**
   * Enter the orthographic mode
   *
   * @param xsize The size of the panel being used
   * @param ysize The size of the panel being used
   */
  protected void enterOrtho(int xsize, int ysize) {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, width, height, 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    GL11.glTranslatef((width - xsize) / 2, (height - ysize) / 2, 0);
  }
Пример #14
0
 /**
  * Applies an orthographic projection matrix. The matrix mode will be returned it its previous
  * value. GL_MODELVIEW.
  */
 public void applyOrthographicMatrix() {
   int previousMatrixMode = glGetInteger(GL_MATRIX_MODE);
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   // TODO: Add aspect ratio handling for glOrtho
   glOrtho(-1, 1, -1, 1, 0, 10000);
   glMatrixMode(previousMatrixMode);
 }
Пример #15
0
  private void initGL() {
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // sets background to grey
    glClearDepth(1.0f); // clear depth buffer
    glEnable(GL_DEPTH_TEST); // Enables depth testing
    glDepthFunc(GL_LEQUAL); // sets the type of test to use for depth testing
    glMatrixMode(GL_PROJECTION); // sets the matrix mode to project

    // GLU.gluOrtho2D(-10, 10, -10, 10);
    // GLU.gluOrtho2D(0 - COORD_WIDTH / 2, 0 + COORD_WIDTH / 2, 0 - COORD_HEIGHT / 2, 0 +
    // COORD_HEIGHT / 2);
    float fovy = 90.0f;
    float aspect = DISPLAY_MODE.getWidth() / (float) DISPLAY_MODE.getHeight();
    float zNear = 0.1f;
    float zFar = 20000.0f;
    GLU.gluPerspective(fovy, aspect, zNear, zFar);

    glViewport(0, 0, DISPLAY_MODE.getWidth(), DISPLAY_MODE.getHeight());
    // GLU.gluOrtho2D(-10, 10, -10, 10);
    // GLU.gluOrtho2D(-1, 1, -1, 1);

    glOrtho(
        0 - COORD_WIDTH / 2,
        0 + COORD_WIDTH / 2,
        0 - COORD_HEIGHT / 2,
        0 + COORD_HEIGHT / 2,
        zNear,
        zFar);

    System.out.println(COORD_WIDTH + ", " + COORD_HEIGHT);

    glMatrixMode(GL_MODELVIEW);

    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

    // ----------- Variables & method calls added for Lighting Test -----------//
    initLightArrays();
    glShadeModel(GL_SMOOTH);
    glMaterial(GL_FRONT, GL_SPECULAR, matSpecular); // sets specular material color
    glMaterialf(GL_FRONT, GL_SHININESS, 50.0f); // sets shininess

    glLight(GL_LIGHT0, GL_POSITION, lightPosition); // sets light position
    glLight(GL_LIGHT0, GL_SPECULAR, whiteLight); // sets specular light to white
    glLight(GL_LIGHT0, GL_DIFFUSE, whiteLight); // sets diffuse light to white
    glLightModel(GL_LIGHT_MODEL_AMBIENT, lModelAmbient); // global ambient light

    glEnable(GL_LIGHTING); // enables lighting
    glEnable(GL_LIGHT0); // enables light0

    glEnable(GL_COLOR_MATERIAL); // enables opengl to use glColor3f to define material color
    glColorMaterial(
        GL_FRONT,
        GL_AMBIENT_AND_DIFFUSE); // tell opengl glColor3f effects the ambient and diffuse properties
                                 // of material
    // ----------- END: Variables & method calls added for Lighting Test -----------//

  }
Пример #16
0
 public static void orthoMode(Size size) {
   GL11.glDisable(GL11.GL_DEPTH_TEST);
   GL11.glMatrixMode(GL11.GL_PROJECTION);
   GL11.glPushMatrix();
   GL11.glLoadIdentity();
   GL11.glOrtho(0, size.getWidth(), 0, size.getHeight(), -10, 10);
   GL11.glMatrixMode(GL11.GL_MODELVIEW);
   GL11.glPushMatrix();
   GL11.glLoadIdentity();
 }
Пример #17
0
 private void setupDisplay() {
   int width = Display.getWidth();
   int height = Display.getHeight();
   GL11.glMatrixMode(GL11.GL_PROJECTION);
   GL11.glLoadIdentity();
   GL11.glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1);
   GL11.glMatrixMode(GL11.GL_MODELVIEW);
   GL11.glScissor(0, 0, width, height);
   GL11.glViewport(0, 0, width, height);
   renderHandler.init();
 }
Пример #18
0
  /** @see GameState#render(clusterfun.ui.window.GameWindow, int) */
  public void render(GameWindow window, boolean picking) {
    // CLEAR the screen
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);

    GL11.glLoadIdentity();
    GL11.glOrtho(0, 800, 600, 0, -1, 1);

    // RENDER the loading image
    pleaseWait.render();

    rendered = true;
  }
Пример #19
0
 private void loadOrthogonal() {
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glOrtho(
       -LWJGLSandbox.DISPLAY_WIDTH / FACTOR,
       LWJGLSandbox.DISPLAY_WIDTH / FACTOR,
       -LWJGLSandbox.DISPLAY_HEIGHT / FACTOR,
       LWJGLSandbox.DISPLAY_HEIGHT / FACTOR,
       CLIP_NEAR,
       CLIP_FAR);
   glMatrixMode(GL_MODELVIEW);
 }
Пример #20
0
  private static void initGL() {
    // Allows texturing
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    // Sets up camera
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, width, height, 0, zNear, -zFar);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
  }
Пример #21
0
 private void globaldraw() {
   GL11.glMatrixMode(GL11.GL_PROJECTION);
   GL11.glLoadIdentity();
   GL11.glOrtho(
       0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight(), -1, 1);
   GL11.glMatrixMode(GL11.GL_MODELVIEW);
   GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);
   for (int i = 0; i < blocks.size(); i++) blocks.get(i).onDraw(xorig);
   player.onDraw();
   Display.sync(120);
   setPoints();
 }
Пример #22
0
 /** R_SetGL2D */
 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);
 }
Пример #23
0
  @Override
  protected void init() {
    glEnable(GL_LINE_SMOOTH);
    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); // brak efektu na moim kompie
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glMatrixMode(GL_PROJECTION); // chcemy zrobić coś na macierzy projekcji
    glLoadIdentity();
    if (width > height) {
      glOrtho(-5 * (float) width / height, 5 * (float) width / height, -5, 5, -5, 5);
    } else {

      glOrtho(-5, 5, -5 * (float) height / width, 5 * (float) height / width, -5, 5);
    }
    // glTranslatef(-0.5f, -0.5f, 0);
    // glScalef(0.5f, 0.5f, 0.5f);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(1, 1, 1, 0, 0, 0, 0, 1, 0);
    // glScalef(0.5f, 0.5f, 0.5f);

    buffer.rewind();
    buffer.put(data);
    buffer.rewind();

    brickIndices.rewind();
    brickIndices.put(indidata);
    brickIndices.rewind();

    paintedWall.rewind();
    paintedWall.put(paintedWallindi);
    paintedWall.rewind();

    glInterleavedArrays(GL_C3F_V3F, 0, buffer);
  }
Пример #24
0
  public Game() {

    try {

      Display.setDisplayMode(new DisplayMode(800, 600));
      Display.create();

      GL11.glMatrixMode(GL11.GL_PROJECTION);
      GL11.glLoadIdentity();
      GL11.glOrtho(0, 800, 0, 600, 1, -1);
      GL11.glMatrixMode(GL11.GL_MODELVIEW);

    } catch (LWJGLException e) {
      gtest.util.Logger.exception(e);
    }
  }
Пример #25
0
  private void loop() {
    GL.createCapabilities();
    System.out.println("OPENGL VERSION " + glGetString(GL_VERSION));
    glClearColor(0, 0, 0, 0);
    glEnable(GL_TEXTURE_2D);
    glDisable(GL_DEPTH_TEST);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, WORLD_X, WORLD_Y, 0, -1, 1);

    while (!glfwWindowShouldClose(winID)) {
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      drawMe();
      glfwSwapBuffers(winID);
      glfwPollEvents();
    }
  }
Пример #26
0
  @Override
  public void init(int width, int height) {
    this.screenWidth = width;

    // init OpenGL
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, this.screenWidth, 0, height, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_DEPTH);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    System.out.println("OpenGL version: " + GL11.glGetString(GL11.GL_VERSION));
  }
Пример #27
0
 private void loadScreen() throws LWJGLException {
   ScaledResolution scaledresolution =
       new ScaledResolution(gameSettings, displayWidth, displayHeight);
   GL11.glClear(16640);
   GL11.glMatrixMode(5889 /*GL_PROJECTION*/);
   GL11.glLoadIdentity();
   GL11.glOrtho(
       0.0D, scaledresolution.field_25121_a, scaledresolution.field_25120_b, 0.0D, 1000D, 3000D);
   GL11.glMatrixMode(5888 /*GL_MODELVIEW0_ARB*/);
   GL11.glLoadIdentity();
   GL11.glTranslatef(0.0F, 0.0F, -2000F);
   GL11.glViewport(0, 0, displayWidth, displayHeight);
   GL11.glClearColor(0.0F, 0.0F, 0.0F, 0.0F);
   Tessellator tessellator = Tessellator.instance;
   GL11.glDisable(2896 /*GL_LIGHTING*/);
   GL11.glEnable(3553 /*GL_TEXTURE_2D*/);
   GL11.glDisable(2912 /*GL_FOG*/);
   GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, renderEngine.getTexture("/title/mojang.png"));
   tessellator.startDrawingQuads();
   tessellator.setColorOpaque_I(0xffffff);
   tessellator.addVertexWithUV(0.0D, displayHeight, 0.0D, 0.0D, 0.0D);
   tessellator.addVertexWithUV(displayWidth, displayHeight, 0.0D, 0.0D, 0.0D);
   tessellator.addVertexWithUV(displayWidth, 0.0D, 0.0D, 0.0D, 0.0D);
   tessellator.addVertexWithUV(0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
   tessellator.draw();
   char c = '\u0100';
   char c1 = '\u0100';
   GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
   tessellator.setColorOpaque_I(0xffffff);
   func_6274_a(
       (scaledresolution.getScaledWidth() - c) / 2,
       (scaledresolution.getScaledHeight() - c1) / 2,
       0,
       0,
       c,
       c1);
   GL11.glDisable(2896 /*GL_LIGHTING*/);
   GL11.glDisable(2912 /*GL_FOG*/);
   GL11.glEnable(3008 /*GL_ALPHA_TEST*/);
   GL11.glAlphaFunc(516, 0.1F);
   Display.swapBuffers();
 }
Пример #28
0
  public static void main(String[] args) {
    try {
      Display.setDisplayMode(new DisplayMode(640, 480));
      Display.setTitle("Timer Demo");
      Display.create();
    } catch (LWJGLException e) {
      e.printStackTrace();
      Display.destroy();
      System.exit(1);
    }

    int x = 100;
    int y = 100;
    int dx = 1;
    int dy = 1;

    // Initialization code OpenGL
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, 640, 480, 0, 1, -1);
    glMatrixMode(GL_MODELVIEW);

    lastFrame = getTime();

    while (!Display.isCloseRequested()) {
      // Render

      glClear(GL_COLOR_BUFFER_BIT);

      double delta = getDelta();
      x += delta * dx * 0.1;
      y += delta * dy * 0.1;

      glRecti(x, y, x + 30, y + 30);

      Display.update();
      Display.sync(60);
    }

    Display.destroy();
    System.exit(0);
  }
Пример #29
0
 private void updateAchievementWindowScale() {
   GL11.glViewport(0, 0, theGame.displayWidth, theGame.displayHeight);
   GL11.glMatrixMode(5889 /*GL_PROJECTION*/);
   GL11.glLoadIdentity();
   GL11.glMatrixMode(5888 /*GL_MODELVIEW0_ARB*/);
   GL11.glLoadIdentity();
   achievementWindowWidth = theGame.displayWidth;
   achievementWindowHeight = theGame.displayHeight;
   ScaledResolution scaledresolution =
       new ScaledResolution(theGame.gameSettings, theGame.displayWidth, theGame.displayHeight);
   achievementWindowWidth = scaledresolution.getScaledWidth();
   achievementWindowHeight = scaledresolution.getScaledHeight();
   GL11.glClear(256);
   GL11.glMatrixMode(5889 /*GL_PROJECTION*/);
   GL11.glLoadIdentity();
   GL11.glOrtho(0.0D, achievementWindowWidth, achievementWindowHeight, 0.0D, 1000D, 3000D);
   GL11.glMatrixMode(5888 /*GL_MODELVIEW0_ARB*/);
   GL11.glLoadIdentity();
   GL11.glTranslatef(0.0F, 0.0F, -2000F);
 }
  private static void renderHUDOverlayItem(
      Minecraft minecraft, EntityPlayer entityPlayer, ItemStack itemStack) {
    float overlayScale = 2f;
    float overlayOpacity = 1f;
    GL11.glPushMatrix();
    ScaledResolution sr =
        new ScaledResolution(minecraft, minecraft.displayWidth, minecraft.displayHeight);
    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(
        0.0D, sr.getScaledWidth_double(), sr.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
    GL11.glPushMatrix();
    RenderHelper.enableGUIStandardItemLighting();
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glEnable(GL11.GL_COLOR_MATERIAL);
    GL11.glEnable(GL11.GL_LIGHTING);
    int hudOverlayX = 0;
    int hudOverlayY = 0;

    hudOverlayX = (int) (sr.getScaledWidth() - 16 * overlayScale);
    hudOverlayY = (int) (sr.getScaledHeight() - 16 * overlayScale);

    RenderUtils.renderItemIntoGUI(
        minecraft.fontRenderer,
        itemStack,
        hudOverlayX,
        hudOverlayY,
        overlayOpacity,
        overlayScale,
        -90);

    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();
    GL11.glPopMatrix();
  }