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_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.º 3
0
  /** R_SetupFrame */
  void R_SetupFrame() {
    r_framecount++;

    //	build the transformation matrix for the given view angles
    Math3D.VectorCopy(r_newrefdef.vieworg, r_origin);

    Math3D.AngleVectors(r_newrefdef.viewangles, vpn, vright, vup);

    //	current viewcluster
    mleaf_t leaf;
    if ((r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) == 0) {
      r_oldviewcluster = r_viewcluster;
      r_oldviewcluster2 = r_viewcluster2;
      leaf = Mod_PointInLeaf(r_origin, r_worldmodel);
      r_viewcluster = r_viewcluster2 = leaf.cluster;

      // check above and below so crossing solid water doesn't draw wrong
      if (leaf.contents == 0) { // look down a bit
        Math3D.VectorCopy(r_origin, temp);
        temp[2] -= 16;
        leaf = Mod_PointInLeaf(temp, r_worldmodel);
        if ((leaf.contents & Defines.CONTENTS_SOLID) == 0 && (leaf.cluster != r_viewcluster2))
          r_viewcluster2 = leaf.cluster;
      } else { // look up a bit
        Math3D.VectorCopy(r_origin, temp);
        temp[2] += 16;
        leaf = Mod_PointInLeaf(temp, r_worldmodel);
        if ((leaf.contents & Defines.CONTENTS_SOLID) == 0 && (leaf.cluster != r_viewcluster2))
          r_viewcluster2 = leaf.cluster;
      }
    }

    for (int i = 0; i < 4; i++) v_blend[i] = r_newrefdef.blend[i];

    c_brush_polys = 0;
    c_alias_polys = 0;

    // clear out the portion of the screen that the NOWORLDMODEL defines
    if ((r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) != 0) {
      GL11.glEnable(GL11.GL_SCISSOR_TEST);
      GL11.glClearColor(0.3f, 0.3f, 0.3f, 1.0f);
      GL11.glScissor(
          r_newrefdef.x,
          vid.height - r_newrefdef.height - r_newrefdef.y,
          r_newrefdef.width,
          r_newrefdef.height);
      GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
      GL11.glClearColor(1.0f, 0.0f, 0.5f, 0.5f);
      GL11.glDisable(GL11.GL_SCISSOR_TEST);
    }
  }
Exemplo n.º 4
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();
 }
Exemplo n.º 5
0
 /** Sets the clear color based on the the current theme's clear color. */
 public static void setClearColor() {
   glClearColor(
       currentTheme.clearColor[0],
       currentTheme.clearColor[1],
       currentTheme.clearColor[2],
       currentTheme.clearColor[3]);
 }
Exemplo n.º 6
0
  /** Initialise the GL context */
  protected void initGL() {
    Log.info("Starting display " + width + "x" + height);
    String extensions = GL11.glGetString(GL11.GL_EXTENSIONS);

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_LIGHTING);

    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.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, width, height);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    if (input == null) {
      input = new Input(height);
    }
    input.init(height);
    input.removeListener(lastGame);
    input.addListener(game);
    lastGame = game;
  }
  private void activate() {
    if (_active == 0) {
      try {
        _oldContext = ContextManager.getCurrentContext();
        _pbuffer.makeCurrent();

        ContextManager.switchContext(_pbuffer);

        ContextManager.getCurrentContext().clearEnforcedStates();
        ContextManager.getCurrentContext().enforceStates(_enforcedStates);

        if (_bgColorDirty) {
          GL11.glClearColor(
              _backgroundColor.getRed(),
              _backgroundColor.getGreen(),
              _backgroundColor.getBlue(),
              _backgroundColor.getAlpha());
          _bgColorDirty = false;
        }
      } catch (final LWJGLException e) {
        logger.logp(Level.SEVERE, this.getClass().toString(), "activate()", "Exception", e);
        throw new Ardor3dException();
      }
    }
    _active++;
  }
