Exemplo n.º 1
2
  public static void setClearColor(float red, float green, float blue) {
    clearColor[0] = red;
    clearColor[1] = green;
    clearColor[2] = blue;

    if (isShadowPass) {
      glClearColor(clearColor[0], clearColor[1], clearColor[2], 1.0f);
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      return;
    }

    glDrawBuffers(dfbDrawBuffers);
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glDrawBuffers(GL_COLOR_ATTACHMENT0_EXT);
    glClearColor(clearColor[0], clearColor[1], clearColor[2], 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glDrawBuffers(GL_COLOR_ATTACHMENT1_EXT);
    glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glDrawBuffers(dfbDrawBuffers);
  }
Exemplo n.º 2
0
  /** R_Clear */
  void R_Clear() {
    if (gl_ztrick.value != 0.0f) {

      if (gl_clear.value != 0.0f) {
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
      }

      trickframe++;
      if ((trickframe & 1) != 0) {
        gldepthmin = 0;
        gldepthmax = 0.49999f;
        GL11.glDepthFunc(GL11.GL_LEQUAL);
      } else {
        gldepthmin = 1;
        gldepthmax = 0.5f;
        GL11.glDepthFunc(GL11.GL_GEQUAL);
      }
    } else {
      if (gl_clear.value != 0.0f) GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
      else GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);

      gldepthmin = 0;
      gldepthmax = 1;
      GL11.glDepthFunc(GL11.GL_LEQUAL);
    }
    GL11.glDepthRange(gldepthmin, gldepthmax);
  }
Exemplo n.º 3
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++;
    }
  }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
0
  public void draw() {
    // Clear The Screen And The Depth Buffer
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    if (camera != null) {
      camera.updatePosition();
    } else {
      camera = (Camera) object_list.getItem(Camera.CAMERA_NAME);
      if (camera != null) {
        camera.updatePosition();
      } else {
        System.out.println("WARNING: Tried to draw without camera set...");
        return;
      }
    }

    // Draw the 3d stuff
    for (Entity ent : object_list.getEntitiesAndSubEntities()) {
      Boolean should_draw = (Boolean) ent.getProperty(Entity.SHOULD_DRAW);
      if (should_draw == null) should_draw = false;
      if (should_draw) ent.drawProgrammablePipe();
    }

    // Draw the window manager stuff
    if (window_manager != null) window_manager.draw();

    Display.update();
  }
Exemplo n.º 6
0
  public void render() {
    lock.lock();

    quads = 0;
    draw_calls = 0;
    batch_draw_calls = 0;

    GL11.glLoadIdentity();
    GLU.gluLookAt(
        camera.pos.x,
        camera.pos.y,
        camera.pos.z,
        camera.pos.x + camera.look.x,
        camera.pos.y + camera.look.y,
        camera.pos.z + camera.look.z,
        camera.up.x,
        camera.up.y,
        camera.up.z);

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

    for (ChunkNode.Batch batch : batches) render_batch(batch);

    GL11.glFlush();

    lock.unlock();
  }
Exemplo n.º 7
0
 /* (non-Javadoc)
  * @see chu.engine.Game#loop()
  */
 @Override
 public void loop() {
   while (!Display.isCloseRequested()) {
     final long time = System.nanoTime();
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
     glClearDepth(1.0f);
     getInput();
     final ArrayList<Message> messages = new ArrayList<>();
     if (client != null) {
       synchronized (client.messagesLock) {
         messages.addAll(client.messages);
         for (Message m : messages) client.messages.remove(m);
       }
     }
     SoundStore.get().poll(0);
     glPushMatrix();
     // Global resolution scale
     //			Renderer.scale(scaleX, scaleY);
     currentStage.beginStep(messages);
     currentStage.onStep();
     currentStage.processAddStack();
     currentStage.processRemoveStack();
     currentStage.render();
     //				FEResources.getBitmapFont("stat_numbers").render(
     //						(int)(1.0f/getDeltaSeconds())+"", 440f, 0f, 0f);
     currentStage.endStep();
     glPopMatrix();
     Display.update();
     timeDelta = System.nanoTime() - time;
   }
   AL.destroy();
   Display.destroy();
   if (client != null && client.isOpen()) client.quit();
 }
