namespace Msp {
namespace GL {
-Animation::Animation():
- armature(0),
- looping(false)
-{ }
-
Animation::~Animation()
{
for(TimedKeyFrame &k: keyframes)
};
private:
- const Armature *armature;
+ const Armature *armature = 0;
std::vector<TimedKeyFrame> keyframes;
std::vector<Event> events;
- bool looping;
+ bool looping = false;
std::vector<UniformInfo> uniforms;
std::vector<Curve *> curves;
- unsigned uniform_curve_offset;
+ unsigned uniform_curve_offset = 0;
public:
- Animation();
~Animation();
void set_armature(const Armature &);
class AnimationEventObserver
{
protected:
- AnimationEventObserver() { }
+ AnimationEventObserver() = default;
public:
- virtual ~AnimationEventObserver() { }
+ virtual ~AnimationEventObserver() = default;
virtual void animation_event(Placeable *, const std::string &, const Variant &) { }
};
namespace Msp {
namespace GL {
-// Avoid synthesizing RefPtr c'tor and d'tor in files including keyframe.h
-KeyFrame::KeyFrame()
-{ }
-
-KeyFrame::~KeyFrame()
-{ }
-
void KeyFrame::set_transform(const Transform &t)
{
transform = t;
private:
Transform transform;
UniformMap uniforms;
- const Pose *pose;
+ const Pose *pose = 0;
public:
- KeyFrame();
- ~KeyFrame();
-
void set_transform(const Transform &);
void set_matrix(const Matrix &);
void set_uniform(const std::string &, const AnimatedUniform &);
namespace Msp {
namespace GL {
-Pose::Pose():
- armature(0)
-{ }
-
-Pose::Pose(const Armature &a):
- armature(0)
+Pose::Pose(const Armature &a)
{
set_armature(a);
}
void rotation(float, float, float, float);
};
- const Armature *armature;
+ const Armature *armature = 0;
std::vector<Link> links;
public:
- Pose();
+ Pose() = default;
Pose(const Armature &);
void set_armature(const Armature &);
namespace Msp {
namespace GL {
-Transform::Transform():
- position(0.0f, 0.0f, 0.0f),
- euler(Angle::zero(), Angle::zero(), Angle::zero()),
- scale(1.0f, 1.0f, 1.0f),
- mask(NONE)
-{ }
-
Transform Transform::from_matrix(const Matrix &matrix)
{
Transform trn;
private:
Vector3 position;
AngleVector3 euler;
- Vector3 scale;
- ComponentMask mask;
+ Vector3 scale = { 1.0f, 1.0f, 1.0f };
+ ComponentMask mask = NONE;
public:
- Transform();
-
static Transform from_matrix(const Matrix &);
void set_position(const Vector3 &);
friend class OpenGLVertexSetup;
protected:
- unsigned id;
+ unsigned id = 0;
static OpenGLBuffer *scratch_binding;
namespace Msp {
namespace GL {
-OpenGLCommands::OpenGLCommands():
- pipeline_state(0)
-{ }
-
void OpenGLCommands::use_pipeline(const PipelineState *ps)
{
pipeline_state = ps;
class OpenGLCommands
{
protected:
- const PipelineState *pipeline_state;
+ const PipelineState *pipeline_state = 0;
- OpenGLCommands();
+ OpenGLCommands() = default;
void use_pipeline(const PipelineState *);
void clear(const ClearValue *);
namespace Msp {
namespace GL {
-OpenGLProgram::OpenGLProgram():
- linked(false)
+OpenGLProgram::OpenGLProgram()
{
static Require _req(ARB_shader_objects);
id = glCreateProgram();
- fill(stage_ids, stage_ids+MAX_STAGES, 0);
}
OpenGLProgram::~OpenGLProgram()
UniformCall(unsigned l, unsigned s, FuncPtr f): location(l), size(s), func(f) { }
};
- unsigned id;
- unsigned stage_ids[MAX_STAGES];
- bool linked;
+ unsigned id = 0;
+ unsigned stage_ids[MAX_STAGES] = { };
+ bool linked = false;
std::vector<UniformCall> uniform_calls;
std::string debug_name;
friend class OpenGLPipelineState;
protected:
- unsigned id;
+ unsigned id = 0;
OpenGLSampler();
OpenGLTexture *OpenGLTexture::scratch_binding = 0;
OpenGLTexture::OpenGLTexture(unsigned t):
- id(0),
target(t)
{
static bool alignment_init = false;
friend class OpenGLPipelineState;
protected:
- unsigned id;
+ unsigned id = 0;
unsigned target;
std::string debug_name;
namespace Msp {
namespace GL {
-Font::Font():
- native_size(1),
- ascent(1),
- descent(0),
- cap_height(1),
- x_height(0.5)
-{ }
-
-// Avoid synthesizing ~RefPtr in files including font.h
-Font::~Font()
-{ }
-
void Font::set_texture(const Texture2D &t)
{
texture = &t;
}
-Font::Glyph::Glyph():
- code(0),
- x1(0),
- y1(0),
- x2(1),
- y2(1),
- w(1),
- h(1),
- off_x(0),
- off_y(0),
- advance(1)
-{ }
-
-
Font::Loader::Loader(Font &f, Collection &c):
DataFile::CollectionObjectLoader<Font>(f, &c)
{
void texcoords(float, float, float, float);
};
- unsigned code;
- float x1, y1;
- float x2, y2;
- float w, h;
- float off_x, off_y;
- float advance;
-
- Glyph();
+ unsigned code = 0;
+ float x1 = 0.0f;
+ float y1 = 0.0f;
+ float x2 = 1.0f;
+ float y2 = 1.0f;
+ float w = 1.0f;
+ float h = 1.0f;
+ float off_x = 0.0f;
+ float off_y = 0.0f;
+ float advance = 1.0f;
};
private:
typedef std::map<CodePair, float> KerningMap;
typedef std::map<CodePair, unsigned> LigatureMap;
- const Texture2D *texture;
- float native_size;
- float ascent;
- float descent;
- float cap_height;
- float x_height;
+ const Texture2D *texture = 0;
+ float native_size = 1.0f;
+ float ascent = 1.0f;
+ float descent = 0.0f;
+ float cap_height = 1.0f;
+ float x_height = 0.5f;
GlyphMap glyphs;
KerningMap kerning;
LigatureMap ligatures;
public:
- Font();
- ~Font();
-
void set_texture(const Texture2D &);
const Texture2D &get_texture() const;
namespace Msp {
namespace GL {
-GeometryBuilder::GeometryBuilder():
- generate_tan(false),
- tex_fit(STRETCH)
-{ }
-
GeometryBuilder &GeometryBuilder::tangents(bool t)
{
generate_tan = t;
};
protected:
- bool generate_tan;
- TextureFit tex_fit;
+ bool generate_tan = false;
+ TextureFit tex_fit = STRETCH;
- GeometryBuilder();
+ GeometryBuilder() = default;
public:
DEPRECATED GeometryBuilder &tbn(bool t = true) { return tangents(t); }
namespace Msp {
namespace GL {
-SequenceTemplate::SequenceTemplate():
- hdr(false),
- alpha(false),
- required_multisample(0),
- max_multisample(0),
- clear_enabled(false),
- clear_depth(1.0f),
- clear_stencil(0)
-{ }
-
SequenceTemplate::~SequenceTemplate()
{
for(const PostProcessor &p: postprocessors)
}
-SequenceTemplate::Step::~Step()
-{ }
-
-
SequenceTemplate::PostProcessor::PostProcessor(GL::PostProcessor::Template *ppt):
postprocessor_template(ppt)
{ }
};
std::string tag;
- const Lighting *lighting;
+ const Lighting *lighting = 0;
DepthTest depth_test;
StencilTest stencil_test;
Blend blend;
std::string slot_name;
- Renderable *default_renderable;
-
- ~Step();
+ Renderable *default_renderable = 0;
};
struct PostProcessor
typedef TypeRegistry<PostProcLoader::AddPostProc, PostProcLoader &> PostProcessorRegistry;
- bool hdr;
- bool alpha;
- unsigned required_multisample;
- unsigned max_multisample;
+ bool hdr = false;
+ bool alpha = false;
+ unsigned required_multisample = 0;
+ unsigned max_multisample = 0;
std::vector<Step> steps;
std::vector<PostProcessor> postprocessors;
- bool clear_enabled;
+ bool clear_enabled = false;
std::vector<Color> clear_colors;
- float clear_depth;
- int clear_stencil;
+ float clear_depth = 1.0f;
+ int clear_stencil = 0;
public:
- SequenceTemplate();
~SequenceTemplate();
bool get_hdr() const { return hdr; }
public:
VertexBuilder() { normal(0, 0, 1); }
- virtual ~VertexBuilder() { }
+ virtual ~VertexBuilder() = default;
void set_matrix(const Matrix &m)
{ mtx = m; }
namespace Msp {
namespace GL {
-Version::Version()
-{
- major = 0;
- minor = 0;
-}
-
Version::Version(unsigned short a, unsigned short i)
{
major = a;
struct Version
{
- unsigned short major;
- unsigned short minor;
+ unsigned short major = 0;
+ unsigned short minor = 0;
- Version();
+ Version() = default;
Version(unsigned short, unsigned short);
Version(const std::string &);
namespace Msp {
namespace GL {
-Blend::Blend():
- enabled(false),
- equation(ADD),
- src_factor(ONE),
- dst_factor(ZERO),
- constant(0.0f, 0.0f, 0.0f, 0.0f),
- write_mask(WRITE_ALL)
-{ }
-
Blend::Blend(BlendFactor sf, BlendFactor df):
enabled(true),
- equation(ADD),
src_factor(sf),
- dst_factor(df),
- constant(0.0f, 0.0f, 0.0f, 0.0f),
- write_mask(WRITE_ALL)
+ dst_factor(df)
{ }
Blend::Blend(BlendEquation e, BlendFactor sf, BlendFactor df):
enabled(true),
equation(e),
src_factor(sf),
- dst_factor(df),
- constant(0.0f, 0.0f, 0.0f, 0.0f),
- write_mask(WRITE_ALL)
+ dst_factor(df)
{ }
void factors(BlendFactor, BlendFactor);
};
- bool enabled;
- BlendEquation equation;
- BlendFactor src_factor;
- BlendFactor dst_factor;
- Color constant;
- ColorWriteMask write_mask;
-
- Blend();
+ bool enabled = false;
+ BlendEquation equation = ADD;
+ BlendFactor src_factor = ONE;
+ BlendFactor dst_factor = ZERO;
+ Color constant = { 0.0f, 0.0f, 0.0f, 0.0f };
+ ColorWriteMask write_mask = WRITE_ALL;
+
+ Blend() = default;
Blend(BlendFactor, BlendFactor);
Blend(BlendEquation, BlendFactor, BlendFactor);
};
namespace Msp {
namespace GL {
-Buffer::Buffer():
- size(0)
-{ }
-
void Buffer::storage(unsigned sz)
{
if(size>0)
friend BufferBackend;
private:
- unsigned size;
+ unsigned size = 0;
public:
- Buffer();
-
/** Defines the storage size of the buffer. Must be called before data can
be uploaded. Storage cannot be changed once set. */
void storage(unsigned);
namespace Msp {
namespace GL {
-Bufferable::Bufferable():
- buffer(0),
- offset(0),
- next_in_buffer(0),
- prev_in_buffer(0),
- location_dirty(false),
- dirty(false)
-{ }
-
Bufferable::~Bufferable()
{
unlink_from_buffer();
};
private:
- Buffer *buffer;
- unsigned offset;
- Bufferable *next_in_buffer;
- Bufferable *prev_in_buffer;
- mutable bool location_dirty;
+ Buffer *buffer = 0;
+ unsigned offset = 0;
+ Bufferable *next_in_buffer = 0;
+ Bufferable *prev_in_buffer = 0;
+ mutable bool location_dirty = false;
protected:
- mutable bool dirty;
+ mutable bool dirty = false;
- Bufferable();
+ Bufferable() = default;
public:
virtual ~Bufferable();
namespace Msp {
namespace GL {
-ClipPlane::ClipPlane():
- eq(0, 0, 0, 1),
- generation(0)
-{ }
-
ClipPlane::ClipPlane(const Vector4 &e):
- eq(e),
- generation(0)
+ eq(e)
{ }
ClipPlane::ClipPlane(const Vector3 &p, const Vector3 &d):
- eq(compose(d, -dot(p, d))),
- generation(0)
+ eq(compose(d, -dot(p, d)))
{ }
void ClipPlane::set_equation(const Vector4 &e)
class ClipPlane
{
private:
- Vector4 eq;
- unsigned generation;
+ Vector4 eq = { 0.0f, 0.0f, 0.0f, 1.0f };
+ unsigned generation = 0;
public:
- ClipPlane();
+ ClipPlane() = default;
ClipPlane(const Vector4 &);
ClipPlane(const Vector3 &, const Vector3 &);
struct Color
{
- float r, g, b, a;
-
- Color(): r(1), g(1), b(1), a(1) { }
- Color(float v): r(v), g(v), b(v), a(1) { }
- Color(float r_, float g_, float b_): r(r_), g(g_), b(b_), a(1) { }
+ float r = 1.0f;
+ float g = 1.0f;
+ float b = 1.0f;
+ float a = 1.0f;
+
+ Color() = default;
+ Color(float v): r(v), g(v), b(v) { }
+ Color(float r_, float g_, float b_): r(r_), g(g_), b(b_) { }
Color(float r_, float g_, float b_, float a_): r(r_), g(g_), b(b_), a(a_) { }
Color operator*(float f) const { return Color(r*f, g*f, b*f, a); }
Color operator+(const Color &c) const { return Color(r+c.r, g+c.g, b+c.b, 1-(1-a)*(1-c.a)); }
namespace Msp {
namespace GL {
-DepthTest::DepthTest():
- enabled(false),
- compare(LESS),
- write(true)
-{ }
-
DepthTest::DepthTest(Predicate c, bool w):
enabled(true),
compare(c),
void compare(Predicate);
};
- bool enabled;
- Predicate compare;
- bool write;
+ bool enabled = false;
+ Predicate compare = LESS;
+ bool write = true;
- DepthTest();
+ DepthTest() = default;
DepthTest(Predicate, bool = true);
};
}
-Framebuffer::Attachment::Attachment():
- tex(0),
- level(0),
- layer(0)
-{ }
-
void Framebuffer::Attachment::set(Texture &t, unsigned l, int z)
{
tex = &t;
private:
struct Attachment
{
- Texture *tex;
- unsigned level;
- int layer;
+ Texture *tex = 0;
+ unsigned level = 0;
+ int layer = 0;
- Attachment();
void set(Texture &, unsigned, int);
void clear();
};
namespace Msp {
namespace GL {
-FrameFormat::FrameFormat():
- count(0),
- samples(1)
-{ }
-
FrameFormat::FrameFormat(FrameAttachment fa):
count(1),
samples(1)
private:
enum { MAX_ATTACHMENTS = 7 };
- std::uint8_t count;
- std::uint8_t samples;
+ std::uint8_t count = 0;
+ std::uint8_t samples = 0;
FrameAttachment attachments[MAX_ATTACHMENTS];
public:
- FrameFormat();
+ FrameFormat() = default;
FrameFormat(FrameAttachment);
FrameFormat operator,(FrameAttachment) const;
namespace Msp {
namespace GL {
-Mesh::Mesh():
- vbuf(0),
- ibuf(0),
- dirty(0),
- disallow_rendering(false),
- face_winding(NON_MANIFOLD)
-{ }
-
Mesh::Mesh(const VertexFormat &f):
Mesh()
{
VertexArray vertices;
std::vector<Batch> batches;
- Buffer *vbuf;
- Buffer *ibuf;
+ Buffer *vbuf = 0;
+ Buffer *ibuf = 0;
VertexSetup vtx_setup;
- mutable unsigned short dirty;
- bool disallow_rendering;
- FaceWinding face_winding;
+ mutable unsigned short dirty = 0;
+ bool disallow_rendering = false;
+ FaceWinding face_winding = NON_MANIFOLD;
std::string debug_name;
public:
- Mesh();
+ Mesh() = default;
Mesh(const VertexFormat &);
~Mesh();
}
-SpirVModule::EntryPoint::EntryPoint():
- stage(VERTEX)
-{ }
-
-
-SpirVModule::StructMember::StructMember():
- type(VOID),
- struct_type(0),
- offset(0),
- array_size(0),
- array_size_spec(0),
- array_stride(0),
- matrix_stride(0)
-{ }
-
-
-SpirVModule::Variable::Variable():
- type(VOID),
- struct_type(0),
- location(-1),
- descriptor_set(-1),
- binding(-1)
-{ }
-
bool SpirVModule::Variable::operator==(const Variable &other) const
{
if(storage!=UNIFORM_CONSTANT && storage!=UNIFORM)
}
-SpirVModule::TypeInfo::TypeInfo():
- type(VOID),
- struct_type(0),
- array_size_spec(0),
- array_size(0),
- array_stride(0),
- storage(static_cast<StorageClass>(-1))
-{ }
-
-
uint32_t SpirVModule::Reflection::get_opcode(uint32_t op)
{
return op&0xFFFF;
};
protected:
- Module() { }
+ Module() = default;
public:
- virtual ~Module() { }
+ virtual ~Module() = default;
virtual Format get_format() const = 0;
struct EntryPoint
{
std::string name;
- Stage stage;
+ Stage stage = VERTEX;
std::vector<const Variable *> globals;
-
- EntryPoint();
};
struct StructMember
{
std::string name;
- DataType type;
- const Structure *struct_type;
- unsigned offset;
- unsigned array_size;
- const Constant *array_size_spec;
- unsigned array_stride;
- unsigned matrix_stride;
-
- StructMember();
+ DataType type = VOID;
+ const Structure *struct_type = 0;
+ unsigned offset = 0;
+ unsigned array_size = 0;
+ const Constant *array_size_spec = 0;
+ unsigned array_stride = 0;
+ unsigned matrix_stride = 0;
};
struct Structure
{
std::string name;
std::vector<StructMember> members;
- unsigned size;
+ unsigned size = 0;
};
struct Variable
{
std::string name;
- StorageClass storage;
- DataType type;
- const Structure *struct_type;
- const Constant *array_size_spec;
- unsigned array_size;
- int location;
- int descriptor_set;
- int binding;
-
- Variable();
+ StorageClass storage = static_cast<StorageClass>(-1);
+ DataType type = VOID;
+ const Structure *struct_type = 0;
+ const Constant *array_size_spec = 0;
+ unsigned array_size = 0;
+ int location = -1;
+ int descriptor_set = -1;
+ int binding = -1;
bool operator==(const Variable &) const;
};
struct Constant
{
std::string name;
- int constant_id;
- DataType type;
+ int constant_id = -1;
+ DataType type = VOID;
union
{
- int i_value;
+ int i_value = 0;
float f_value;
};
};
private:
struct TypeInfo
{
- DataType type;
- const Structure *struct_type;
- const Constant *array_size_spec;
- unsigned array_size;
- unsigned array_stride;
- StorageClass storage;
-
- TypeInfo();
+ DataType type = VOID;
+ const Structure *struct_type = 0;
+ const Constant *array_size_spec = 0;
+ unsigned array_size = 0;
+ unsigned array_stride = 0;
+ StorageClass storage = static_cast<StorageClass>(-1);
};
struct Reflection
std::vector<Constant> spec_constants;
public:
- SpirVModule() { }
+ SpirVModule() = default;
SpirVModule(const SpirVModule &);
SpirVModule &operator=(const SpirVModule &);
private:
namespace Msp {
namespace GL {
-PipelineState::PipelineState():
- framebuffer(0),
- viewport(0),
- scissor(0),
- shprog(0),
- vertex_setup(0),
- front_face(COUNTERCLOCKWISE),
- face_cull(NO_CULL),
- enabled_clip_planes(0),
- depth_test(0),
- stencil_test(0),
- blend(0),
- changes(0)
-{ }
-
template<typename T>
void PipelineState::set(T &target, T value, unsigned flag)
{
SCISSOR = 2048
};
- const Framebuffer *framebuffer;
- const Rect *viewport;
- const Rect *scissor;
- const Program *shprog;
- const VertexSetup *vertex_setup;
- FaceWinding front_face;
- CullMode face_cull;
- unsigned enabled_clip_planes;
+ const Framebuffer *framebuffer = 0;
+ const Rect *viewport = 0;
+ const Rect *scissor = 0;
+ const Program *shprog = 0;
+ const VertexSetup *vertex_setup = 0;
+ FaceWinding front_face = COUNTERCLOCKWISE;
+ CullMode face_cull = NO_CULL;
+ unsigned enabled_clip_planes = 0;
std::vector<BoundTexture> textures;
std::vector<BoundUniformBlock> uniform_blocks;
- const DepthTest *depth_test;
- const StencilTest *stencil_test;
- const Blend *blend;
- mutable unsigned changes;
+ const DepthTest *depth_test = 0;
+ const StencilTest *stencil_test = 0;
+ const Blend *blend = 0;
+ mutable unsigned changes = 0;
-public:
- PipelineState();
-
-private:
template<typename T>
void set(T &, T, unsigned);
public:
public:
/// Constructs an empty Program with no shader stages attached.
- Program() { }
+ Program() = default;
/// Constructs a Program from a Module, with specialization constants.
Program(const Module &, const std::map<std::string, int> & = std::map<std::string, int>());
struct Rect
{
- int left;
- int bottom;
- unsigned width;
- unsigned height;
+ int left = 0;
+ int bottom = 0;
+ unsigned width = 0;
+ unsigned height = 0;
- Rect(): left(0), bottom(0), width(0), height(0) { }
+ Rect() = default;
Rect(int l, int b, unsigned w, unsigned h): left(l), bottom(b), width(w), height(h) { }
};
}
-ReflectData::UniformInfo::UniformInfo():
- block(0),
- location(-1),
- array_size(0),
- array_stride(0),
- matrix_stride(0),
- type(VOID),
- binding(-1)
-{ }
-
-
-ReflectData::UniformBlockInfo::UniformBlockInfo():
- data_size(0),
- bind_point(-1),
- layout_hash(0)
-{ }
-
void ReflectData::UniformBlockInfo::sort_uniforms()
{
sort(uniforms, [](const UniformInfo *u1, const UniformInfo *u2){ return u1->location<u2->location; });
layout_hash = hash32(layout_descriptor);
}
-
-ReflectData::AttributeInfo::AttributeInfo():
- location(-1),
- array_size(0),
- type(VOID)
-{ }
-
} // namespace GL
} // namespace Msp
struct UniformInfo
{
std::string name;
- const UniformBlockInfo *block;
+ const UniformBlockInfo *block = 0;
union
{
- int location;
+ int location = -1;
unsigned offset;
};
- unsigned array_size;
- unsigned array_stride;
- unsigned matrix_stride;
- DataType type;
+ unsigned array_size = 0;
+ unsigned array_stride = 0;
+ unsigned matrix_stride = 0;
+ DataType type = VOID;
Tag tag;
- int binding;
-
- UniformInfo();
+ int binding = -1;
};
struct UniformBlockInfo
{
std::string name;
- unsigned data_size;
- int bind_point;
+ unsigned data_size = 0;
+ int bind_point = -1;
std::vector<const UniformInfo *> uniforms;
- LayoutHash layout_hash;
-
- UniformBlockInfo();
+ LayoutHash layout_hash = 0;
void sort_uniforms();
void update_layout_hash();
struct AttributeInfo
{
std::string name;
- unsigned location;
- unsigned array_size;
- DataType type;
-
- AttributeInfo();
+ unsigned location = -1;
+ unsigned array_size = 0;
+ DataType type = VOID;
};
std::vector<UniformBlockInfo> uniform_blocks;
namespace Msp {
namespace GL {
-Sampler::Sampler():
- min_filter(NEAREST_MIPMAP_LINEAR),
- mag_filter(LINEAR),
- max_anisotropy(1.0f),
- wrap_s(REPEAT),
- wrap_t(REPEAT),
- wrap_r(REPEAT),
- border_color(Color(0.0f, 0.0f, 0.0f, 0.0f)),
- compare(false),
- cmp_func(LEQUAL),
- dirty_params(0)
-{ }
-
void Sampler::update() const
{
SamplerBackend::update(dirty_params);
COMPARE = 128
};
- TextureFilter min_filter;
- TextureFilter mag_filter;
- float max_anisotropy;
- TextureWrap wrap_s;
- TextureWrap wrap_t;
- TextureWrap wrap_r;
- Color border_color;
- bool compare;
- Predicate cmp_func;
- mutable int dirty_params;
+ TextureFilter min_filter = NEAREST_MIPMAP_LINEAR;
+ TextureFilter mag_filter = LINEAR;
+ float max_anisotropy = 1.0f;
+ TextureWrap wrap_s = REPEAT;
+ TextureWrap wrap_t = REPEAT;
+ TextureWrap wrap_r = REPEAT;
+ Color border_color = { 0.0f, 0.0f, 0.0f, 0.0f };
+ bool compare = false;
+ Predicate cmp_func = LEQUAL;
+ mutable int dirty_params = 0;
-public:
- Sampler();
-
-private:
void update() const;
public:
namespace Msp {
namespace GL {
-StencilTest::StencilTest():
- enabled(false),
- compare(ALWAYS),
- stencil_fail_op(KEEP),
- depth_fail_op(KEEP),
- depth_pass_op(KEEP),
- reference(0)
-{ }
-
-
StencilTest::Loader::Loader(StencilTest &st):
ObjectLoader<StencilTest>(st)
{
void actions(StencilOp, StencilOp, StencilOp);
};
- bool enabled;
- Predicate compare;
- StencilOp stencil_fail_op;
- StencilOp depth_fail_op;
- StencilOp depth_pass_op;
- unsigned reference;
-
- StencilTest();
+ bool enabled = false;
+ Predicate compare = ALWAYS;
+ StencilOp stencil_fail_op = KEEP;
+ StencilOp depth_fail_op = KEEP;
+ StencilOp depth_pass_op = KEEP;
+ unsigned reference = 0;
};
void operator>>(const LexicalConverter &, StencilOp &);
*/
struct Tag
{
- unsigned id;
+ unsigned id = 0;
- Tag(): id(0) { }
+ Tag() = default;
Tag(const char *);
Tag(const std::string &s);
namespace Msp {
namespace GL {
-Texture1D::Texture1D():
- width(0)
-{ }
-
void Texture1D::storage(PixelFormat fmt, unsigned wd, unsigned lv)
{
if(width>0)
};
private:
- unsigned width;
- unsigned levels;
+ unsigned width = 0;
+ unsigned levels = 0;
public:
- Texture1D();
-
void storage(PixelFormat, unsigned, unsigned = 0);
void image(unsigned, const void *);
namespace Msp {
namespace GL {
-Texture2D::Texture2D():
- width(0),
- height(0)
-{ }
-
Texture2D::~Texture2D()
{
set_manager(0);
};
private:
- unsigned width;
- unsigned height;
- unsigned levels;
+ unsigned width = 0;
+ unsigned height = 0;
+ unsigned levels = 0;
public:
- Texture2D();
virtual ~Texture2D();
/** Defines storage structure for the texture. If lv is zero, the number
namespace Msp {
namespace GL {
-Texture2DMultisample::Texture2DMultisample():
- width(0),
- height(0)
-{ }
-
void Texture2DMultisample::storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned sm)
{
if(width>0)
friend Texture2DMultisampleBackend;
private:
- unsigned width;
- unsigned height;
- unsigned samples;
+ unsigned width = 0;
+ unsigned height = 0;
+ unsigned samples = 0;
public:
- Texture2DMultisample();
-
void storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned sm);
virtual void image(const Graphics::Image &, unsigned = 0);
namespace GL {
Texture3D::Texture3D(unsigned t):
- Texture3DBackend(t),
- width(0),
- height(0),
- depth(0)
-{ }
-
-Texture3D::Texture3D():
- width(0),
- height(0),
- depth(0)
+ Texture3DBackend(t)
{ }
void Texture3D::storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned dp, unsigned lv)
};
protected:
- unsigned width;
- unsigned height;
- unsigned depth;
- unsigned levels;
+ unsigned width = 0;
+ unsigned height = 0;
+ unsigned depth = 0;
+ unsigned levels = 0;
Texture3D(unsigned);
public:
- Texture3D();
+ Texture3D() = default;
/** Defines storage structure for the texture. If lv is zero, the number
of mipmap levels is automatically determined from storage dimensions.
1, 3
};
-TextureCube::TextureCube():
- size(0)
-{ }
-
void TextureCube::storage(PixelFormat fmt, unsigned sz, unsigned lv)
{
if(size>0)
};
private:
- unsigned size;
- unsigned levels;
+ unsigned size = 0;
+ unsigned levels = 0;
static const Vector3 directions[6];
static const unsigned orientations[12];
public:
- TextureCube();
-
/** Defines storage structure for the texture. If lv is zero, the number
of mipmap levels is automatically determined from storage dimensions.
namespace Msp {
namespace GL {
-VertexArray::VertexArray():
- stride(0)
-{ }
-
VertexArray::VertexArray(const VertexFormat &f)
{
set_format(f);
private:
VertexFormat format;
std::vector<char> data;
- unsigned stride;
+ unsigned stride = 0;
VertexArray(const VertexArray &);
VertexArray &operator=(const VertexArray &);
public:
- VertexArray();
+ VertexArray() = default;
/// Construct a VertexArray and set its format.
VertexArray(const VertexFormat &);
namespace Msp {
namespace GL {
-VertexFormat::VertexFormat():
- count(0)
-{ }
-
VertexFormat::VertexFormat(VertexAttribute a):
count(1)
{
private:
enum { MAX_ATTRIBUTES = 15 };
- std::uint8_t count;
+ std::uint8_t count = 0;
VertexAttribute attributes[MAX_ATTRIBUTES];
public:
- VertexFormat();
+ VertexFormat() = default;
VertexFormat(VertexAttribute);
VertexFormat operator,(VertexAttribute) const;
namespace Msp {
namespace GL {
-VertexSetup::VertexSetup():
- dirty(0),
- vertex_array(0),
- inst_array(0),
- index_buffer(0),
- index_type(UNSIGNED_SHORT)
-{ }
-
void VertexSetup::set_format(const VertexFormat &vfmt)
{
if(!verify_format(vfmt))
INDEX_BUFFER = 4
};
- mutable unsigned dirty;
- const VertexArray *vertex_array;
+ mutable unsigned dirty = 0;
+ const VertexArray *vertex_array = 0;
VertexFormat vertex_format;
- const VertexArray *inst_array;
+ const VertexArray *inst_array = 0;
VertexFormat inst_format;
- const Buffer *index_buffer;
- DataType index_type;
+ const Buffer *index_buffer = 0;
+ DataType index_type = UNSIGNED_SHORT;
public:
- VertexSetup();
-
void set_format(const VertexFormat &);
void set_format_instanced(const VertexFormat &, const VertexFormat &);
}
-AmbientOcclusion::Template::Template():
- n_samples(16),
- occlusion_radius(0.5f),
- darkness(1.0f),
- edge_depth_threshold(0.1f)
-{ }
-
AmbientOcclusion *AmbientOcclusion::Template::create(unsigned width, unsigned height) const
{
RefPtr<AmbientOcclusion> ao = new AmbientOcclusion(width/size_divisor, height/size_divisor);
Loader(Template &);
};
- unsigned n_samples;
- float occlusion_radius;
- float darkness;
- float edge_depth_threshold;
-
- Template();
+ unsigned n_samples = 16;
+ float occlusion_radius = 0.5f;
+ float darkness = 1.0f;
+ float edge_depth_threshold = 0.1f;
virtual AmbientOcclusion *create(unsigned, unsigned) const;
};
}
-Bloom::Template::Template():
- radius(2.0f),
- strength(0.2f)
-{ }
-
Bloom *Bloom::Template::create(unsigned width, unsigned height) const
{
RefPtr<Bloom> bloom = new Bloom(width/size_divisor, height/size_divisor);
Loader(Template &);
};
- float radius;
- float strength;
-
- Template();
+ float radius = 2.0f;
+ float strength = 0.2f;
virtual Bloom *create(unsigned, unsigned) const;
};
}
-ColorCurve::Template::Template():
- exposure_adjust(0.0f),
- brightness_response(0.4f),
- gamma(1.0f),
- srgb(false)
-{ }
-
ColorCurve *ColorCurve::Template::create(unsigned, unsigned) const
{
RefPtr<ColorCurve> colorcurve = new ColorCurve();
void srgb();
};
- float exposure_adjust;
- float brightness_response;
- float gamma;
- bool srgb;
-
- Template();
+ float exposure_adjust = 0.0f;
+ float brightness_response = 0.4f;
+ float gamma = 1.0f;
+ bool srgb = false;
virtual ColorCurve *create(unsigned, unsigned) const;
};
EnvironmentMap::EnvironmentMap(unsigned s, PixelFormat f, unsigned l, Renderable &r, Renderable &e):
Effect(r),
+ size(s),
environment(e),
irradiance_shprog(Resources::get_global().get<Program>("_envmap_irradiance.glsl.shader")),
specular_shprog(Resources::get_global().get<Program>("_envmap_specular.glsl.shader")),
if(!l || (1U<<(l-1))>=s)
throw invalid_argument("EnvironmentMap::EnvironmentMap");
- size = s;
- rendered = false;
- update_interval = 1;
- update_delay = 0;
-
env_tex.storage(f, size, l);
depth_buf.storage(DEPTH_COMPONENT32F, size, size, 1);
for(unsigned i=0; i<6; ++i)
const Sampler &sampler;
const Sampler &mip_sampler;
ProgramData shdata;
- bool rendered;
- unsigned update_interval;
- unsigned update_delay;
+ bool rendered = false;
+ unsigned update_interval = 1;
+ unsigned update_delay = 0;
public:
EnvironmentMap(unsigned size, PixelFormat, Renderable &rend, Renderable &env);
namespace Msp {
namespace GL {
-PostProcessor::Template::Template():
- size_divisor(1)
-{ }
-
-
PostProcessor::Template::Loader::Loader(Template &t):
DataFile::ObjectLoader<Template>(t)
{
Loader(Template &);
};
- unsigned size_divisor;
+ unsigned size_divisor = 1;
- Template();
- virtual ~Template() { }
+ virtual ~Template() = default;
virtual PostProcessor *create(unsigned, unsigned) const = 0;
};
height(h),
lighting(l),
shadow_caster(c),
- sampler(Resources::get_global().get<Sampler>("_linear_clamp_shadow.samp")),
- radius(1),
- depth_bias(4),
- darkness(1.0f),
- rendered(false)
+ sampler(Resources::get_global().get<Sampler>("_linear_clamp_shadow.samp"))
{
depth_buf.storage(DEPTH_COMPONENT32F, width, height, 1);
fbo.set_format((DEPTH_ATTACHMENT,DEPTH_COMPONENT32F));
Texture2D depth_buf;
const Sampler &sampler;
Vector3 target;
- float radius;
- float depth_bias;
- float darkness;
+ float radius = 1.0f;
+ float depth_bias = 4.0f;
+ float darkness = 1.0f;
ProgramData shdata;
- bool rendered;
+ bool rendered = false;
std::string debug_name;
ShadowMap(unsigned, unsigned, Renderable &, const Lighting *, Renderable &);
namespace SL {
Compiler::Compiler():
- features(DeviceInfo::get_global().glsl_features),
- module(0),
- compiled(false),
- specialized(false)
+ features(DeviceInfo::get_global().glsl_features)
{ }
Compiler::Compiler(const Features &f):
- features(f),
- module(0),
- compiled(false),
- specialized(false)
+ features(f)
{ }
Compiler::~Compiler()
};
Features features;
- Module *module;
+ Module *module = 0;
std::vector<std::string> imported_names;
- bool compiled;
- bool specialized;
+ bool compiled = false;
+ bool specialized = false;
std::map<std::string, int> spec_values;
public:
namespace GL {
namespace SL {
-Features::Features():
- target_api(OPENGL),
- arb_enhanced_layouts(false),
- arb_explicit_attrib_location(false),
- arb_explicit_uniform_location(false),
- arb_gpu_shader5(false),
- arb_separate_shader_objects(false),
- arb_uniform_buffer_object(false),
- ext_gpu_shader4(false),
- ext_texture_array(false),
- constant_id_range(0x80000000U),
- uniform_binding_range(84),
- texture_binding_range(96)
-{ }
-
Features Features::from_version(const Version &ver)
{
Features features;
struct Features
{
- GraphicsApi target_api;
+ GraphicsApi target_api = OPENGL;
Version glsl_version;
- bool arb_enhanced_layouts;
- bool arb_explicit_attrib_location;
- bool arb_explicit_uniform_location;
- bool arb_gpu_shader5;
- bool arb_separate_shader_objects;
- bool arb_uniform_buffer_object;
- bool ext_gpu_shader4;
- bool ext_texture_array;
- unsigned constant_id_range;
- unsigned uniform_binding_range;
- unsigned texture_binding_range;
-
- Features();
+ bool arb_enhanced_layouts = false;
+ bool arb_explicit_attrib_location = false;
+ bool arb_explicit_uniform_location = false;
+ bool arb_gpu_shader5 = false;
+ bool arb_separate_shader_objects = false;
+ bool arb_uniform_buffer_object = false;
+ bool ext_gpu_shader4 = false;
+ bool ext_texture_array = false;
+ unsigned constant_id_range = 0x80000000U;
+ unsigned uniform_binding_range = 84;
+ unsigned texture_binding_range = 96;
static Features from_version(const Version &);
static Features latest();
namespace GL {
namespace SL {
-StructOrganizer::StructOrganizer():
- offset(-1)
-{ }
-
void StructOrganizer::visit(StructDeclaration &strct)
{
SetForScope<int> set_offset(offset, 0);
}
-PrecisionConverter::PrecisionConverter():
- stage(0)
-{ }
-
void PrecisionConverter::apply(Stage &s)
{
stage = &s;
}
-LegacyConverter::LegacyConverter():
- frag_out(0)
-{ }
-
void LegacyConverter::apply(Stage &s, const Features &feat)
{
stage = &s;
class StructOrganizer: private TraversingVisitor
{
private:
- int offset;
+ int offset = -1;
public:
- StructOrganizer();
-
void apply(Stage &s) { s.content.visit(*this); }
private:
class PrecisionConverter: private TraversingVisitor
{
private:
- Stage *stage;
+ Stage *stage = 0;
std::set<std::string> have_default;
NodeList<Statement>::iterator insert_point;
std::set<Node *> nodes_to_remove;
public:
- PrecisionConverter();
-
void apply(Stage &);
private:
class LegacyConverter: private TraversingVisitor
{
private:
- Stage *stage;
+ Stage *stage = 0;
Features features;
- VariableDeclaration *frag_out;
+ VariableDeclaration *frag_out = 0;
NodeList<Statement>::iterator uniform_insert_point;
std::set<Node *> nodes_to_remove;
public:
- LegacyConverter();
-
virtual void apply(Stage &, const Features &);
private:
}
-InterfaceGenerator::InterfaceGenerator():
- stage(0),
- function_scope(false),
- copy_block(false),
- iface_target_block(0)
-{ }
-
string InterfaceGenerator::get_out_prefix(Stage::Type type)
{
if(type==Stage::VERTEX)
class InterfaceGenerator: private TraversingVisitor
{
private:
- Stage *stage;
+ Stage *stage = 0;
std::string in_prefix;
std::string out_prefix;
- bool function_scope;
- bool copy_block;
+ bool function_scope = false;
+ bool copy_block = false;
std::vector<VariableDeclaration *> declared_inputs;
- Block *iface_target_block;
+ Block *iface_target_block = 0;
NodeList<Statement>::iterator iface_insert_point;
NodeList<Statement>::iterator assignment_insert_point;
std::set<Node *> nodes_to_remove;
public:
- InterfaceGenerator();
-
void apply(Stage &);
private:
{ }
-Diagnostic::Diagnostic():
- severity(INFO),
- source(0),
- line(0),
- provoking_source(0),
- provoking_line(0)
-{ }
-
Diagnostic::Diagnostic(Severity v, int s, unsigned l, const string &m):
severity(v),
source(s),
ERR
};
- Severity severity;
- int source;
- unsigned line;
- int provoking_source;
- unsigned provoking_line;
+ Severity severity = INFO;
+ int source = 0;
+ unsigned line = 0;
+ int provoking_source = 0;
+ unsigned provoking_line = 0;
std::string message;
- Diagnostic();
+ Diagnostic() = default;
Diagnostic(Severity, int, unsigned, const std::string &);
};
namespace GL {
namespace SL {
-ConstantSpecializer::ConstantSpecializer():
- values(0)
-{ }
-
void ConstantSpecializer::apply(Stage &stage, const map<string, int> &v)
{
values = &v;
}
-InlineableFunctionLocator::InlineableFunctionLocator():
- current_function(0),
- return_count(0)
-{ }
-
void InlineableFunctionLocator::visit(FunctionCall &call)
{
FunctionDeclaration *def = call.declaration;
}
-InlineContentInjector::InlineContentInjector():
- source_func(0),
- pass(REFERENCED)
-{ }
-
string InlineContentInjector::apply(Stage &stage, FunctionDeclaration &target_func, Block &tgt_blk, const NodeList<Statement>::iterator &ins_pt, FunctionCall &call)
{
source_func = call.declaration->definition;
}
-FunctionInliner::FunctionInliner():
- current_function(0),
- r_any_inlined(false),
- r_inlined_here(false)
-{ }
-
bool FunctionInliner::apply(Stage &s)
{
stage = &s;
}
-ExpressionInliner::ExpressionInliner():
- r_ref_info(0),
- r_trivial(false),
- access_read(true),
- access_write(false),
- iteration_init(false),
- iteration_body(0),
- r_oper(0)
-{ }
-
bool ExpressionInliner::apply(Stage &s)
{
s.content.visit(*this);
}
-UnreachableCodeRemover::UnreachableCodeRemover():
- reachable(true)
-{ }
-
bool UnreachableCodeRemover::apply(Stage &stage)
{
stage.content.visit(*this);
}
-UnusedVariableRemover::UnusedVariableRemover():
- stage(0),
- interface_block(0),
- r_assignment(0),
- assignment_target(false),
- r_side_effects(false),
- in_struct(false),
- composite_reference(false),
- in_loop(0)
-{ }
-
bool UnusedVariableRemover::apply(Stage &s)
{
stage = &s;
class ConstantSpecializer: private TraversingVisitor
{
private:
- const std::map<std::string, int> *values;
+ const std::map<std::string, int> *values = 0;
public:
- ConstantSpecializer();
-
void apply(Stage &, const std::map<std::string, int> &);
private:
private:
std::map<FunctionDeclaration *, unsigned> refcounts;
std::set<FunctionDeclaration *> inlineable;
- FunctionDeclaration *current_function;
- unsigned return_count;
+ FunctionDeclaration *current_function = 0;
+ unsigned return_count = 0;
public:
- InlineableFunctionLocator();
-
std::set<FunctionDeclaration *> apply(Stage &s) { s.content.visit(*this); return inlineable; }
private:
RENAME
};
- FunctionDeclaration *source_func;
+ FunctionDeclaration *source_func = 0;
Block staging_block;
- Pass pass;
+ Pass pass = REFERENCED;
RefPtr<Statement> r_inlined_statement;
std::set<Node *> dependencies;
std::set<std::string> referenced_names;
std::string r_result_name;
public:
- InlineContentInjector();
-
std::string apply(Stage &, FunctionDeclaration &, Block &, const NodeList<Statement>::iterator &, FunctionCall &);
private:
class FunctionInliner: private TraversingVisitor
{
private:
- Stage *stage;
+ Stage *stage = 0;
std::set<FunctionDeclaration *> inlineable;
- FunctionDeclaration *current_function;
+ FunctionDeclaration *current_function = 0;
NodeList<Statement>::iterator insert_point;
RefPtr<Expression> r_inline_result;
- bool r_any_inlined;
- bool r_inlined_here;
+ bool r_any_inlined = false;
+ bool r_inlined_here = false;
public:
- FunctionInliner();
-
bool apply(Stage &);
private:
private:
struct ExpressionUse
{
- RefPtr<Expression> *reference;
- Block *ref_scope;
- bool blocked;
-
- ExpressionUse(): reference(0), ref_scope(0), blocked(false) { }
+ RefPtr<Expression> *reference = 0;
+ Block *ref_scope = 0;
+ bool blocked = false;
};
struct ExpressionInfo
{
Assignment::Target target;
RefPtr<Expression> expression;
- Block *assign_scope;
+ Block *assign_scope = 0;
std::vector<ExpressionUse> uses;
- bool trivial;
-
- ExpressionInfo(): expression(0), assign_scope(0), trivial(false) { }
+ bool trivial = false;
};
std::list<ExpressionInfo> expressions;
std::map<Assignment::Target, ExpressionInfo *> assignments;
- ExpressionInfo *r_ref_info;
- bool r_trivial;
- bool access_read;
- bool access_write;
- bool iteration_init;
- Block *iteration_body;
- const Operator *r_oper;
+ ExpressionInfo *r_ref_info = 0;
+ bool r_trivial = false;
+ bool access_read = true;
+ bool access_write = false;
+ bool iteration_init = false;
+ Block *iteration_body = 0;
+ const Operator *r_oper = 0;
public:
- ExpressionInliner();
-
bool apply(Stage &);
private:
class ConstantFolder: private TraversingVisitor
{
private:
- VariableDeclaration *iteration_var;
+ VariableDeclaration *iteration_var = 0;
Variant iter_init_value;
Variant r_constant_value;
- bool iteration_init;
- bool r_constant;
- bool r_literal;
- bool r_uses_iter_var;
- bool r_any_folded;
+ bool iteration_init = false;
+ bool r_constant = false;
+ bool r_literal = false;
+ bool r_uses_iter_var = false;
+ bool r_any_folded = false;
public:
bool apply(Stage &s) { s.content.visit(*this); return r_any_folded; }
NodeList<Statement>::iterator insert_point;
std::set<Node *> nodes_to_remove;
RefPtr<Expression> r_ternary_result;
- bool r_external_side_effects;
+ bool r_external_side_effects = false;
public:
void apply(Stage &);
class UnreachableCodeRemover: private TraversingVisitor
{
private:
- bool reachable;
+ bool reachable = true;
std::set<Node *> unreachable_nodes;
public:
- UnreachableCodeRemover();
-
virtual bool apply(Stage &);
private:
private:
struct AssignmentInfo
{
- Node *node;
+ Node *node = 0;
Assignment::Target target;
std::vector<Node *> used_by;
- unsigned in_loop;
-
- AssignmentInfo(): node(0) { }
+ unsigned in_loop = 0;
};
struct VariableInfo
{
- InterfaceBlock *interface_block;
+ InterfaceBlock *interface_block = 0;
std::vector<AssignmentInfo *> assignments;
- bool initialized;
- bool output;
- bool referenced;
-
- VariableInfo(): interface_block(0), initialized(false), output(false), referenced(false) { }
+ bool initialized = false;
+ bool output = false;
+ bool referenced = false;
};
typedef std::map<Statement *, VariableInfo> BlockVariableMap;
- Stage *stage;
+ Stage *stage = 0;
BlockVariableMap variables;
std::list<AssignmentInfo> assignments;
- InterfaceBlock *interface_block;
- Assignment *r_assignment;
- bool assignment_target;
- bool r_side_effects;
- bool in_struct;
- bool composite_reference;
- unsigned in_loop;
+ InterfaceBlock *interface_block = 0;
+ Assignment *r_assignment = 0;
+ bool assignment_target = false;
+ bool r_side_effects = false;
+ bool in_struct = false;
+ bool composite_reference = false;
+ unsigned in_loop = 0;
std::vector<Node *> loop_ext_refs;
Assignment::Target r_reference;
std::set<Node *> unused_nodes;
public:
- UnusedVariableRemover();
-
bool apply(Stage &);
private:
namespace GL {
namespace SL {
-Formatter::Formatter():
- stage(0),
- source_index(0),
- source_line(1),
- indent(0),
- parameter_list(false),
- omit_builtin(false),
- r_empty_name(false)
-{ }
-
string Formatter::apply(Stage &s)
{
stage = &s;
class Formatter: private TraversingVisitor
{
private:
- Stage *stage;
+ Stage *stage = 0;
std::string formatted;
- unsigned source_index;
- unsigned source_line;
- unsigned indent;
- bool parameter_list;
- bool omit_builtin;
- bool r_empty_name;
+ unsigned source_index = 0;
+ unsigned source_line = 1;
+ unsigned indent = 0;
+ bool parameter_list = false;
+ bool omit_builtin = false;
+ bool r_empty_name = false;
public:
- Formatter();
-
std::string apply(Stage &);
private:
unsigned TypeComparer::next_tag = 1;
-TypeComparer::TypeComparer():
- first(0),
- second(0),
- first_tag(0),
- r_result(false)
-{ }
-
void TypeComparer::compare(Node &node1, Node &node2)
{
if(&node1==&node2)
}
-LocationCounter::LocationCounter():
- r_count(0)
-{ }
-
void LocationCounter::visit(BasicTypeDeclaration &basic)
{
r_count = basic.kind==BasicTypeDeclaration::MATRIX ? basic.size>>16 : 1;
class TypeComparer: private NodeVisitor
{
private:
- Node *first;
- Node *second;
- unsigned first_tag;
- bool r_result;
+ Node *first = 0;
+ Node *second = 0;
+ unsigned first_tag = 0;
+ bool r_result = false;
static unsigned next_tag;
public:
- TypeComparer();
-
bool apply(TypeDeclaration &t1, TypeDeclaration &t2) { compare(t1, t2); return r_result; }
private:
class LocationCounter: private NodeVisitor
{
private:
- unsigned r_count;
+ unsigned r_count = 0;
public:
- LocationCounter();
-
unsigned apply(VariableDeclaration &v) { v.visit(*this); return r_count; }
private:
Result(unsigned s, unsigned a): size(s), alignment(a), stride(s+a-1-(s+a-1)%a) { }
};
private:
- unsigned r_size;
- unsigned r_alignment;
- int r_offset;
+ unsigned r_size = 0;
+ unsigned r_alignment = 1;
+ int r_offset = -1;
public:
Result apply(VariableDeclaration &v) { v.visit(*this); return Result(r_size, r_alignment); }
}
-TypeResolver::TypeResolver():
- stage(0),
- iface_block(0),
- r_any_resolved(false)
-{ }
-
bool TypeResolver::apply(Stage &s)
{
stage = &s;
}
-VariableResolver::VariableResolver():
- stage(0),
- r_any_resolved(false),
- record_target(false),
- r_self_referencing(false)
-{ }
-
bool VariableResolver::apply(Stage &s)
{
stage = &s;
}
-ExpressionResolver::ExpressionResolver():
- stage(0),
- r_any_resolved(false)
-{ }
-
bool ExpressionResolver::apply(Stage &s)
{
stage = &s;
class BlockHierarchyResolver: private TraversingVisitor
{
private:
- bool r_any_resolved;
+ bool r_any_resolved = false;
public:
- BlockHierarchyResolver(): r_any_resolved(false) { }
-
bool apply(Stage &s) { r_any_resolved = false; s.content.visit(*this); return r_any_resolved; }
private:
class TypeResolver: private TraversingVisitor
{
private:
- Stage *stage;
+ Stage *stage = 0;
std::map<TypeDeclaration *, TypeDeclaration *> alias_map;
std::map<TypeDeclaration *, TypeDeclaration *> array_types;
NodeList<Statement>::iterator type_insert_point;
- InterfaceBlock *iface_block;
- bool r_any_resolved;
+ InterfaceBlock *iface_block = 0;
+ bool r_any_resolved = false;
public:
- TypeResolver();
-
bool apply(Stage &);
private:
class VariableResolver: private TraversingVisitor
{
private:
- Stage *stage;
+ Stage *stage = 0;
RefPtr<Expression> r_replacement_expr;
- bool r_any_resolved;
- bool record_target;
- bool r_self_referencing;
+ bool r_any_resolved = false;
+ bool record_target = false;
+ bool r_self_referencing = false;
Assignment::Target r_assignment_target;
std::vector<VariableDeclaration *> redeclared_builtins;
std::set<Node *> nodes_to_remove;
public:
- VariableResolver();
-
bool apply(Stage &);
private:
struct ArgumentInfo
{
- BasicTypeDeclaration *type;
- unsigned component_count;
-
- ArgumentInfo(): type(0), component_count(0) { }
+ BasicTypeDeclaration *type = 0;
+ unsigned component_count = 0;
};
- Stage *stage;
+ Stage *stage = 0;
std::vector<BasicTypeDeclaration *> basic_types;
NodeList<Statement>::iterator insert_point;
- bool r_any_resolved;
+ bool r_any_resolved = false;
public:
- ExpressionResolver();
-
bool apply(Stage &);
private:
class FunctionResolver: private TraversingVisitor
{
private:
- Stage *stage;
+ Stage *stage = 0;
std::map<std::string, std::vector<FunctionDeclaration *> > declarations;
- bool r_any_resolved;
+ bool r_any_resolved = false;
public:
bool apply(Stage &);
namespace GL {
namespace SL {
-SourceMap::SourceMap():
- base_index(0)
-{ }
-
void SourceMap::set_name(unsigned i, const string &n)
{
if(source_names.empty())
class SourceMap
{
private:
- unsigned base_index;
+ unsigned base_index = 0;
std::vector<std::string> source_names;
public:
- SourceMap();
-
void set_name(unsigned, const std::string &);
unsigned get_count() const { return base_index+source_names.size(); }
const std::string &get_name(unsigned) const;
};
SpirVGenerator::SpirVGenerator():
- stage(0),
- current_function(0),
- writer(content),
- next_id(1),
- r_expression_result_id(0),
- constant_expression(false),
- spec_constant(false),
- reachable(false),
- composite_access(false),
- r_composite_base_id(0),
- r_composite_base(0),
- assignment_source_id(0),
- loop_merge_block_id(0),
- loop_continue_target_id(0)
+ writer(content)
{ }
void SpirVGenerator::apply(Module &module)
bool operator<(const ConstantKey &) const;
};
- Stage *stage;
- FunctionDeclaration *current_function;
+ Stage *stage = 0;
+ FunctionDeclaration *current_function = 0;
std::vector<const InterfaceLayout *> interface_layouts;
SpirVContent content;
SpirVWriter writer;
std::map<std::string, Id> function_type_ids;
std::map<ConstantKey, Id> constant_ids;
std::map<const VariableDeclaration *, Id> variable_load_ids;
- Id next_id;
- Id r_expression_result_id;
- bool r_constant_result;
- bool constant_expression;
- bool spec_constant;
- bool reachable;
- bool composite_access;
- Id r_composite_base_id;
- Node *r_composite_base;
+ Id next_id = 1;
+ Id r_expression_result_id = 0;
+ bool r_constant_result = false;
+ bool constant_expression = false;
+ bool spec_constant = false;
+ bool reachable = false;
+ bool composite_access = false;
+ Id r_composite_base_id = 0;
+ Node *r_composite_base = 0;
std::vector<unsigned> r_composite_chain;
- Id assignment_source_id;
- Id loop_merge_block_id;
- Id loop_continue_target_id;
+ Id assignment_source_id = 0;
+ Id loop_merge_block_id = 0;
+ Id loop_continue_target_id = 0;
static const BuiltinFunctionInfo builtin_functions[];
}
-Block::Block():
- use_braces(false),
- parent(0)
-{ }
-
Block::Block(const Block &other):
Node(other),
body(other.body),
}
-Expression::Expression():
- oper(0),
- type(0),
- lvalue(false)
-{ }
-
-
void Literal::visit(NodeVisitor &visitor)
{
visitor.visit(*this);
}
-VariableReference::VariableReference():
- declaration(0)
-{ }
-
VariableReference::VariableReference(const VariableReference &other):
Expression(other),
- name(other.name),
- declaration(0)
+ name(other.name)
{ }
void VariableReference::visit(NodeVisitor &visitor)
}
-InterfaceBlockReference::InterfaceBlockReference():
- declaration(0)
-{ }
-
InterfaceBlockReference::InterfaceBlockReference(const InterfaceBlockReference &other):
Expression(other),
- name(other.name),
- declaration(0)
+ name(other.name)
{ }
void InterfaceBlockReference::visit(NodeVisitor &visitor)
}
-MemberAccess::MemberAccess():
- declaration(0),
- index(-1)
-{ }
-
MemberAccess::MemberAccess(const MemberAccess &other):
Expression(other),
left(other.left),
- member(other.member),
- declaration(0),
- index(-1)
+ member(other.member)
+ // Do not copy declaration
{ }
void MemberAccess::visit(NodeVisitor &visitor)
}
-Swizzle::Swizzle():
- count(0)
-{
- fill(components, components+4, 0);
-}
-
void Swizzle::visit(NodeVisitor &visitor)
{
visitor.visit(*this);
}
-Assignment::Assignment():
- self_referencing(false)
-{ }
-
Assignment::Assignment(const Assignment &other):
BinaryExpression(other),
self_referencing(other.self_referencing)
+ // Do not copy target
{ }
void Assignment::visit(NodeVisitor &visitor)
}
-Assignment::Target::Target(Statement *d):
- declaration(d),
- chain_len(0)
-{
- fill(chain, chain+7, 0);
-}
-
bool Assignment::Target::operator<(const Target &other) const
{
if(declaration!=other.declaration)
}
-FunctionCall::FunctionCall():
- constructor(false),
- declaration(0)
-{ }
-
FunctionCall::FunctionCall(const FunctionCall &other):
Expression(other),
name(other.name),
constructor(other.constructor),
- arguments(other.arguments),
- declaration(0)
+ arguments(other.arguments)
+ // Do not copy declaration
{ }
void FunctionCall::visit(NodeVisitor &visitor)
}
-BasicTypeDeclaration::BasicTypeDeclaration():
- kind(ALIAS),
- size(0),
- sign(true),
- base_type(0)
-{ }
-
BasicTypeDeclaration::BasicTypeDeclaration(const BasicTypeDeclaration &other):
TypeDeclaration(other),
kind(other.kind),
size(other.size),
sign(other.sign),
- base(other.base),
- base_type(0)
+ base(other.base)
+ // Do not copy base type
{ }
void BasicTypeDeclaration::visit(NodeVisitor &visitor)
}
-ImageTypeDeclaration::ImageTypeDeclaration():
- dimensions(TWO),
- array(false),
- sampled(true),
- shadow(false)
-{ }
-
void ImageTypeDeclaration::visit(NodeVisitor &visitor)
{
visitor.visit(*this);
}
-StructDeclaration::StructDeclaration():
- interface_block(0)
+StructDeclaration::StructDeclaration()
{
members.use_braces = true;
}
StructDeclaration::StructDeclaration(const StructDeclaration &other):
TypeDeclaration(other),
- members(other.members),
- interface_block(0)
+ members(other.members)
+ // Do not copy interface block
{ }
StructDeclaration::~StructDeclaration()
}
-VariableDeclaration::VariableDeclaration():
- constant(false),
- array(false),
- type_declaration(0),
- linked_declaration(0)
-{ }
-
VariableDeclaration::VariableDeclaration(const VariableDeclaration &other):
Statement(other),
layout(other.layout),
name(other.name),
array(other.array),
array_size(other.array_size),
- init_expression(other.init_expression),
- type_declaration(0),
- linked_declaration(0)
+ init_expression(other.init_expression)
+ // Do not copy type and linked declarations
{ }
VariableDeclaration::~VariableDeclaration()
}
-InterfaceBlock::InterfaceBlock():
- array(false),
- type_declaration(0),
- struct_declaration(0),
- linked_block(0)
-{ }
-
InterfaceBlock::InterfaceBlock(const InterfaceBlock &other):
Statement(other),
interface(other.interface),
block_name(other.block_name),
members(other.members),
instance_name(other.instance_name),
- array(other.array),
- type_declaration(0),
- struct_declaration(0),
- linked_block(0)
+ array(other.array)
+ // Do not copy pointers to other nodes
{ }
InterfaceBlock::~InterfaceBlock()
}
-FunctionDeclaration::FunctionDeclaration():
- virtua(false),
- overrd(false),
- definition(0),
- return_type_declaration(0)
-{ }
-
FunctionDeclaration::FunctionDeclaration(const FunctionDeclaration &other):
Statement(other),
return_type(other.return_type),
overrd(other.overrd),
body(other.body),
signature(other.signature),
- definition(other.definition==&other ? this : 0),
- return_type_declaration(0)
+ definition(other.definition==&other ? this : 0)
+ // Do not copy return type declaration
{ }
void FunctionDeclaration::visit(NodeVisitor &visitor)
struct Node
{
- int source;
- unsigned line;
+ int source = GENERATED_SOURCE;
+ unsigned line = 1;
- Node(): source(GENERATED_SOURCE), line(1) { }
- Node(const Node &n): source(n.source), line(n.line) { }
+ Node() = default;
+ Node(const Node &) = default;
private:
Node &operator=(const Node &);
public:
- virtual ~Node() { }
+ virtual ~Node() = default;
virtual Node *clone() const = 0;
virtual void visit(NodeVisitor &) = 0;
class NodePtr: public RefPtr<T>
{
public:
- NodePtr() { }
+ NodePtr() = default;
NodePtr(T *p): RefPtr<T>(p) { }
NodePtr(const NodePtr &p): RefPtr<T>(p ? p->clone() : 0) { }
- NodePtr &operator=(const NodePtr &p) { RefPtr<T>::operator=(p); return *this; }
+ NodePtr &operator=(const NodePtr &p) = default;
template<typename U>
NodePtr(const RefPtr<U> &p): RefPtr<T>(p) { }
class NodeContainer: public C
{
public:
- NodeContainer() { }
+ NodeContainer() = default;
NodeContainer(const NodeContainer &);
void push_back_nocopy(const typename C::value_type &v)
struct Block: Node
{
NodeList<Statement> body;
- bool use_braces;
+ bool use_braces = false;
std::map<std::string, VariableDeclaration *> variables;
- Block *parent;
+ Block *parent = 0;
- Block();
+ Block() = default;
Block(const Block &);
virtual Block *clone() const { return new Block(*this); }
struct Expression: Node
{
- const Operator *oper;
+ const Operator *oper = 0;
- TypeDeclaration *type;
- bool lvalue;
-
- Expression();
+ TypeDeclaration *type = 0;
+ bool lvalue = false;
virtual Expression *clone() const = 0;
};
{
std::string name;
- VariableDeclaration *declaration;
+ VariableDeclaration *declaration = 0;
- VariableReference();
+ VariableReference() = default;
VariableReference(const VariableReference &);
virtual VariableReference *clone() const { return new VariableReference(*this); }
{
std::string name;
- InterfaceBlock *declaration;
+ InterfaceBlock *declaration = 0;
- InterfaceBlockReference();
+ InterfaceBlockReference() = default;
InterfaceBlockReference(const InterfaceBlockReference &);
virtual InterfaceBlockReference *clone() const { return new InterfaceBlockReference(*this); }
NodePtr<Expression> left;
std::string member;
- VariableDeclaration *declaration;
- int index;
+ VariableDeclaration *declaration = 0;
+ int index = -1;
- MemberAccess();
+ MemberAccess() = default;
MemberAccess(const MemberAccess &);
virtual MemberAccess *clone() const { return new MemberAccess(*this); }
{
NodePtr<Expression> left;
std::string component_group;
- unsigned count;
- std::uint8_t components[4];
-
- Swizzle();
+ unsigned count = 0;
+ std::uint8_t components[4] = { 0, 0, 0, 0 };
virtual Swizzle *clone() const { return new Swizzle(*this); }
virtual void visit(NodeVisitor &);
ARRAY = 0xC0
};
- Statement *declaration;
- std::uint8_t chain_len;
- std::uint8_t chain[7];
+ Statement *declaration = 0;
+ std::uint8_t chain_len = 0;
+ std::uint8_t chain[7] = { };
- Target(Statement * = 0);
+ Target(Statement *d = 0): declaration(d) { }
bool operator<(const Target &) const;
};
- bool self_referencing;
+ bool self_referencing = false;
Target target;
- Assignment();
+ Assignment() = default;
Assignment(const Assignment &);
virtual Assignment *clone() const { return new Assignment(*this); }
struct FunctionCall: Expression
{
std::string name;
- bool constructor;
+ bool constructor = false;
NodeArray<Expression> arguments;
- FunctionDeclaration *declaration;
+ FunctionDeclaration *declaration = 0;
- FunctionCall();
+ FunctionCall() = default;
FunctionCall(const FunctionCall &);
virtual FunctionCall *clone() const { return new FunctionCall(*this); }
ARRAY
};
- Kind kind;
- unsigned size;
- bool sign;
+ Kind kind = ALIAS;
+ unsigned size = 0;
+ bool sign = true;
std::string base;
- TypeDeclaration *base_type;
+ TypeDeclaration *base_type = 0;
- BasicTypeDeclaration();
+ BasicTypeDeclaration() = default;
BasicTypeDeclaration(const BasicTypeDeclaration &);
virtual BasicTypeDeclaration *clone() const { return new BasicTypeDeclaration(*this); }
CUBE
};
- Dimensions dimensions;
- bool array;
- bool sampled;
- bool shadow;
+ Dimensions dimensions = TWO;
+ bool array = false;
+ bool sampled = true;
+ bool shadow = false;
std::string base;
- TypeDeclaration *base_type;
-
- ImageTypeDeclaration();
+ TypeDeclaration *base_type = 0;
virtual ImageTypeDeclaration *clone() const { return new ImageTypeDeclaration(*this); }
virtual void visit(NodeVisitor &);
{
Block members;
- InterfaceBlock *interface_block;
+ InterfaceBlock *interface_block = 0;
StructDeclaration();
StructDeclaration(const StructDeclaration &);
struct VariableDeclaration: Statement
{
NodePtr<Layout> layout;
- bool constant;
+ bool constant = false;
std::string sampling;
std::string interpolation;
std::string interface;
std::string precision;
std::string type;
std::string name;
- bool array;
+ bool array = false;
NodePtr<Expression> array_size;
NodePtr<Expression> init_expression;
- TypeDeclaration *type_declaration;
- VariableDeclaration *linked_declaration;
+ TypeDeclaration *type_declaration = 0;
+ VariableDeclaration *linked_declaration = 0;
- VariableDeclaration();
+ VariableDeclaration() = default;
VariableDeclaration(const VariableDeclaration &);
~VariableDeclaration();
std::string block_name;
NodePtr<Block> members;
std::string instance_name;
- bool array;
+ bool array = false;
/* An interface block's ultimate base type is always a struct. The
immediate type may be either that same struct or an array of it. */
- TypeDeclaration *type_declaration;
- StructDeclaration *struct_declaration;
- InterfaceBlock *linked_block;
+ TypeDeclaration *type_declaration = 0;
+ StructDeclaration *struct_declaration = 0;
+ InterfaceBlock *linked_block = 0;
- InterfaceBlock();
+ InterfaceBlock() = default;
InterfaceBlock(const InterfaceBlock &);
~InterfaceBlock();
std::string return_type;
std::string name;
NodeArray<VariableDeclaration> parameters;
- bool virtua;
- bool overrd;
+ bool virtua = false;
+ bool overrd = false;
Block body;
std::string signature;
- FunctionDeclaration *definition;
- TypeDeclaration *return_type_declaration;
+ FunctionDeclaration *definition = 0;
+ TypeDeclaration *return_type_declaration = 0;
- FunctionDeclaration();
+ FunctionDeclaration() = default;
FunctionDeclaration(const FunctionDeclaration &);
virtual FunctionDeclaration *clone() const { return new FunctionDeclaration(*this); }
namespace GL {
namespace SL {
-Tokenizer::Tokenizer():
- allow_preprocess(true),
- suppress_line_advance(false)
+Tokenizer::Tokenizer()
{
static string empty;
iter = empty.begin();
struct Location
{
std::string name;
- unsigned line;
+ unsigned line = 0;
- Location(): line(0) { }
+ Location() = default;
Location(const std::string &n, unsigned l): name(n), line(l) { }
};
std::string::const_iterator iter;
std::string::const_iterator source_end;
Location location;
- bool progress_mark;
- bool allow_preprocess;
- bool suppress_line_advance;
+ bool progress_mark = false;
+ bool allow_preprocess = true;
+ bool suppress_line_advance = false;
std::string last_token;
std::deque<std::string> next_tokens;
namespace GL {
namespace SL {
-Validator::Validator():
- stage(0),
- last_provoker(0)
-{ }
-
void Validator::diagnose(Node &node, Node &provoking_node, Diagnostic::Severity severity, const string &message)
{
Diagnostic diag;
}
-DeclarationValidator::DeclarationValidator():
- scope(GLOBAL),
- iface_layout(0),
- iface_block(0),
- variable(0)
-{ }
-
const char *DeclarationValidator::describe_variable(ScopeType scope)
{
switch(scope)
}
-IdentifierValidator::IdentifierValidator():
- anonymous_block(false)
-{ }
-
void IdentifierValidator::multiple_definition(const string &name, Statement &statement, Statement &previous)
{
error(statement, format("Multiple definition of %s", name));
}
-ExpressionValidator::ExpressionValidator():
- current_function(0),
- constant_expression(false)
-{ }
-
void ExpressionValidator::visit(VariableReference &var)
{
if(var.declaration && constant_expression && !var.declaration->constant)
}
-FlowControlValidator::FlowControlValidator():
- reachable(true)
-{ }
-
void FlowControlValidator::visit(Block &block)
{
for(const RefPtr<Statement> &s: block.body)
class Validator: protected TraversingVisitor
{
protected:
- Stage *stage;
- Node *last_provoker;
+ Stage *stage = 0;
+ Node *last_provoker = 0;
- Validator();
+ Validator() = default;
void diagnose(Node &, Node &, Diagnostic::Severity, const std::string &);
void diagnose(Node &n, Diagnostic::Severity s, const std::string &m) { diagnose(n, n, s, m); }
FUNCTION
};
- ScopeType scope;
- InterfaceLayout *iface_layout;
- InterfaceBlock *iface_block;
- VariableDeclaration *variable;
+ ScopeType scope = GLOBAL;
+ InterfaceLayout *iface_layout = 0;
+ InterfaceBlock *iface_block = 0;
+ VariableDeclaration *variable = 0;
public:
- DeclarationValidator();
-
void apply(Stage &s) { stage = &s; s.content.visit(*this); }
private:
std::map<Block *, BlockDeclarationMap> declarations;
std::map<std::string, InterfaceBlock *> interface_blocks;
std::map<std::string, FunctionDeclaration *> overloaded_functions;
- bool anonymous_block;
+ bool anonymous_block = false;
public:
- IdentifierValidator();
-
void apply(Stage &s) { stage = &s; s.content.visit(*this); }
private:
class ExpressionValidator: private Validator
{
private:
- FunctionDeclaration *current_function;
- bool constant_expression;
+ FunctionDeclaration *current_function = 0;
+ bool constant_expression = false;
public:
- ExpressionValidator();
-
void apply(Stage &s) { stage = &s; s.content.visit(*this); }
private:
class FlowControlValidator: private Validator
{
private:
- bool reachable;
+ bool reachable = true;
public:
- FlowControlValidator();
-
void apply(Stage &s) { stage = &s; s.content.visit(*this); }
private:
private:
struct Uniform
{
- Node *node;
- TypeDeclaration *type;
+ Node *node = 0;
+ TypeDeclaration *type = 0;
std::string name;
- int location;
- unsigned loc_count;
- int desc_set;
- int bind_point;
-
- Uniform(): node(0), type(0), location(-1), loc_count(1), desc_set(0), bind_point(-1) { }
+ int location = -1;
+ unsigned loc_count = 1;
+ int desc_set = 0;
+ int bind_point = -1;
};
std::list<Uniform> uniforms;
}
-NodeRemover::NodeRemover():
- stage(0),
- to_remove(0),
- recursive_remove(false)
-{ }
-
void NodeRemover::apply(Stage &s, const set<Node *> &tr)
{
stage = &s;
}
-NodeReorderer::NodeReorderer():
- reorder_before(0),
- to_reorder(0)
-{ }
-
void NodeReorderer::apply(Stage &stage, Node &before, const set<Node *> &tr)
{
reorder_before = &before;
class NodeVisitor
{
protected:
- NodeVisitor() { }
+ NodeVisitor() = default;
public:
- virtual ~NodeVisitor() { }
+ virtual ~NodeVisitor() = default;
virtual void visit(Block &) { }
virtual void visit(Literal &) { }
class TraversingVisitor: public NodeVisitor
{
protected:
- Block *current_block;
+ Block *current_block = 0;
- TraversingVisitor(): current_block(0) { }
+ TraversingVisitor() = default;
public:
virtual void enter(Block &) { }
class NodeRemover: private TraversingVisitor
{
private:
- Stage *stage;
- const std::set<Node *> *to_remove;
- bool recursive_remove;
+ Stage *stage = 0;
+ const std::set<Node *> *to_remove = 0;
+ bool recursive_remove = false;
public:
- NodeRemover();
-
void apply(Stage &, const std::set<Node *> &);
private:
class NodeReorderer: private TraversingVisitor
{
private:
- Node *reorder_before;
- const std::set<Node *> *to_reorder;
+ Node *reorder_before = 0;
+ const std::set<Node *> *to_reorder = 0;
public:
- NodeReorderer();
-
void apply(Stage &, Node &, const std::set<Node *> &);
private:
namespace Msp {
namespace GL {
-DirectionalLight::DirectionalLight():
- transmittance(1.0f),
- direction(0.0f, 0.0f, -1.0f)
-{ }
-
void DirectionalLight::update_matrix()
{
Vector3 up_dir;
};
private:
- Color transmittance;
- Vector3 direction;
+ Color transmittance = { 1.0f };
+ Vector3 direction = { 0.0f, 0.0f, -1.0f };
-public:
- DirectionalLight();
-
-private:
void update_matrix();
public:
namespace Msp {
namespace GL {
-Light::Light():
- color(1.0f),
- generation(0)
-{ }
-
void Light::set_color(const Color &c)
{
color = c;
};
protected:
- Color color;
- unsigned generation;
+ Color color = { 1.0f };
+ unsigned generation = 0;
- Light();
+ Light() = default;
public:
- virtual ~Light() { }
+ virtual ~Light() = default;
/** Sets the color of the Light. */
void set_color(const Color &);
};
protected:
- const Sampler *sampler;
+ const Sampler *sampler = 0;
ProgramData shdata;
- Material(): sampler(0) { }
+ Material() = default;
public:
- virtual ~Material() { }
+ virtual ~Material() = default;
virtual const Program *create_compatible_shader(const std::map<std::string, int> & = std::map<std::string, int>()) const;
protected:
namespace Msp {
namespace GL {
-PointLight::PointLight():
- position(0.0f, 0.0f, 0.0f),
- attenuation{1.0f, 0.0f, 0.1f}
-{ }
-
void PointLight::update_matrix()
{
matrix = Matrix::translation(position);
};
private:
- Vector3 position;
- float attenuation[3];
+ Vector3 position = { 0.0f, 0.0f, 0.0f };
+ float attenuation[3] = { 1.0f, 0.0f, 0.1f };
-public:
- PointLight();
-
-private:
void update_matrix();
public:
namespace Msp {
namespace GL {
-RenderMethod::RenderMethod():
- shprog(0),
- shprog_from_material(false),
- shdata(0),
- material(0),
- face_cull(CULL_BACK),
- receive_shadows(false),
- image_based_lighting(false)
-{ }
-
void RenderMethod::set_material_textures()
{
const Tag *material_texture_tags = material->get_texture_tags();
TextureSlot(Tag t): tag(t), texture(0), sampler(0) { }
};
- const Program *shprog;
- bool shprog_from_material;
+ const Program *shprog = 0;
+ bool shprog_from_material = false;
RefPtr<ProgramData> shdata;
std::map<Tag, Tag> uniform_slots;
- const Material *material;
+ const Material *material = 0;
std::string material_slot;
std::vector<TextureSlot> textures;
- CullMode face_cull;
- bool receive_shadows;
- bool image_based_lighting;
+ CullMode face_cull = CULL_BACK;
+ bool receive_shadows = false;
+ bool image_based_lighting = false;
-public:
- RenderMethod();
-
-private:
void maybe_create_material_shader();
void set_material_textures();
Tag()
};
-UnlitMaterial::UnlitMaterial():
- texture(0),
- vertex_color(false)
+UnlitMaterial::UnlitMaterial()
{
set_color(Color(1.0f));
}
};
private:
- const Texture *texture;
+ const Texture *texture = 0;
Color color;
- bool vertex_color;
+ bool vertex_color = false;
static const Tag texture_tags[];
namespace Msp {
namespace GL {
-Camera::Camera():
- fov(Geometry::Angle<float>::from_turns(0.125)),
- height(0),
- aspect(4.0/3.0),
- clip_near(0.1),
- clip_far(10),
- frustum_x(0),
- frustum_y(0),
- position(0, 0, 0),
- look_dir(0, 0, -1),
- up_dir(0, 1, 0)
+Camera::Camera()
{
update_projection_matrix();
update_object_matrix();
};
private:
- Geometry::Angle<float> fov;
- float height;
- float aspect;
+ Geometry::Angle<float> fov = Geometry::Angle<float>::from_turns(0.125f);
+ float height = 0.0f;
+ float aspect = 4.0f/3.0f;
// Some compilers have "near" and "far" keywords
- float clip_near;
- float clip_far;
- float frustum_x;
- float frustum_y;
+ float clip_near = 0.1f;
+ float clip_far = 10.0f;
+ float frustum_x = 0.0f;
+ float frustum_y = 0.0f;
Geometry::Angle<float> rotate;
- Vector3 position;
- Vector3 look_dir;
- Vector3 up_dir;
+ Vector3 position = { 0.0f, 0.0f, 0.0f };
+ Vector3 look_dir = { 0.0f, 0.0f, -1.0f };
+ Vector3 up_dir = { 0.0f, 1.0f, 0.0f };
Matrix view_matrix;
Matrix proj_matrix;
ProgramData shdata;
const Matrix Object::identity_matrix;
Object::Object():
- lods(1),
- lod0_watched(false)
+ lods(1)
{ }
Object::Object(const Mesh *m, const Technique *t):
- lods(1),
- lod0_watched(false)
+ Object()
{
set_mesh(m);
set_technique(t);
std::vector<LevelOfDetail> lods;
Geometry::BoundingSphere<float, 3> bounding_sphere;
- bool lod0_watched;
+ bool lod0_watched = false;
static const Matrix identity_matrix;
OccludedScene::OccludedScene():
bounding_mesh(Resources::get_global().get<Mesh>("_occluder.mesh")),
bounding_shader(Resources::get_global().get<Program>("_occluder.glsl.shader")),
- no_depth_write(LEQUAL, false),
- occluder_min_size(0.25f),
- queries(OCCLUSION_QUERY, 0),
- cache_dirty(false)
+ queries(OCCLUSION_QUERY, 0)
{
no_color_write.write_mask = WRITE_NONE;
}
renderer.render(*i->renderable, tag);
}
-
-OccludedScene::OccludedRenderable::OccludedRenderable():
- renderable(0),
- bounding_sphere(0),
- in_frustum(false),
- occluder(false)
-{ }
-
} // namespace GL
} // namespace Msp
private:
struct OccludedRenderable
{
- Renderable *renderable;
- const Geometry::BoundingSphere<float, 3> *bounding_sphere;
- bool in_frustum;
- bool occluder;
-
- OccludedRenderable();
+ Renderable *renderable = 0;
+ const Geometry::BoundingSphere<float, 3> *bounding_sphere = 0;
+ bool in_frustum = false;
+ bool occluder = false;
};
const Mesh &bounding_mesh;
const Program &bounding_shader;
Blend no_color_write;
- DepthTest no_depth_write;
+ DepthTest no_depth_write = { LEQUAL, false };
std::set<Renderable *> renderables;
- float occluder_min_size;
+ float occluder_min_size = 0.25f;
mutable QueryPool queries;
mutable std::vector<OccludedRenderable> occluded_cache;
- mutable bool cache_dirty;
+ mutable bool cache_dirty = false;
public:
OccludedScene();
protected:
Matrix matrix;
- Placeable() { }
+ Placeable() = default;
public:
- virtual ~Placeable() { }
+ virtual ~Placeable() = default;
virtual void set_matrix(const Matrix &);
class PlacedRenderable: public Renderable, public Placeable
{
protected:
- PlacedRenderable() { }
+ PlacedRenderable() = default;
public:
/* Reimplement to clear ambiguity between Renderable and Placeable. This
}
-ProgramData::TaggedUniform::TaggedUniform():
- type(VOID),
- array_size(0),
- data_offset(0),
- data_size(0)
-{ }
-
-
ProgramData::SharedBlock::SharedBlock(ReflectData::LayoutHash h):
block_hash(h),
used(0),
struct TaggedUniform
{
Tag tag;
- DataType type;
- unsigned array_size;
- unsigned data_offset;
- unsigned data_size;
-
- TaggedUniform();
+ DataType type = VOID;
+ unsigned array_size = 0;
+ unsigned data_offset = 0;
+ unsigned data_size = 0;
};
struct SharedBlock
class Renderable
{
protected:
- Renderable() { }
+ Renderable() = default;
public:
- virtual ~Renderable() { }
+ virtual ~Renderable() = default;
/** Returns the model matrix of the Renderable. Null is returned if no such
matrix exists. The matrix should be in world space for some effects to work
}
-Renderer::BoundTexture::BoundTexture():
- unit(-1),
- texture(0),
- sampler(0),
- replaced(-1)
-{ }
-
-
Renderer::BoundProgramData::BoundProgramData(const ProgramData *d):
- shdata(d),
- generation(0)
-{ }
-
-
-Renderer::State::State():
- camera(0),
- framebuffer(0),
- viewport(0),
- scissor(0),
- texture_count(0),
- clipping(0),
- shprog(0),
- shdata_count(0),
- vertex_setup(0),
- front_face(NON_MANIFOLD),
- face_cull(NO_CULL),
- depth_test(0),
- stencil_test(0),
- blend(0),
- object_lod_bias(0)
+ shdata(d)
{ }
} // namespace GL
struct BoundTexture
{
Tag tag;
- mutable int unit;
- const Texture *texture;
- const Sampler *sampler;
- int replaced;
-
- BoundTexture();
+ mutable int unit = -1;
+ const Texture *texture = 0;
+ const Sampler *sampler = 0;
+ int replaced = -1;
};
struct BoundProgramData
{
const ProgramData *shdata;
- mutable unsigned generation;
+ mutable unsigned generation = 0;
BoundProgramData(const ProgramData *);
};
struct State
{
- const Camera *camera;
+ const Camera *camera = 0;
Matrix model_matrix;
- const Framebuffer *framebuffer;
- const Rect *viewport;
- const Rect *scissor;
- unsigned texture_count;
- const Clipping *clipping;
- const Program *shprog;
- unsigned shdata_count;
- const VertexSetup *vertex_setup;
- FaceWinding front_face;
- CullMode face_cull;
- const DepthTest *depth_test;
- const StencilTest *stencil_test;
- const Blend *blend;
- unsigned object_lod_bias;
-
- State();
+ const Framebuffer *framebuffer = 0;
+ const Rect *viewport = 0;
+ const Rect *scissor = 0;
+ unsigned texture_count = 0;
+ const Clipping *clipping = 0;
+ const Program *shprog = 0;
+ unsigned shdata_count = 0;
+ const VertexSetup *vertex_setup = 0;
+ FaceWinding front_face = NON_MANIFOLD;
+ CullMode face_cull = NO_CULL;
+ const DepthTest *depth_test = 0;
+ const StencilTest *stencil_test = 0;
+ const Blend *blend = 0;
+ unsigned object_lod_bias = 0;
};
enum ChangeMask
mutable Matrix culling_matrix;
mutable Vector4 frustum_edges[6];
- Scene() { }
+ Scene() = default;
private:
Scene(const Scene &);
Scene &operator=(const Scene &);
public:
- virtual ~Scene() { }
+ virtual ~Scene() = default;
virtual void add(Renderable &) = 0;
virtual void remove(Renderable &) = 0;
namespace Msp {
namespace GL {
-Sequence::Sequence():
- width(0),
- height(0),
- target{0, 0},
- target_ms(0),
- clear_enabled(false),
- clear_depth(1.0f),
- clear_stencil(0)
-{ }
-
Sequence::Sequence(unsigned w, unsigned h, const FrameFormat &f):
width(w),
height(h),
- target_format(f),
- target_ms(0),
- clear_enabled(false),
- clear_depth(1.0f),
- clear_stencil(0)
+ target_format(f)
{
if(target_format.empty())
throw invalid_argument("Sequence::Sequence");
std::vector<Step> steps;
std::vector<PostProcStep> postproc;
- unsigned width;
- unsigned height;
+ unsigned width = 0;
+ unsigned height = 0;
FrameFormat target_format;
- RenderTarget *target[2];
- RenderTarget *target_ms;
- bool clear_enabled;
+ RenderTarget *target[2] = { 0, 0 };
+ RenderTarget *target_ms = 0;
+ bool clear_enabled = false;
std::vector<Color> clear_colors;
- float clear_depth;
- int clear_stencil;
+ float clear_depth = 1.0f;
+ int clear_stencil = 0;
public:
- Sequence();
+ Sequence() = default;
Sequence(unsigned, unsigned, const FrameFormat &);
~Sequence();
namespace Msp {
namespace GL {
-Slot::Slot():
- renderable(0)
-{ }
-
void Slot::set(Renderable *r)
{
renderable = r;
class Slot: public Renderable
{
private:
- Renderable *renderable;
+ Renderable *renderable = 0;
public:
- Slot();
-
void set(Renderable *);
Renderable *get() const { return renderable; }
Text::Text(const Font &f, const Technique *tech, Tag tex_slot):
ObjectInstance(object),
font(f),
- mesh((TEXCOORD2, VERTEX2)),
- horz_align(0.0f),
- vert_offset(0.0f),
- width(0.0f)
+ mesh((TEXCOORD2, VERTEX2))
{
object.set_mesh(&mesh);
if(tech)
Mesh mesh;
Object object;
Tag texture_slot;
- float horz_align;
- float vert_offset;
- float width;
+ float horz_align = 0.0f;
+ float vert_offset = 0.0f;
+ float width = 0.0f;
public:
Text(const Font &, const Technique * = 0, Tag = Tag());
namespace Msp {
namespace GL {
-ZSortedScene::ZSortedScene():
- order(BACK_TO_FRONT),
- reference(FURTHEST)
-{ }
-
void ZSortedScene::add(Renderable &r)
{
if(renderables.insert(&r).second && !sorted_cache.empty())
};
std::set<Renderable *> renderables;
- SortOrder order;
- DepthReference reference;
+ SortOrder order = BACK_TO_FRONT;
+ DepthReference reference = FURTHEST;
mutable std::vector<SortedRenderable> sorted_cache;
public:
- ZSortedScene();
-
virtual void add(Renderable &);
virtual void remove(Renderable &);
namespace Msp {
namespace GL {
-Resource::Resource():
- manager(0)
-{ }
-
Resource::~Resource()
{
if(manager)
};
protected:
- ResourceManager *manager;
- void *manager_data;
+ ResourceManager *manager = 0;
+ void *manager_data = 0;
- Resource();
+ Resource() = default;
public:
virtual ~Resource();
{ }
-ResourceManager::ResourceManager():
- policy(LOAD_ON_DEMAND),
- async_loads(true),
- total_data_size(0),
- size_limit(0),
- frame(0),
- min_retain_frames(30),
- max_retain_frames(0),
- next_unload(0)
-{ }
-
ResourceManager::~ResourceManager()
{
thread.terminate();
void terminate();
};
- LoadingPolicy policy;
- bool async_loads;
+ LoadingPolicy policy = LOAD_ON_DEMAND;
+ bool async_loads = true;
mutable Mutex map_mutex;
std::map<const Resource *, ManagedResource> resources;
std::deque<ManagedResource *> queue;
- std::uint64_t total_data_size;
- std::uint64_t size_limit;
- unsigned frame;
- unsigned min_retain_frames;
- unsigned max_retain_frames;
- unsigned next_unload;
+ std::uint64_t total_data_size = 0;
+ std::uint64_t size_limit = 0;
+ unsigned frame = 0;
+ unsigned min_retain_frames = 30;
+ unsigned max_retain_frames = 0;
+ unsigned next_unload = 0;
LoadingThread thread;
public:
- ResourceManager();
~ResourceManager();
void set_loading_policy(LoadingPolicy);
class ResourceObserver
{
protected:
- ResourceObserver() { }
+ ResourceObserver() = default;
public:
- virtual ~ResourceObserver() { }
+ virtual ~ResourceObserver() = default;
virtual void resource_loaded(Resource &) { }
virtual void resource_unloaded(Resource &) { }