コード例 #1
0
ファイル: Window.java プロジェクト: TeamField3/jTTD
 public static void setFullscreen(boolean fullscreen) {
   try {
     if (fullscreen) {
       displayMode = Display.getDisplayMode();
       Display.setDisplayMode(Display.getDesktopDisplayMode());
     } else {
       Display.setDisplayMode(displayMode);
     }
     Display.setFullscreen(fullscreen);
   } catch (LWJGLException e) {
     e.printStackTrace();
     System.exit(1);
   }
 }
コード例 #2
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();
 }
コード例 #3
0
ファイル: GUI.java プロジェクト: NordicRaven/Pokemon-MMO
  public void start() {
    try {
      Display.setDisplayMode(new DisplayMode(800, 600));
      Display.create();
    } catch (LWJGLException e) {
      e.printStackTrace();
      System.exit(0);
    }

    initGL(); // init OpenGL
    try {
      font = new Font("assets/text.png", "assets/text.txt", 6, 13);
      font.buildFont(2); // build the textures for text
      s = new Sprite("assets/pokemon_sprites/front/643.png");
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(0);
    }
    getDelta(); // call once before loop to initialise lastFrame
    lastFPS = getTime(); // call before loop to initialise fps timer

    while (!Display.isCloseRequested() && !finished) {
      int delta = getDelta();

      update(delta);
      renderGL();

      Display.update();
      Display.sync(60); // cap fps to 60fps
    }

    Display.destroy();
  }
コード例 #4
0
ファイル: OpenGLApp.java プロジェクト: schlop/ICG-Projekt
  /**
   * Start the application. The window is opened and the main loop is entered. This call does not
   * return until the window is closed or an exception was caught.
   */
  public void start() {
    try {
      Display.setDisplayMode(new DisplayMode(width, height));
      Display.setTitle(title);
      if (multisampling) Display.create(new PixelFormat().withSamples(8));
      else Display.create();

      // Sync buffer swap with vertical sync. Results in 60 fps on my Mac
      // Book.
      Display.setSwapInterval(1);
      Display.setVSyncEnabled(true);

      input = new Input();
      application.init();

      while (!Display.isCloseRequested()) {
        input.update();
        input.setWindowSize(width, height);
        application.simulate(time.elapsed(), input);
        application.display(width, height, input);
        Display.update();
      }
    } catch (LWJGLException e) {
      e.printStackTrace();
    } finally {
      Display.destroy();
    }
  }