Exemplo n.º 8
0
  public void renderGL() {
    GL11.glClear(
        GL11.GL_COLOR_BUFFER_BIT
            | GL11.GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer

    GL11.glColor3f(0.5f, 0.5f, 1.0f); // set the color of the quad (R,G,B,A)
    GL11.glBegin(GL11.GL_QUADS); // draw quad
    GL11.glVertex2f(100, 100);
    GL11.glVertex2f(100 + 200, 100);
    GL11.glVertex2f(100 + 200, 100 + 200);
    GL11.glVertex2f(100, 100 + 200);
    GL11.glEnd();

    font.draw_str("HELLO", 150, 150);

    s.draw(100, 400, 2f);
    s.draw(300, 400, 2.23f);

    GL11.glColor3f(0.5f, 0.5f, 1.0f); // R,G,B,A Set The Color To Blue One Time Only
    GL11.glPushMatrix(); // draw quad
    GL11.glTranslatef(x, y, 0);
    GL11.glRotatef(rotation, 0f, 0f, 1f);
    GL11.glTranslatef(-x, -y, 0);

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2f(x - 50, y - 50);
    GL11.glVertex2f(x + 50, y - 50);
    GL11.glVertex2f(x + 50, y + 50);
    GL11.glVertex2f(x - 50, y + 50);
    GL11.glEnd();
    GL11.glPopMatrix();
  }
Exemplo n.º 9
0
  /** R_SetPalette */
  protected void R_SetPalette(byte[] palette) {
    // 256 RGB values (768 bytes)
    // or null
    int i;
    int color = 0;

    if (palette != null) {
      int j = 0;
      for (i = 0; i < 256; i++) {
        color = (palette[j++] & 0xFF) << 0;
        color |= (palette[j++] & 0xFF) << 8;
        color |= (palette[j++] & 0xFF) << 16;
        color |= 0xFF000000;
        r_rawpalette[i] = color;
      }
    } else {
      for (i = 0; i < 256; i++) {
        r_rawpalette[i] = d_8to24table[i] | 0xff000000;
      }
    }
    GL_SetTexturePalette(r_rawpalette);

    GL11.glClearColor(0, 0, 0, 0);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
    GL11.glClearColor(1f, 0f, 0.5f, 0.5f);
  }
Exemplo n.º 10
0
  public void clearBuffers(boolean color, boolean depth, boolean stencil) {
    int bits = 0;
    if (color) {
      // See explanations of the depth below, we must enable color write to be able to clear the
      // color buffer
      if (context.colorWriteEnabled == false) {
        glColorMask(true, true, true, true);
        context.colorWriteEnabled = true;
      }
      bits = GL_COLOR_BUFFER_BIT;
    }
    if (depth) {

      // glClear(GL_DEPTH_BUFFER_BIT) seems to not work when glDepthMask is false
      // here s some link on openl board
      // http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=257223
      // if depth clear is requested, we enable the depthMask
      if (context.depthWriteEnabled == false) {
        glDepthMask(true);
        context.depthWriteEnabled = true;
      }
      bits |= GL_DEPTH_BUFFER_BIT;
    }
    if (stencil) {
      bits |= GL_STENCIL_BUFFER_BIT;
    }
    if (bits != 0) {
      glClear(bits);
    }
  }
Exemplo n.º 11
0
  /**
   * The menu sequence that allows the user to select options.
   *
   * <p>
   *
   * <ul>
   *   <li>QuickStart (random character created for the player)
   *   <li>Create new character
   *   <li>Load a character
   *   <li>
   *   <li>Settings, including keybindings
   *   <li>Quit
   * </ul>
   */
  private void menuSelectionSequence() {

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

    Input.poll();
    mouseEvents = Input.getMouseEvents();

    for (GLUIComponent b : menuSelectionButtons) {

      b.processMouseEvents(mouseEvents);
      b.update(0);
      b.renderGL();
    }

    try {
      menuTheme
          .getFont()
          .glDrawText(
              "\\c#FFFFFFUniQuest",
              (Main.SCREEN_WIDTH - menuTheme.getFont().getStringWidth("UniQuest")) / 2 + 2,
              50);
    } catch (InvalidEscapeSequenceException e) {
      e.printStackTrace();
    }

    Display.update();

    if (Display.isCloseRequested()) {
      Game.GAME_STATE = Game.GAME_STATE_QUIT;
      menu = false;
    }
  }
Exemplo n.º 12
0
 public static void render() {
   GL11.glClearColor(0f, 255f / 191f, 1f, 0f);
   GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
   GL11.glColor3f(0.5f, 0.5f, 1.0f);
   GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
   GL11.glLoadIdentity();
   lookThrough();
   /*doPicking();
   namemap = new HashMap<Integer, Location>();
   Render.renderArray(world.getSpawn());
   GL11.glLoadIdentity();
   game.render();
   stopPicking();*/
   // Picking junk
   /*GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
   GL11.glColor3f(0.5f,0.5f,1.0f);
   GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
   GL11.glLoadIdentity();
   lookThrough();*/
   Render.renderArray(world.getSpawn());
   Render.renderEntities(world.entities);
   /*GL11.glLoadIdentity();
   game.render();*/
   Display.update();
 }
  public void display(long deltaTime) {
    Display.sync(60);
    elapsedTime += deltaTime;

    if (Display.wasResized()) resize();

    float[] offsets = computePositionOffsets(0, 0, deltaTime);
    float xOffset = offsets[0];
    float yOffset = offsets[1];
    adjustVertexData(xOffset, yOffset);

    glClearColor(0, 0, 0, 0);
    glClear(GL_COLOR_BUFFER_BIT);

    glUseProgram(program);

    glBindBuffer(GL_ARRAY_BUFFER, positionBufferObject);
    glEnableVertexAttribArray(0);
    glVertexAttribPointer(0, 4, GL_FLOAT, false, 0, 0);

    glDrawArrays(GL_TRIANGLES, 0, 3);

    glDisableVertexAttribArray(0);
    glUseProgram(0);

    Display.update(); // calls (among other things) swapBuffers()
  }
Exemplo n.º 14
0
  public void renderLoop() {
    angle += 2.0f;

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glPushMatrix();
    glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
    glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
    glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);

    glPushMatrix();
    glTranslatef(-3.0f, -2.0f, 0.0f);
    glRotatef(angle, 0.0f, 0.0f, 1.0f);
    glCallList(gear1);
    glPopMatrix();

    glPushMatrix();
    glTranslatef(3.1f, -2.0f, 0.0f);
    glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
    glCallList(gear2);
    glPopMatrix();

    glPushMatrix();
    glTranslatef(-3.1f, 4.2f, 0.0f);
    glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
    glCallList(gear3);
    glPopMatrix();

    glPopMatrix();
  }
