shit is rotating now

This commit is contained in:
JonasJan2 2024-06-06 22:55:52 +02:00
parent 3436a8b38a
commit 32afa76813
1 changed files with 26 additions and 2 deletions

View File

@ -56,6 +56,8 @@ GLfloat step = 0.0f;
const GLfloat pi = 3.14159f;
vec3 cameraPosition = {0.0f, 3.0f, 5.5f};
vec3 objectPosition = {0.0f, 0.0f, 0.0f};
GLfloat radius = 1.0f;
int numModels = 4;
char* models[] = {
@ -85,6 +87,25 @@ void handleInputs(double deltaTime) {
if (glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS) {
cameraPosition.y -= deltaTime * 10;
}
if (glfwGetKey(window, GLFW_KEY_L) == GLFW_PRESS) {
objectPosition.x += deltaTime * 10;
}
if (glfwGetKey(window, GLFW_KEY_J) == GLFW_PRESS) {
objectPosition.x -= deltaTime * 10;
}
if (glfwGetKey(window, GLFW_KEY_I) == GLFW_PRESS) {
objectPosition.z += deltaTime * 10;
}
if (glfwGetKey(window, GLFW_KEY_K) == GLFW_PRESS) {
objectPosition.z -= deltaTime * 10;
}
if (glfwGetKey(window, GLFW_KEY_R) == GLFW_PRESS) {
radius += deltaTime * 10;
}
if (glfwGetKey(window, GLFW_KEY_F) == GLFW_PRESS) {
radius -= deltaTime * 10;
}
}
// input handler to quit with ESC
@ -147,7 +168,6 @@ void init(void) {
vertexTextConst = NULL;
// create and compile fragment shader
const GLchar *fragmentTextConst = fragmentShader_glsl;
GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
@ -312,7 +332,11 @@ void draw(void) {
rotateX(&modelTransformation, &modelTransformation, stepi);
} else if (i == 3) {
// Example transformations for the fourth object
vec3 v = {1.0f, 0.0f, 0.0f};
vec3 v = {
objectPosition.x + cos(stepi) * 1.0f,
objectPosition.y + sin(stepi) * 1.0f,
objectPosition.z
};
translate(&modelTransformation, &modelTransformation, &v);
}