From 4bdfa0aa4ee3ad00429e8d68823532bdb2d72a97 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Tue, 12 Aug 2014 18:18:30 +0200 Subject: Remove unused accessors from CDevice --- src/graphics/core/device.h | 40 +------- src/graphics/opengl/gldevice.cpp | 211 +-------------------------------------- src/graphics/opengl/gldevice.h | 112 +++++++++------------ 3 files changed, 49 insertions(+), 314 deletions(-) (limited to 'src/graphics') diff --git a/src/graphics/core/device.h b/src/graphics/core/device.h index a896104..476136e 100644 --- a/src/graphics/core/device.h +++ b/src/graphics/core/device.h @@ -258,26 +258,16 @@ public: //! Sets the transform matrix of given type virtual void SetTransform(TransformType type, const Math::Matrix &matrix) = 0; - //! Returns the current transform matrix of given type - virtual const Math::Matrix& GetTransform(TransformType type) = 0; - //! Multiplies the current transform matrix of given type by given matrix - virtual void MultiplyTransform(TransformType type, const Math::Matrix &matrix) = 0; //! Sets the current material virtual void SetMaterial(const Material &material) = 0; - //! Returns the current material - virtual const Material& GetMaterial() = 0; //! Returns the maximum number of lights available virtual int GetMaxLightCount() = 0; //! Sets the light at given index virtual void SetLight(int index, const Light &light) = 0; - //! Returns the current light at given index - virtual const Light& GetLight(int index) = 0; //! Enables/disables the light at given index virtual void SetLightEnabled(int index, bool enabled) = 0; - //! Returns the current enable state of light at given index - virtual bool GetLightEnabled(int index) = 0; //! Creates a texture from image; the image can be safely removed after that virtual Texture CreateTexture(CImage *image, const TextureCreateParams ¶ms) = 0; @@ -294,17 +284,11 @@ public: virtual void SetTexture(int index, const Texture &texture) = 0; //! Sets the texture image by ID at given texture stage virtual void SetTexture(int index, unsigned int textureId) = 0; - //! Returns the (multi)texture at given index - virtual Texture GetTexture(int index) = 0; //! Enables/disables the given texture stage virtual void SetTextureEnabled(int index, bool enabled) = 0; - //! Returns the current enable state of given texture stage - virtual bool GetTextureEnabled(int index) = 0; //! Sets the params for texture stage with given index virtual void SetTextureStageParams(int index, const TextureStageParams ¶ms) = 0; - //! Returns the current params of texture stage with given index - virtual TextureStageParams GetTextureStageParams(int index) = 0; //! Sets only the texture wrap modes (for faster than thru stage params) virtual void SetTextureStageWrap(int index, TexWrapMode wrapS, TexWrapMode wrapT) = 0; @@ -348,61 +332,39 @@ public: //! Enables/disables the given render state virtual void SetRenderState(RenderState state, bool enabled) = 0; - //! Returns the current setting of given render state - virtual bool GetRenderState(RenderState state) = 0; //! Sets the function of depth test virtual void SetDepthTestFunc(CompFunc func) = 0; - //! Returns the current function of depth test - virtual CompFunc GetDepthTestFunc() = 0; //! Sets the depth bias (constant value added to Z-coords) virtual void SetDepthBias(float factor) = 0; - //! Returns the current depth bias - virtual float GetDepthBias() = 0; //! Sets the alpha test function and reference value virtual void SetAlphaTestFunc(CompFunc func, float refValue) = 0; - //! Returns the current alpha test function and reference value - virtual void GetAlphaTestFunc(CompFunc &func, float &refValue) = 0; //! Sets the blending functions for source and destination operations virtual void SetBlendFunc(BlendFunc srcBlend, BlendFunc dstBlend) = 0; - //! Returns the current blending functions for source and destination operations - virtual void GetBlendFunc(BlendFunc &srcBlend, BlendFunc &dstBlend) = 0; //! Sets the clear color virtual void SetClearColor(const Color &color) = 0; - //! Returns the current clear color - virtual Color GetClearColor() = 0; //! Sets the global ambient color virtual void SetGlobalAmbient(const Color &color) = 0; - //! Returns the global ambient color - virtual Color GetGlobalAmbient() = 0; //! Sets the fog parameters: mode, color, start distance, end distance and density (for exp models) virtual void SetFogParams(FogMode mode, const Color &color, float start, float end, float density) = 0; - //! Returns the current fog parameters: mode, color, start distance, end distance and density (for exp models) - virtual void GetFogParams(FogMode &mode, Color &color, float &start, float &end, float &density) = 0; //! Sets the current cull mode virtual void SetCullMode(CullMode mode) = 0; - //! Returns the current cull mode - virtual CullMode GetCullMode() = 0; //! Sets the shade model virtual void SetShadeModel(ShadeModel model) = 0; - //! Returns the current shade model - virtual ShadeModel GetShadeModel() = 0; //! Sets the current fill mode virtual void SetFillMode(FillMode mode) = 0; - //! Returns the current fill mode - virtual FillMode GetFillMode() = 0; //! Returns the pixels of the entire screen - virtual void* GetFrameBufferPixels()const = 0; + virtual void* GetFrameBufferPixels() const = 0; }; diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp index b42f29d..10eec90 100644 --- a/src/graphics/opengl/gldevice.cpp +++ b/src/graphics/opengl/gldevice.cpp @@ -290,11 +290,6 @@ void CGLDevice::SetUseVbo(bool vboAvailable) m_vboAvailable = vboAvailable; } -bool CGLDevice::GetUseVbo() -{ - return m_vboAvailable; -} - void CGLDevice::BeginScene() { Clear(); @@ -339,44 +334,6 @@ void CGLDevice::SetTransform(TransformType type, const Math::Matrix &matrix) } } -const Math::Matrix& CGLDevice::GetTransform(TransformType type) -{ - if (type == TRANSFORM_WORLD) - return m_worldMat; - else if (type == TRANSFORM_VIEW) - return m_viewMat; - else if (type == TRANSFORM_PROJECTION) - return m_projectionMat; - else - assert(false); - - return m_worldMat; // to avoid warning -} - -void CGLDevice::MultiplyTransform(TransformType type, const Math::Matrix &matrix) -{ - if (type == TRANSFORM_WORLD) - { - m_worldMat = Math::MultiplyMatrices(m_worldMat, matrix); - UpdateModelviewMatrix(); - } - else if (type == TRANSFORM_VIEW) - { - m_viewMat = Math::MultiplyMatrices(m_viewMat, matrix); - UpdateModelviewMatrix(); - } - else if (type == TRANSFORM_PROJECTION) - { - m_projectionMat = Math::MultiplyMatrices(m_projectionMat, matrix); - glMatrixMode(GL_PROJECTION); - glLoadMatrixf(m_projectionMat.Array()); - } - else - { - assert(false); - } -} - void CGLDevice::UpdateModelviewMatrix() { m_modelviewMat = Math::MultiplyMatrices(m_viewMat, m_worldMat); @@ -402,11 +359,6 @@ void CGLDevice::SetMaterial(const Material &material) glMaterialfv(GL_FRONT, GL_SPECULAR, m_material.specular.Array()); } -const Material& CGLDevice::GetMaterial() -{ - return m_material; -} - int CGLDevice::GetMaxLightCount() { return m_lights.size(); @@ -482,14 +434,6 @@ void CGLDevice::UpdateLightPosition(int index) glPopMatrix(); } -const Light& CGLDevice::GetLight(int index) -{ - assert(index >= 0); - assert(index < static_cast( m_lights.size() )); - - return m_lights[index]; -} - void CGLDevice::SetLightEnabled(int index, bool enabled) { assert(index >= 0); @@ -503,14 +447,6 @@ void CGLDevice::SetLightEnabled(int index, bool enabled) glDisable(GL_LIGHT0 + index); } -bool CGLDevice::GetLightEnabled(int index) -{ - assert(index >= 0); - assert(index < static_cast( m_lights.size() )); - - return m_lightsEnabled[index]; -} - /** If image is invalid, returns invalid texture. Otherwise, returns pointer to new Texture struct. This struct must not be deleted in other way than through DeleteTexture() */ @@ -781,15 +717,6 @@ void CGLDevice::SetTexture(int index, unsigned int textureId) UpdateTextureParams(index); } -/** - Returns the previously assigned texture or invalid texture if the given stage is not enabled. */ -Texture CGLDevice::GetTexture(int index) -{ - assert(index >= 0 && index < static_cast( m_currentTextures.size() )); - - return m_currentTextures[index]; -} - void CGLDevice::SetTextureEnabled(int index, bool enabled) { assert(index >= 0 && index < static_cast( m_currentTextures.size() )); @@ -813,13 +740,6 @@ void CGLDevice::SetTextureEnabled(int index, bool enabled) glDisable(GL_TEXTURE_2D); } -bool CGLDevice::GetTextureEnabled(int index) -{ - assert(index >= 0 && index < static_cast( m_currentTextures.size() )); - - return m_texturesEnabled[index]; -} - /** Sets the texture parameters for the given texture stage. If the given texture was not set (bound) yet, nothing happens. @@ -1002,13 +922,6 @@ void CGLDevice::SetTextureStageWrap(int index, TexWrapMode wrapS, TexWrapMode wr else assert(false); } -TextureStageParams CGLDevice::GetTextureStageParams(int index) -{ - assert(index >= 0 && index < static_cast( m_currentTextures.size() )); - - return m_textureStageParams[index]; -} - GLenum TranslateGfxPrimitive(PrimitiveType type) { GLenum flag = 0; @@ -1529,30 +1442,6 @@ void CGLDevice::SetRenderState(RenderState state, bool enabled) glDisable(flag); } -bool CGLDevice::GetRenderState(RenderState state) -{ - if (state == RENDER_STATE_LIGHTING) - return m_lighting; - - GLenum flag = 0; - - switch (state) - { - case RENDER_STATE_DEPTH_WRITE: flag = GL_DEPTH_WRITEMASK; break; - case RENDER_STATE_BLENDING: flag = GL_BLEND; break; - case RENDER_STATE_FOG: flag = GL_FOG; break; - case RENDER_STATE_DEPTH_TEST: flag = GL_DEPTH_TEST; break; - case RENDER_STATE_ALPHA_TEST: flag = GL_ALPHA_TEST; break; - case RENDER_STATE_CULLING: flag = GL_CULL_FACE; break; - default: assert(false); break; - } - - GLboolean result = GL_FALSE; - glGetBooleanv(flag, &result); - - return result == GL_TRUE; -} - CompFunc TranslateGLCompFunc(GLenum flag) { switch (flag) @@ -1592,39 +1481,16 @@ void CGLDevice::SetDepthTestFunc(CompFunc func) glDepthFunc(TranslateGfxCompFunc(func)); } -CompFunc CGLDevice::GetDepthTestFunc() -{ - GLint flag = 0; - glGetIntegerv(GL_DEPTH_FUNC, &flag); - return TranslateGLCompFunc(static_cast(flag)); -} - void CGLDevice::SetDepthBias(float factor) { glPolygonOffset(factor, 0.0f); } -float CGLDevice::GetDepthBias() -{ - GLfloat result = 0.0f; - glGetFloatv(GL_POLYGON_OFFSET_FACTOR, &result); - return result; -} - void CGLDevice::SetAlphaTestFunc(CompFunc func, float refValue) { glAlphaFunc(TranslateGfxCompFunc(func), refValue); } -void CGLDevice::GetAlphaTestFunc(CompFunc &func, float &refValue) -{ - GLint flag = 0; - glGetIntegerv(GL_ALPHA_TEST_FUNC, &flag); - func = TranslateGLCompFunc(static_cast(flag)); - - glGetFloatv(GL_ALPHA_TEST_REF, static_cast(&refValue)); -} - BlendFunc TranslateGLBlendFunc(GLenum flag) { switch (flag) @@ -1671,41 +1537,16 @@ void CGLDevice::SetBlendFunc(BlendFunc srcBlend, BlendFunc dstBlend) glBlendFunc(TranslateGfxBlendFunc(srcBlend), TranslateGfxBlendFunc(dstBlend)); } -void CGLDevice::GetBlendFunc(BlendFunc &srcBlend, BlendFunc &dstBlend) -{ - GLint srcFlag = 0; - glGetIntegerv(GL_ALPHA_TEST_FUNC, &srcFlag); - srcBlend = TranslateGLBlendFunc(static_cast(srcFlag)); - - GLint dstFlag = 0; - glGetIntegerv(GL_ALPHA_TEST_FUNC, &dstFlag); - dstBlend = TranslateGLBlendFunc(static_cast(dstFlag)); -} - void CGLDevice::SetClearColor(const Color &color) { glClearColor(color.r, color.g, color.b, color.a); } -Color CGLDevice::GetClearColor() -{ - GLfloat color[4] = { 0.0f }; - glGetFloatv(GL_COLOR_CLEAR_VALUE, color); - return Color(color[0], color[1], color[2], color[3]); -} - void CGLDevice::SetGlobalAmbient(const Color &color) { glLightModelfv(GL_LIGHT_MODEL_AMBIENT, color.Array()); } -Color CGLDevice::GetGlobalAmbient() -{ - GLfloat color[4] = { 0.0f }; - glGetFloatv(GL_LIGHT_MODEL_AMBIENT, color); - return Color(color[0], color[1], color[2], color[3]); -} - void CGLDevice::SetFogParams(FogMode mode, const Color &color, float start, float end, float density) { if (mode == FOG_LINEAR) glFogi(GL_FOG_MODE, GL_LINEAR); @@ -1719,23 +1560,6 @@ void CGLDevice::SetFogParams(FogMode mode, const Color &color, float start, floa glFogfv(GL_FOG_COLOR, color.Array()); } -void CGLDevice::GetFogParams(FogMode &mode, Color &color, float &start, float &end, float &density) -{ - GLint flag = 0; - glGetIntegerv(GL_FOG_MODE, &flag); - if (flag == GL_LINEAR) mode = FOG_LINEAR; - else if (flag == GL_EXP) mode = FOG_EXP; - else if (flag == GL_EXP2) mode = FOG_EXP2; - else assert(false); - - glGetFloatv(GL_FOG_START, static_cast(&start)); - glGetFloatv(GL_FOG_END, static_cast(&end)); - glGetFloatv(GL_FOG_DENSITY, static_cast(&density)); - GLfloat col[4] = { 0.0f }; - glGetFloatv(GL_FOG_COLOR, col); - color = Color(col[0], col[1], col[2], col[3]); -} - void CGLDevice::SetCullMode(CullMode mode) { // Cull clockwise back faces, so front face is the opposite @@ -1745,16 +1569,6 @@ void CGLDevice::SetCullMode(CullMode mode) else assert(false); } -CullMode CGLDevice::GetCullMode() -{ - GLint flag = 0; - glGetIntegerv(GL_FRONT_FACE, &flag); - if (flag == GL_CW) return CULL_CCW; - else if (flag == GL_CCW) return CULL_CW; - else assert(false); - return CULL_CW; -} - void CGLDevice::SetShadeModel(ShadeModel model) { if (model == SHADE_FLAT) glShadeModel(GL_FLAT); @@ -1762,16 +1576,6 @@ void CGLDevice::SetShadeModel(ShadeModel model) else assert(false); } -ShadeModel CGLDevice::GetShadeModel() -{ - GLint flag = 0; - glGetIntegerv(GL_SHADE_MODEL, &flag); - if (flag == GL_FLAT) return SHADE_FLAT; - else if (flag == GL_SMOOTH) return SHADE_SMOOTH; - else assert(false); - return SHADE_FLAT; -} - void CGLDevice::SetFillMode(FillMode mode) { if (mode == FILL_POINT) glPolygonMode(GL_FRONT_AND_BACK, GL_POINT); @@ -1780,21 +1584,10 @@ void CGLDevice::SetFillMode(FillMode mode) else assert(false); } -FillMode CGLDevice::GetFillMode() -{ - GLint flag = 0; - glGetIntegerv(GL_POLYGON_MODE, &flag); - if (flag == GL_POINT) return FILL_POINT; - else if (flag == GL_LINE) return FILL_LINES; - else if (flag == GL_FILL) return FILL_POLY; - else assert(false); - return FILL_POINT; -} - void* CGLDevice::GetFrameBufferPixels()const{ - GLubyte* pixels = new GLubyte [4 * m_config.size.x * m_config.size.y]; - + GLubyte* pixels = new GLubyte[4 * m_config.size.x * m_config.size.y]; + glReadPixels(0, 0, m_config.size.x, m_config.size.y, GL_RGBA, GL_UNSIGNED_BYTE, pixels); unsigned int* p = static_cast ( static_cast(pixels) ); diff --git a/src/graphics/opengl/gldevice.h b/src/graphics/opengl/gldevice.h index 267ee73..ef9d1a6 100644 --- a/src/graphics/opengl/gldevice.h +++ b/src/graphics/opengl/gldevice.h @@ -92,103 +92,83 @@ public: CGLDevice(const GLDeviceConfig &config); virtual ~CGLDevice(); - virtual void DebugHook(); - virtual void DebugLights(); + virtual void DebugHook() override; + virtual void DebugLights() override; - virtual bool Create(); - virtual void Destroy(); + virtual bool Create() override; + virtual void Destroy() override; void ConfigChanged(const GLDeviceConfig &newConfig); void SetUseVbo(bool useVbo); - bool GetUseVbo(); - virtual void BeginScene(); - virtual void EndScene(); + virtual void BeginScene() override; + virtual void EndScene() override; - virtual void Clear(); + virtual void Clear() override; - virtual void SetTransform(TransformType type, const Math::Matrix &matrix); - virtual const Math::Matrix& GetTransform(TransformType type); - virtual void MultiplyTransform(TransformType type, const Math::Matrix &matrix); + virtual void SetTransform(TransformType type, const Math::Matrix &matrix) override; - virtual void SetMaterial(const Material &material); - virtual const Material& GetMaterial(); + virtual void SetMaterial(const Material &material) override; - virtual int GetMaxLightCount(); - virtual void SetLight(int index, const Light &light); - virtual const Light& GetLight(int index); - virtual void SetLightEnabled(int index, bool enabled); - virtual bool GetLightEnabled(int index); + virtual int GetMaxLightCount() override; + virtual void SetLight(int index, const Light &light) override; + virtual void SetLightEnabled(int index, bool enabled) override; - virtual Texture CreateTexture(CImage *image, const TextureCreateParams ¶ms); - virtual Texture CreateTexture(ImageData *data, const TextureCreateParams ¶ms); - virtual void DestroyTexture(const Texture &texture); - virtual void DestroyAllTextures(); + virtual Texture CreateTexture(CImage *image, const TextureCreateParams ¶ms) override; + virtual Texture CreateTexture(ImageData *data, const TextureCreateParams ¶ms) override; + virtual void DestroyTexture(const Texture &texture) override; + virtual void DestroyAllTextures() override; - virtual int GetMaxTextureStageCount(); - virtual void SetTexture(int index, const Texture &texture); - virtual void SetTexture(int index, unsigned int textureId); - virtual Texture GetTexture(int index); - virtual void SetTextureEnabled(int index, bool enabled); - virtual bool GetTextureEnabled(int index); + virtual int GetMaxTextureStageCount() override; + virtual void SetTexture(int index, const Texture &texture) override; + virtual void SetTexture(int index, unsigned int textureId) override; + virtual void SetTextureEnabled(int index, bool enabled) override; - virtual void SetTextureStageParams(int index, const TextureStageParams ¶ms); - virtual TextureStageParams GetTextureStageParams(int index); + virtual void SetTextureStageParams(int index, const TextureStageParams ¶ms) override; - virtual void SetTextureStageWrap(int index, Gfx::TexWrapMode wrapS, Gfx::TexWrapMode wrapT); + virtual void SetTextureStageWrap(int index, Gfx::TexWrapMode wrapS, Gfx::TexWrapMode wrapT) override; virtual void DrawPrimitive(PrimitiveType type, const Vertex *vertices , int vertexCount, - Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)); + Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) override; virtual void DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, int vertexCount, - Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)); - virtual void DrawPrimitive(PrimitiveType type, const VertexCol *vertices , int vertexCount); + Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) override; + virtual void DrawPrimitive(PrimitiveType type, const VertexCol *vertices , int vertexCount) override; - virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount); - virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount); - virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount); - virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount); - virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount); - virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount); - virtual void DrawStaticBuffer(unsigned int bufferId); - virtual void DestroyStaticBuffer(unsigned int bufferId); + virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) override; + virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) override; + virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) override; + virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) override; + virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) override; + virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) override; + virtual void DrawStaticBuffer(unsigned int bufferId) override; + virtual void DestroyStaticBuffer(unsigned int bufferId) override; - virtual int ComputeSphereVisibility(const Math::Vector ¢er, float radius); + virtual int ComputeSphereVisibility(const Math::Vector ¢er, float radius) override; - virtual void SetRenderState(RenderState state, bool enabled); - virtual bool GetRenderState(RenderState state); + virtual void SetRenderState(RenderState state, bool enabled) override; - virtual void SetDepthTestFunc(CompFunc func); - virtual CompFunc GetDepthTestFunc(); + virtual void SetDepthTestFunc(CompFunc func) override; - virtual void SetDepthBias(float factor); - virtual float GetDepthBias(); + virtual void SetDepthBias(float factor) override; - virtual void SetAlphaTestFunc(CompFunc func, float refValue); - virtual void GetAlphaTestFunc(CompFunc &func, float &refValue); + virtual void SetAlphaTestFunc(CompFunc func, float refValue) override; - virtual void SetBlendFunc(BlendFunc srcBlend, BlendFunc dstBlend); - virtual void GetBlendFunc(BlendFunc &srcBlend, BlendFunc &dstBlend); + virtual void SetBlendFunc(BlendFunc srcBlend, BlendFunc dstBlend) override; - virtual void SetClearColor(const Color &color); - virtual Color GetClearColor(); + virtual void SetClearColor(const Color &color) override; - virtual void SetGlobalAmbient(const Color &color); - virtual Color GetGlobalAmbient(); + virtual void SetGlobalAmbient(const Color &color) override; - virtual void SetFogParams(FogMode mode, const Color &color, float start, float end, float density); - virtual void GetFogParams(FogMode &mode, Color &color, float &start, float &end, float &density); + virtual void SetFogParams(FogMode mode, const Color &color, float start, float end, float density) override; - virtual void SetCullMode(CullMode mode); - virtual CullMode GetCullMode(); + virtual void SetCullMode(CullMode mode) override; - virtual void SetShadeModel(ShadeModel model); - virtual ShadeModel GetShadeModel(); + virtual void SetShadeModel(ShadeModel model) override; - virtual void SetFillMode(FillMode mode) ; - virtual FillMode GetFillMode(); + virtual void SetFillMode(FillMode mode) override; - virtual void* GetFrameBufferPixels()const; + virtual void* GetFrameBufferPixels() const override; private: //! Updates internal modelview matrix -- cgit v1.2.3-1-g7c22