summaryrefslogtreecommitdiffstats
path: root/src/graphics/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphics/opengl')
-rw-r--r--src/graphics/opengl/gldevice.cpp16
-rw-r--r--src/graphics/opengl/gldevice.h4
-rw-r--r--src/graphics/opengl/test/CMakeLists.txt7
-rw-r--r--src/graphics/opengl/test/light_test.cpp8
-rw-r--r--src/graphics/opengl/test/model_test.cpp8
-rw-r--r--src/graphics/opengl/test/texture_test.cpp2
-rw-r--r--src/graphics/opengl/test/transform_test.cpp8
7 files changed, 25 insertions, 28 deletions
diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp
index 3526b13..7221421 100644
--- a/src/graphics/opengl/gldevice.cpp
+++ b/src/graphics/opengl/gldevice.cpp
@@ -20,6 +20,7 @@
#include "common/config.h"
#include "common/image.h"
+#include "common/logger.h"
#include "math/geometry.h"
@@ -80,13 +81,10 @@ void Gfx::CGLDevice::DebugHook()
glColor3i(0, 0, 0);
}
-std::string Gfx::CGLDevice::GetError()
-{
- return m_error;
-}
-
bool Gfx::CGLDevice::Create()
{
+ GetLogger()->Info("Creating CDevice\n");
+
#if defined(USE_GLEW)
static bool glewInited = false;
@@ -96,13 +94,13 @@ bool Gfx::CGLDevice::Create()
if (glewInit() != GLEW_OK)
{
- m_error = "GLEW initialization failed";
+ GetLogger()->Error("GLEW initialization failed\n");
return false;
}
if ( (! GLEW_ARB_multitexture) || (! GLEW_EXT_texture_env_combine) || (! GLEW_EXT_secondary_color) )
{
- m_error = "GLEW reports required extensions not supported";
+ GetLogger()->Error("GLEW reports required extensions not supported\n");
return false;
}
}
@@ -142,6 +140,8 @@ bool Gfx::CGLDevice::Create()
m_texturesEnabled = std::vector<bool> (maxTextures, false);
m_textureStageParams = std::vector<Gfx::TextureStageParams>(maxTextures, Gfx::TextureStageParams());
+ GetLogger()->Info("CDevice created successfully\n");
+
return true;
}
@@ -385,7 +385,7 @@ Gfx::Texture Gfx::CGLDevice::CreateTexture(CImage *image, const Gfx::TextureCrea
ImageData *data = image->GetData();
if (data == NULL)
{
- m_error = "Invalid texture data";
+ GetLogger()->Error("Invalid texture data\n");
return Gfx::Texture(); // invalid texture
}
diff --git a/src/graphics/opengl/gldevice.h b/src/graphics/opengl/gldevice.h
index 3daea8a..b59af1c 100644
--- a/src/graphics/opengl/gldevice.h
+++ b/src/graphics/opengl/gldevice.h
@@ -78,8 +78,6 @@ public:
virtual void DebugHook();
- virtual std::string GetError();
-
virtual bool Create();
virtual void Destroy();
@@ -169,8 +167,6 @@ private:
private:
//! Current config
Gfx::GLDeviceConfig m_config;
- //! Last encountered error
- std::string m_error;
//! Current world matrix
Math::Matrix m_worldMat;
diff --git a/src/graphics/opengl/test/CMakeLists.txt b/src/graphics/opengl/test/CMakeLists.txt
index 8ed7364..be33ac6 100644
--- a/src/graphics/opengl/test/CMakeLists.txt
+++ b/src/graphics/opengl/test/CMakeLists.txt
@@ -6,7 +6,7 @@ find_package(SDL_image REQUIRED)
find_package(PNG REQUIRED)
set(CMAKE_BUILD_TYPE debug)
-set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -O0")
+set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -O0 -Wold-style-cast -std=gnu++0x")
set(ADD_LIBS "")
@@ -77,8 +77,9 @@ ${ADD_LIBS}
add_executable(texture_test ${TEXTURE_SOURCES})
target_link_libraries(texture_test ${LIBS})
-add_executable(model_test ${MODEL_SOURCES})
-target_link_libraries(model_test ${LIBS})
+# Temporarily disabling because of dependencies on CEngine et al.
+#add_executable(model_test ${MODEL_SOURCES})
+#target_link_libraries(model_test ${LIBS})
add_executable(transform_test ${TRANSFORM_SOURCES})
target_link_libraries(transform_test ${LIBS})
diff --git a/src/graphics/opengl/test/light_test.cpp b/src/graphics/opengl/test/light_test.cpp
index 80fa911..6ff3b1c 100644
--- a/src/graphics/opengl/test/light_test.cpp
+++ b/src/graphics/opengl/test/light_test.cpp
@@ -313,7 +313,7 @@ void KeyboardUp(SDLKey key)
void MouseMove(int x, int y)
{
- Math::Point currentPos((float)x, (float)y);
+ Math::Point currentPos(static_cast<float>(x), static_cast<float>(y));
static bool first = true;
if (first || (x < 10) || (y < 10) || (x > 790) || (y > 590))
@@ -326,8 +326,8 @@ void MouseMove(int x, int y)
return;
}
- ROTATION.y = ROTATION_BASE.y + ((float) (x - MOUSE_POS_BASE.x) / 800.0f) * Math::PI;
- ROTATION.x = ROTATION_BASE.x + ((float) (y - MOUSE_POS_BASE.y) / 600.0f) * Math::PI;
+ ROTATION.y = ROTATION_BASE.y + (static_cast<float> (x - MOUSE_POS_BASE.x) / 800.0f) * Math::PI;
+ ROTATION.x = ROTATION_BASE.x + (static_cast<float> (y - MOUSE_POS_BASE.y) / 600.0f) * Math::PI;
}
int main(int argc, char *argv[])
@@ -378,7 +378,7 @@ int main(int argc, char *argv[])
//SDL_WM_GrabInput(SDL_GRAB_ON);
SDL_ShowCursor(SDL_DISABLE);
- Gfx::CGLDevice *device = new Gfx::CGLDevice();
+ Gfx::CGLDevice *device = new Gfx::CGLDevice(Gfx::GLDeviceConfig());
device->Create();
Init(device);
diff --git a/src/graphics/opengl/test/model_test.cpp b/src/graphics/opengl/test/model_test.cpp
index 3e8efe6..e951e6e 100644
--- a/src/graphics/opengl/test/model_test.cpp
+++ b/src/graphics/opengl/test/model_test.cpp
@@ -54,7 +54,7 @@ void LoadTexture(Gfx::CGLDevice *device, const std::string &name)
Gfx::Texture tex = GetTexture(name);
- if (tex.valid)
+ if (tex.Valid())
return;
CImage img;
@@ -84,7 +84,7 @@ void Init(Gfx::CGLDevice *device, Gfx::CModelFile *model)
{
std::vector<Gfx::ModelTriangle> &triangles = model->GetTriangles();
- for (int i = 0; i < (int) triangles.size(); ++i)
+ for (int i = 0; i < static_cast<int>( triangles.size() ); ++i)
{
LoadTexture(device, triangles[i].tex1Name);
LoadTexture(device, triangles[i].tex2Name);
@@ -131,7 +131,7 @@ void Render(Gfx::CGLDevice *device, Gfx::CModelFile *modelFile)
Gfx::VertexTex2 tri[3];
- for (int i = 0; i < (int) triangles.size(); ++i)
+ for (int i = 0; i < static_cast<int>( triangles.size() ); ++i)
{
device->SetTexture(0, GetTexture(triangles[i].tex1Name));
device->SetTexture(1, GetTexture(triangles[i].tex2Name));
@@ -334,7 +334,7 @@ int main(int argc, char *argv[])
SDL_WM_SetCaption("Model Test", "Model Test");
- Gfx::CGLDevice *device = new Gfx::CGLDevice();
+ Gfx::CGLDevice *device = new Gfx::CGLDevice(Gfx::GLDeviceConfig());
device->Create();
Init(device, modelFile);
diff --git a/src/graphics/opengl/test/texture_test.cpp b/src/graphics/opengl/test/texture_test.cpp
index c3c568b..534a5c0 100644
--- a/src/graphics/opengl/test/texture_test.cpp
+++ b/src/graphics/opengl/test/texture_test.cpp
@@ -160,7 +160,7 @@ int main()
SDL_WM_SetCaption("Texture Test", "Texture Test");
- Gfx::CGLDevice *device = new Gfx::CGLDevice();
+ Gfx::CGLDevice *device = new Gfx::CGLDevice(Gfx::GLDeviceConfig());
device->Create();
Init(device);
diff --git a/src/graphics/opengl/test/transform_test.cpp b/src/graphics/opengl/test/transform_test.cpp
index 83819b8..cddd1b8 100644
--- a/src/graphics/opengl/test/transform_test.cpp
+++ b/src/graphics/opengl/test/transform_test.cpp
@@ -215,7 +215,7 @@ void KeyboardUp(SDLKey key)
void MouseMove(int x, int y)
{
- Math::Point currentPos((float)x, (float)y);
+ Math::Point currentPos(static_cast<float>(x), static_cast<float>(y));
static bool first = true;
if (first || (x < 10) || (y < 10) || (x > 790) || (y > 590))
@@ -228,8 +228,8 @@ void MouseMove(int x, int y)
return;
}
- ROTATION.y = ROTATION_BASE.y + ((float) (x - MOUSE_POS_BASE.x) / 800.0f) * Math::PI;
- ROTATION.x = ROTATION_BASE.x + ((float) (y - MOUSE_POS_BASE.y) / 600.0f) * Math::PI;
+ ROTATION.y = ROTATION_BASE.y + (static_cast<float> (x - MOUSE_POS_BASE.x) / 800.0f) * Math::PI;
+ ROTATION.x = ROTATION_BASE.x + (static_cast<float> (y - MOUSE_POS_BASE.y) / 600.0f) * Math::PI;
}
int main(int argc, char *argv[])
@@ -280,7 +280,7 @@ int main(int argc, char *argv[])
//SDL_WM_GrabInput(SDL_GRAB_ON);
SDL_ShowCursor(SDL_DISABLE);
- Gfx::CGLDevice *device = new Gfx::CGLDevice();
+ Gfx::CGLDevice *device = new Gfx::CGLDevice(Gfx::GLDeviceConfig());
device->Create();
Init(device);