Package org.lwjgl.opengl

Examples of org.lwjgl.opengl.DisplayMode


  /**
   * Tests setting display modes
   */
  private void setDisplayModeTest() throws LWJGLException {
    DisplayMode mode = null;
    DisplayMode[] modes = null;

    System.out.println("==== Test setDisplayMode ====");
    System.out.println("Retrieving available displaymodes");
    modes = Display.getAvailableDisplayModes();
View Full Code Here


      if (Keyboard.getEventKey() == Keyboard.KEY_F) {
        try {
          if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) ||
              Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
            System.out.println("Performing Display.destroy()/create() cycle");
            DisplayMode saved_mode = Display.getDisplayMode();
            Display.destroy();
            Display.setDisplayMode(saved_mode);
            Display.setFullscreen(fullscreen = !fullscreen);
            Display.create();
          } else
View Full Code Here

      }
    }
    //check for window key
    if (Keyboard.isKeyDown(Keyboard.KEY_W)) {
      try {
        mode = new DisplayMode(640, 480);
        Display.setDisplayModeAndFullscreen(mode);
        glInit();
      } catch (Exception e) {
        e.printStackTrace();
      }
View Full Code Here

   */
  private void init() throws LWJGLException {
    // create Window of size 300x300
    Display.setLocation((Display.getDisplayMode().getWidth() - 300) / 2,
                        (Display.getDisplayMode().getHeight() - 300) / 2);
    Display.setDisplayMode(new DisplayMode(300, 300));
    Display.setTitle("Gears");
    Display.create();

    // setup ogl
    FloatBuffer pos = BufferUtils.createFloatBuffer(4).put(new float[] { 5.0f, 5.0f, 10.0f, 0.0f});
View Full Code Here

  /**
   * Sets the display mode for fullscreen mode
   */
  protected boolean setDisplayMode() {
    // get modes
    DisplayMode dm = new DisplayMode(WINDOW_WIDTH, WINDOW_HEIGHT);

    try {
      Display.setDisplayMode(dm);
      return true;
    } catch (Exception e) {
View Full Code Here

  private void createDisplay() throws LWJGLException {
    int width = 300;
    int height = 300;

    Display.setDisplayMode(new DisplayMode(width,height));
    Display.create();
    Display.setVSyncEnabled(true);

    glEnable(GL_TEXTURE_2D);
    glShadeModel(GL_SMOOTH);
View Full Code Here

  @NiftyEventSubscriber(id="resolutions")
  public void onResolution(final String id, final DropDownSelectionChangedEvent<DisplayMode> event) {
    screen.findElementByName("whiteOverlay").startEffect(EffectEventId.onCustom, new EndNotify() {
      @Override
      public void perform() {
        DisplayMode displayMode = event.getSelection();
        try {
          Display.setDisplayMode(displayMode);

          GL11.glMatrixMode(GL11.GL_PROJECTION);
            GL11.glLoadIdentity();
            GL11.glOrtho(0, displayMode.getWidth(), displayMode.getHeight(), 0, -9999, 9999);

          GL11.glMatrixMode(GL11.GL_MODELVIEW);

          nifty.resolutionChanged();
        } catch (LWJGLException e) {
View Full Code Here

   * Get all LWJGL DisplayModes into the DropDown
   * @param screen
   */
  private void fillResolutionDropDown(final Screen screen) {
    try {
      DisplayMode currentMode = Display.getDisplayMode();
      List <DisplayMode> sorted = new ArrayList<DisplayMode>();

      DisplayMode[] modes = Display.getAvailableDisplayModes();
      for (int i=0; i<modes.length; i++) {
        DisplayMode mode = modes[i];
        if (mode.getBitsPerPixel() == 32 && mode.getFrequency() == currentMode.getFrequency()) {
          // since Nifty does not yet support automatically rescaling of the GUI and since this
          // example/demo was designed for 1024x768 pixel we can't allow resolutions below this size.
          if (mode.getWidth() >= 1024 && mode.getHeight() >= 768) {
            sorted.add(mode);
          }
        }
      }

View Full Code Here

   */
  private static boolean initGraphics(final String title) {
    int width = 1920;
    int height = 1200;
    try {
      DisplayMode currentMode = Display.getDisplayMode();
      log.fine("currentmode: " + currentMode.getWidth() + ", " + currentMode.getHeight() + ", " + currentMode.getBitsPerPixel() + ", " + currentMode.getFrequency());

      width = currentMode.getWidth();
      height = currentMode.getHeight();

      //  get available modes, and print out
      DisplayMode[] modes = Display.getAvailableDisplayModes();
      log.fine("Found " + modes.length + " display modes");

      List < DisplayMode > matching = new ArrayList < DisplayMode >();
      for (int i = 0; i < modes.length; i++) {
        DisplayMode mode = modes[i];
        if (mode.getWidth() == WIDTH && mode.getHeight() == HEIGHT && mode.getBitsPerPixel() == 32 ) {
          log.fine(mode.getWidth() + ", " + mode.getHeight() + ", " + mode.getBitsPerPixel() + ", " + mode.getFrequency());
          matching.add(mode);
        }
      }

      DisplayMode[] matchingModes = matching.toArray(new DisplayMode[0]);

      // find mode with matching freq
      boolean found = false;
      for (int i = 0; i < matchingModes.length; i++) {
        if (matchingModes[i].getFrequency() == currentMode.getFrequency()) {
          log.fine("using mode: " + matchingModes[i].getWidth() + ", "
              + matchingModes[i].getHeight() + ", "
              + matchingModes[i].getBitsPerPixel() + ", "
              + matchingModes[i].getFrequency());
          Display.setDisplayMode(matchingModes[i]);
          found = true;
          break;
        }
      }

      if (!found) {
        Arrays.sort(matchingModes, new Comparator < DisplayMode >() {
          public int compare(final DisplayMode o1, final DisplayMode o2) {
            if (o1.getFrequency() > o2.getFrequency()) {
              return 1;
            } else if (o1.getFrequency() < o2.getFrequency()) {
              return -1;
            } else {
              return 0;
            }
          }
        });

        for (DisplayMode mode : matchingModes) {
          log.fine("using fallback mode: " + mode.getWidth() + ", "
              + mode.getHeight() + ", "
              + mode.getBitsPerPixel() + ", "
              + mode.getFrequency());
          Display.setDisplayMode(mode);
          break;
        }
      }

View Full Code Here

*/
public class DisplayListsDemo {

    public static void main(String[] args) {
        try {
            Display.setDisplayMode(new DisplayMode(640, 480));
            Display.setTitle("Display Lists Demo");
            Display.create();
        } catch (LWJGLException e) {
            e.printStackTrace();
            Display.destroy();
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.