Merge branch 'master' of github.com:sippeangelo/Escape-the-Dawn
Conflicts: Escape-the-Dawn/Escape-the-Dawn.vcxproj Escape-the-Dawn/Escape-the-Dawn.vcxproj.filters
This commit is contained in:
@@ -5,6 +5,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Escape-the-Dawn", "Escape-t
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tests", "Tests\Tests.vcxproj", "{B9A8F4AA-BE85-45EA-84DD-652D13DD22BE}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Executable", "Executable\Executable.vcxproj", "{A9755CAA-62DC-442D-B82C-F548546CFD38}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
@@ -19,6 +21,10 @@ Global
|
||||
{B9A8F4AA-BE85-45EA-84DD-652D13DD22BE}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{B9A8F4AA-BE85-45EA-84DD-652D13DD22BE}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{B9A8F4AA-BE85-45EA-84DD-652D13DD22BE}.Release|Win32.Build.0 = Release|Win32
|
||||
{A9755CAA-62DC-442D-B82C-F548546CFD38}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{A9755CAA-62DC-442D-B82C-F548546CFD38}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{A9755CAA-62DC-442D-B82C-F548546CFD38}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{A9755CAA-62DC-442D-B82C-F548546CFD38}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
#include <GL/glew.h>
|
||||
#define GLFW_INCLUDE_GLU
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <glext.h>
|
||||
|
||||
#include "logging.h"
|
||||
#include "glerror.h"
|
||||
|
||||
#include "World.h"
|
||||
|
||||
class Engine
|
||||
{
|
||||
public:
|
||||
Engine(int argc, char* argv[])
|
||||
{
|
||||
// Initialize GLFW
|
||||
if (!glfwInit()) {
|
||||
LOG_ERROR("GLFW: Initialization failed");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Create a window
|
||||
m_Window = glfwCreateWindow(1280, 720, "OpenGL", nullptr, nullptr);
|
||||
if (!m_Window) {
|
||||
LOG_ERROR("GLFW: Failed to create window");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
glfwMakeContextCurrent(m_Window);
|
||||
|
||||
// GL version info
|
||||
glGetIntegerv(GL_MAJOR_VERSION, &glVersion[0]);
|
||||
glGetIntegerv(GL_MINOR_VERSION, &glVersion[1]);
|
||||
glVendor = (GLchar*)glGetString(GL_VENDOR);
|
||||
std::stringstream ss;
|
||||
ss << glVendor << " OpenGL " << glVersion[0] << "." << glVersion[1];
|
||||
#ifdef DEBUG
|
||||
ss << " DEBUG";
|
||||
#endif
|
||||
LOG_INFO(ss.str().c_str());
|
||||
glfwSetWindowTitle(m_Window, ss.str().c_str());
|
||||
|
||||
// Initialize GLEW
|
||||
if (glewInit() != GLEW_OK) {
|
||||
LOG_ERROR("GLEW: Initialization failed");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
bool Running() const { return !glfwWindowShouldClose(m_Window); }
|
||||
|
||||
void Tick()
|
||||
{
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
||||
private:
|
||||
GLFWwindow* m_Window;
|
||||
GLint glVersion[2];
|
||||
GLchar* glVendor;
|
||||
};
|
||||
@@ -16,13 +16,13 @@
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
@@ -42,7 +42,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LibraryPath>$(SolutionDir)\Libraries\glew-1.10.0\lib\Debug\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Debug;$(LibraryPath)</LibraryPath>
|
||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
||||
<IntDir>$(SolutionDir)build\$(Configuration)\</IntDir>
|
||||
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
|
||||
<TargetName>$(ProjectName)-$(Configuration)</TargetName>
|
||||
<IncludePath>$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
@@ -52,7 +52,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LibraryPath>$(SolutionDir)\Libraries\glew-1.10.0\lib\Release\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Release;$(LibraryPath)</LibraryPath>
|
||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
||||
<IntDir>$(SolutionDir)build\$(Configuration)\</IntDir>
|
||||
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
|
||||
<TargetName>$(ProjectName)-$(Configuration)</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
@@ -69,6 +69,12 @@
|
||||
</Link>
|
||||
<PostBuildEvent />
|
||||
<PostBuildEvent />
|
||||
<Lib>
|
||||
<AdditionalDependencies>opengl32.lib;glu32.lib;glew32sd.lib;glfw3.lib</AdditionalDependencies>
|
||||
<ForceSymbolReferences>
|
||||
</ForceSymbolReferences>
|
||||
</Lib>
|
||||
<ProjectReference />
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
@@ -86,8 +92,12 @@
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>opengl32.lib;glu32.lib;glew32s.lib;glfw3.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalDependencies>opengl32.lib;glu32.lib;glew32s.lib;glfw3.lib;</AdditionalDependencies>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Engine.h" />
|
||||
<ClCompile Include="AABB.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="Model.cpp" />
|
||||
@@ -125,6 +135,7 @@
|
||||
<ClInclude Include="glerror.h" />
|
||||
<ClInclude Include="Model.h" />
|
||||
<ClInclude Include="Renderer\Renderer.h" />
|
||||
<ClInclude Include="ShaderProgram.h" />
|
||||
<ClInclude Include="Systems\InputSystem.h" />
|
||||
<ClInclude Include="System.h" />
|
||||
<ClInclude Include="Systems\CollisionSystem.h" />
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
<Filter>Systems</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Model.cpp" />
|
||||
<ClCompile Include="Engine.h" />
|
||||
<ClCompile Include="AABB.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -58,10 +59,11 @@
|
||||
<ClInclude Include="Systems\SoundSystem.h">
|
||||
<Filter>Systems</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Model.h" />
|
||||
<ClInclude Include="Components\Transform.h">
|
||||
<Filter>Components</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Model.h" />
|
||||
<ClInclude Include="ShaderProgram.h" />
|
||||
<ClInclude Include="Components\Bounds.h">
|
||||
<Filter>Components</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Renderer::Renderer()
|
||||
{
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void Renderer::Draw()
|
||||
@@ -10,7 +10,7 @@ void Renderer::Draw()
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glClearColor(1.0f, 1.0f, 0.0f, 1.0f);
|
||||
|
||||
glUseProgram(shaderProgram);
|
||||
m_ShaderProgram->Bind();
|
||||
}
|
||||
|
||||
void Renderer::DrawText()
|
||||
@@ -32,65 +32,7 @@ void Renderer::AddObjectToDraw()
|
||||
|
||||
void Renderer::LoadContent()
|
||||
{
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
LOG_INFO("Compiling Shader");
|
||||
|
||||
GLuint vertexShader = CompileShader(GL_VERTEX_SHADER, "Shaders/Vertex.glsl");
|
||||
GLuint fragmentShader = CompileShader(GL_FRAGMENT_SHADER, "Shaders\Fragment.glsl");
|
||||
|
||||
shaderProgram = glCreateProgram();
|
||||
glAttachShader(shaderProgram, vertexShader);
|
||||
glAttachShader(shaderProgram, fragmentShader);
|
||||
LOG_INFO("Linking shader program...");
|
||||
glLinkProgram(shaderProgram);
|
||||
if(GLERROR("glLinkProgram"))
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
m_ShaderProgram->AddShader(std::unique_ptr<Shader>(new VertexShader("Shaders/Vertex.glsl")));
|
||||
m_ShaderProgram->AddShader(std::unique_ptr<Shader>(new FragmentShader("Shaders/Fragment.glsl")));
|
||||
m_ShaderProgram->Link();
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
#include "glerror.h"
|
||||
|
||||
#include "ShaderProgram.h"
|
||||
|
||||
class Renderer
|
||||
{
|
||||
public:
|
||||
GLuint shaderProgram;
|
||||
std::shared_ptr<ShaderProgram> m_ShaderProgram;
|
||||
GLuint VAO;
|
||||
|
||||
std::vector<std::vector<float>> Vertices;
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
#include "ShaderProgram.h"
|
||||
|
||||
GLuint Shader::CompileShader(GLenum shaderType, std::string fileName)
|
||||
{
|
||||
LOG_INFO("Compiling shader \"%s\"", fileName.c_str());
|
||||
|
||||
std::string shaderFile;
|
||||
std::ifstream in(fileName, std::ios::in);
|
||||
if(!in)
|
||||
{
|
||||
LOG_ERROR("Error: Failed to open shader file \"%s\"", fileName.c_str());
|
||||
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);
|
||||
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)
|
||||
{
|
||||
LOG_ERROR("Shader compilation failed");
|
||||
GLsizei infoLogLength;
|
||||
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength);
|
||||
GLchar* infolog = new GLchar[infoLogLength];
|
||||
glGetShaderInfoLog(shader, infoLogLength, &infoLogLength, infolog);
|
||||
LOG_ERROR(infolog);
|
||||
delete[] infolog;
|
||||
}
|
||||
|
||||
if(GLERROR("glCompileShader"))
|
||||
return 0;
|
||||
|
||||
return shader;
|
||||
}
|
||||
|
||||
Shader::Shader(GLenum shaderType, std::string fileName) : m_ShaderType(shaderType), m_FileName(fileName)
|
||||
{
|
||||
m_ShaderHandle = 0;
|
||||
}
|
||||
|
||||
Shader::~Shader()
|
||||
{
|
||||
glDeleteShader(m_ShaderHandle);
|
||||
}
|
||||
|
||||
GLuint Shader::Compile()
|
||||
{
|
||||
m_ShaderHandle = CompileShader(m_ShaderType, m_FileName);
|
||||
return m_ShaderHandle;
|
||||
}
|
||||
|
||||
GLenum Shader::GetType() const
|
||||
{
|
||||
return m_ShaderType;
|
||||
}
|
||||
|
||||
std::string Shader::GetFileName() const
|
||||
{
|
||||
return m_FileName;
|
||||
}
|
||||
|
||||
GLuint Shader::GetHandle() const
|
||||
{
|
||||
return m_ShaderHandle;
|
||||
}
|
||||
|
||||
bool Shader::IsCompiled() const
|
||||
{
|
||||
return m_ShaderHandle != 0;
|
||||
}
|
||||
|
||||
ShaderProgram::ShaderProgram()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
ShaderProgram::ShaderProgram(std::string vertexShaderFile, std::string fragmentShaderFile)
|
||||
{
|
||||
AddShader(std::unique_ptr<Shader>(new VertexShader(vertexShaderFile)));
|
||||
AddShader(std::unique_ptr<Shader>(new VertexShader(fragmentShaderFile)));
|
||||
Initialize();
|
||||
}
|
||||
|
||||
ShaderProgram::~ShaderProgram()
|
||||
{
|
||||
Unbind();
|
||||
glDeleteProgram(m_ShaderProgramHandle);
|
||||
}
|
||||
|
||||
void ShaderProgram::AddShader(std::unique_ptr<Shader> shader)
|
||||
{
|
||||
if (!shader->IsCompiled()) {
|
||||
shader->Compile();
|
||||
}
|
||||
|
||||
m_Shaders.push_back(std::move(shader));
|
||||
}
|
||||
|
||||
GLuint ShaderProgram::Link()
|
||||
{
|
||||
LOG_INFO("Linking shader program");
|
||||
m_ShaderProgramHandle = glCreateProgram();
|
||||
for (auto &shader : m_Shaders) {
|
||||
glAttachShader(m_ShaderProgramHandle, shader->GetHandle());
|
||||
}
|
||||
glLinkProgram(m_ShaderProgramHandle);
|
||||
if (GLERROR("glLinkProgram"))
|
||||
return 0;
|
||||
|
||||
for (auto &shader : m_Shaders) {
|
||||
shader.release();
|
||||
}
|
||||
m_Shaders.clear();
|
||||
|
||||
return m_ShaderProgramHandle;
|
||||
}
|
||||
|
||||
void ShaderProgram::Bind()
|
||||
{
|
||||
if (m_ShaderProgramHandle == 0)
|
||||
return;
|
||||
|
||||
glUseProgram(m_ShaderProgramHandle);
|
||||
}
|
||||
|
||||
void ShaderProgram::Unbind()
|
||||
{
|
||||
glActiveShaderProgram(0, 0);
|
||||
}
|
||||
|
||||
void ShaderProgram::Initialize()
|
||||
{
|
||||
m_ShaderProgramHandle = 0;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
#ifndef ShaderProgram_h__
|
||||
#define ShaderProgram_h__
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#include <GL/glew.h>
|
||||
#define GLFW_INCLUDE_GLU
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <glext.h>
|
||||
|
||||
#include "glerror.h"
|
||||
|
||||
class Shader
|
||||
{
|
||||
public:
|
||||
static GLuint CompileShader(GLenum shaderType, std::string fileName);
|
||||
|
||||
Shader(GLenum shaderType, std::string fileName);
|
||||
|
||||
virtual ~Shader();
|
||||
|
||||
GLuint Compile();
|
||||
|
||||
GLenum GetType() const;
|
||||
std::string GetFileName() const;
|
||||
GLuint GetHandle() const;
|
||||
bool IsCompiled() const;
|
||||
|
||||
protected:
|
||||
GLenum m_ShaderType;
|
||||
std::string m_FileName;
|
||||
GLint m_ShaderHandle;
|
||||
};
|
||||
|
||||
template <int SHADERTYPE>
|
||||
class ShaderType : public Shader
|
||||
{
|
||||
public:
|
||||
ShaderType(std::string fileName)
|
||||
: Shader(SHADERTYPE, fileName) { }
|
||||
};
|
||||
|
||||
class VertexShader : public ShaderType<GL_VERTEX_SHADER>
|
||||
{
|
||||
public:
|
||||
VertexShader(std::string fileName)
|
||||
: ShaderType(fileName) { }
|
||||
};
|
||||
|
||||
class FragmentShader : public ShaderType<GL_FRAGMENT_SHADER>
|
||||
{
|
||||
public:
|
||||
FragmentShader(std::string fileName)
|
||||
: ShaderType(fileName) { }
|
||||
};
|
||||
|
||||
class GeometryShader : public ShaderType<GL_GEOMETRY_SHADER>
|
||||
{
|
||||
public:
|
||||
GeometryShader(std::string fileName)
|
||||
: ShaderType(fileName) { }
|
||||
};
|
||||
|
||||
class ShaderProgram
|
||||
{
|
||||
public:
|
||||
ShaderProgram();
|
||||
~ShaderProgram();
|
||||
|
||||
ShaderProgram(std::string vertexShaderFile, std::string fragmentShaderFile);
|
||||
|
||||
void AddShader(std::unique_ptr<Shader> shader);
|
||||
|
||||
GLuint Link();
|
||||
|
||||
void Bind();
|
||||
|
||||
void Unbind();
|
||||
|
||||
private:
|
||||
GLuint m_ShaderProgramHandle;
|
||||
std::vector<std::unique_ptr<Shader>> m_Shaders;
|
||||
|
||||
void Initialize();
|
||||
};
|
||||
|
||||
#endif // ShaderProgram_h__
|
||||
@@ -0,0 +1,18 @@
|
||||
#version 440
|
||||
|
||||
uniform mat4 MVP;
|
||||
uniform sampler2D texture0;
|
||||
|
||||
in VertexData {
|
||||
vec3 Position;
|
||||
vec3 Color;
|
||||
vec2 TextureCoord;
|
||||
} Input;
|
||||
|
||||
out vec4 FragmentColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 texel = texture2D(texture0, Input.TextureCoord);
|
||||
FragmentColor = texel * vec4(Input.Color, 0);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#version 440
|
||||
|
||||
uniform mat4 MVP;
|
||||
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec2 TextureCoord;
|
||||
|
||||
out VertexData {
|
||||
vec3 Position;
|
||||
vec3 Normal;
|
||||
vec2 TextureCoord;
|
||||
} Output;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVP * vec4(Position, 1.0);
|
||||
|
||||
Output.Position = Position;
|
||||
Output.Normal = Normal;
|
||||
Output.TextureCoord = TextureCoord;
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "System.h"
|
||||
#include "logging.h"
|
||||
|
||||
#include "Components/Transform.h"
|
||||
#include "Components/TransformComponent.h"
|
||||
|
||||
|
||||
namespace Systems
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
#include <GL/glew.h>
|
||||
#define GLFW_INCLUDE_GLU
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <glext.h>
|
||||
|
||||
#include "logging.h"
|
||||
#include "glerror.h"
|
||||
|
||||
#include "World.h"
|
||||
|
||||
GLFWwindow* window;
|
||||
GLint glVersion[2];
|
||||
GLchar* glVendor;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// Initialize GLFW
|
||||
if (!glfwInit())
|
||||
{
|
||||
LOG_ERROR("GLFW: Initialization failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Create a window
|
||||
window = glfwCreateWindow(1280, 720, "OpenGL", nullptr, nullptr);
|
||||
if (!window)
|
||||
{
|
||||
LOG_ERROR("GLFW: Failed to create window");
|
||||
return 1;
|
||||
}
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
// GL version info
|
||||
glGetIntegerv(GL_MAJOR_VERSION, &glVersion[0]);
|
||||
glGetIntegerv(GL_MINOR_VERSION, &glVersion[1]);
|
||||
glVendor = (GLchar*)glGetString(GL_VENDOR);
|
||||
std::stringstream ss;
|
||||
ss << glVendor << " OpenGL " << glVersion[0] << "." << glVersion[1];
|
||||
#ifdef DEBUG
|
||||
ss << " DEBUG";
|
||||
#endif
|
||||
LOG_INFO(ss.str().c_str());
|
||||
glfwSetWindowTitle(window, ss.str().c_str());
|
||||
|
||||
// Initialize GLEW
|
||||
if (glewInit() != GLEW_OK)
|
||||
{
|
||||
LOG_ERROR("GLEW: Initialization failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Main loop
|
||||
while (!glfwWindowShouldClose(window))
|
||||
{
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{A9755CAA-62DC-442D-B82C-F548546CFD38}</ProjectGuid>
|
||||
<RootNamespace>Executable</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IncludePath>$(SolutionDir)\Escape-the-Dawn;$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath)</IncludePath>
|
||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
||||
<TargetName>$(SolutionName)-$(Configuration)</TargetName>
|
||||
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IncludePath>$(SolutionDir)\Escape-the-Dawn;$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath)</IncludePath>
|
||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
||||
<TargetName>$(SolutionName)-$(Configuration)</TargetName>
|
||||
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>GLEW_STATIC;DEBUG;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>GLEW_STATIC;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Escape-the-Dawn\Escape-the-Dawn.vcxproj">
|
||||
<Project>{fe405cfa-8fce-4867-92cf-797e73b36482}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "Engine.h"
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
Engine engine(argc, argv);
|
||||
while (engine.Running())
|
||||
engine.Tick();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+2
-5
@@ -42,11 +42,13 @@
|
||||
<IncludePath>$(SolutionDir)\Escape-the-Dawn\;$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(BOOST_ROOT);$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(BOOST_ROOT)\lib32-msvc-11.0;$(LibraryPath)</LibraryPath>
|
||||
<OutDir>$(ProjectDir)$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IncludePath>$(SolutionDir)\Escape-the-Dawn\;$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(BOOST_ROOT);$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(BOOST_ROOT)\lib32-msvc-11.0;$(LibraryPath)</LibraryPath>
|
||||
<OutDir>$(ProjectDir)$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@@ -83,11 +85,6 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Escape-the-Dawn\Escape-the-Dawn.vcxproj">
|
||||
<Project>{fe405cfa-8fce-4867-92cf-797e73b36482}</Project>
|
||||
<Private>true</Private>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<LinkLibraryDependencies>true</LinkLibraryDependencies>
|
||||
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "World.h"
|
||||
#include "Components/Transform.h"
|
||||
#include "Components/TransformComponent.h"
|
||||
|
||||
#define BOOST_TEST_MODULE World
|
||||
#define BOOST_TEST_DYN_LINK
|
||||
|
||||
Reference in New Issue
Block a user