コード例 #1
0
 private static void setUpCamera() {
   cam =
       new EulerCamera(
           (float) Display.getWidth() / (float) Display.getHeight(), -2.19f, 1.36f, 11.45f);
   cam.setFieldOfView(70);
   cam.applyPerspectiveMatrix();
 }
コード例 #2
0
 private static void checkInput() {
   cam.processMouse(1, 80, -80);
   cam.processKeyboard(16, 1, 1, 1);
   if (Mouse.isButtonDown(0)) {
     Mouse.setGrabbed(true);
   } else if (Mouse.isButtonDown(1)) {
     Mouse.setGrabbed(false);
   }
 }
コード例 #3
0
 private static void render() {
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   glLoadIdentity();
   camera.applyTranslations();
   glUseProgram(currentShaderProgram);
   glLight(
       GL_LIGHT0,
       GL_POSITION,
       BufferTools.asFlippedFloatBuffer(camera.x(), camera.y(), camera.z(), 1));
   glDrawArrays(GL_TRIANGLES, 0, model.faces.size() * 3);
 }
コード例 #4
0
 private static void checkInput() {
   timer.update();
   camera.processMouse(1, 80, -80);
   camera.processKeyboard(16, 1, 1, 1);
   if (Mouse.isButtonDown(0)) Mouse.setGrabbed(true);
   else if (Mouse.isButtonDown(1)) Mouse.setGrabbed(false);
   while (Keyboard.next()) {
     if (Keyboard.isKeyDown(Keyboard.KEY_P)) {
       currentShaderProgram = perPixelShaderProgram;
     } else if (Keyboard.isKeyDown(Keyboard.KEY_V)) {
       currentShaderProgram = perVertexShaderProgram;
     }
   }
 }
コード例 #5
0
 private static void render() {
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   glLoadIdentity();
   cam.applyTranslations();
   glUseProgram(shaderProgram);
   glLight(GL_LIGHT0, GL_POSITION, asFloatBuffer(cam.x(), cam.y(), cam.z(), 1));
   glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle);
   glVertexPointer(3, GL_FLOAT, 0, 0L);
   glBindBuffer(GL_ARRAY_BUFFER, vboNormalHandle);
   glNormalPointer(GL_FLOAT, 0, 0L);
   glEnableClientState(GL_VERTEX_ARRAY);
   glEnableClientState(GL_NORMAL_ARRAY);
   glColor3f(0.4f, 0.27f, 0.17f);
   glMaterialf(GL_FRONT, GL_SHININESS, 10f);
   glDrawArrays(GL_TRIANGLES, 0, model.faces.size() * 3);
   glDisableClientState(GL_VERTEX_ARRAY);
   glDisableClientState(GL_NORMAL_ARRAY);
   glBindBuffer(GL_ARRAY_BUFFER, 0);
   glUseProgram(0);
 }