瀏覽代碼

use java timer, stop generating unused mipmap

Kajetan Johannes Hammerle 5 年之前
父節點
當前提交
d77d8592f5
共有 2 個文件被更改,包括 5 次插入5 次删除
  1. 4 4
      src/me/hammerle/snuviengine/api/Engine.java
  2. 1 1
      src/me/hammerle/snuviengine/api/Texture.java

+ 4 - 4
src/me/hammerle/snuviengine/api/Engine.java

@@ -121,7 +121,7 @@ public class Engine
 
     private static void loop(IGame game)
     {
-        long newTime = glfwGetTimerValue();
+        long newTime = System.nanoTime();
         long oldTime;
         long lag = 0;
         long frameLag = 0;
@@ -130,7 +130,7 @@ public class Engine
         while(!glfwWindowShouldClose(window))
         {
             oldTime = newTime;
-            newTime = glfwGetTimerValue();
+            newTime = System.nanoTime();
             lag += newTime - oldTime;
             frameLag += newTime - oldTime;
 
@@ -164,9 +164,9 @@ public class Engine
                     frameLag -= nanosPerFrame;
                     // make sure no frames are rendered immediately after each other
                     // this happens if the game tick takes too long
-                    if(lastFrame + nanosPerFrame - 1000000 < glfwGetTimerValue())
+                    if(lastFrame + nanosPerFrame - 1000000 < System.nanoTime())
                     {
-                        lastFrame = glfwGetTimerValue();
+                        lastFrame = System.nanoTime();
 
                         game.renderTick(renderer, (float) lag / nanosPerTick);
                         tpsTimer.draw(renderer);

+ 1 - 1
src/me/hammerle/snuviengine/api/Texture.java

@@ -119,7 +119,7 @@ public class Texture
         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, buffer);
-        glGenerateMipmap(GL_TEXTURE_2D);
+        //glGenerateMipmap(GL_TEXTURE_2D);
     }
     
     public Texture(String path)