Exemplo n.º 15
0
  private void downsampleSceneInto1x1pixelsBuffer() {
    PerformanceMonitor.startActivity("Rendering eye adaption");

    materials.downSampler.enable();
    FBO downSampledFBO;

    for (int i = 4; i >= 0; i--) {

      downSampledFBO = buffers.downSampledScene[i];
      materials.downSampler.setFloat("size", downSampledFBO.width(), true);

      downSampledFBO.bind();

      setViewportTo(downSampledFBO.dimensions());
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

      // TODO: move this block above, for consistency
      if (i == 4) {
        buffers.initialPost.bindTexture();
      } else {
        buffers.downSampledScene[i + 1].bindTexture();
      }

      renderFullscreenQuad();

      graphicState.bindDisplay(); // TODO: probably can be removed or moved out of the loop
    }

    setViewportToWholeDisplay(); // TODO: verify this is necessary

    PerformanceMonitor.endActivity();
  }
Exemplo n.º 16
0
  // TODO: have a flag to invert the eyes (Cross Eye 3D), as mentioned in
  // TODO: http://forum.terasology.org/threads/happy-coding.1018/#post-11264
  private void renderFinalStereoImage(WorldRenderer.WorldRenderingStage renderingStage) {
    if (renderingProcess.isNotTakingScreenshot()) {
      buffers.sceneFinal.bind();
    } else {
      buffers.ocUndistorted.bind();
    }

    switch (renderingStage) {
      case LEFT_EYE:
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        renderFullscreenQuad(0, 0, fullScale.width() / 2, fullScale.height());

        break;

      case RIGHT_EYE:
        // no glClear() here: the rendering for the second eye is being added besides the first
        // eye's rendering
        renderFullscreenQuad(
            fullScale.width() / 2 + 1, 0, fullScale.width() / 2, fullScale.height());

        if (renderingProcess.isNotTakingScreenshot()) {
          graphicState.bindDisplay();
          applyOculusDistortion(buffers.sceneFinal);

        } else {
          buffers.sceneFinal.bind();
          applyOculusDistortion(buffers.ocUndistorted);
          renderingProcess.saveScreenshot();
          // when saving a screenshot we do NOT send the image to screen,
          // to avoid the brief flicker of the screenshot for one frame
        }

        break;
    }
  }
