summaryrefslogtreecommitdiffstats
path: root/src/graphics/opengl/gldevice.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphics/opengl/gldevice.h')
-rw-r--r--src/graphics/opengl/gldevice.h94
1 files changed, 93 insertions, 1 deletions
diff --git a/src/graphics/opengl/gldevice.h b/src/graphics/opengl/gldevice.h
index a2fb4a0..0b4702a 100644
--- a/src/graphics/opengl/gldevice.h
+++ b/src/graphics/opengl/gldevice.h
@@ -21,11 +21,103 @@
#include "graphics/common/device.h"
+
+#include <vector>
+
+
namespace Gfx {
+/**
+ \struct GLDeviceConfig
+ \brief Additional config with OpenGL-specific settings */
+struct GLDeviceConfig : public DeviceConfig
+{
+ //! Size of red channel in bits
+ int redSize;
+ //! Size of green channel in bits
+ int greenSize;
+ //! Size of blue channel in bits
+ int blueSize;
+ //! Size of alpha channel in bits
+ int alphaSize;
+ //! Color depth in bits
+ int depthSize;
+
+ //! Force hardware acceleration (video mode set will fail on lack of hw accel)
+ bool hardwareAccel;
+
+ //! Constructor calls LoadDefaults()
+ GLDeviceConfig() { LoadDefault(); }
+
+ //! Loads the default values
+ void LoadDefault();
+};
+
+/**
+ \class CGLDevice
+ \brief Implementation of CDevice interface in OpenGL
+
+ Provides the concrete implementation of 3D device in OpenGL.
+
+ This class should be initialized (by calling Initialize() ) only after
+ setting the video mode by CApplication, once the OpenGL context is defined.
+ Because of that, CGLDeviceConfig is outside the CDevice class and must be set
+ in CApplication.
+*/
class CGLDevice : public Gfx::CDevice
{
- // TODO
+public:
+ CGLDevice();
+ virtual ~CGLDevice();
+
+ virtual void Initialize();
+ virtual void Destroy();
+
+ virtual void BeginScene();
+ virtual void EndScene();
+
+ virtual void Clear();
+
+ virtual void SetTransform(Gfx::TransformType type, const Math::Matrix &matrix);
+ virtual const Math::Matrix& GetTransform(Gfx::TransformType type);
+ virtual void MultiplyTransform(Gfx::TransformType type, const Math::Matrix &matrix);
+
+ virtual void SetMaterial(const Gfx::Material &material);
+ virtual const Gfx::Material& GetMaterial();
+
+ virtual int GetMaxLightCount();
+ virtual void SetLight(int index, const Gfx::Light &light);
+ virtual const Gfx::Light& GetLight(int index);
+ virtual void SetLightEnabled(int index, bool enabled);
+ virtual bool GetLightEnabled(int index);
+
+ virtual int GetMaxTextureCount();
+ virtual const Gfx::Texture& GetTexture(int index);
+ virtual void SetTexture(int index, const Gfx::Texture &texture);
+
+ virtual void SetRenderState(Gfx::RenderState state, bool enabled);
+ virtual bool GetRenderState(Gfx::RenderState state);
+
+ virtual void DrawPrimitive(Gfx::PrimitiveType, Vertex *vertices, int vertexCount);
+ virtual void DrawPrimitive(Gfx::PrimitiveType, VertexTex2 *vertices, int vertexCount);
+
+private:
+ //! Current world matrix
+ Math::Matrix m_worldMat;
+ //! Current view matrix
+ Math::Matrix m_viewMat;
+ //! Current projection matrix
+ Math::Matrix m_projectionMat;
+ //! The current material
+ Gfx::Material m_material;
+ //! Current lights
+ std::vector<Gfx::Light> m_lights;
+ //! Current lights enable status
+ std::vector<bool> m_lightsEnabled;
+ //! Current textures
+ std::vector<Gfx::Texture> m_textures;
+ //! Current render state
+ unsigned long m_renderState;
};
}; // namespace Gfx