コード例 #1
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();
  }
コード例 #2
0
ファイル: WindowsDisplay.java プロジェクト: ravenocean/lwjgl
  private void restoreDisplayMode() {
    try {
      doSetGammaRamp(current_gamma);
    } catch (LWJGLException e) {
      LWJGLUtil.log("Failed to restore gamma: " + e.getMessage());
    }

    if (!mode_set) {
      mode_set = true;
      try {
        nSwitchDisplayMode(current_mode);
      } catch (LWJGLException e) {
        LWJGLUtil.log("Failed to restore display mode: " + e.getMessage());
      }
    }
  }
コード例 #3
0
ファイル: WindowsDisplay.java プロジェクト: ravenocean/lwjgl
 public void resetDisplayMode() {
   try {
     doSetGammaRamp(saved_gamma);
   } catch (LWJGLException e) {
     LWJGLUtil.log("Failed to reset gamma ramp: " + e.getMessage());
   }
   current_gamma = saved_gamma;
   if (mode_set) {
     mode_set = false;
     nResetDisplayMode();
   }
   resetCursorClipping();
 }
コード例 #4
0
ファイル: WindowsDisplay.java プロジェクト: ravenocean/lwjgl
 private void updateClipping() {
   if ((Display.isFullscreen() || (mouse != null && mouse.isGrabbed()))
       && !isMinimized
       && isFocused
       && (getForegroundWindow() == getHwnd() || hasParent)) {
     try {
       setupCursorClipping(getHwnd());
     } catch (LWJGLException e) {
       LWJGLUtil.log("setupCursorClipping failed: " + e.getMessage());
     }
   } else {
     resetCursorClipping();
   }
 }
コード例 #5
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;
  }
コード例 #6
0
  private int detectControllers() {
    validControllers.clear();
    inValidControllers.clear();

    try {
      if (!Controllers.isCreated()) Controllers.create();

      if (Controllers.getControllerCount() > 0) {
        LogHelper.Info("Found " + Controllers.getControllerCount() + " controller(s) in total.");
        for (int joyIndex = 0; joyIndex < Controllers.getControllerCount(); joyIndex++) {
          Controller thisController = Controllers.getController(joyIndex);

          logControllerInfo(thisController);

          if (controllerUtils.meetsInputRequirements(
              thisController, requiredButtonCount, requiredMinButtonCount, requiredAxisCount)) {
            LogHelper.Info(
                "Controller #"
                    + joyIndex
                    + " ( "
                    + thisController.getName()
                    + ") meets the input requirements");
            addControllerToList(validControllers, thisController.getName(), joyIndex);
          } else {
            LogHelper.Info("This controller does not meet the input requirements");
            addControllerToList(inValidControllers, thisController.getName(), joyIndex);
          }
          LogHelper.Info("---");
        }
      }
    } catch (org.lwjgl.LWJGLException e) {
      System.err.println("Couldn't initialize Controllers: " + e.getMessage());
    }

    LogHelper.Info("Found " + validControllers.size() + " valid controllers!");
    return validControllers.size();
  }