Exemplo n.º 17
0
  /**
   * Part of the deferred lighting technique, this method applies lighting through screen-space
   * calculations to the previously flat-lit world rendering stored in the primary FBO. // TODO:
   * rename sceneOpaque* FBOs to primaryA/B
   *
   * <p>See http://en.wikipedia.org/wiki/Deferred_shading as a starting point.
   */
  public void applyLightBufferPass() {

    int texId = 0;

    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    buffers.sceneOpaque.bindTexture();
    materials.lightBufferPass.setInt("texSceneOpaque", texId++);

    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    buffers.sceneOpaque.bindDepthTexture();
    materials.lightBufferPass.setInt("texSceneOpaqueDepth", texId++);

    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    buffers.sceneOpaque.bindNormalsTexture();
    materials.lightBufferPass.setInt("texSceneOpaqueNormals", texId++);

    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    buffers.sceneOpaque.bindLightBufferTexture();
    materials.lightBufferPass.setInt("texSceneOpaqueLightBuffer", texId, true);

    buffers.sceneOpaquePingPong.bind();
    graphicState.setRenderBufferMask(buffers.sceneOpaquePingPong, true, true, true);

    setViewportTo(buffers.sceneOpaquePingPong.dimensions());
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // TODO: verify this is necessary

    renderFullscreenQuad();

    graphicState.bindDisplay(); // TODO: verify this is necessary
    setViewportToWholeDisplay(); // TODO: verify this is necessary

    renderingProcess.swapSceneOpaqueFBOs();
    buffers.sceneOpaque.attachDepthBufferTo(buffers.sceneReflectiveRefractive);
  }
Exemplo n.º 18
0
  public void start() {
    // ウィンドウの生成
    try {
      Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
      // Display.setTitle("SimField");
      Display.create();
    } catch (LWJGLException e) {
      e.printStackTrace();
      System.exit(0);
    }

    initGL();

    // メインループ
    while (!Display.isCloseRequested()) {
      GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
      /**
       * for(Life l : lifeSet.getArray()){ l.renderLife(); } for(Life lr: lifeRedSet.getArray()){
       * lr.renderLife(); } for(Life lb: lifeBlueSet.getArray()){ lb.renderLife(); }
       */
      for (Life l : life) {
        l.renderLife();
      }
      for (Life lr : lifeRed) {
        lr.renderLife();
      }
      for (Life lb : lifeBlue) {
        lb.renderLife();
      }
      status.updateFPS();
      Display.update(); // オンスクリーンに反映
      Display.sync(60); // FPSを60に固定
    }
  }
