[EDIT] code style guide - toolbox & main

This commit is contained in:
Menno
2021-05-18 11:31:25 +02:00
parent 5047467206
commit 0517f9e897
10 changed files with 20 additions and 65 deletions

View File

@@ -1,18 +1,16 @@
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <glm/gtc/matrix_transform.hpp>
#include <vector>
#define STB_IMAGE_IMPLEMENTATION
#include <ostream>
#include "stb_image.h"
#include <ostream>
#include "models/Model.h"
#include "renderEngine/Loader.h"
#include "renderEngine/ObjLoader.h"
#include "renderEngine/Renderer.h"
#include "shaders/StaticShader.h"
#include "toolbox/Toolbox.h"
#include "toolbox/math.h"
#pragma comment(lib, "glfw3.lib")
#pragma comment(lib, "glew32s.lib")

View File

@@ -1,5 +1,4 @@
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include "../stb_image.h"
#include "Loader.h"

View File

@@ -3,7 +3,7 @@
#include <iostream>
#include "../models/Model.h"
#include "Renderer.h"
#include "../toolbox/Toolbox.h"
#include "../toolbox/math.h"
namespace renderEngine
{
@@ -52,7 +52,7 @@ namespace renderEngine
glEnableVertexAttribArray(1);
// Load the transformation of the model into the shader
const glm::mat4 modelMatrix = toolbox::createModelMatrix(entity.getPosition(), entity.getRotation(), entity.getScale());
const glm::mat4 modelMatrix = toolbox::CreateModelMatrix(entity.getPosition(), entity.getRotation(), entity.getScale());
shader.loadModelMatrix(modelMatrix);
// Draw the model

View File

@@ -1,5 +1,5 @@
#include "StaticShader.h"
#include "../toolbox/Toolbox.h"
#include "../toolbox/math.h"
namespace shaders
{
@@ -69,7 +69,7 @@ namespace shaders
void StaticShader::loadViewMatrix(entities::Camera& camera) const
{
const glm::mat4 viewMatrix = toolbox::createViewMatrix(camera);
const glm::mat4 viewMatrix = toolbox::CreateViewMatrix(camera);
loadMatrix(location_viewMatrix, viewMatrix);
}

View File

@@ -1,17 +0,0 @@
#version 400 core
// The FragmentShader is run for each pixel in a face on the screen.
// Interpolated textureCoordinates of the vertex (relative to the distance to each vertex)
in vec2 passTextureCoords;
// Final color of the pixel
out vec4 outColor;
// The texture of the model
uniform sampler2D textureSampler;
void main(void)
{
outColor = texture(textureSampler, passTextureCoords);
}

View File

@@ -1,25 +0,0 @@
#version 400 core
// The VertexShader is run for each vertex on the screen.
// Position of the vertex
in vec3 position;
// Coordinates of the texture
in vec2 textureCoords;
// Equal to the textureCoords
out vec2 passTextureCoords;
uniform mat4 modelMatrix;
uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;
void main(void)
{
// Tell OpenGL where to render the vertex
gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.0);
// Pass the textureCoords directly to the fragment shader
passTextureCoords = textureCoords;
}

View File

@@ -1,8 +1,8 @@
#include "Toolbox.h"
#include "math.h"
namespace toolbox
{
glm::mat4 createModelMatrix(glm::vec3 translation, glm::vec3 rotation, float scale)
glm::mat4 CreateModelMatrix(glm::vec3 translation, glm::vec3 rotation, float scale)
{
glm::mat4 matrix(1.0f);
matrix = glm::translate(matrix, translation);
@@ -13,14 +13,14 @@ namespace toolbox
return matrix;
}
glm::mat4 createViewMatrix(entities::Camera& camera)
glm::mat4 CreateViewMatrix(entities::Camera& camera)
{
glm::mat4 matrix(1.0f);
matrix = glm::rotate(matrix, glm::radians(camera.getRotation().x), glm::vec3(1, 0, 0));
matrix = glm::rotate(matrix, glm::radians(camera.getRotation().y), glm::vec3(0, 1, 0));
matrix = glm::rotate(matrix, glm::radians(camera.getRotation().z), glm::vec3(0, 0, 1));
const glm::vec3 negativeCamPos = glm::vec3(-camera.getPosition().x, -camera.getPosition().y, -camera.getPosition().z);
matrix = glm::translate(matrix, negativeCamPos);
const glm::vec3 negative_cam_pos = glm::vec3(-camera.getPosition().x, -camera.getPosition().y, -camera.getPosition().z);
matrix = glm::translate(matrix, negative_cam_pos);
return matrix;
}
}

View File

@@ -8,7 +8,7 @@ namespace toolbox
#define WINDOW_WIDTH 1400.0f
#define WINDOW_HEIGT 800.0f
glm::mat4 createModelMatrix(glm::vec3 translation, glm::vec3 rotation, float scale);
glm::mat4 CreateModelMatrix(glm::vec3 translation, glm::vec3 rotation, float scale);
glm::mat4 createViewMatrix(entities::Camera& camera);
glm::mat4 CreateViewMatrix(entities::Camera& camera);
}

View File

@@ -21,13 +21,13 @@
<ItemGroup>
<ClCompile Include="src\entities\Camera.cpp" />
<ClCompile Include="src\entities\Entity.cpp" />
<ClCompile Include="src\MainManager.cpp" />
<ClCompile Include="src\main.cpp" />
<ClCompile Include="src\renderEngine\Loader.cpp" />
<ClCompile Include="src\renderEngine\ObjLoader.cpp" />
<ClCompile Include="src\renderEngine\Renderer.cpp" />
<ClCompile Include="src\shaders\ShaderProgram.cpp" />
<ClCompile Include="src\shaders\StaticShader.cpp" />
<ClCompile Include="src\toolbox\Toolbox.cpp" />
<ClCompile Include="src\toolbox\math.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\entities\Camera.h" />
@@ -39,7 +39,7 @@
<ClInclude Include="src\shaders\ShaderProgram.h" />
<ClInclude Include="src\shaders\StaticShader.h" />
<ClInclude Include="src\stb_image.h" />
<ClInclude Include="src\toolbox\Toolbox.h" />
<ClInclude Include="src\toolbox\math.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>

View File

@@ -36,10 +36,10 @@
<ClCompile Include="src\shaders\StaticShader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\toolbox\Toolbox.cpp">
<ClCompile Include="src\main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\MainManager.cpp">
<ClCompile Include="src\toolbox\math.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
@@ -68,10 +68,10 @@
<ClInclude Include="src\shaders\StaticShader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\toolbox\Toolbox.h">
<ClInclude Include="src\stb_image.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\stb_image.h">
<ClInclude Include="src\toolbox\math.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>