コード例 #5
0
  /**
   * *************************************************************************************************************************************************************************************************
   * 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();
  }
コード例 #6
0
ファイル: RotatingRect.java プロジェクト: Kageetai/HTW-CG
  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();
  }
コード例 #7
0
  public void start() {
    try {
      Display.setDisplayMode(new DisplayMode(800, 600));
      Display.create();
    } catch (LWJGLException e) {
      e.printStackTrace();
      System.exit(0);
    }

    initGL(); // init OpenGL
    getDelta(); // call once before loop to initialise lastFrame
    lastFPS = getTime(); // call before loop to initialise fps timer

    while (!Display.isCloseRequested()) {
      int delta = getDelta();

      update(delta);
      renderGL();

      Display.update();
      Display.sync(60); // cap fps to 60fps
    }

    Display.destroy();
  }
コード例 #8
0
ファイル: Codenav.java プロジェクト: Haynesy/Codenav
  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);
  }
コード例 #9
0
ファイル: Main.java プロジェクト: bruckart/OpenCraft
  // ***************************************************************************
  // initDisplay
  // ***************************************************************************
  private static void initDisplay(boolean fullscreen) {
    DisplayMode chosenMode = null;

    try {
      DisplayMode[] modes = Display.getAvailableDisplayModes();

      for (int i = 0; i < modes.length; i++) {
        if ((modes[i].getWidth() == targetWidth) && (modes[i].getHeight() == targetHeight)) {
          chosenMode = modes[i];
          break;
        }
      }
    } catch (LWJGLException e) {
      Sys.alert("Error", "Unable to determine display modes.");
      System.exit(0);
    }

    // at this point if we have no mode there was no appropriate, let the user know
    // and give up
    if (chosenMode == null) {
      Sys.alert("Error", "Unable to find appropriate display mode.");
      System.exit(0);
    }

    try {
      Display.setDisplayMode(chosenMode);
      Display.setFullscreen(fullscreen);
      Display.setTitle("OpenCraft");
      Display.create();

    } catch (LWJGLException e) {
      Sys.alert("Error", "Unable to create display.");
      System.exit(0);
    }
  }
コード例 #10
0
ファイル: SplitMan.java プロジェクト: ElConquistador/SplitMan
  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");
  }
コード例 #11
0
ファイル: Base.java プロジェクト: betel/Development01
  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に固定
    }
  }
コード例 #12
0
ファイル: TwlTest.java プロジェクト: ClausRT/Java-GURPS-4e
 public static void main(String[] args) throws Exception {
   Display.setTitle("TWL Examples");
   Display.setDisplayMode(new DisplayMode(800, 600));
   Display.setVSyncEnabled(true);
   Display.create();
   TwlTest twlTest = new TwlTest();
   twlTest.run();
 }
コード例 #13
0
ファイル: Game.java プロジェクト: Tmuch/UnknownGame
  public Game(boolean host) {
    try {
      if (host) {
        System.out.println("Hosting...");
        server = new ServerSocket(port, 4, InetAddress.getByName(serverIP));
        System.out.println("Ready!\nAwaiting client...");
        client = server.accept();
        System.out.println("Client connected!\nBuffering...");
        out = new ObjectOutputStream(client.getOutputStream());
        in = new ObjectInputStream(client.getInputStream());
        System.out.println("Buffered!\nPinging for 256 bytes...");
        long start = System.currentTimeMillis();
        byte[] ping = new byte[256];
        in.read(ping);
        System.out.println("Latency: " + (System.currentTimeMillis() - start));
        out.writeLong(start);
        out.flush();
        System.out.println("Starting threads...");
        new ThreadSend(world, out);
        new ThreadReceive(world, in);
        System.out.println("Started!\nCreating game world...");
      } else {
        System.out.println("Connecting...");
        socket = new Socket(connectIP, port);
        System.out.println("Connected!\nBuffering...");
        in = new ObjectInputStream(socket.getInputStream());
        out = new ObjectOutputStream(socket.getOutputStream());
        byte[] ping = new byte[256];
        new Random().nextBytes(ping);
        System.out.println("Buffered\nPinging for 256 bytes...");
        out.write(ping);
        out.flush();
        long latency = in.readLong();
        System.out.println("Latency: " + (System.currentTimeMillis() - latency));
        System.out.println("Starting threads...");
        new ThreadReceive(world, in);
        new ThreadSend(world, out);
        System.out.println("Started!\nCreating game world...");
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    try {
      Display.setDisplayMode(new DisplayMode(width, height));
      Display.create();
    } catch (Exception e) {
      e.printStackTrace();
    }

    world.init();

    while (!Display.isCloseRequested()) {
      if (ended) break;
      world.update();
    }

    Display.destroy();
  }
コード例 #14
0
ファイル: Window.java プロジェクト: TeamField3/jTTD
 public static void setSize(int width, int height) {
   try {
     displayMode = new DisplayMode(width, height);
     Display.setDisplayMode(displayMode);
   } catch (LWJGLException e) {
     e.printStackTrace();
     System.exit(1);
   }
 }
コード例 #15
0
  /**
   * Set the display mode to be used
   *
   * @param width The width of the display required
   * @param height The height of the display required
   * @param fullscreen True if we want fullscreen mode
   */
  public void setDisplayMode(int width, int height, boolean fullscreen) {

    // return if requested DisplayMode is already set
    if ((Display.getDisplayMode().getWidth() == width)
        && (Display.getDisplayMode().getHeight() == height)
        && (Display.isFullscreen() == fullscreen)) {
      return;
    }

    try {
      DisplayMode targetDisplayMode = null;

      if (fullscreen) {
        DisplayMode[] modes = Display.getAvailableDisplayModes();
        int freq = 0;

        for (int i = 0; i < modes.length; i++) {
          DisplayMode current = modes[i];

          if ((current.getWidth() == width) && (current.getHeight() == height)) {
            if ((targetDisplayMode == null) || (current.getFrequency() >= freq)) {
              if ((targetDisplayMode == null)
                  || (current.getBitsPerPixel() > targetDisplayMode.getBitsPerPixel())) {
                targetDisplayMode = current;
                freq = targetDisplayMode.getFrequency();
              }
            }

            // if we've found a match for bpp and frequence against the
            // original display mode then it's probably best to go for this one
            // since it's most likely compatible with the monitor
            if ((current.getBitsPerPixel() == Display.getDesktopDisplayMode().getBitsPerPixel())
                && (current.getFrequency() == Display.getDesktopDisplayMode().getFrequency())) {
              targetDisplayMode = current;
              break;
            }
          }
        }
      } else {
        targetDisplayMode = new DisplayMode(width, height);
      }

      if (targetDisplayMode == null) {
        System.out.println(
            "Failed to find value mode: " + width + "x" + height + " fs=" + fullscreen);
        return;
      }

      Display.setDisplayMode(targetDisplayMode);
      Display.setFullscreen(fullscreen);

    } catch (LWJGLException e) {
      System.out.println(
          "Unable to setup mode " + width + "x" + height + " fullscreen=" + fullscreen + e);
    }
  }