Exemplo n.º 19
0
 private void render() {
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   engine.Render();
   int error = glGetError();
   if (error != GL_NO_ERROR) System.out.println("Error: " + GLUtil.getErrorString(error));
   glfwSwapBuffers(window);
 }
  @Override
  protected void update(double time) {
    glClear(GL_COLOR_BUFFER_BIT);

    program.activate();

    // Bind to the VAO that has all the information about the vertices
    glBindVertexArray(vaoId);
    glEnableVertexAttribArray(0);
    glEnableVertexAttribArray(1);

    // Bind to the index VBO that has all the information about the order of the vertices
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboiId);

    // Draw the vertices
    glDrawElements(GL_TRIANGLES, indicesCount, GL_UNSIGNED_BYTE, 0);

    // Put everything back to default (deselect)
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
    glDisableVertexAttribArray(0);
    glDisableVertexAttribArray(1);
    glBindVertexArray(0);

    Program.deactivate();
  }
  public void updateMap() {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

    for (int c = 0; c < Generation.chunklist.chunks.size(); c++) {
      int cx = Generation.chunklist.chunks.get(c).chunkY;
      int cy = Generation.chunklist.chunks.get(c).chunkX;
      int[][] top = Generation.chunklist.chunks.get(c).TOPBLOCK;

      for (int x = 0; x < 16; x++) {
        for (int y = 0; y < 16; y++) {
          int id = top[x][y];

          GL11.glPushMatrix();
          GL11.glTranslatef(x * 2 + (cx * 32), y * 2 + (cy * 32), 0);
          getColor(id, c, x, y);

          GL11.glBegin(GL11.GL_QUADS);
          GL11.glVertex2f(x * 2 + (cx * 32), y * 2 + (cy * 32) + 4);
          GL11.glVertex2f(x * 2 + (cx * 32), y * 2 + (cy * 32));
          GL11.glVertex2f(x * 2 + (cx * 32) + 4, y * 2 + (cy * 32));
          GL11.glVertex2f(x * 2 + (cx * 32) + 4, y * 2 + (cy * 32) + 4);
          GL11.glEnd();
          GL11.glPopMatrix();
        }
      }
    }
  }
Exemplo n.º 22
0
  private void draw() {

    // Clear the screen and depth buffer
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();

    // set up GameContext.getCamera()
    GL11.glPushMatrix();

    GL11.glScalef(scale, scale, scale);
    GL11.glTranslatef(
        -GameContext.getCamera().getPosition().getx(),
        -GameContext.getCamera().getPosition().gety(),
        0);
    GL11.glTranslatef(4f, 3f, 0);

    map.draw();

    if (editorMode) {
      Quad q = new Quad(editorTag.getPosition(), map.getLookupTile(currentEditorTile).getTexture());
      GameContext.getPipe().addDrawable(q);
    }

    for (Entity ae : entities) {
      ae.draw();
    }

    GameContext.getPipe().renderContent();

    GL11.glPopMatrix();

    // overlay console text

    GL11.glPushMatrix();
    GL11.glScalef(2f, 2f, 2f);

    if (console.isEnabled()) {
      gtest.drawing.util.drawString(new Coord(0, 0), "> " + console.getText());
    }

    if (GameContext.isDebugMode()) {
      gtest.drawing.util.drawString(
          new Coord(0, 285), "tiles drawn " + GameContext.getFromLog("tilesLastDrawn"));
      gtest.drawing.util.drawString(
          new Coord(0, 275), "textures bound " + GameContext.getFromLog("textureBinds"));
      gtest.drawing.util.drawString(new Coord(0, 265), "FPS " + GameContext.getFromLog("fps"));
    }

    GL11.glPopMatrix();

    Display.update();

    // clean up

    GameContext.getPipe().clear();
    GameContext.addToLog("tilesLastDrawn", "0");
    GameContext.addToLog("textureBinds", "0");
  }
Exemplo n.º 23
0
 /**
  * Prepares the screen for rendering, which includes clearing it.
  *
  * <p>Also does the current {@link JumboRenderModule}'s custom preparation action.
  */
 public static void prepare() {
   if (wasResized) {
     update();
   }
   GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
   wasResized = Display.wasResized();
   current.prepare();
 }
Exemplo n.º 24
0
 public void run() {
   while (!Display.isCloseRequested()) {
     GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
     gui.update();
     Display.update();
     TestUtils.reduceInputLag();
   }
 }
