Fixat lite classer osv
This commit is contained in:
@@ -89,7 +89,14 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="Renderer.cpp" />
|
||||
<ClCompile Include="Renderer\Renderer.cpp" />
|
||||
<ClCompile Include="Systems\CollisionSystem.cpp" />
|
||||
<ClCompile Include="Systems\InputSystem.cpp" />
|
||||
<ClCompile Include="Systems\LevelGenerationSystem.cpp" />
|
||||
<ClCompile Include="Systems\ParticleSystem.cpp" />
|
||||
<ClCompile Include="Systems\PlayerSystem.cpp" />
|
||||
<ClCompile Include="Systems\RenderSystem.cpp" />
|
||||
<ClCompile Include="Systems\SoundsSystem.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Component.h" />
|
||||
@@ -98,12 +105,19 @@
|
||||
<ClInclude Include="Entity.h" />
|
||||
<ClInclude Include="logging.h" />
|
||||
<ClInclude Include="glerror.h" />
|
||||
<ClInclude Include="Renderer.h" />
|
||||
<ClInclude Include="Renderer\Renderer.h" />
|
||||
<ClInclude Include="Systems\CollisionSystem.h" />
|
||||
<ClInclude Include="Systems\InputSystem.h" />
|
||||
<ClInclude Include="Systems\LevelGenerationSystem.h" />
|
||||
<ClInclude Include="Systems\ParticleSystem.h" />
|
||||
<ClInclude Include="Systems\PlayerSystem.h" />
|
||||
<ClInclude Include="Systems\RenderSystem.h" />
|
||||
<ClInclude Include="Systems\SoundSystem.h" />
|
||||
<ClInclude Include="World.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Fragment.glsl" />
|
||||
<None Include="Vertex.glsl" />
|
||||
<None Include="Shaders\Fragment.glsl" />
|
||||
<None Include="Shaders\Vertex.glsl" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
||||
@@ -25,12 +25,39 @@
|
||||
<Filter Include="Shaders">
|
||||
<UniqueIdentifier>{26dccea6-3d9c-4d5f-9db2-98621e35ffcb}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\Systems">
|
||||
<UniqueIdentifier>{e7de2e5a-0a73-437a-8d01-5f23770e5cba}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\Systems">
|
||||
<UniqueIdentifier>{7673cacc-e435-4028-9354-b2c8b559c7b3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Renderer.cpp">
|
||||
<ClCompile Include="Systems\CollisionSystem.cpp">
|
||||
<Filter>Source Files\Systems</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Systems\InputSystem.cpp">
|
||||
<Filter>Source Files\Systems</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Systems\LevelGenerationSystem.cpp">
|
||||
<Filter>Source Files\Systems</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Systems\ParticleSystem.cpp">
|
||||
<Filter>Source Files\Systems</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Systems\PlayerSystem.cpp">
|
||||
<Filter>Source Files\Systems</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Systems\RenderSystem.cpp">
|
||||
<Filter>Source Files\Systems</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Systems\SoundsSystem.cpp">
|
||||
<Filter>Source Files\Systems</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Renderer\Renderer.cpp">
|
||||
<Filter>Source Files\Renderer</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
@@ -56,15 +83,36 @@
|
||||
<ClInclude Include="ComponentFactory.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Renderer.h">
|
||||
<ClInclude Include="Systems\CollisionSystem.h">
|
||||
<Filter>Header Files\Systems</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Systems\InputSystem.h">
|
||||
<Filter>Header Files\Systems</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Systems\LevelGenerationSystem.h">
|
||||
<Filter>Header Files\Systems</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Systems\ParticleSystem.h">
|
||||
<Filter>Header Files\Systems</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Systems\PlayerSystem.h">
|
||||
<Filter>Header Files\Systems</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Systems\RenderSystem.h">
|
||||
<Filter>Header Files\Systems</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Systems\SoundSystem.h">
|
||||
<Filter>Header Files\Systems</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Renderer\Renderer.h">
|
||||
<Filter>Header Files\Renderer</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Fragment.glsl">
|
||||
<None Include="Shaders\Fragment.glsl">
|
||||
<Filter>Shaders</Filter>
|
||||
</None>
|
||||
<None Include="Vertex.glsl">
|
||||
<None Include="Shaders\Vertex.glsl">
|
||||
<Filter>Shaders</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
//Skicka models och skit till renderer.
|
||||
@@ -1,21 +1,18 @@
|
||||
#include "Renderer.h"
|
||||
#include "Renderer/Renderer.h"
|
||||
|
||||
Renderer::Renderer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Renderer::PushVertices(std::vector<float> _Verts)
|
||||
void Renderer::Draw()
|
||||
{
|
||||
Vertices.push_back(_Verts);
|
||||
|
||||
}
|
||||
void Renderer::PushNormals(std::vector<float> _Normals)
|
||||
|
||||
void Renderer::DrawText()
|
||||
{
|
||||
Normals.push_back(_Normals);
|
||||
}
|
||||
void Renderer::PushTextureCoords(std::vector<float> _Textcords)
|
||||
{
|
||||
TextureCoords.push_back(_Textcords);
|
||||
|
||||
}
|
||||
|
||||
//Fixa med shaders, lägga in alla verts osv.
|
||||
@@ -64,5 +61,4 @@ GLuint Renderer::CompileShader(GLenum shaderType, std::string fileName)
|
||||
return 0;
|
||||
|
||||
return shader;
|
||||
|
||||
}
|
||||
@@ -25,14 +25,10 @@ public:
|
||||
GLuint VAO;
|
||||
|
||||
Renderer();
|
||||
|
||||
void Draw();
|
||||
void DrawText();
|
||||
|
||||
std::vector<std::vector<float>> Vertices;
|
||||
std::vector<std::vector<float>> Normals;
|
||||
std::vector<std::vector<float>> TextureCoords;
|
||||
|
||||
void PushVertices(std::vector<float>);
|
||||
void PushNormals(std::vector<float>);
|
||||
void PushTextureCoords(std::vector<float>);
|
||||
GLuint CompileShader(GLenum, std::string);
|
||||
|
||||
};
|
||||
@@ -0,0 +1,55 @@
|
||||
#include "Renderer.h"
|
||||
|
||||
Renderer::Renderer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//Fixa med shaders, lägga in alla verts osv.
|
||||
|
||||
|
||||
GLuint Renderer::CompileShader(GLenum shaderType, std::string fileName)
|
||||
{
|
||||
std::string shaderFile;
|
||||
std::ifstream in(fileName, std::ios::in);
|
||||
|
||||
if(!in)
|
||||
{
|
||||
LOG_ERROR("Error: Failed to open shader file %s", fileName);
|
||||
return 0;
|
||||
}
|
||||
in.seekg(0, std::ios::end);
|
||||
shaderFile.resize((int)in.tellg());
|
||||
in.seekg(0, std::ios::beg);
|
||||
in.read(&shaderFile[0], shaderFile.size());
|
||||
in.close();
|
||||
|
||||
GLuint shader = glCreateShader(shaderType); //GL_VERTEX_SHADER, GL_FRAGMENT_SHADER
|
||||
if(GLERROR("glCreateShader"))
|
||||
return 0;
|
||||
|
||||
const GLchar* shaderFiles = shaderFile.c_str();
|
||||
const GLint length = shaderFile.length();
|
||||
glShaderSource(shader, 1, &shaderFiles, &length);
|
||||
if(GLERROR("glShaderSource"))
|
||||
return 0;
|
||||
|
||||
glCompileShader(shader);
|
||||
GLint compileStatus;
|
||||
glGetShaderiv(shader, GL_COMPILE_STATUS, &compileStatus);
|
||||
if(compileStatus != GL_TRUE)
|
||||
{
|
||||
GLsizei infoLogLength;
|
||||
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength);
|
||||
GLchar* infolog = new GLchar[infoLogLength];
|
||||
glGetShaderInfoLog(shader, infoLogLength, &infoLogLength, infolog);
|
||||
std::cerr << infolog << std::endl;
|
||||
delete[] infolog;
|
||||
}
|
||||
|
||||
if(GLERROR("glCompileShader"))
|
||||
return 0;
|
||||
|
||||
return shader;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#include <GL/glew.h>
|
||||
#define GLFW_INCLUDE_GLU
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <glext.h>
|
||||
#define GLM_FORCE_RADIANS
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
#include "glerror.h"
|
||||
|
||||
|
||||
class Renderer
|
||||
{
|
||||
public:
|
||||
GLuint shaderProgram;
|
||||
GLuint VAO;
|
||||
|
||||
Renderer();
|
||||
|
||||
void Draw();
|
||||
void DrawText();
|
||||
|
||||
void AddObjectToDraw();
|
||||
void AddTextToDraw();
|
||||
|
||||
GLuint CompileShader(GLenum, std::string);
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user