=== modified file 'src/scene-refract.cpp'
@@ -176,19 +176,32 @@
bool
DistanceRenderTarget::setup(unsigned int width, unsigned int height)
{
+ static const string vtx_shader_filename(GLMARK_DATA_PATH"/shaders/depth.vert");
+ static const string frg_shader_filename(GLMARK_DATA_PATH"/shaders/depth.frag");
+
+ ShaderSource vtx_source(vtx_shader_filename);
+ ShaderSource frg_source(frg_shader_filename);
+
+ if (!Scene::load_shaders_from_strings(program_, vtx_source.str(), frg_source.str())) {
+ return false;
+ }
+
canvas_width_ = width;
canvas_height_ = height;
width_ = canvas_width_ * 2;
height_ = canvas_height_ * 2;
- static const string vtx_shader_filename(GLMARK_DATA_PATH"/shaders/depth.vert");
- static const string frg_shader_filename(GLMARK_DATA_PATH"/shaders/depth.frag");
-
- ShaderSource vtx_source(vtx_shader_filename);
- ShaderSource frg_source(frg_shader_filename);
-
- if (!Scene::load_shaders_from_strings(program_, vtx_source.str(), frg_source.str())) {
- return false;
+ // If the texture will be too large for the implemnetation, we need to
+ // clamp the dimensions but maintain the aspect ratio.
+ GLint tex_size(0);
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, &tex_size);
+ unsigned int max_size = static_cast<unsigned int>(tex_size);
+ if (max_size < width_ || max_size < height_) {
+ float aspect = static_cast<float>(width) / static_cast<float>(height);
+ width_ = max_size;
+ height_ = width_ / aspect;
+ Log::debug("DistanceRenderTarget::setup: original texture size (%u x %u), clamped to (%u x %u)\n",
+ canvas_width_ * 2, canvas_height_ * 2, width_, height_);
}
glGenTextures(2, &tex_[0]);
@@ -217,7 +230,7 @@
tex_[COLOR], 0);
unsigned int status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
- Log::error("DepthRenderState::setup: glCheckFramebufferStatus failed (0x%x)\n", status);
+ Log::error("DistanceRenderTarget::setup: glCheckFramebufferStatus failed (0x%x)\n", status);
return false;
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
=== modified file 'src/scene-shadow.cpp'
@@ -73,19 +73,32 @@
bool
DepthRenderTarget::setup(unsigned int width, unsigned int height)
{
+ static const string vtx_shader_filename(GLMARK_DATA_PATH"/shaders/depth.vert");
+ static const string frg_shader_filename(GLMARK_DATA_PATH"/shaders/depth.frag");
+
+ ShaderSource vtx_source(vtx_shader_filename);
+ ShaderSource frg_source(frg_shader_filename);
+
+ if (!Scene::load_shaders_from_strings(program_, vtx_source.str(), frg_source.str())) {
+ return false;
+ }
+
canvas_width_ = width;
canvas_height_ = height;
width_ = canvas_width_ * 2;
height_ = canvas_height_ * 2;
- static const string vtx_shader_filename(GLMARK_DATA_PATH"/shaders/depth.vert");
- static const string frg_shader_filename(GLMARK_DATA_PATH"/shaders/depth.frag");
-
- ShaderSource vtx_source(vtx_shader_filename);
- ShaderSource frg_source(frg_shader_filename);
-
- if (!Scene::load_shaders_from_strings(program_, vtx_source.str(), frg_source.str())) {
- return false;
+ // If the texture will be too large for the implemnetation, we need to
+ // clamp the dimensions but maintain the aspect ratio.
+ GLint tex_size(0);
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, &tex_size);
+ unsigned int max_size = static_cast<unsigned int>(tex_size);
+ if (max_size < width_ || max_size < height_) {
+ float aspect = static_cast<float>(width) / static_cast<float>(height);
+ width_ = max_size;
+ height_ = width_ / aspect;
+ Log::debug("DepthRenderTarget::setup: original texture size (%u x %u), clamped to (%u x %u)\n",
+ canvas_width_ * 2, canvas_height_ * 2, width_, height_);
}
glGenTextures(1, &tex_);
@@ -104,7 +117,7 @@
tex_, 0);
unsigned int status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
- Log::error("DepthRenderState::setup: glCheckFramebufferStatus failed (0x%x)\n", status);
+ Log::error("DepthRenderTarget::setup: glCheckFramebufferStatus failed (0x%x)\n", status);
return false;
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);