Exemplo n.º 8
0
  private void initialise() {
    DisplayMode mode = new DisplayMode(WIDTH, HEIGHT);
    Display.setTitle(TITLE);

    input = new InputHandler();
    display = new CodeDisplay(input);

    try {
      Display.setDisplayMode(mode);
      Display.setResizable(false);
      Display.create();

      if (!GLContext.getCapabilities().OpenGL33)
        System.err.printf("You must have at least OpenGL 3.3 to run this program\n");
    } catch (LWJGLException e) {
      e.printStackTrace();
      System.exit(-1);
    }

    // Set clear color

    glShadeModel(GL_SMOOTH);
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL); // Less than or equal
    glClearDepth(1.0);

    establishProjectionMatrix();

    // glEnable(GL_LIGHTING);
    // glEnable(GL_LIGHT0);
  }
  /**
   * *************************************************************************************************************************************************************************************************
   * Initialization stuff comes in here...
   * ************************************************************************************************************************************************************************************************
   */
  private void init() {

    try {
      Display.setDisplayMode(new DisplayMode(640, 480));
      Display.setVSyncEnabled(true);
      Display.setTitle("MS3D Loader [G36C]");
      Display.create();

      Keyboard.create();

    } catch (LWJGLException e) {
      Sys.alert("Error", "Initialization failed!\n\n" + e.getMessage());
      System.exit(0);
    }

    /* OpenGL */
    int width = Display.getDisplayMode().getWidth();
    int height = Display.getDisplayMode().getHeight();

    GL11.glViewport(0, 0, width, height); // Reset The Current Viewport
    GL11.glMatrixMode(GL11.GL_PROJECTION); // Select The Projection Matrix
    GL11.glLoadIdentity(); // Reset The Projection Matrix
    GLU.gluPerspective(
        45.0f,
        ((float) width / (float) height),
        0.1f,
        1000.0f); // Calculate The Aspect Ratio Of The Window
    GL11.glMatrixMode(GL11.GL_MODELVIEW); // Select The Modelview Matrix
    GL11.glLoadIdentity(); // Reset The Modelview Matrix

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Background color
    GL11.glClearDepth(1.0f);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);

    // Load model
    //		g36c = new
    // MS3DModel(resourceLoader.loadResourceAsStream("models/gsg9.ms3d"),this.getClass().getResource("./data/textures").getPath());
    g36c =
        new MS3DModel(
            resourceLoader.loadResourceAsStream("models/assassin.ms3d"),
            this.getClass().getResource("./data/textures").getPath());

    //		tdsLoader=new TDSLoader();
    //		try {
    //			tdsLoader.load(resourceLoader.loadResourceAsStream("models/face.3ds"));
    //			System.out.println(tdsLoader.getObjectSize());
    //		} catch (IOException e) {
    //			e.printStackTrace();
    //		}

    // Load font
    font = new Font(resourceLoader.loadResourceAsStream("textures/font.bmp"), 12, width, height);

    // Init timer
    timer = new Timer();
  }
  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.º 11
0
 @Override
 public void render() {
   GL11.glClearColor(
       (float) color.getRed() / 255,
       (float) color.getGreen() / 255,
       (float) color.getBlue() / 255,
       0);
 }
Exemplo n.º 12
0
 /**
  * Set the JumboColor OpenGL will clear to screen to.
  *
  * @param c the new JumboColor
  */
 public static void setRefreshcolor(JumboColor c) {
   if (c == null) {
     throw new NullPointerException("Input is null!");
   }
   refreshcolor.x = c.getRed() / 255.0f;
   refreshcolor.y = c.getGreen() / 255.0f;
   refreshcolor.z = c.getBlue() / 255.0f;
   GL11.glClearColor(refreshcolor.x, refreshcolor.y, refreshcolor.z, 1);
 }
Exemplo n.º 13
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 -----------//

  }
Exemplo n.º 14
0
  @Override
  protected void render() {
    glClearColor(0, 0, 0, 0);
    glClear(GL_COLOR_BUFFER_BIT);
    glRotatef(1, 1, 0, 0);

    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
    glDrawElements(GL_QUAD_STRIP, brickIndices);
    glPolygonMode(GL_FRONT, GL_FILL);
    glDrawElements(GL_QUADS, paintedWall);
  }
Exemplo n.º 15
0
 public void render() {
   glPushMatrix();
   {
     glClearColor(0, 0, 0, 0);
     glColor4f(255, 255, 255, 255);
     tileMap.render();
     player.render(tileMap.getX(), tileMap.getY());
     chat.render();
     robot.render();
   }
   glPopMatrix();
 }
