Skip to content

Commit

Permalink
View fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
xfusek08 committed Feb 21, 2020
1 parent 0fe4533 commit 25ab77e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 17 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ source_group("GeoPlanetDemo\\vt\\planet" FILES ${SRC_GEO_PLANET_DEMO_VT_PLANET})
source_group("GeoPlanetDemo\\sdl" FILES ${SRC_GEO_PLANET_DEMO_SDL})
source_group("GeoPlanetDemo\\interfaces" FILES ${SRC_GEO_PLANET_DEMO_INTERFACES})

source_group("vendor\\stb" FILES ${SRC_VENDOR_STB})
source_group("vendor\\imgui" FILES ${SRC_VENDOR_IAMGUI})
source_group("vendor\\stb" FILES ${SRC_VENDOR_STB})
source_group("vendor\\imgui" FILES ${SRC_VENDOR_IAMGUI})

# generate shader definitions from SHADER_FILES based on their location
set(SHADER_COMPILE_DEFINITIONS )
Expand Down
5 changes: 3 additions & 2 deletions resources/shaders/basic/vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

in layout(location = 0) vec3 position;

uniform mat4 projectionMatrix; // Projection matrix
uniform mat4 viewMatrix; // View Matrix
uniform mat4 projectionMatrix; // Projection matrix
uniform mat4 viewMatrix; // View Matrix

void main()
{
gl_Position = projectionMatrix * viewMatrix * vec4(position, 1.0f);
// gl_Position = vec4(position, 1.0f);
}
3 changes: 3 additions & 0 deletions src/GeoPlanetDemo/ApplicationGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <GeoPlanetDemo/core/Camera.h>
#include <GeoPlanetDemo/core/Scene.h>
#include <GeoPlanetDemo/core/Utils.h>

#include <GeoPlanetDemo/sdl/SDLGlMainLoop.h>
#include <GeoPlanetDemo/sdl/SDLPerformance.h>
Expand Down Expand Up @@ -222,4 +223,6 @@ int ApplicationGui::vtTypeToInt(vt::VTType val) const
}
++index;
}
GPD_ASSERT(false, "ApplicationGui::vtTypeToInt(" << val << "): not found.");
return -1;
}
12 changes: 6 additions & 6 deletions src/GeoPlanetDemo/core/Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace gpd
// flags
inline bool hasViewChanged() const { return viewChanged || !changeAccepted; }
inline void setViewChanged() { viewChanged = true; changeAccepted = false; }
inline void acceptChange() { changeAccepted = true; }
inline void acceptChange() { changeAccepted = true; }

// matrices
glm::mat4 getViewMatrix();
Expand All @@ -44,10 +44,10 @@ namespace gpd
inline glm::vec3 getUpVector() const { return up; }
inline glm::vec3 getCameraDirection() const { return position - target; }

inline void setCameraPosition(glm::vec3 position) { position = position; setViewChanged(); }
inline void setTargetPosition(glm::vec3 target) { target = target; setViewChanged(); }
inline void setUpVector(glm::vec3 up) { up = up; setViewChanged(); }
inline void setViewSize(unsigned int width, unsigned int height) { viewWidth = width; viewHeight = height; updateProjectionMatrix(); setViewChanged(); }
inline void setCameraPosition(glm::vec3 position) { this->position = position; setViewChanged(); }
inline void setTargetPosition(glm::vec3 target) { this->target = target; setViewChanged(); }
inline void setUpVector(glm::vec3 up) { this->up = up; setViewChanged(); }
inline void setViewSize(unsigned int width, unsigned int height) { this->viewWidth = width; this->viewHeight = height; updateProjectionMatrix(); setViewChanged(); }
inline void setViewSize(glm::uvec2 newSize) { setViewSize(newSize.x, newSize.y); }

// projection scalars
Expand All @@ -59,7 +59,7 @@ namespace gpd
// properties

// flags
bool viewChanged = true;
bool viewChanged = true;
bool changeAccepted = false;

glm::mat4 viewMatrix;
Expand Down
13 changes: 8 additions & 5 deletions src/GeoPlanetDemo/core/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@

#define STREAM_TO_STR(S) (std::ostringstream() << S).str()

#define GPD_LOG_ERROR(...) gpd::core::Log::getLogger()->writeError(STREAM_TO_STR(__VA_ARGS__))
#define GPD_LOG_WARNING(...) gpd::core::Log::getLogger()->writeWarning(STREAM_TO_STR(__VA_ARGS__))
#define GPD_LOG_INFO(...) gpd::core::Log::getLogger()->writeInfo(STREAM_TO_STR(__VA_ARGS__))

#ifdef GPD_DEBUG
#define GPD_LOG_DEBUG(...) gpd::core::Log::getLogger()->writeDebug(STREAM_TO_STR(__VA_ARGS__))
#include <stdio.h>
#define GPD_LOG_DEBUG(...) gpd::core::Log::getLogger()->writeDebug(STREAM_TO_STR(__VA_ARGS__))
#define GPD_LOG_DEBUG_F(...) printf(__VA_ARGS__)
#else
#define GPD_LOG_DEBUG(...)
#define GPD_LOG_DEBUG_F(...)
#endif

#ifdef GPD_ENABLE_ASSERTS
#define GPD_ASSERT(x, ...) { if(!(x)) { GPD_LOG_ERROR("Assertion Failed: " << __VA_ARGS__); __debugbreak(); } }
#else
#define GPD_ASSERT(x, ...)
#endif

#define GPD_LOG_ERROR(...) gpd::core::Log::getLogger()->writeError(STREAM_TO_STR(__VA_ARGS__))
#define GPD_LOG_WARNING(...) gpd::core::Log::getLogger()->writeWarning(STREAM_TO_STR(__VA_ARGS__))
#define GPD_LOG_INFO(...) gpd::core::Log::getLogger()->writeInfo(STREAM_TO_STR(__VA_ARGS__))
4 changes: 2 additions & 2 deletions src/GeoPlanetDemo/vt/VTFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ namespace gpd
return getMap()[type]->create(type, gl);
}

static std::map<std::string, VTFactorySpecific*>& getMap()
static std::map<VTType, VTFactorySpecific*>& getMap()
{
static std::map<std::string, VTFactorySpecific*> map;
static std::map<VTType, VTFactorySpecific*> map;
return map;
}

Expand Down

0 comments on commit 25ab77e

Please sign in to comment.