diff --git a/src/graphics/core/device.h b/src/graphics/core/device.h index c5b990d1..ca7fa15f 100644 --- a/src/graphics/core/device.h +++ b/src/graphics/core/device.h @@ -54,55 +54,38 @@ namespace Gfx struct DeviceConfig { //! Screen size - Math::IntPoint size; + Math::IntPoint size = Math::IntPoint(800, 600); //! Bits per pixel - int bpp; + int bpp = 32; //! Full screen - bool fullScreen; + bool fullScreen = false; //! Resizeable window - bool resizeable; + bool resizeable = true; //! Double buffering - bool doubleBuf; + bool doubleBuf = true; //! No window frame (also set with full screen) - bool noFrame; + bool noFrame = false; //! Size of red channel in bits - int redSize; + int redSize = 8; //! Size of green channel in bits - int greenSize; + int greenSize = 8; //! Size of blue channel in bits - int blueSize; + int blueSize = 8; //! Size of alpha channel in bits - int alphaSize; + int alphaSize = 8; //! Color depth in bits - int depthSize; + int depthSize = 24; //! Stencil depth in bits - int stencilSize; + int stencilSize = 8; //! Force hardware acceleration (video mode set will fail on lack of hw accel) - bool hardwareAccel; - - //! Constructor calls LoadDefault() - DeviceConfig() { LoadDefault(); } + bool hardwareAccel = true; //! Loads the default values - inline void LoadDefault() + void LoadDefault() { - size = Math::IntPoint(800, 600); - bpp = 32; - fullScreen = false; - resizeable = true; - doubleBuf = true; - noFrame = false; - - hardwareAccel = true; - - redSize = 8; - blueSize = 8; - greenSize = 8; - alphaSize = 8; - depthSize = 24; - stencilSize = 8; + *this = DeviceConfig(); } }; diff --git a/src/graphics/core/framebuffer.h b/src/graphics/core/framebuffer.h index c5197ef2..d3e550ae 100644 --- a/src/graphics/core/framebuffer.h +++ b/src/graphics/core/framebuffer.h @@ -34,34 +34,22 @@ namespace Gfx struct FramebufferParams { //! Requested width of buffers - int width; + int width = 1024; //! Requested height of buffers - int height; + int height = 1024; //! Requested depth buffer - int depth; + int depth = 16; //! Requested number of samples for multisampling - int samples; + int samples = 1; //! true requests color texture - bool colorTexture; + bool colorTexture = false; //! true requests depth texture - bool depthTexture; - - - //! Initializes - FramebufferParams() - { - LoadDefault(); - } + bool depthTexture = false; //! Loads default values void LoadDefault() { - width = 1024; - height = 1024; - depth = 16; - samples = 1; - colorTexture = false; - depthTexture = false; + *this = FramebufferParams(); } }; diff --git a/src/graphics/core/light.h b/src/graphics/core/light.h index e2938af7..5aa731dc 100644 --- a/src/graphics/core/light.h +++ b/src/graphics/core/light.h @@ -54,48 +54,32 @@ enum LightType struct Light { //! Type of light source - LightType type; + LightType type = LIGHT_POINT; //! Color of ambient light - Color ambient; + Color ambient = Color(0.4f, 0.4f, 0.4f); //! Color of diffuse light - Color diffuse; + Color diffuse = Color(0.8f, 0.8f, 0.8f); //! Color of specular light - Color specular; + Color specular = Color(1.0f, 1.0f, 1.0f); //! Position in world space (for point & spot lights) - Math::Vector position; + Math::Vector position = Math::Vector(0.0f, 0.0f, 0.0f); //! Direction in world space (for directional & spot lights) - Math::Vector direction; + Math::Vector direction = Math::Vector(0.0f, 0.0f, 1.0f); //! Constant attenuation factor - float attenuation0; + float attenuation0 = 1.0f; //! Linear attenuation factor - float attenuation1; + float attenuation1 = 0.0f; //! Quadratic attenuation factor - float attenuation2; + float attenuation2 = 0.0f; //! Angle of spotlight cone (0-PI/2 radians) - float spotAngle; - + float spotAngle = Math::PI/2.0f; //! Intensity of spotlight (0 = uniform; 128 = most intense) - float spotIntensity; - - //! Constructor; calls LoadDefault() - Light() - { - LoadDefault(); - } + float spotIntensity = 0.0f; //! Loads default values void LoadDefault() { - type = LIGHT_POINT; - 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; - attenuation1 = attenuation2 = 0.0f; - spotAngle = Math::PI/2.0f; - spotIntensity = 0.0f; + *this = Light(); } }; diff --git a/src/graphics/core/texture.h b/src/graphics/core/texture.h index 34f95741..6ef9cf15 100644 --- a/src/graphics/core/texture.h +++ b/src/graphics/core/texture.h @@ -155,26 +155,18 @@ enum TexMixArgument struct TextureCreateParams { //! Whether to generate mipmaps - bool mipmap; + bool mipmap = false; //! Format of source image data - TexImgFormat format; + TexImgFormat format = TEX_IMG_RGB; //! General texture filtering mode - TexFilter filter; + TexFilter filter = TEX_FILTER_NEAREST; //! Pad the image to nearest power of 2 dimensions - bool padToNearestPowerOfTwo; - - //! Constructor; calls LoadDefault() - TextureCreateParams() - { LoadDefault(); } + bool padToNearestPowerOfTwo = false; //! Loads the default values - inline void LoadDefault() + void LoadDefault() { - format = TEX_IMG_RGB; - mipmap = false; - padToNearestPowerOfTwo = false; - - filter = TEX_FILTER_NEAREST; + *this = TextureCreateParams(); } }; @@ -188,40 +180,28 @@ struct TextureCreateParams struct TextureStageParams { //! Mixing operation done on color values - TexMixOperation colorOperation; + TexMixOperation colorOperation = TEX_MIX_OPER_DEFAULT; //! 1st argument of color operations - TexMixArgument colorArg1; + TexMixArgument colorArg1 = TEX_MIX_ARG_COMPUTED_COLOR; //! 2nd argument of color operations - TexMixArgument colorArg2; + TexMixArgument colorArg2 = TEX_MIX_ARG_TEXTURE; //! Mixing operation done on alpha values - TexMixOperation alphaOperation; + TexMixOperation alphaOperation = TEX_MIX_OPER_DEFAULT; //! 1st argument of alpha operations - TexMixArgument alphaArg1; + TexMixArgument alphaArg1 = TEX_MIX_ARG_COMPUTED_COLOR; //! 2nd argument of alpha operations - TexMixArgument alphaArg2; + TexMixArgument alphaArg2 = TEX_MIX_ARG_TEXTURE; //! Wrap mode for 1st tex coord - TexWrapMode wrapS; + TexWrapMode wrapS = TEX_WRAP_REPEAT; //! Wrap mode for 2nd tex coord - TexWrapMode wrapT; + TexWrapMode wrapT = TEX_WRAP_REPEAT; //! Constant color factor (for TEX_MIX_ARG_FACTOR) Color factor; - //! Constructor; calls LoadDefault() - TextureStageParams() - { LoadDefault(); } - //! Loads the default values - inline void LoadDefault() + void LoadDefault() { - colorOperation = TEX_MIX_OPER_DEFAULT; - colorArg1 = TEX_MIX_ARG_COMPUTED_COLOR; - colorArg2 = TEX_MIX_ARG_TEXTURE; - - alphaOperation = TEX_MIX_OPER_DEFAULT; - alphaArg1 = TEX_MIX_ARG_COMPUTED_COLOR; - alphaArg2 = TEX_MIX_ARG_TEXTURE; - - wrapS = wrapT = TEX_WRAP_REPEAT; + *this = TextureStageParams(); } }; @@ -255,22 +235,14 @@ struct TextureGenerationParams { struct Coord { - TexGenMode mode; - float plane[4]; + TexGenMode mode = TEX_GEN_NONE; + float plane[4] = {}; }; Coord coords[4]; - TextureGenerationParams() + void LoadDefault() { - LoadDefault(); - } - - inline void LoadDefault() - { - for (int i = 0; i < 4; i++) - { - coords[i].mode = TEX_GEN_NONE; - } + *this = TextureGenerationParams(); } }; @@ -284,19 +256,13 @@ struct TextureGenerationParams struct Texture { //! ID of the texture in graphics engine; 0 = invalid texture - unsigned int id; + unsigned int id = 0; //! Size of texture Math::IntPoint size; //! Original size of texture (as loaded from image) Math::IntPoint originalSize; //! Whether the texture has alpha channel - bool alpha; - - Texture() - { - id = 0; - alpha = false; - } + bool alpha = false; //! Returns whether the texture is valid (ID != 0) bool Valid() const @@ -311,7 +277,7 @@ struct Texture } //! Comparator for use in texture maps and sets - inline bool operator<(const Texture &other) const + bool operator<(const Texture &other) const { // Invalid textures are always "less than" every other texture @@ -328,7 +294,7 @@ struct Texture } //! Comparator - inline bool operator==(const Texture &other) const + bool operator==(const Texture &other) const { if (Valid() != other.Valid()) return false; diff --git a/src/graphics/model/model_io_structs.h b/src/graphics/model/model_io_structs.h index 0091f4ac..a5366e69 100644 --- a/src/graphics/model/model_io_structs.h +++ b/src/graphics/model/model_io_structs.h @@ -23,8 +23,6 @@ #include "graphics/model/model_triangle.h" -#include - namespace Gfx { @@ -166,18 +164,13 @@ struct ModelTriangleV3 : ModelTriangle {}; struct OldModelHeader { //! Revision number - int revision; + int revision = 0; //! Version number - int version; + int version = 0; //! Total number of triangles - int totalTriangles; + int totalTriangles = 0; //! Reserved area - int reserved[10]; - - OldModelHeader() - { - memset(this, 0, sizeof(*this)); - } + int reserved[10] = {0}; }; @@ -189,20 +182,15 @@ struct OldModelHeader */ struct OldModelTriangleV1 { - char used; - char selected; + char used = 0; + char selected = 0; Vertex p1; Vertex p2; Vertex p3; Material material; - char texName[20]; - float min; - float max; - - OldModelTriangleV1() - { - memset(this, 0, sizeof(*this)); - } + char texName[20] = {0}; + float min = 0; + float max = 0; }; /** @@ -213,25 +201,20 @@ struct OldModelTriangleV1 */ struct OldModelTriangleV2 { - char used; - char selected; + char used = 0; + char selected = 0; Vertex p1; Vertex p2; Vertex p3; Material material; - char texName[20]; - float min; - float max; - long state; - short reserved1; - short reserved2; - short reserved3; - short reserved4; - - OldModelTriangleV2() - { - memset(this, 0, sizeof(*this)); - } + char texName[20] = {0}; + float min = 0.0f; + float max = 0.0f; + long state = 0; + short reserved1 = 0; + short reserved2 = 0; + short reserved3 = 0; + short reserved4 = 0; }; /** @@ -242,25 +225,20 @@ struct OldModelTriangleV2 */ struct OldModelTriangleV3 { - char used; - char selected; + char used = 0; + char selected = 0; VertexTex2 p1; VertexTex2 p2; VertexTex2 p3; Material material; - char texName[20]; - float min; - float max; - long state; - short texNum2; - short reserved2; - short reserved3; - short reserved4; - - OldModelTriangleV3() - { - memset(this, 0, sizeof(*this)); - } + char texName[20] = {0}; + float min = 0.0f; + float max = 0.0f; + long state = 0; + short texNum2 = 0; + short reserved2 = 0; + short reserved3 = 0; + short reserved4 = 0; }; } // namespace Gfx