コード例 #16
0
ファイル: Globals.java プロジェクト: TeamCDG/NutEngine
  public static void setWindowResolution(int width, int height) {
    Globals.windowWidth = width;
    Globals.windowHeight = height;
    Globals.aspectRatio = (float) Globals.windowWidth / (float) Globals.windowHeight;
    Globals.windowMatrix.set(
        1 / Globals.aspectRatio,
        0.0f,
        0.0f,
        0.0f,
        0.0f,
        1.0f,
        0.0f,
        0.0f,
        0.0f,
        0.0f,
        1.0f,
        0.0f,
        0.0f,
        0.0f,
        0.0f,
        1.0f);

    // for(IWindowChangeListener lis : Globals.windowChangeListener)
    // {
    //	lis.onWindowResolutionChange(Globals.windowWidth, Globals.windowHeight);
    // }

    try {
      DisplayMode[] modes = Display.getAvailableDisplayModes();

      DisplayMode finalMode = new DisplayMode(Globals.getWindowWidth(), Globals.getWindowHeight());

      for (int i = 0; i < modes.length; i++) {
        DisplayMode current = modes[i];
        if (current.getWidth() == Globals.getWindowWidth()
            && current.getHeight() == Globals.getWindowHeight()
            && current.getBitsPerPixel() == 32
            && current.getFrequency() == 60) finalMode = current;
      }

      Display.setDisplayMode(finalMode);

      if (!Display.isCreated()) {
        PixelFormat pixelFormat = new PixelFormat();
        ContextAttribs contextAtrributes =
            new ContextAttribs(3, 2).withForwardCompatible(true).withProfileCore(true);
        Display.create(pixelFormat, contextAtrributes);
      }

      GL11.glViewport(0, 0, Globals.getWindowWidth(), Globals.getWindowHeight());
    } catch (LWJGLException e) {
      e.printStackTrace();
      System.exit(-1);
    }
    Display.update();
  }
コード例 #17
0
 private static void setUpDisplay() {
   try {
     Display.setDisplayMode(new DisplayMode(WINDOW_DIMENSIONS[0], WINDOW_DIMENSIONS[1]));
     Display.setTitle(WINDOW_TITLE);
     Display.create();
   } catch (LWJGLException e) {
     e.printStackTrace();
     cleanUp(true);
   }
 }
コード例 #18
0
ファイル: LLC.java プロジェクト: JackdDvice/LLC
  /** Setups the Display */
  private void initDisplay() throws LWJGLException {
    Display.setDisplayMode(standartDisplayMode);
    Display.setResizable(true);
    Display.setVSyncEnabled(true);
    Display.setTitle("LLC - " + VERSION);
    Display.create();

    Keyboard.create();
    Mouse.create();
  }
コード例 #19
0
 private void createWindow() {
   try {
     Display.setDisplayMode(DISPLAY_MODE);
     Display.setFullscreen(fullscreen);
     Display.setTitle(WINDOW_TITLE);
     Display.create();
   } catch (LWJGLException e) {
     e.printStackTrace();
   }
 }
