diff options
Diffstat (limited to 'src/graphics/core')
-rw-r--r-- | src/graphics/core/color.h | 29 | ||||
-rw-r--r-- | src/graphics/core/device.h | 4 | ||||
-rw-r--r-- | src/graphics/core/texture.h | 34 | ||||
-rw-r--r-- | src/graphics/core/vertex.h | 24 |
4 files changed, 70 insertions, 21 deletions
diff --git a/src/graphics/core/color.h b/src/graphics/core/color.h index 4b152c1..0bec7e9 100644 --- a/src/graphics/core/color.h +++ b/src/graphics/core/color.h @@ -79,6 +79,35 @@ struct Color }; /** + * \struct IntColor + * \brief Color with integer values + * + * May be used for precise pixel manipulations. + */ +struct IntColor +{ + //! Red, green, blue and alpha components + unsigned char r, g, b, a; + + //! Constructor; default values are (0,0,0,0) = black + explicit IntColor(unsigned char aR = 0, unsigned char aG = 0, unsigned char aB = 0, unsigned char aA = 0) + : r(aR), g(aG), b(aB), a(aA) {} +}; + +inline Color IntColorToColor(IntColor color) +{ + return Color(color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f); +} + +inline IntColor ColorToIntColor(Color color) +{ + return IntColor(static_cast<unsigned char>(color.r * 255.0f), + static_cast<unsigned char>(color.g * 255.0f), + static_cast<unsigned char>(color.b * 255.0f), + static_cast<unsigned char>(color.a * 255.0f)); +} + +/** * \struct ColorHSV * \brief HSV color */ diff --git a/src/graphics/core/device.h b/src/graphics/core/device.h index 7c60d21..0d76644 100644 --- a/src/graphics/core/device.h +++ b/src/graphics/core/device.h @@ -99,7 +99,6 @@ enum TransformType enum RenderState { RENDER_STATE_LIGHTING, - RENDER_STATE_TEXTURING, RENDER_STATE_BLENDING, RENDER_STATE_FOG, RENDER_STATE_DEPTH_TEST, @@ -305,6 +304,9 @@ public: //! 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; + //! Sets the texture factor to the given color value virtual void SetTextureFactor(const Color &color) = 0; //! Returns the current texture factor diff --git a/src/graphics/core/texture.h b/src/graphics/core/texture.h index e9117e2..3ebbee5 100644 --- a/src/graphics/core/texture.h +++ b/src/graphics/core/texture.h @@ -28,6 +28,7 @@ // Graphics module namespace namespace Gfx { + /** * \enum TexImgFormat * \brief Format of image data @@ -117,11 +118,12 @@ enum TexMixArgument }; /** - \struct TextureCreateParams - \brief Parameters for texture creation - - These params define how particular texture is created and later displayed. - They must be specified at texture creation time and cannot be changed later. */ + * \struct TextureCreateParams + * \brief Parameters for texture creation + * + * These params define how particular texture is created and later displayed. + * They must be specified at texture creation time and cannot be changed later. + */ struct TextureCreateParams { //! Whether to generate mipmaps @@ -149,11 +151,12 @@ struct TextureCreateParams }; /** - \struct TextureStageParams - \brief Parameters for a texture unit - - These params define the behavior of texturing units (stages). - They can be changed freely and are feature of graphics engine, not any particular texture. */ + * \struct TextureStageParams + * \brief Parameters for a texture unit + * + * These params define the behavior of texturing units (stages). + * They can be changed freely and are features of graphics engine, not any particular texture. + */ struct TextureStageParams { //! Mixing operation done on color values @@ -193,11 +196,12 @@ struct TextureStageParams }; /** - \struct Texture - \brief Info about a texture - - Identifies (through id) a texture created in graphics engine. - Also contains some additional data. */ + * \struct Texture + * \brief Info about a texture + * + * Identifies (through id) a texture created in graphics engine. + * Also contains some additional data. + */ struct Texture { //! ID of the texture in graphics engine; 0 = invalid texture diff --git a/src/graphics/core/vertex.h b/src/graphics/core/vertex.h index e2c35c3..2ee6be4 100644 --- a/src/graphics/core/vertex.h +++ b/src/graphics/core/vertex.h @@ -33,6 +33,7 @@ // Graphics module namespace namespace Gfx { + /** * \struct Vertex * \brief Vertex of a primitive @@ -43,17 +44,23 @@ namespace Gfx { * - vertex coordinates (x,y,z) as Math::Vector, * - normal coordinates (nx,ny,nz) as Math::Vector * - texture coordinates (u,v) as Math::Point. + * + * Additional padding is provided to align to even multiplies of 4 floats for faster access. */ struct Vertex { Math::Vector coord; + float pad1; Math::Vector normal; + float pad2; Math::Point texCoord; + float pad3, pad4; explicit Vertex(Math::Vector aCoord = Math::Vector(), Math::Vector aNormal = Math::Vector(), Math::Point aTexCoord = Math::Point()) - : coord(aCoord), normal(aNormal), texCoord(aTexCoord) {} + : coord(aCoord), pad1(0.0f), normal(aNormal), + pad2(0.0f),texCoord(aTexCoord), pad3(0.0f), pad4(0.0f) {} //! Returns a string "(c: [...], n: [...], tc: [...])" @@ -74,16 +81,18 @@ struct Vertex * It contains: * - vertex coordinates (x,y,z) as Math::Vector, * - RGBA color as Color + * + * Additional padding is provided to align to even multiplies of 4 floats for faster access. */ struct VertexCol { Math::Vector coord; + float pad; Color color; explicit VertexCol(Math::Vector aCoord = Math::Vector(), - Color aColor = Color(), - Math::Point aTexCoord = Math::Point()) - : coord(aCoord), color(aColor) {} + Color aColor = Color()) + : coord(aCoord), pad(0.0f), color(aColor) {} //! Returns a string "(c: [...], col: [...])" inline std::string ToString() const @@ -102,11 +111,15 @@ struct VertexCol * * In addition to fields from Vector, it contains * secondary texture coordinates (u2, v2) as Math::Point + * + * Additional padding is provided to align to even multiplies of 4 floats for faster access. */ struct VertexTex2 { Math::Vector coord; + float pad1; Math::Vector normal; + float pad2; Math::Point texCoord; Math::Point texCoord2; @@ -114,7 +127,8 @@ struct VertexTex2 Math::Vector aNormal = Math::Vector(), Math::Point aTexCoord = Math::Point(), Math::Point aTexCoord2 = Math::Point()) - : coord(aCoord), normal(aNormal), texCoord(aTexCoord), texCoord2(aTexCoord2) {} + : coord(aCoord), pad1(0.0f), normal(aNormal), pad2(0.0f), + texCoord(aTexCoord), texCoord2(aTexCoord2) {} //! Sets the fields from Vertex with texCoord2 = (0,0) void FromVertex(const Vertex &v) |