Exemplo n.º 16
0
  private void doRenderLoop() {
    try {
      while (!isDisplayable()) {
        Thread.sleep(50);
      }
      Display.setParent(this);
      Display.setVSyncEnabled(true);
      Display.create();
      mMouseState = new boolean[Mouse.getButtonCount()];
      for (int i = 0; i < mMouseState.length; i++) {
        mMouseState[i] = Mouse.isButtonDown(i);
      }

      // GL11.glsetSwapInterval(1);
      GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
      // gl11.glColor3f(1.0f, 0.0f, 0.0f);
      GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
      GL11.glClearDepth(1.0);
      GL11.glLineWidth(2);
      GL11.glEnable(GL11.GL_DEPTH_TEST);
      if (mScene.getAmbientLight() != null) {
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glLightModel(
            GL11.GL_LIGHT_MODEL_AMBIENT, Color4fLogic.toFloatBuffer(mScene.getAmbientLight()));
      }
      if (mScene.getColorMaterialFace() != JGLColorMaterialFace.UNSET) {
        initMaterial();
      }
      if (mScene.getFogMode() != JGLFogMode.UNSET) {
        initFog();
      }

      Dimension newDim;

      while (!Display.isCloseRequested() && !mCloseRequested) {
        newDim = mNewCanvasSize.getAndSet(null);
        if (newDim != null) {
          GL11.glViewport(0, 0, newDim.width, newDim.height);
          syncViewportSize();
        }
        doRender();
        doMouse();
        doKeys();
        doEye();
        Display.update();
      }

      Display.destroy();
    } catch (InterruptedException | LWJGLException e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 17
0
  private void loop() {
    GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    GL11.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);

    while (GLFW.glfwWindowShouldClose(window) != GL11.GL_TRUE) {
      GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
      GL11.glPushMatrix();
      for (Robot r : robots) r.draw();
      GL11.glPopMatrix();
      GLFW.glfwSwapBuffers(window);
      GLFW.glfwPollEvents();
    }
  }
Exemplo n.º 18
0
  @Override
  protected void init() {
    glClearColor(0, 0, 0, 0);
    glPixelZoom(1, -1);

    try {
      for (int i = 0; i < fonts.length; ++i) {
        fonts[i] = new Font(new File(FONT_NAMES[i]), FONT_MAPS[i], width, height);
      }
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }
  }
Exemplo n.º 19
0
  @Override
  public void render() {
    glClearColor(0.2f, 0.4f, 0.7f, 1.0f);
    this.title.render();
    this.twitter.render();

    for (int i = 0; i < texts.length; i++) {
      ResourceManager.font.render(texts[i], 5, i * 8 + 100, 16, 16);
    }

    ResourceManager.font.render(
        "@ S0orax", 24 + 32 + 5, Game.instance.getHeight() / Game.instance.getScale() - 35, 16, 16);

    this.back.render();
  }
Exemplo n.º 20
0
  public void setUpFog() {
    glEnable(GL_FOG);

    FloatBuffer fogColor = BufferUtils.createFloatBuffer(4);
    fogColor.put(0.1f).put(0.1f).put(0.1f).put(1.0f).flip();

    glFogi(GL_FOG_MODE, GL_LINEAR);
    glFog(GL_FOG_COLOR, fogColor);
    glFogf(GL_FOG_DENSITY, 0.005f);
    glHint(GL_FOG_HINT, GL_NICEST);
    glFogf(GL_FOG_START, 300.0f);
    glFogf(GL_FOG_END, 2000.0f);

    glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
  }
Exemplo n.º 21
0
  public void initGL() {
    // Setup Display
    try {
      if (display_parent != null) {
        Display.setParent(display_parent);
      }
      Display.setDisplayMode(new DisplayMode(1000, 1000));
      Display.create(new PixelFormat(24, 8, 24, 0, 0));
      Display.setTitle("JGE3d");

      // Create a fullscreen window with 1:1 orthographic 2D projection
      // (default)
      Display.setFullscreen(false);

      // Enable vsync if we can (due to how OpenGL works, it cannot be
      // guarenteed to always work)
      // TODO: Make Configurable by User
      Display.setVSyncEnabled(true);
    } catch (LWJGLException e) {
      e.printStackTrace();
    }
    window_manager = new WindowManager();

    // camera = (Camera) objectList.getItem(Camera.CAMERA_NAME);

    setPerspective();

    // Set default openGL for drawing
    // GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    GL11.glClearDepth(1.0f);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LEQUAL);

    // Initialize default settings
    ByteBuffer temp = ByteBuffer.allocateDirect(16);
    temp.order(ByteOrder.nativeOrder());

    if (GLContext.getCapabilities().GL_ARB_vertex_buffer_object) {
      supports_vbo = true;
    } else {
      supports_vbo = false;
    }

    // Blending functions so we can have transparency
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_BLEND);
  }
