From fa58befffe0c0520f50cf9414c3de9949d8c0eed Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Wed, 8 Jul 2020 00:22:44 -0300 Subject: Code fixes to compile in MinGW and MSVC CMakeLists includes --- Project/Project.project | 458 ++++++++++++++++++++++++++++++++++++++++++- Project/Renderer.h | 4 +- Project/Shader.cpp | 8 +- Project/VertexBufferLayout.h | 46 +++-- Project/Workspace.cpp | 2 +- Project/compile_flags.txt | 6 +- 6 files changed, 497 insertions(+), 27 deletions(-) (limited to 'Project') diff --git a/Project/Project.project b/Project/Project.project index c99a14b..b8871c2 100644 --- a/Project/Project.project +++ b/Project/Project.project @@ -137,7 +137,454 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -485,10 +932,19 @@ + + + + - + + + + + + diff --git a/Project/Renderer.h b/Project/Renderer.h index 29b5bf8..59b88ff 100644 --- a/Project/Renderer.h +++ b/Project/Renderer.h @@ -8,10 +8,12 @@ #include "IndexBuffer.h" #include "Shader.h" +#ifdef _MSC_VER #define ASSERT(x) if (!(x)) __debugbreak(); +#endif //_MSC_VER #define GLCall(x) GLClearError();\ x;\ - ASSERT(GLCheckError()) + wxASSERT(GLCheckError()) void GLClearError(); bool GLCheckError(); diff --git a/Project/Shader.cpp b/Project/Shader.cpp index 7835fec..10751e2 100644 --- a/Project/Shader.cpp +++ b/Project/Shader.cpp @@ -72,8 +72,12 @@ ShaderSource Shader::ParseShader(const wxString& filepath) const ss[static_cast(type)] << line + std::string("\n"); } } + + ShaderSource source; + source.vertexShader = ss[0].str(); + source.fragmentShader = ss[1].str(); - return { ss[0].str(), ss[1].str() }; + return source; } unsigned int Shader::CreateShader(std::string& vertexShader, std::string& fragmentShader) const @@ -131,7 +135,7 @@ unsigned int Shader::GetUniformLocation(const std::string& name) GLCall(int location = glGetUniformLocation(m_rendererID, name.c_str())); if (location == -1) { - wxMessageBox(wxString::Format("Atenção! uniform \"%s\" não encontrado", name)); + wxMessageBox(wxString::Format("Atenção! uniform \"%s\" não encontrado", name)); } m_uniformLocationCache[name] = location; diff --git a/Project/VertexBufferLayout.h b/Project/VertexBufferLayout.h index d50b19c..7d527d1 100644 --- a/Project/VertexBufferLayout.h +++ b/Project/VertexBufferLayout.h @@ -21,7 +21,9 @@ struct VertexBufferElement case GL_UNSIGNED_BYTE: return 1; default: break; } +#ifdef _MSC_VER ASSERT(false); +#endif return(0); } }; @@ -37,28 +39,9 @@ public: template void Push(unsigned int count) { +#ifdef _MSC_VER static_assert(false); - } - - template<> - void Push(unsigned int count) - { - m_elements.push_back({ GL_FLOAT, count, GL_FALSE }); - m_stride += count * VertexBufferElement::GetSizeOfType(GL_FLOAT); - } - - template<> - void Push(unsigned int count) - { - m_elements.push_back({ GL_UNSIGNED_INT, count, GL_FALSE }); - m_stride += count * VertexBufferElement::GetSizeOfType(GL_UNSIGNED_INT); - } - - template<> - void Push(unsigned int count) - { - m_elements.push_back({ GL_UNSIGNED_BYTE, count, GL_TRUE }); - m_stride += count * VertexBufferElement::GetSizeOfType(GL_UNSIGNED_BYTE); +#endif } inline const std::vector GetElements() const& { return m_elements; } @@ -69,4 +52,25 @@ private: unsigned int m_stride; }; +template<> inline +void VertexBufferLayout::Push(unsigned int count) +{ + m_elements.push_back({ GL_FLOAT, count, GL_FALSE }); + m_stride += count * VertexBufferElement::GetSizeOfType(GL_FLOAT); +} + +template<> inline +void VertexBufferLayout::Push(unsigned int count) +{ + m_elements.push_back({ GL_UNSIGNED_INT, count, GL_FALSE }); + m_stride += count * VertexBufferElement::GetSizeOfType(GL_UNSIGNED_INT); +} + +template<> inline +void VertexBufferLayout::Push(unsigned int count) +{ + m_elements.push_back({ GL_UNSIGNED_BYTE, count, GL_TRUE }); + m_stride += count * VertexBufferElement::GetSizeOfType(GL_UNSIGNED_BYTE); +} + #endif // VERTEXBUFFERLAYOUT_H diff --git a/Project/Workspace.cpp b/Project/Workspace.cpp index 17c8134..585ec82 100644 --- a/Project/Workspace.cpp +++ b/Project/Workspace.cpp @@ -1025,7 +1025,7 @@ void Workspace::UpdateHeatMap() m_hmPlane->UpdateCoords(); - int iterations = std::lround(3.3 * std::powf(m_camera->GetScale(), 0.62)); + int iterations = std::lround(3.3 * std::pow(m_camera->GetScale(), 0.62)); if (iterations < 1) iterations = 1; m_hmPlane->SmoothPlane(iterations); } diff --git a/Project/compile_flags.txt b/Project/compile_flags.txt index 84934dd..ebae363 100644 --- a/Project/compile_flags.txt +++ b/Project/compile_flags.txt @@ -5,13 +5,17 @@ -IC:\TDM-GCC-32\include -IC:\TDM-GCC-32\lib\gcc\mingw32\9.2.0\include-fixed -IC:\Users\thale\Documents\GitHub\PSP\Project +-IC:\Users\thale\Documents\GitHub\PSP\Project\vendor +-IC:\Users\thale\Documents\GitHub\PSP\ExtLibs\GLEW\include +-IC:\Users\thale\Documents\GitHub\PSP\ExtLibs\GLFW\include -IC:\wxWidgets313\lib\gcc_lib\mswu -IC:\wxWidgets313\include -D_UNICODE -DHAVE_W32API_H +-DUNICODE +-DGLEW_STATIC -D__WXMSW__ -DNDEBUG --DUNICODE -std=gnu++11 -target i686-pc-windows-gnu -- cgit