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);
 }
예제 #2
0
 private static void setUpLighting() {
   glShadeModel(GL_SMOOTH);
   glEnable(GL_DEPTH_TEST);
   glEnable(GL_LIGHTING);
   glEnable(GL_LIGHT0);
   glLightModel(GL_LIGHT_MODEL_AMBIENT, asFloatBuffer(new float[] {0.05f, 0.05f, 0.05f, 1f}));
   glLight(GL_LIGHT0, GL_POSITION, asFloatBuffer(new float[] {0, 0, 0, 1}));
   glEnable(GL_CULL_FACE);
   glCullFace(GL_BACK);
   glEnable(GL_COLOR_MATERIAL);
   glColorMaterial(GL_FRONT, GL_DIFFUSE);
 }
 private static void setUpStates() {
   glShadeModel(GL_SMOOTH);
   glEnable(GL_DEPTH_TEST);
   glEnable(GL_LIGHTING);
   glEnable(GL_LIGHT0);
   glLightModel(
       GL_LIGHT_MODEL_AMBIENT,
       BufferTools.asFlippedFloatBuffer(new float[] {0.05f, 0.05f, 0.05f, 1f}));
   glLight(GL_LIGHT0, GL_POSITION, BufferTools.asFlippedFloatBuffer(new float[] {0, 0, 0, 1}));
   glEnable(GL_CULL_FACE);
   glCullFace(GL_BACK);
   glEnable(GL_COLOR_MATERIAL);
   glColorMaterial(GL_FRONT, GL_DIFFUSE);
   glColor3f(0.4f, 0.27f, 0.17f);
   glMaterialf(GL_FRONT, GL_SHININESS, 10f);
   if (GLContext.getCapabilities().GL_ARB_depth_clamp) {
     glEnable(ARBDepthClamp.GL_DEPTH_CLAMP);
   }
 }
예제 #4
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);
 }