Exemplo n.º 22
0
  @Override
  public void draw(GameTime gameTime) {
    GL11.glClearColor(0, 0, 0, 0);
    GL11.glClearDepth(1.0);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    RasterizerState.CULL_CLOCKWISE.set();
    BlendState.OPAQUE.set();
    DepthState.DEFAULT.set();

    program.use();
    texture.use(TextureUnit.Texture0, program.getUniform("Texture"));
    vb.useAsAttrib(fxsi);
    ib.bind();
    GL11.glDrawElements(PrimitiveType.Triangles, 6, GLType.UnsignedInt, 0);
    ib.unbind();
    texture.unuse();
    GLProgram.unuse();

    if (!savedImage) {
      int sw = game.getWidth();
      int sh = game.getHeight();
      ByteBuffer pb = NativeMem.createByteBuffer(sw * sh * 4);
      GL11.glReadPixels(0, 0, sw, sh, PixelFormat.Rgba, GLType.UnsignedByte, pb);
      pb.position(0);
      pb.limit(sw * sh * 4);

      byte[] cb = new byte[4];
      BufferedImage im = new BufferedImage(sw, sh, BufferedImage.TYPE_INT_ARGB);
      for (int y = sh - 1; y >= 0; y--) {
        for (int x = 0; x < sw; x++) {
          pb.get(cb);
          im.setRGB(
              x, y, (cb[2] & 0xFF) | ((cb[1] & 0xFF) << 8) | ((cb[0] & 0xFF) << 16) | 0xFF000000);
        }
      }

      try {
        ImageIO.write(im, "png", new File("Diag.png"));
        System.out.println("Image Has Been Saved");
      } catch (IOException e) {
        System.out.println(e.getMessage());
      }

      savedImage = true;
    }
  }
Exemplo n.º 23
0
  @Override
  public boolean init(Engine engine) {
    Window window = engine.getGlobal(Window.class);
    try {
      DisplayMode[] modes = Display.getAvailableDisplayModes();
      DisplayMode chosen = modes[0];

      for (DisplayMode mode : modes) {
        if (mode.getWidth() == window.width
            && mode.getHeight() == window.height
            && mode.isFullscreenCapable()) {
          chosen = mode;
        }
        break;
      }

      chosen =
          (DisplayMode)
              JOptionPane.showInputDialog(
                  null,
                  "Display Options",
                  "Display Mode",
                  JOptionPane.QUESTION_MESSAGE,
                  null,
                  modes,
                  chosen);
      if (chosen == null) {
        return false;
      }
      Display.setDisplayMode(chosen);
      Display.setFullscreen(
          JOptionPane.showConfirmDialog(
                  null, "Fullscreen?", "Display Options", JOptionPane.YES_NO_OPTION)
              == JOptionPane.YES_OPTION);
      Display.setVSyncEnabled(true);
      Display.create();

      glClearColor(1, 1, 1, 1);
      glEnable(GL_DEPTH_TEST);
      glEnable(GL_CULL_FACE);
    } catch (LWJGLException ex) {
      System.err.println("Error creating display: " + ex.getMessage());
      return false;
    }

    return true;
  }
Exemplo n.º 24
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();
    }
  }
Exemplo n.º 25
0
  @Override
  public void draw() {
    GL11.glClearColor(0.8f, 0.8f, 0.8f, 0.0f);

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

    GL11.glLoadIdentity();
    GLU.gluLookAt(5.0f, 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
    GL11.glRotatef(rot, 0.0f, 1.0f, 0.0f);
    GL11.glRotatef(rot2, 1.0f, 0.0f, 0.0f);
    drawer.draw();

    Keyboard.poll();

    while (Keyboard.next()) {
      if (Keyboard.getEventKeyState()) {
        if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
          return;
        }
        if (Keyboard.getEventKey() == Keyboard.KEY_RIGHT) {
          rot -= 15.0f;
        }
        if (Keyboard.getEventKey() == Keyboard.KEY_LEFT) {
          rot += 15.0f;
        }
        if (Keyboard.getEventKey() == Keyboard.KEY_UP) {
          rot2 -= 15.0f;
        }
        if (Keyboard.getEventKey() == Keyboard.KEY_DOWN) {
          rot2 += 15.0f;
        }

        if (Keyboard.getEventKey() == Keyboard.KEY_T) {
          if (renderMode == GL11.GL_POLYGON) {
            renderMode = GL11.GL_LINE_LOOP;
          } else {
            renderMode = GL11.GL_POLYGON;
          }
        }
      }
    }
  }