Exemplo n.º 25
0
  /** Render the current frame */
  private static void render() {
    glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

    // TODO: all your rendering goes here
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix();
    glTranslatef(
        Display.getDisplayMode().getWidth() / 2, Display.getDisplayMode().getHeight() / 2, 0.0f);
    glRotatef(angle, 0, 0, 1.0f);
    glBegin(GL_QUADS);
    glVertex2i(-50, -50);
    glVertex2i(50, -50);
    glVertex2i(50, 50);
    glVertex2i(-50, 50);
    glEnd();
    glPopMatrix();
  }
Exemplo n.º 26
0
 public void prepareRender() {
   if (resized) {
     resize();
     resized = false;
     lastFrameResized = true;
   }
   Mouse.update(this);
   GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
 }
Exemplo n.º 27
0
 @Override
 protected void render() {
   glClear(GL_COLOR_BUFFER_BIT);
   glPushMatrix();
   blink();
   activeFont().draw(0, 0, text.substring(0, text.length() - (blink ? 1 : 0)));
   glRasterPos2f(0, 0);
   glPopMatrix();
 }
Exemplo n.º 28
0
  public void render() {
    renderer.prepare();
    renderer.render(model);
    // above must go before glfwSwapBuffers

    glfwSwapBuffers(window);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  }
Exemplo n.º 29
0
  private void keyConfigSequence() {

    while (loop) {

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

      try {
        menuTheme
            .getFont()
            .glDrawText(
                "\\c#FFFFFFKey Bindings",
                (Main.SCREEN_WIDTH - menuTheme.getFont().getStringWidth("Key Bindings")) / 2 + 2,
                50);

      } catch (InvalidEscapeSequenceException e) {
        e.printStackTrace();
      }

      Input.poll();
      mouseEvents = Input.getMouseEvents();
      keyEvents = Input.getKeyEvents();

      try {
        drawKeyConfigText(margin, 75, 30);
      } catch (InvalidEscapeSequenceException e) {

      }

      for (GLUIComponent t : keyConfigTextField) {

        t.processKeyEvents(keyEvents);
        t.processMouseEvents(mouseEvents);
        t.update(0);
        t.renderGL();
      }

      Display.update();

      if (Display.isCloseRequested()) {
        Game.GAME_STATE = Game.GAME_STATE_QUIT;
        menu = false;
        loop = false;
      } else if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
        loop = false;
      }
    }

    for (GLUIComponent t : keyConfigTextField) {

      if (t instanceof GLTextField) {
        ((GLTextField) t).setText(((GLTextField) t).getText().toUpperCase());
        KeyBindings.valueOf(t.getContext().toString())
            .setUserKey(Keyboard.getKeyIndex(((GLTextField) t).getText()));
      }
    }
  }
Exemplo n.º 30
0
  private void loop() {
    long lastFrameTime = 0;

    while (!Display.isCloseRequested()) {
      long now = System.nanoTime();
      long renderFps = 30;
      long nanoPerFrame = 1000000000 / renderFps;

      // update the animation
      if (now - lastFrameTime >= nanoPerFrame) {
        lastFrameTime = now;

        angle += 2.0f;

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        glPushMatrix();
        glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
        glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
        glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);

        glPushMatrix();
        glTranslatef(-3.0f, -2.0f, 0.0f);
        glRotatef(angle, 0.0f, 0.0f, 1.0f);
        glCallList(gear1);
        glPopMatrix();

        glPushMatrix();
        glTranslatef(3.1f, -2.0f, 0.0f);
        glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
        glCallList(gear2);
        glPopMatrix();

        glPushMatrix();
        glTranslatef(-3.1f, 4.2f, 0.0f);
        glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
        glCallList(gear3);
        glPopMatrix();

        glPopMatrix();

        Display.update();
      }

      handleInput();

      if (broadcastController != null) {
        submitFrame();
        broadcastController.update();
      }

      if (chatController != null) {
        chatController.update();
      }
    }
  }