From 8544116298d7a1be176f52be48c9952529f5c446 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 29 Oct 2021 12:48:39 +0300 Subject: [PATCH] Use default member initializers in some more classes --- source/render/instancearray.cpp | 5 +---- source/render/instancearray.h | 6 +++--- source/render/programdata.cpp | 16 +++------------- source/render/programdata.h | 8 ++++---- source/render/renderer.cpp | 3 +-- source/render/renderer.h | 2 +- 6 files changed, 13 insertions(+), 27 deletions(-) diff --git a/source/render/instancearray.cpp b/source/render/instancearray.cpp index f6a7bb63..4a24ac45 100644 --- a/source/render/instancearray.cpp +++ b/source/render/instancearray.cpp @@ -15,10 +15,7 @@ namespace Msp { namespace GL { InstanceArray::InstanceArray(const Object &o): - object(o), - instance_buffer(0), - matrix_location(-1), - matrix_offset(0) + object(o) { const Technique *tech = object.get_technique(); for(const auto &kvp: tech->get_methods()) diff --git a/source/render/instancearray.h b/source/render/instancearray.h index 8f5c7322..0965499f 100644 --- a/source/render/instancearray.h +++ b/source/render/instancearray.h @@ -40,10 +40,10 @@ private: const Object &object; std::vector instances; VertexArray instance_data; - Buffer *instance_buffer; + Buffer *instance_buffer = 0; VertexSetup vtx_setup; - int matrix_location; - unsigned matrix_offset; + int matrix_location = -1; + unsigned matrix_offset = 0; public: InstanceArray(const Object &); diff --git a/source/render/programdata.cpp b/source/render/programdata.cpp index 43bcbf3f..8defce5a 100644 --- a/source/render/programdata.cpp +++ b/source/render/programdata.cpp @@ -17,11 +17,7 @@ namespace Msp { namespace GL { ProgramData::ProgramData(const Program *p): - tied_program(p), - generation(0), - last_buffer_block(0), - buffer(0), - dirty(0) + tied_program(p) { } // Blocks are intentionally left uncopied @@ -29,17 +25,11 @@ ProgramData::ProgramData(const ProgramData &other): tied_program(other.tied_program), uniforms(other.uniforms), uniform_data(other.uniform_data), - generation(other.generation), - last_buffer_block(0), - buffer(0), - dirty(0) + generation(other.generation) { } ProgramData::ProgramData(const ProgramData &other, const Program *p): - tied_program(p), - last_buffer_block(0), - buffer(0), - dirty(0) + tied_program(p) { if(tied_program) { diff --git a/source/render/programdata.h b/source/render/programdata.h index 2eef750c..4e8ee373 100644 --- a/source/render/programdata.h +++ b/source/render/programdata.h @@ -151,12 +151,12 @@ private: const Program *tied_program; std::vector uniforms; std::vector uniform_data; - unsigned generation; + unsigned generation = 0; mutable std::vector blocks; mutable std::vector programs; - mutable UniformBlock *last_buffer_block; - mutable Buffer *buffer; - mutable Mask dirty; + mutable UniformBlock *last_buffer_block = 0; + mutable Buffer *buffer = 0; + mutable Mask dirty = 0; std::string debug_name; public: diff --git a/source/render/renderer.cpp b/source/render/renderer.cpp index 5e155f2e..447ab4e3 100644 --- a/source/render/renderer.cpp +++ b/source/render/renderer.cpp @@ -20,8 +20,7 @@ using namespace std; namespace Msp { namespace GL { -Renderer::Renderer(): - changed(0) +Renderer::Renderer() { state_stack.reserve(16); state_stack.push_back(State()); diff --git a/source/render/renderer.h b/source/render/renderer.h index 42515e82..0496aaf3 100644 --- a/source/render/renderer.h +++ b/source/render/renderer.h @@ -107,7 +107,7 @@ private: SHADER_DATA = 16 }; - unsigned char changed; + unsigned char changed = 0; std::vector state_stack; State *state; std::vector texture_stack; -- 2.45.2