#include <GLES3/gl32.h>
#include <string>
#include <vector>
+#include <glm/glm.hpp>
+#include <glm/ext.hpp>
+#include <glm/gtc/type_ptr.hpp>
const char* vertShaderSrc = R"(
attribute vec4 vertPos;
+uniform mat4 model;
void main() {
- gl_Position = vertPos;
+ gl_Position = model * vertPos;
}
)";
}
)";
+GLuint program;
+
extern "C" void setup() {
GLuint vertShader = glCreateShader(GL_VERTEX_SHADER);
const char* sources[1] = { vertShaderSrc };
new const GLint[1] { (GLint)strlen(fragShaderSrc) });
glCompileShader(fragShader);
- GLuint program = glCreateProgram();
+ program = glCreateProgram();
glAttachShader(program, vertShader);
glAttachShader(program, fragShader);
glLinkProgram(program);
glEnableVertexAttribArray(vertPosLoc);
glVertexAttribPointer(vertPosLoc, 3, GL_FLOAT, false, 0, 0);
}
+
+extern "C" void update(int tick) {
+ GLuint modelLoc = glGetUniformLocation(program, "model");
+ const glm::mat4 model = glm::rotate(glm::mat4(1), (float)tick * 0.001f, glm::vec3(0, 0, 1));
+ glUniformMatrix4fv(modelLoc, 1, false, glm::value_ptr(model));
+}