瀏覽代碼

bug(transform): fix transformation (rotation) along the z axis.

it's not completely fixed yet, but the rotation seems to be reasonable
now.

need to figure out delta_time to maintain current speed of the rotation
Douglas A 2 年之前
父節點
當前提交
d641ffcf20
共有 1 個文件被更改,包括 6 次插入4 次删除
  1. 6 4
      src/main.cpp

+ 6 - 4
src/main.cpp

@@ -4,7 +4,7 @@
 
 #include <iostream>
 #include <string>
-
+#include <math.h>
 #include "graphics.hpp"
 
 #define INITIAL_WIDTH 800
@@ -35,7 +35,7 @@ const std::string vert_shader = R"(
 
 precision mediump float;
 
-layout(location = 0) in vec2 position;
+layout(location = 0) in vec3 position;
 
 void main (void) {
         vec2 uv;
@@ -63,7 +63,7 @@ void transform(float *v, double delta_time) {
         v[4] = x3;
         v[5] = y3;
 
-        angle += 0.01 * delta_time;
+        angle += 0.001 * delta_time;
 }
 
 
@@ -135,7 +135,9 @@ int main()
 
                 transform(v1, delta_time);
                 b1.bind();
-                glBufferSubData(GL_ARRAY_BUFFER, 0, 3 * sizeof(GL_FLOAT), v1);
+
+                //v1[0] += 0.01f;
+                glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(v1), v1);
                 glfwPollEvents();
                 double cur_time = glfwGetTime();
                 delta_time = cur_time - prev_time;