コード例 #20
0
 private void setUpDisplay() {
   try {
     Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
     Display.setTitle("Pong");
     Display.create();
   } catch (LWJGLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
コード例 #21
0
ファイル: Game.java プロジェクト: Woutwo/Project1
  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++;
    }
  }
コード例 #22
0
 private static void setUpDisplay() {
   try {
     Display.setDisplayMode(new DisplayMode(640, 480));
     Display.setVSyncEnabled(true);
     Display.setTitle("Core Lighting Demo");
     Display.create();
   } catch (LWJGLException e) {
     System.err.println("The display wasn't initialized correctly. :(");
     Display.destroy();
     System.exit(1);
   }
 }
コード例 #23
0
ファイル: App.java プロジェクト: knuthelgesen/OpenCLTest
 private void initializeOpenGL() {
   // Open the program window
   try {
     PixelFormat pf = new PixelFormat(24, 8, 24, 0, 16);
     Display.setDisplayMode(new DisplayMode(boxWidth, boxHeight));
     Display.setTitle("Particles");
     Display.setVSyncEnabled(true);
     Display.create(pf);
   } catch (LWJGLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
コード例 #24
0
ファイル: Main.java プロジェクト: Minification/LDEngine
  public Main() {
    try {
      Display.setDisplayMode(new DisplayMode(800, 600));
      Display.create();

      while (!Display.isCloseRequested()) {
        Display.update();
      }

      Display.destroy();
    } catch (LWJGLException e) {
      e.printStackTrace();
    }
  }
コード例 #25
0
ファイル: Window.java プロジェクト: amittaigames/Ludum-GL
 // Sets up the window with a title and size
 public static void init(String title, int width, int height, CoreGame cg, int fps) {
   try {
     Display.setDisplayMode(new DisplayMode(width, height));
     Display.setTitle(title);
     Display.setVSyncEnabled(USE_VSYNC);
     Display.create();
   } catch (Exception e) {
     e.printStackTrace();
   }
   Window.width = width;
   Window.height = height;
   Window.cg = cg;
   Window.fps = fps;
   start();
 }
コード例 #26
0
ファイル: ProgrammableRenderer.java プロジェクト: icdts/jge3d
  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);
  }
コード例 #27
0
  public static void createDisplay() {

    ContextAttribs attribs =
        new ContextAttribs(3, 2).withForwardCompatible(true).withProfileCore(true);

    try {
      Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
      Display.create(new PixelFormat(), attribs);
      Display.setTitle(TITLE);
    } catch (LWJGLException e) {
      e.printStackTrace();
    }

    GL11.glViewport(0, 0, WIDTH, HEIGHT);
    lastFrameTime = getCurrentTime();
  }
コード例 #28
0
ファイル: Game.java プロジェクト: MatthewJWalls/gtest
  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);
    }
  }
コード例 #29
0
ファイル: RenderSystem.java プロジェクト: jellymann/Acropolis
  @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;
  }
コード例 #30
0
ファイル: View.java プロジェクト: Jrokisky/Sonance
  public void update() {
    Display.update();
    Display.sync(fps);
    detectKonami();

    if (Constants.allowFullScr) {
      if ((fullScr && !Display.isFullscreen()) || (!fullScr && Display.isFullscreen())) {
        System.out.println("Performing Display.destroy()/create() cycle");
        sM = Display.getDisplayMode();
        Display.destroy();
        try {
          //					DisplayMode[] d = Display.getAvailableDisplayModes();
          //					int value = 0;
          //					int index = 0;
          //					for(int i = 0; i < d.length; i++){
          //						if(d[i].getWidth() > value){
          //							value = d[i].getWidth();
          //							index = i;
          //						}
          //					}
          Display.setDisplayMode(sM);
          Display.setTitle("Music Dots");
          Display.setFullscreen(fullScr);
          Display.create();
          Display.setVSyncEnabled(true);
          Constants.VIEW_HEIGHT = sM.getHeight();
          Constants.VIEW_WIDTH = sM.getWidth();
          setupOpenGl();
          Fonts.initialize();
        } catch (LWJGLException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    }

    Theme.setClearColor();

    // TODO: we should be calling a "recreateView" function and call this in there. Not sure why
    // we're recreating the view in an update function.
    if (!bPlayerModelInitialized) {
      StaticDrawer.initializeTextures();
      bPlayerModelInitialized = true;
    }

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  }