Package org.lwjgl.opengl

Examples of org.lwjgl.opengl.DisplayMode


    catch (Exception e) {
     
    }
   
    try {
      Display.setDisplayMode(new DisplayMode(windowWidth, windowHeight));
      Display.setTitle(title);
      Display.create();
    } catch (LWJGLException e) {
      e.printStackTrace();
    }
View Full Code Here


        && (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);
View Full Code Here

    int x = settings.getResolutionX();
    int y = settings.getResolutionY();
    int frequency = settings.getFrequency();

    try {
      DisplayMode modes[] = org.lwjgl.util.Display.getAvailableDisplayModes(x, y, x, y, 32, 32, frequency,
          frequency);

      DisplayMode mode = null;

      if (modes.length > 0)
        mode = modes[0];

      if (mode == null) {
        Sys.alert("Error", "Display mode not supported. Switchting to desktop display mode.");

        // use desktop display mode
        mode = Display.getDesktopDisplayMode();

        x = mode.getWidth();
        y = mode.getHeight();
        frequency = mode.getFrequency();

        modes = org.lwjgl.util.Display.getAvailableDisplayModes(x, y, x, y, 32, 32, frequency, frequency);

        if (modes.length > 0)
          mode = modes[0];
        else {
          Sys.alert("Fatal Error", "No valid display mode found.");
          System.exit(1);
        }

        // set fullscreen because we use full resolution now
        settings.setFullscreen(true);
      }

      Display.setDisplayMode(mode);
      Display.setVSyncEnabled(settings.getVSync());
      Display.setFullscreen(settings.getFullscreen());
      Display.setTitle("PonkOut");

      // load icons
      ByteBuffer[] icons = new ByteBuffer[5];
      icons[0] = Texture.getBytes("icon16.tga");
      icons[1] = Texture.getBytes("icon32.tga");
      icons[2] = Texture.getBytes("icon48.tga");
      icons[3] = Texture.getBytes("icon64.tga");
      icons[4] = Texture.getBytes("icon128.tga");

      // set icons
      Display.setIcon(icons);

      // update settings
      settings.setResolution(mode.getWidth(), mode.getHeight());
      settings.setFrequency(mode.getFrequency());

    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
View Full Code Here

      GL11.glEnable(ARBMultisample.GL_MULTISAMPLE_ARB);

    // init projection matrix
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    DisplayMode displayMode = Display.getDisplayMode();
    GLU.gluPerspective(45.0f, (float) displayMode.getWidth() / (float) displayMode.getHeight(), 0.1f, 2000.0f);

    // select modelview matrix
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
  }
View Full Code Here

   
    frustum = new float[6][4];
    clearColor = new Vector3f(1,1,1);
    camera = new Camera();
   
    Display.setDisplayMode(new DisplayMode(screenWidth, screenHeight));
    Display.setFullscreen(false);
    Display.setTitle(windowTitle);
    Display.create();
   
    initGL();
View Full Code Here

    }

    private void initDisplay() {
        System.out.println("Initialising display");
        try {
            Display.setDisplayMode(new DisplayMode(1024, 640));
            Display.setTitle("LWJGL Platformer v" + versionNumber);
            Display.setVSyncEnabled(true);
            Display.create();
            Keyboard.create();
        } catch (LWJGLException ex) {
View Full Code Here

    }
  } 
 
  private void initGL(){
    try {
      Display.setDisplayMode(new DisplayMode(WIDTH,HEIGHT));
      Display.create();
      Display.setTitle(game.dm.getTitle());
    } catch (LWJGLException e) {
      e.printStackTrace();
    }
View Full Code Here

  @Override
  public void createContext(int width, int height) {
   
    try {
     
      Display.setDisplayMode(new DisplayMode(width, height));
      Display.create(new PixelFormat(4, 8, 0));
 
      GL11.glViewport(0, 0, width, height);
      GL11.glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a);
      GL11.glClearDepth(1.0f);
View Full Code Here

    // Link IO Hardware
    postString("Linking IO Hardware...");
    try {
      Display.setParent(canvas);
      Display.setDisplayMode(new DisplayMode(displayWidth, displayHeight));
      Display.create();
      Keyboard.create();
      Mouse.create();
      if (controllersEnabled) {
        Controllers.create();
View Full Code Here

  /** Adjusts the display options, size and fullscreen state. */
  private void adjustDisplayMode() {

    if (fullscreen) {
      // Search for a valid display mode
      DisplayMode m = null;
      try {
        DisplayMode[] modes = Display.getAvailableDisplayModes();
        for (DisplayMode mode : modes) {
          if (mode.isFullscreenCapable() && mode.getBitsPerPixel() >= 32 && mode.getWidth() == displayWidth && mode.getHeight() == displayHeight) {
            m = mode;
            break;
          }
        }
        if (m != null) {
          Display.setDisplayMode(m);
          Display.setFullscreen(true);
        }
      } catch (LWJGLException e) {
        e.printStackTrace();
      }
    } else {
      // Resize display
      try {
        Display.setFullscreen(false);
        Display.setDisplayMode(new DisplayMode(displayWidth, displayHeight));
      } catch (LWJGLException e) {
        e.printStackTrace();
      }
    }
    adjustViewport();
View Full Code Here

TOP

Related Classes of org.lwjgl.opengl.DisplayMode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.