Exemplo n.º 26
0
  public void initRenderer() {
    createWindow();

    // Mouse.setGrabbed(true);

    getLogger().info("SpoutClient Information");
    getLogger().info("Operating System: " + System.getProperty("os.name"));
    getLogger().info("Renderer Mode: " + this.getRenderMode().toString());
    getLogger().info("OpenGL Information");
    getLogger().info("Vendor: " + GL11.glGetString(GL11.GL_VENDOR));
    getLogger().info("OpenGL Version: " + GL11.glGetString(GL11.GL_VERSION));
    getLogger().info("GLSL Version: " + GL11.glGetString(GL20.GL_SHADING_LANGUAGE_VERSION));
    getLogger().info("Max Textures: " + GL11.glGetString(GL20.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS));
    String extensions = "Extensions Supported: ";
    if (getArguments().renderMode == RenderMode.GL30) {
      for (int i = 0; i < GL11.glGetInteger(GL30.GL_NUM_EXTENSIONS); i++) {
        extensions += GL30.glGetStringi(GL11.GL_EXTENSIONS, i) + " ";
      }
    } else {
      extensions += GL11.glGetString(GL11.GL_EXTENSIONS);
    }
    getLogger().info(extensions);
    soundManager.init();
    Spout.getFilesystem().postStartup();

    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glClearColor((135.f / 255.0f), 206.f / 255.f, 250.f / 255.f, 0);

    // worldRenderer = new WorldRenderer(this);
    // worldRenderer.setup();

    renderer = new PrimitiveBatch();
    mat =
        (RenderMaterial)
            this.getFilesystem()
                .getResource("material://Spout/resources/resources/materials/BasicMaterial.smt");
    renderer.begin();
    renderer.addCube(new Vector3(-0.5, -0.5, -0.5), Vector3.ONE, Color.RED, sides);
    renderer.end();

    gui = new SpriteBatch();
  }
Exemplo n.º 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();
 }
Exemplo n.º 28
0
  public void render(int delta) {
    glClearColor(0.5f, 0.5f, 0.8f, 1.0f);
    glClearDepth(1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    update();

    // Like a cake, this has layers. We want ground at the bottom so it goes first.
    for (AbstractEntity e : Window.ground) {
      e.draw();
    }
    for (AbstractEntity e : Window.entities) {
      e.update(delta);
      e.draw();
    }
    if (Window.leftButtonHeld) {
      drawLineBox(Window.iMouseX, Window.iMouseY, Window.mouseX, Window.mouseY, true);
    }
    renderer.flushQueue();
    drawFPS(fps);
  }
  @Override
  protected void display() {
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    glClearDepth(1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    if (useSmoothInterpolation) {
      glUseProgram(smoothInterp.theProgram);
    } else {
      glUseProgram(linearInterp.theProgram);
    }

    if (useFakeHallway) {
      fauxHallway.render();
    } else {
      realHallway.render();
    }

    glUseProgram(0);
  }
Exemplo n.º 30
0
 /**
  * Set the JumboColor that the screen is cleared to every frame.
  *
  * @param r red value represented by 0.0 to 1.0
  * @param g green value represented by 0.0 to 1.0
  * @param b blue value represented by 0.0 to 1.0
  */
 public static void setRefreshcolor(float r, float g, float b) {
   if (r > 1) {
     throw new IllegalArgumentException("Red cannot be greater than 1!");
   }
   if (g > 1) {
     throw new IllegalArgumentException("Green cannot be greater than 1!");
   }
   if (b > 1) {
     throw new IllegalArgumentException("Blue cannot be greater than 1!");
   }
   if (r < 0) {
     throw new IllegalArgumentException("Red cannot be less than 1!");
   }
   if (g < 0) {
     throw new IllegalArgumentException("Green cannot be less than 1!");
   }
   if (b < 0) {
     throw new IllegalArgumentException("Blue cannot be less than 1!");
   }
   refreshcolor = new Position3DF(r, g, b);
   GL11.glClearColor(refreshcolor.x, refreshcolor.y, refreshcolor.z, 1);
 }