summaryrefslogtreecommitdiffstats
path: root/src/graphics/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphics/core')
-rw-r--r--src/graphics/core/color.cpp15
-rw-r--r--src/graphics/core/color.h26
-rw-r--r--src/graphics/core/device.h218
-rw-r--r--src/graphics/core/light.h33
-rw-r--r--src/graphics/core/material.h14
-rw-r--r--src/graphics/core/texture.h85
-rw-r--r--src/graphics/core/vertex.h24
7 files changed, 203 insertions, 212 deletions
diff --git a/src/graphics/core/color.cpp b/src/graphics/core/color.cpp
index f241227..1f9d7a5 100644
--- a/src/graphics/core/color.cpp
+++ b/src/graphics/core/color.cpp
@@ -14,16 +14,19 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// color.cpp
#include "graphics/core/color.h"
#include "math/func.h"
-Gfx::ColorHSV Gfx::RGB2HSV(Gfx::Color color)
+// Graphics module namespace
+namespace Gfx {
+
+
+ColorHSV RGB2HSV(Color color)
{
- Gfx::ColorHSV result;
+ ColorHSV result;
float min = Math::Min(color.r, color.g, color.b);
float max = Math::Max(color.r, color.g, color.b);
@@ -61,9 +64,9 @@ Gfx::ColorHSV Gfx::RGB2HSV(Gfx::Color color)
return result;
}
-Gfx::Color Gfx::HSV2RGB(Gfx::ColorHSV color)
+Color HSV2RGB(ColorHSV color)
{
- Gfx::Color result;
+ Color result;
color.h = Math::Norm(color.h)*360.0f;
color.s = Math::Norm(color.s);
@@ -101,3 +104,5 @@ Gfx::Color Gfx::HSV2RGB(Gfx::ColorHSV color)
return result;
}
+
+} // namespace Gfx
diff --git a/src/graphics/core/color.h b/src/graphics/core/color.h
index bcd0af1..4b152c1 100644
--- a/src/graphics/core/color.h
+++ b/src/graphics/core/color.h
@@ -21,14 +21,17 @@
#pragma once
+
#include <sstream>
+// Graphics module namespace
namespace Gfx {
/**
- \struct Color
- \brief RGBA color */
+ * \struct Color
+ * \brief RGBA color
+ */
struct Color
{
//! Red, green, blue and alpha components
@@ -38,9 +41,9 @@ struct Color
explicit Color(float aR = 0.0f, float aG = 0.0f, float aB = 0.0f, float aA = 0.0f)
: r(aR), g(aG), b(aB), a(aA) {}
- inline Gfx::Color Inverse() const
+ inline Color Inverse() const
{
- return Gfx::Color(1.0f - r, 1.0f - g, 1.0f - b, 1.0f - a);
+ return Color(1.0f - r, 1.0f - g, 1.0f - b, 1.0f - a);
}
//! Returns the struct cast to \c float* array; use with care!
@@ -64,20 +67,21 @@ struct Color
return s.str();
}
- inline bool operator==(const Gfx::Color &other) const
+ inline bool operator==(const Color &other) const
{
return r == other.r && g == other.g && b == other.b && a == other.a;
}
- inline bool operator!=(const Gfx::Color &other) const
+ inline bool operator!=(const Color &other) const
{
return ! this->operator==(other);
}
};
/**
- \struct ColorHSV
- \brief HSV color */
+ * \struct ColorHSV
+ * \brief HSV color
+ */
struct ColorHSV
{
float h, s, v;
@@ -96,10 +100,10 @@ struct ColorHSV
};
//! Converts a RGB color to HSV color
-Gfx::ColorHSV RGB2HSV(Gfx::Color color);
+ColorHSV RGB2HSV(Color color);
//! Converts a HSV color to RGB color
-Gfx::Color HSV2RGB(Gfx::ColorHSV color);
+Color HSV2RGB(ColorHSV color);
-}; // namespace Gfx
+} // namespace Gfx
diff --git a/src/graphics/core/device.h b/src/graphics/core/device.h
index 9eb6f6d..7c60d21 100644
--- a/src/graphics/core/device.h
+++ b/src/graphics/core/device.h
@@ -17,7 +17,7 @@
/**
* \file graphics/core/device.h
- * \brief Abstract graphics device - Gfx::CDevice class and related structs/enums
+ * \brief Abstract graphics device - CDevice class and related structs/enums
*/
#pragma once
@@ -28,6 +28,7 @@
#include "graphics/core/material.h"
#include "graphics/core/texture.h"
#include "graphics/core/vertex.h"
+
#include "math/intpoint.h"
#include "math/matrix.h"
@@ -38,14 +39,15 @@ class CImage;
struct ImageData;
+// Graphics module namespace
namespace Gfx {
/**
- \struct DeviceConfig
- \brief General config for graphics device
-
- These settings are common window options set by SDL.
-*/
+ * \struct DeviceConfig
+ * \brief General config for graphics device
+ *
+ * These settings are common window options set by SDL.
+ */
struct DeviceConfig
{
//! Screen size
@@ -78,10 +80,11 @@ struct DeviceConfig
/**
- \enum TransformType
- \brief Type of transformation in rendering pipeline
-
- These correspond to DirectX's three transformation matrices. */
+ * \enum TransformType
+ * \brief Type of transformation in rendering pipeline
+ *
+ * These correspond to DirectX's three transformation matrices.
+ */
enum TransformType
{
TRANSFORM_WORLD,
@@ -90,8 +93,9 @@ enum TransformType
};
/**
- \enum RenderState
- \brief Render states that can be enabled/disabled */
+ * \enum RenderState
+ * \brief Render states that can be enabled/disabled
+ */
enum RenderState
{
RENDER_STATE_LIGHTING,
@@ -106,8 +110,9 @@ enum RenderState
};
/**
- \enum CompFunc
- \brief Type of function used to compare values */
+ * \enum CompFunc
+ * \brief Type of function used to compare values
+ */
enum CompFunc
{
COMP_FUNC_NEVER,
@@ -121,8 +126,9 @@ enum CompFunc
};
/**
- \enum BlendFunc
- \brief Type of blending function */
+ * \enum BlendFunc
+ * \brief Type of blending function
+ */
enum BlendFunc
{
BLEND_ZERO,
@@ -139,8 +145,9 @@ enum BlendFunc
};
/**
- \enum FogMode
- \brief Type of fog calculation function */
+ * \enum FogMode
+ * \brief Type of fog calculation function
+ */
enum FogMode
{
FOG_LINEAR,
@@ -149,8 +156,9 @@ enum FogMode
};
/**
- \enum CullMode
- \brief Culling mode for polygons */
+ * \enum CullMode
+ * \brief Culling mode for polygons
+ */
enum CullMode
{
//! Cull clockwise faces
@@ -160,8 +168,9 @@ enum CullMode
};
/**
- \enum ShadeModel
- \brief Shade model used in rendering */
+ * \enum ShadeModel
+ * \brief Shade model used in rendering
+ */
enum ShadeModel
{
SHADE_FLAT,
@@ -169,8 +178,9 @@ enum ShadeModel
};
/**
- \enum FillMode
- \brief Polygon fill mode */
+ * \enum FillMode
+ * \brief Polygon fill mode
+ */
enum FillMode
{
//! Draw only points
@@ -178,12 +188,13 @@ enum FillMode
//! Draw only lines
FILL_LINES,
//! Draw full polygons
- FILL_FILL
+ FILL_POLY
};
/**
- \enum PrimitiveType
- \brief Type of primitive to render */
+ * \enum PrimitiveType
+ * \brief Type of primitive to render
+ */
enum PrimitiveType
{
PRIMITIVE_POINTS,
@@ -194,10 +205,11 @@ enum PrimitiveType
};
/**
- \enum IntersectPlane
- \brief Intersection plane of projection volume
-
- These flags can be OR'd together. */
+ * \enum IntersectPlane
+ * \brief Intersection plane of projection volume
+ *
+ * These flags can be OR'd together.
+ */
enum IntersectPlane
{
INTERSECT_PLANE_LEFT = 0x01,
@@ -211,67 +223,16 @@ enum IntersectPlane
INTERSECT_PLANE_FRONT | INTERSECT_PLANE_BACK
};
-/*
-
-Notes for rewriting DirectX code:
-
->> SetRenderState() translates to many functions depending on param
-
-D3DRENDERSTATE_ALPHABLENDENABLE -> SetRenderState() with RENDER_STATE_BLENDING
-D3DRENDERSTATE_ALPHAFUNC -> SetAlphaTestFunc() func
-D3DRENDERSTATE_ALPHAREF -> SetAlphaTestFunc() ref
-D3DRENDERSTATE_ALPHATESTENABLE -> SetRenderState() with RENDER_STATE_ALPHA_TEST
-D3DRENDERSTATE_AMBIENT -> SetGlobalAmbient()
-D3DRENDERSTATE_CULLMODE -> SetCullMode()
-D3DRENDERSTATE_DESTBLEND -> SetBlendFunc() dest blending func
-D3DRENDERSTATE_DITHERENABLE -> SetRenderState() with RENDER_STATE_DITHERING
-D3DRENDERSTATE_FILLMODE -> SetFillMode()
-D3DRENDERSTATE_FOGCOLOR -> SetFogParams()
-D3DRENDERSTATE_FOGENABLE -> SetRenderState() with RENDER_STATE_FOG
-D3DRENDERSTATE_FOGEND -> SetFogParams()
-D3DRENDERSTATE_FOGSTART -> SetFogParams()
-D3DRENDERSTATE_FOGVERTEXMODE -> SetFogParams() fog model
-D3DRENDERSTATE_LIGHTING -> SetRenderState() with RENDER_STATE_LIGHTING
-D3DRENDERSTATE_SHADEMODE -> SetShadeModel()
-D3DRENDERSTATE_SPECULARENABLE -> doesn't matter (always enabled)
-D3DRENDERSTATE_SRCBLEND -> SetBlendFunc() src blending func
-D3DRENDERSTATE_TEXTUREFACTOR -> SetTextureFactor()
-D3DRENDERSTATE_ZBIAS -> SetDepthBias()
-D3DRENDERSTATE_ZENABLE -> SetRenderState() with RENDER_STATE_DEPTH_TEST
-D3DRENDERSTATE_ZFUNC -> SetDepthTestFunc()
-D3DRENDERSTATE_ZWRITEENABLE -> SetRenderState() with RENDER_STATE_DEPTH_WRITE
-
-
->> SetTextureStageState() translates to SetTextureParams() or CreateTexture() for some params
-
-Params from enum in struct TextureCreateParams or TextureParams
- D3DTSS_ADDRESS -> Gfx::TexWrapMode wrapS, wrapT
- D3DTSS_ALPHAARG1 -> Gfx::TexMixArgument alphaArg1
- D3DTSS_ALPHAARG2 -> Gfx::TexMixArgument alphaArg2
- D3DTSS_ALPHAOP -> Gfx::TexMixOperation alphaOperation
- D3DTSS_COLORARG1 -> Gfx::TexMixArgument colorArg1
- D3DTSS_COLORARG2 -> Gfx::TexMixArgument colorArg2
- D3DTSS_COLOROP -> Gfx::TexMixOperation colorOperation
- D3DTSS_MAGFILTER -> Gfx::TexMagFilter magFilter
- D3DTSS_MINFILTER -> Gfx::TexMinFilter minFilter
- D3DTSS_TEXCOORDINDEX -> doesn't matter (texture coords are set explicitly by glMultiTexCoordARB*)
-
-Note that D3DTSS_ALPHAOP or D3DTSS_COLOROP set to D3DTOP_DISABLE must translate to disabling the whole texture stage.
-In DirectX, you shouldn't mix enabling one and disabling the other.
-Also, if previous stage is disabled in DirectX, the later ones are disabled, too. In OpenGL, that is not the case.
-
-*/
-
/**
- \class CDevice
- \brief Abstract interface of graphics device
-
- It is based on DIRECT3DDEVICE class from DirectX to make it easier to port existing code.
- It encapsulates the general graphics device state and provides a common interface
- to graphics-specific functions which will be used throughout the program,
- both in CEngine class and in UI classes. Note that it doesn't contain all functions from DirectX,
- only those that were used in old code.
-
+ * \class CDevice
+ * \brief Abstract interface of graphics device
+ *
+ * It is based on DIRECT3DDEVICE class from DirectX to make it easier to port existing code.
+ * It encapsulates the general graphics device state and provides a common interface
+ * to graphics-specific functions which will be used throughout the program,
+ * both in CEngine class and in UI classes. Note that it doesn't contain all functions from DirectX,
+ * only those that were used in old code.
+ *
*/
class CDevice
{
@@ -302,72 +263,72 @@ public:
virtual void MultiplyTransform(TransformType type, const Math::Matrix &matrix) = 0;
//! Sets the current material
- virtual void SetMaterial(const Gfx::Material &material) = 0;
+ virtual void SetMaterial(const Material &material) = 0;
//! Returns the current material
- virtual const Gfx::Material& GetMaterial() = 0;
+ 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 Gfx::Light &light) = 0;
+ virtual void SetLight(int index, const Light &light) = 0;
//! Returns the current light at given index
- virtual const Gfx::Light& GetLight(int index) = 0;
+ 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 Gfx::Texture CreateTexture(CImage *image, const Gfx::TextureCreateParams &params) = 0;
+ virtual Texture CreateTexture(CImage *image, const TextureCreateParams &params) = 0;
//! Creates a texture from raw image data; image data can be freed after that
- virtual Gfx::Texture CreateTexture(ImageData *data, const Gfx::TextureCreateParams &params) = 0;
+ virtual Texture CreateTexture(ImageData *data, const TextureCreateParams &params) = 0;
//! Deletes a given texture, freeing it from video memory
- virtual void DestroyTexture(const Gfx::Texture &texture) = 0;
+ virtual void DestroyTexture(const Texture &texture) = 0;
//! Deletes all textures created so far
virtual void DestroyAllTextures() = 0;
//! Returns the maximum number of multitexture stages
virtual int GetMaxTextureCount() = 0;
//! Sets the texture at given texture stage
- virtual void SetTexture(int index, const Gfx::Texture &texture) = 0;
+ 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 Gfx::Texture GetTexture(int index) = 0;
+ 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 Gfx::TextureStageParams &params) = 0;
+ virtual void SetTextureStageParams(int index, const TextureStageParams &params) = 0;
//! Returns the current params of texture stage with given index
- virtual Gfx::TextureStageParams GetTextureStageParams(int index) = 0;
+ virtual TextureStageParams GetTextureStageParams(int index) = 0;
//! Sets the texture factor to the given color value
- virtual void SetTextureFactor(const Gfx::Color &color) = 0;
+ virtual void SetTextureFactor(const Color &color) = 0;
//! Returns the current texture factor
- virtual Gfx::Color GetTextureFactor() = 0;
+ virtual Color GetTextureFactor() = 0;
//! Renders primitive composed of vertices with single texture
- virtual void DrawPrimitive(Gfx::PrimitiveType type, const Gfx::Vertex *vertices , int vertexCount) = 0;
+ virtual void DrawPrimitive(PrimitiveType type, const Vertex *vertices , int vertexCount) = 0;
//! Renders primitive composed of vertices with color information and single texture
- virtual void DrawPrimitive(Gfx::PrimitiveType type, const Gfx::VertexCol *vertices , int vertexCount) = 0;
+ virtual void DrawPrimitive(PrimitiveType type, const VertexCol *vertices , int vertexCount) = 0;
//! Renders primitive composed of vertices with multitexturing (2 textures)
- virtual void DrawPrimitive(Gfx::PrimitiveType type, const Gfx::VertexTex2 *vertices, int vertexCount) = 0;
+ virtual void DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, int vertexCount) = 0;
//! Tests whether a sphere intersects the 6 clipping planes of projection volume
virtual int ComputeSphereVisibility(const Math::Vector &center, float radius) = 0;
//! Enables/disables the given render state
- virtual void SetRenderState(Gfx::RenderState state, bool enabled) = 0;
+ virtual void SetRenderState(RenderState state, bool enabled) = 0;
//! Returns the current setting of given render state
- virtual bool GetRenderState(Gfx::RenderState state) = 0;
+ virtual bool GetRenderState(RenderState state) = 0;
//! Sets the function of depth test
- virtual void SetDepthTestFunc(Gfx::CompFunc func) = 0;
+ virtual void SetDepthTestFunc(CompFunc func) = 0;
//! Returns the current function of depth test
- virtual Gfx::CompFunc GetDepthTestFunc() = 0;
+ virtual CompFunc GetDepthTestFunc() = 0;
//! Sets the depth bias (constant value added to Z-coords)
virtual void SetDepthBias(float factor) = 0;
@@ -375,44 +336,45 @@ public:
virtual float GetDepthBias() = 0;
//! Sets the alpha test function and reference value
- virtual void SetAlphaTestFunc(Gfx::CompFunc func, float refValue) = 0;
+ virtual void SetAlphaTestFunc(CompFunc func, float refValue) = 0;
//! Returns the current alpha test function and reference value
- virtual void GetAlphaTestFunc(Gfx::CompFunc &func, float &refValue) = 0;
+ virtual void GetAlphaTestFunc(CompFunc &func, float &refValue) = 0;
//! Sets the blending functions for source and destination operations
- virtual void SetBlendFunc(Gfx::BlendFunc srcBlend, Gfx::BlendFunc dstBlend) = 0;
+ virtual void SetBlendFunc(BlendFunc srcBlend, BlendFunc dstBlend) = 0;
//! Returns the current blending functions for source and destination operations
- virtual void GetBlendFunc(Gfx::BlendFunc &srcBlend, Gfx::BlendFunc &dstBlend) = 0;
+ virtual void GetBlendFunc(BlendFunc &srcBlend, BlendFunc &dstBlend) = 0;
//! Sets the clear color
- virtual void SetClearColor(const Gfx::Color &color) = 0;
+ virtual void SetClearColor(const Color &color) = 0;
//! Returns the current clear color
- virtual Gfx::Color GetClearColor() = 0;
+ virtual Color GetClearColor() = 0;
//! Sets the global ambient color
- virtual void SetGlobalAmbient(const Gfx::Color &color) = 0;
+ virtual void SetGlobalAmbient(const Color &color) = 0;
//! Returns the global ambient color
- virtual Gfx::Color GetGlobalAmbient() = 0;
+ virtual Color GetGlobalAmbient() = 0;
//! Sets the fog parameters: mode, color, start distance, end distance and density (for exp models)
- virtual void SetFogParams(Gfx::FogMode mode, const Gfx::Color &color, float start, float end, float density) = 0;
+ 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(Gfx::FogMode &mode, Gfx::Color &color, float &start, float &end, float &density) = 0;
+ virtual void GetFogParams(FogMode &mode, Color &color, float &start, float &end, float &density) = 0;
//! Sets the current cull mode
- virtual void SetCullMode(Gfx::CullMode mode) = 0;
+ virtual void SetCullMode(CullMode mode) = 0;
//! Returns the current cull mode
- virtual Gfx::CullMode GetCullMode() = 0;
+ virtual CullMode GetCullMode() = 0;
//! Sets the shade model
- virtual void SetShadeModel(Gfx::ShadeModel model) = 0;
+ virtual void SetShadeModel(ShadeModel model) = 0;
//! Returns the current shade model
- virtual Gfx::ShadeModel GetShadeModel() = 0;
+ virtual ShadeModel GetShadeModel() = 0;
//! Sets the current fill mode
- virtual void SetFillMode(Gfx::FillMode mode) = 0;
+ virtual void SetFillMode(FillMode mode) = 0;
//! Returns the current fill mode
- virtual Gfx::FillMode GetFillMode() = 0;
+ virtual FillMode GetFillMode() = 0;
};
-}; // namespace Gfx
+
+} // namespace Gfx
diff --git a/src/graphics/core/light.h b/src/graphics/core/light.h
index 0601c5b..35f37e6 100644
--- a/src/graphics/core/light.h
+++ b/src/graphics/core/light.h
@@ -24,14 +24,17 @@
#include "graphics/core/color.h"
+
#include "math/vector.h"
+// Graphics module namespace
namespace Gfx {
/**
- \enum LightType
- \brief Type of light in 3D scene */
+ * \enum LightType
+ * \brief Type of light in 3D scene
+ */
enum LightType
{
LIGHT_POINT,
@@ -40,20 +43,21 @@ enum LightType
};
/**
- \struct Light
- \brief Properties of light in 3D scene
-
- This structure was created as analog to DirectX's D3DLIGHT. */
+ * \struct Light
+ * \brief Properties of light in 3D scene
+ *
+ * This structure was created as analog to DirectX's D3DLIGHT.
+ */
struct Light
{
//! Type of light source
- Gfx::LightType type;
+ LightType type;
//! Color of ambient light
- Gfx::Color ambient;
+ Color ambient;
//! Color of diffuse light
- Gfx::Color diffuse;
+ Color diffuse;
//! Color of specular light
- Gfx::Color specular;
+ Color specular;
//! Position in world space (for point & spot lights)
Math::Vector position;
//! Direction in world space (for directional & spot lights)
@@ -80,9 +84,9 @@ struct Light
void LoadDefault()
{
type = LIGHT_POINT;
- ambient = Gfx::Color(0.4f, 0.4f, 0.4f);
- diffuse = Gfx::Color(0.8f, 0.8f, 0.8f);
- specular = Gfx::Color(1.0f, 1.0f, 1.0f);
+ ambient = Color(0.4f, 0.4f, 0.4f);
+ diffuse = Color(0.8f, 0.8f, 0.8f);
+ specular = Color(1.0f, 1.0f, 1.0f);
position = Math::Vector(0.0f, 0.0f, 0.0f);
direction = Math::Vector(0.0f, 0.0f, 1.0f);
attenuation0 = 1.0f;
@@ -92,4 +96,5 @@ struct Light
}
};
-}; // namespace Gfx
+
+} // namespace Gfx
diff --git a/src/graphics/core/material.h b/src/graphics/core/material.h
index 156ff36..07782d5 100644
--- a/src/graphics/core/material.h
+++ b/src/graphics/core/material.h
@@ -25,6 +25,7 @@
#include "graphics/core/color.h"
+// Graphics module namespace
namespace Gfx {
/**
@@ -40,21 +41,22 @@ namespace Gfx {
struct Material
{
//! Diffuse color
- Gfx::Color diffuse;
+ Color diffuse;
//! Ambient color
- Gfx::Color ambient;
+ Color ambient;
//! Specular color
- Gfx::Color specular;
+ Color specular;
- bool operator==(const Gfx::Material &mat) const
+ bool operator==(const Material &mat) const
{
return diffuse == mat.diffuse && ambient == mat.ambient && specular == mat.specular;
}
- bool operator!=(const Gfx::Material &mat) const
+ bool operator!=(const Material &mat) const
{
return ! operator==(mat);
}
};
-}; // namespace Gfx
+
+} // namespace Gfx
diff --git a/src/graphics/core/texture.h b/src/graphics/core/texture.h
index 8abe86a..e9117e2 100644
--- a/src/graphics/core/texture.h
+++ b/src/graphics/core/texture.h
@@ -21,14 +21,17 @@
#pragma once
+
#include "math/intpoint.h"
+// Graphics module namespace
namespace Gfx {
/**
- \enum TexImgFormat
- \brief Format of image data */
+ * \enum TexImgFormat
+ * \brief Format of image data
+ */
enum TexImgFormat
{
//! Try to determine automatically (may not work)
@@ -44,10 +47,11 @@ enum TexImgFormat
};
/**
- \enum TexMinFilter
- \brief Texture minification filter
-
- Corresponds to OpenGL modes but should translate to DirectX too. */
+ * \enum TexMinFilter
+ * \brief Texture minification filter
+ *
+ * Corresponds to OpenGL modes but should translate to DirectX too.
+ */
enum TexMinFilter
{
TEX_MIN_FILTER_NEAREST,
@@ -59,8 +63,9 @@ enum TexMinFilter
};
/**
- \enum TexMagFilter
- \brief Texture magnification filter */
+ * \enum TexMagFilter
+ * \brief Texture magnification filter
+ */
enum TexMagFilter
{
TEX_MAG_FILTER_NEAREST,
@@ -68,8 +73,9 @@ enum TexMagFilter
};
/**
- \enum TexWrapMode
- \brief Wrapping mode for texture coords */
+ * \enum TexWrapMode
+ * \brief Wrapping mode for texture coords
+ */
enum TexWrapMode
{
TEX_WRAP_CLAMP,
@@ -77,8 +83,9 @@ enum TexWrapMode
};
/**
- \enum TexMixOperation
- \brief Multitexture mixing operation */
+ * \enum TexMixOperation
+ * \brief Multitexture mixing operation
+ */
enum TexMixOperation
{
//! Default operation on default params (modulate on computed & texture)
@@ -94,8 +101,9 @@ enum TexMixOperation
};
/**
- \enum TexMixArgument
- \brief Multitexture mixing argument */
+ * \enum TexMixArgument
+ * \brief Multitexture mixing argument
+ */
enum TexMixArgument
{
//! Color from current texture
@@ -119,11 +127,11 @@ struct TextureCreateParams
//! Whether to generate mipmaps
bool mipmap;
//! Format of source image data
- Gfx::TexImgFormat format;
+ TexImgFormat format;
//! Minification filter
- Gfx::TexMinFilter minFilter;
+ TexMinFilter minFilter;
//! Magnification filter
- Gfx::TexMagFilter magFilter;
+ TexMagFilter magFilter;
//! Constructor; calls LoadDefault()
TextureCreateParams()
@@ -132,11 +140,11 @@ struct TextureCreateParams
//! Loads the default values
inline void LoadDefault()
{
- format = Gfx::TEX_IMG_RGB;
+ format = TEX_IMG_RGB;
mipmap = false;
- minFilter = Gfx::TEX_MIN_FILTER_NEAREST;
- magFilter = Gfx::TEX_MAG_FILTER_NEAREST;
+ minFilter = TEX_MIN_FILTER_NEAREST;
+ magFilter = TEX_MAG_FILTER_NEAREST;
}
};
@@ -149,21 +157,21 @@ struct TextureCreateParams
struct TextureStageParams
{
//! Mixing operation done on color values
- Gfx::TexMixOperation colorOperation;
+ TexMixOperation colorOperation;
//! 1st argument of color operations
- Gfx::TexMixArgument colorArg1;
+ TexMixArgument colorArg1;
//! 2nd argument of color operations
- Gfx::TexMixArgument colorArg2;
+ TexMixArgument colorArg2;
//! Mixing operation done on alpha values
- Gfx::TexMixOperation alphaOperation;
+ TexMixOperation alphaOperation;
//! 1st argument of alpha operations
- Gfx::TexMixArgument alphaArg1;
+ TexMixArgument alphaArg1;
//! 2nd argument of alpha operations
- Gfx::TexMixArgument alphaArg2;
+ TexMixArgument alphaArg2;
//! Wrap mode for 1st tex coord
- Gfx::TexWrapMode wrapS;
+ TexWrapMode wrapS;
//! Wrap mode for 2nd tex coord
- Gfx::TexWrapMode wrapT;
+ TexWrapMode wrapT;
//! Constructor; calls LoadDefault()
TextureStageParams()
@@ -172,15 +180,15 @@ struct TextureStageParams
//! Loads the default values
inline void LoadDefault()
{
- colorOperation = Gfx::TEX_MIX_OPER_DEFAULT;
- colorArg1 = Gfx::TEX_MIX_ARG_COMPUTED_COLOR;
- colorArg2 = Gfx::TEX_MIX_ARG_TEXTURE;
+ colorOperation = TEX_MIX_OPER_DEFAULT;
+ colorArg1 = TEX_MIX_ARG_COMPUTED_COLOR;
+ colorArg2 = TEX_MIX_ARG_TEXTURE;
- alphaOperation = Gfx::TEX_MIX_OPER_DEFAULT;
- alphaArg1 = Gfx::TEX_MIX_ARG_COMPUTED_COLOR;
- alphaArg2 = Gfx::TEX_MIX_ARG_TEXTURE;
+ alphaOperation = TEX_MIX_OPER_DEFAULT;
+ alphaArg1 = TEX_MIX_ARG_COMPUTED_COLOR;
+ alphaArg2 = TEX_MIX_ARG_TEXTURE;
- wrapS = wrapT = Gfx::TEX_WRAP_REPEAT;
+ wrapS = wrapT = TEX_WRAP_REPEAT;
}
};
@@ -218,7 +226,7 @@ struct Texture
}
//! Comparator for use in texture maps and sets
- inline bool operator<(const Gfx::Texture &other) const
+ inline bool operator<(const Texture &other) const
{
// Invalid textures are always "less than" every other texture
@@ -235,7 +243,7 @@ struct Texture
}
//! Comparator
- inline bool operator==(const Gfx::Texture &other) const
+ inline bool operator==(const Texture &other) const
{
if (Valid() != other.Valid())
return false;
@@ -246,4 +254,5 @@ struct Texture
}
};
-}; // namespace Gfx
+
+} // namespace Gfx
diff --git a/src/graphics/core/vertex.h b/src/graphics/core/vertex.h
index a99d618..9ab4dbb 100644
--- a/src/graphics/core/vertex.h
+++ b/src/graphics/core/vertex.h
@@ -23,11 +23,14 @@
#include "graphics/core/color.h"
+
#include "math/vector.h"
#include "math/point.h"
#include <sstream>
+
+// Graphics module namespace
namespace Gfx {
/**
@@ -72,20 +75,20 @@ struct Vertex
*
* It contains:
* - vertex coordinates (x,y,z) as Math::Vector,
- * - RGBA color as Gfx::Color,
- * - RGBA specular color as Gfx::Color,
+ * - RGBA color as Color,
+ * - RGBA specular color as Color,
* - texture coordinates (u,v) as Math::Point.
*/
struct VertexCol
{
Math::Vector coord;
- Gfx::Color color;
- Gfx::Color specular;
+ Color color;
+ Color specular;
Math::Point texCoord;
explicit VertexCol(Math::Vector aCoord = Math::Vector(),
- Gfx::Color aColor = Gfx::Color(),
- Gfx::Color aSpecular = Gfx::Color(),
+ Color aColor = Color(),
+ Color aSpecular = Color(),
Math::Point aTexCoord = Math::Point())
: coord(aCoord), color(aColor), specular(aSpecular), texCoord(aTexCoord) {}
@@ -105,7 +108,7 @@ struct VertexCol
* \struct VertexTex2
* \brief Vertex with secondary texture coordinates
*
- * In addition to fields from Gfx::Vector, it contains
+ * In addition to fields from Vector, it contains
* secondary texture coordinates (u2, v2) as Math::Point
*/
struct VertexTex2
@@ -121,8 +124,8 @@ struct VertexTex2
Math::Point aTexCoord2 = Math::Point())
: coord(aCoord), normal(aNormal), texCoord(aTexCoord), texCoord2(aTexCoord2) {}
- //! Sets the fields from Gfx::Vertex with texCoord2 = (0,0)
- void FromVertex(const Gfx::Vertex &v)
+ //! Sets the fields from Vertex with texCoord2 = (0,0)
+ void FromVertex(const Vertex &v)
{
coord = v.coord;
normal = v.normal;
@@ -141,4 +144,5 @@ struct VertexTex2
}
};
-}; // namespace Gfx
+
+} // namespace Gfx