reformatted

This commit is contained in:
Eikthyrnir 2023-11-18 02:56:00 +01:00
parent 0e406f71c8
commit ce33570341
3 changed files with 17 additions and 18 deletions

View File

@ -4,7 +4,7 @@
#include "Shader_Loader.h"
#include "Render_Utils.h"
#include "ex_1_1.hpp"
#include "ex_1_7.hpp"

View File

@ -8,7 +8,7 @@ uniform vec3 cameraPos;
uniform float time;
in vec3 vertexNormalOut;
out vec3 vertexPosOut;
in vec3 vertexPosOut;
out vec4 outColor;
void main()
@ -24,6 +24,5 @@ void main()
float specular = pow(max(dot(viewDir, reflectDir), 0.0), glossPow);
float diffuse = intensity;
//outColor = vec4(lightColor * (color * diffuse + specular ), 1.0);
outColor = vec4(1.0);
outColor = vec4(lightColor * (color * diffuse + specular ), 1.0);
}

View File

@ -32,7 +32,7 @@ glm::vec3 lightColor = glm::vec3(1.f, 1.f, 1.f);
glm::vec3 spaceshipPos = glm::vec3(-4.f, 0, 0);
glm::vec3 spaceshipDir = glm::vec3(1.f, 0.f, 0.f);
GLuint VAO,VBO;
GLuint VAO, VBO;
float aspectRatio = 1.f;
@ -52,8 +52,8 @@ void updateDeltaTime(float time) {
glm::mat4 createCameraMatrix()
{
glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir,glm::vec3(0.f,1.f,0.f)));
glm::vec3 cameraUp = glm::normalize(glm::cross(cameraSide,cameraDir));
glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir, glm::vec3(0.f, 1.f, 0.f)));
glm::vec3 cameraUp = glm::normalize(glm::cross(cameraSide, cameraDir));
glm::mat4 cameraRotrationMatrix = glm::mat4({
cameraSide.x,cameraSide.y,cameraSide.z,0,
cameraUp.x,cameraUp.y,cameraUp.z ,0,
@ -77,12 +77,12 @@ glm::mat4 createPerspectiveMatrix()
perspectiveMatrix = glm::mat4({
1,0.,0.,0.,
0.,aspectRatio,0.,0.,
0.,0.,(f+n) / (n - f),2*f * n / (n - f),
0.,0.,(f + n) / (n - f),2 * f * n / (n - f),
0.,0.,-1.,0.,
});
perspectiveMatrix=glm::transpose(perspectiveMatrix);
perspectiveMatrix = glm::transpose(perspectiveMatrix);
return perspectiveMatrix;
}
@ -93,7 +93,7 @@ void drawObjectColor(Core::RenderContext& context, glm::mat4 modelMatrix, glm::v
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
glUniformMatrix4fv(glGetUniformLocation(program, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUniformMatrix4fv(glGetUniformLocation(program, "modelMat"), 1, GL_FALSE, (float*)&modelMatrix);
glUniform3f(glGetUniformLocation(program, "color"), color.x,color.y,color.z);
glUniform3f(glGetUniformLocation(program, "color"), color.x, color.y, color.z);
glUniform3f(glGetUniformLocation(program, "lightDir"), lightDir.x, lightDir.y, lightDir.z);
glUniform3f(glGetUniformLocation(program, "lightColor"), lightColor.x, lightColor.y, lightColor.z);
glUniform3f(glGetUniformLocation(program, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
@ -114,7 +114,7 @@ void renderScene(GLFWwindow* window)
drawObjectColor(sphereContext,glm::mat4(),glm::vec3(1.0, 1.0, 0.3));
drawObjectColor(sphereContext, glm::mat4(), glm::vec3(1.0, 1.0, 0.3));
drawObjectColor(sphereContext, glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::scale(glm::vec3(0.3f)), glm::vec3(0.2, 0.7, 0.3));
@ -139,7 +139,7 @@ void renderScene(GLFWwindow* window)
drawObjectColor(shipContext,
glm::translate(spaceshipPos) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()) * glm::scale(glm::vec3(0.2f)),
glm::vec3(0.3, 0.3, 0.5)
);
);
glfwSwapBuffers(window);
@ -152,7 +152,7 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height)
void loadModelToContext(std::string path, Core::RenderContext& context)
{
Assimp::Importer import;
const aiScene* scene = import.ReadFile(path, aiProcess_Triangulate | aiProcess_CalcTangentSpace);
const aiScene * scene = import.ReadFile(path, aiProcess_Triangulate | aiProcess_CalcTangentSpace);
if (!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
{