Skip to content

Commit 8bf4761

Browse files
author
Christian Koehlke
committed
bugfix
-resolution is now correctly applied to the OpenGL Viewport -added the ability the set the shadowmap resolution in the config
1 parent d678788 commit 8bf4761

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

Game/Renderer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ glm::vec3 Renderer::transformedSunDirection3;
128128
FrameBuffer Renderer::frameBuffer;
129129
FrameBuffer Renderer::depthMapBuffer;
130130

131+
int Renderer::shadowMapResolution;
132+
131133

132134
void Renderer::initOpenGL(SDL_Window** window)
133135
{
@@ -206,6 +208,7 @@ void Renderer::init(std::shared_ptr<Player> player)
206208
skyboxVertexBuffer = new VertexBuffer(skyboxVertices, 36, VertexType::_VertexPos);
207209
axisVertexBuffer = new VertexBuffer(axisVertices, 6, VertexType::_VertexPosCol);
208210

211+
shadowMapResolution = std::stoi(ConfigManager::readConfig("shadow_map_resolution"));
209212
int w, h;
210213
SDL_GetWindowSize(*window, &w, &h);
211214
frameBuffer.create(w, h, FrameBufferTextureType::colorMap | FrameBufferTextureType::stencilMap);
@@ -325,7 +328,9 @@ void Renderer::calcShadows(std::vector< std::shared_ptr<Object>> objects)
325328

326329
depthMapBuffer.unbind();
327330
// 2. then render scene as normal with shadow mapping (using depth map)
328-
glViewport(0, 0, 960, 540); //actual resolution
331+
int width, height;
332+
SDL_GetWindowSize(*window, &width, &height);
333+
glViewport(0, 0, width, height); //actual resolution
329334
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
330335

331336

Game/Renderer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static class Renderer
9898
static bool wireframeMode;
9999
static bool showNormalMode;
100100

101-
static const int shadowMapResolution = 4096;
101+
static int shadowMapResolution;
102102

103103

104104

Game/config.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ bots = 0
33
bot_speed_mult = 0.5
44
resolution_width = 960
55
resolution_height = 540
6+
shadow_map_resolution = 4096
67
fov = 90
78
fullscreen = 0
89
showdebug_console = 1

0 commit comments

Comments
 (0)