[colobot] 378/390: Added warnings and information what shader files are not available
Didier Raboud
odyx at moszumanska.debian.org
Fri Jun 12 14:22:07 UTC 2015
This is an automated email from the git hooks/post-receive script.
odyx pushed a commit to branch upstream/latest
in repository colobot.
commit d33ddae15a8f3d5d8e33cb0f4428b6a4632a2b5d
Author: Tomasz Kapuściński <tomaszkax86 at gmail.com>
Date: Fri May 29 12:39:14 2015 +0200
Added warnings and information what shader files are not available
---
src/graphics/opengl/gl21device.cpp | 41 +++++++++++++++++++++++---------------
src/graphics/opengl/gl33device.cpp | 11 ++++++++--
2 files changed, 34 insertions(+), 18 deletions(-)
diff --git a/src/graphics/opengl/gl21device.cpp b/src/graphics/opengl/gl21device.cpp
index 555fede..c4a6067 100644
--- a/src/graphics/opengl/gl21device.cpp
+++ b/src/graphics/opengl/gl21device.cpp
@@ -190,6 +190,13 @@ bool CGL21Device::Create()
// Extract OpenGL version
const char *version = reinterpret_cast<const char*>(glGetString(GL_VERSION));
sscanf(version, "%d.%d", &m_glMajor, &m_glMinor);
+
+ if (m_glMajor < 2)
+ {
+ GetLogger()->Error("Your hardware does not support OpenGL 2.0 or 2.1.");
+ return false;
+ }
+
GetLogger()->Info("OpenGL %d.%d\n", m_glMajor, m_glMinor);
m_framebufferObject = glewIsSupported("GL_EXT_framebuffer_object");
@@ -236,15 +243,13 @@ bool CGL21Device::Create()
m_lightsEnabled = std::vector<bool> (numLights, false);
int maxTextures = 0;
- glGetIntegerv(GL_MAX_TEXTURE_UNITS, &maxTextures);
- GetLogger()->Info("Maximum texture units: %d\n", maxTextures);
+ glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextures);
+ GetLogger()->Info("Maximum texture image units: %d\n", maxTextures);
m_currentTextures = std::vector<Texture> (maxTextures, Texture());
m_texturesEnabled = std::vector<bool> (maxTextures, false);
m_textureStageParams = std::vector<TextureStageParams>(maxTextures, TextureStageParams());
- /*
- // Will be enabled when proper shaders are written
int value;
if (CProfile::GetInstance().GetIntProperty("Setup", "PerPixelLighting", value))
{
@@ -255,18 +260,23 @@ bool CGL21Device::Create()
CLogger::GetInstance().Info("Using per-pixel lighting\n");
else
CLogger::GetInstance().Info("Using per-vertex lighting\n");
- // */
-
- CLogger::GetInstance().Info("Using per-vertex lighting\n");
// Create shader program
GLchar source[65536];
const GLchar *sources[] = { source };
- PHYSFS_file *file = PHYSFS_openRead("shaders/vertex_shader_21_pervertex.glsl");
+ char filename[128];
+
+ if (m_perPixelLighting)
+ sprintf(filename, "shaders/vertex_shader_21_perpixel.glsl");
+ else
+ sprintf(filename, "shaders/vertex_shader_21_pervertex.glsl");
+
+ PHYSFS_file *file = PHYSFS_openRead(filename);
if (file == nullptr)
{
CLogger::GetInstance().Error("Cannot read vertex shader code file!\n");
+ CLogger::GetInstance().Error("Missing file \"%s\"\n", filename);
return false;
}
@@ -296,10 +306,16 @@ bool CGL21Device::Create()
return false;
}
- file = PHYSFS_openRead("shaders/fragment_shader_21_pervertex.glsl");
+ if (m_perPixelLighting)
+ sprintf(filename, "shaders/fragment_shader_21_perpixel.glsl");
+ else
+ sprintf(filename, "shaders/fragment_shader_21_pervertex.glsl");
+
+ file = PHYSFS_openRead(filename);
if (file == nullptr)
{
CLogger::GetInstance().Error("Cannot read fragment shader code file!\n");
+ CLogger::GetInstance().Error("Missing file \"%s\"\n", filename);
return false;
}
@@ -1608,13 +1624,6 @@ void CGL21Device::SetRenderState(RenderState state, bool enabled)
glUniform1i(uni_LightingEnabled, enabled ? 1 : 0);
- /*
- if (enabled)
- glEnable(GL_LIGHTING);
- else
- glDisable(GL_LIGHTING);
- // */
-
if (enabled)
{
for (int index = 0; index < static_cast<int>( m_lights.size() ); ++index)
diff --git a/src/graphics/opengl/gl33device.cpp b/src/graphics/opengl/gl33device.cpp
index da05c0b..a4f31b6 100644
--- a/src/graphics/opengl/gl33device.cpp
+++ b/src/graphics/opengl/gl33device.cpp
@@ -191,9 +191,14 @@ bool CGL33Device::Create()
sscanf(version, "%d.%d", &m_glMajor, &m_glMinor);
int glVersion = 10 * m_glMajor + m_glMinor;
- if (glVersion < 33)
+ if (glVersion < 30)
{
- GetLogger()->Error("OpenGL 3.3 unavailable. Game might not work at all.\n");
+ GetLogger()->Error("Your hardware does not support OpenGL 3.0+. Exiting.\n");
+ return false;
+ }
+ else if (glVersion < 33)
+ {
+ GetLogger()->Warn("Full OpenGL 3.3 unavailable. Graphics might be bugged.\n");
}
else
{
@@ -272,6 +277,7 @@ bool CGL33Device::Create()
if (file == nullptr)
{
CLogger::GetInstance().Error("Cannot read vertex shader code file!\n");
+ CLogger::GetInstance().Error("Missing file \"%s\"\n", filename);
return false;
}
@@ -310,6 +316,7 @@ bool CGL33Device::Create()
if (file == nullptr)
{
CLogger::GetInstance().Error("Cannot read fragment shader code file!\n");
+ CLogger::GetInstance().Error("Missing file \"%s\"\n", filename);
return false;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git
More information about the Pkg-games-commits
mailing list