From b7ecc29c204faede028556d1942b2d61d5cda9ee Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 18 Sep 2021 15:15:32 +0300 Subject: [PATCH] Mark constant data as const --- source/builders/sphere.cpp | 4 ++-- source/builders/sphere.h | 4 ++-- source/core/texture.cpp | 2 +- source/core/texture.h | 2 +- source/core/texturecube.cpp | 6 +++--- source/core/texturecube.h | 6 +++--- source/effects/environmentmap.cpp | 2 +- source/glsl/debug.cpp | 2 +- source/glsl/syntax.cpp | 2 +- source/render/object.cpp | 2 +- source/render/object.h | 2 +- 11 files changed, 17 insertions(+), 17 deletions(-) diff --git a/source/builders/sphere.cpp b/source/builders/sphere.cpp index f7e06eb7..7873d3a2 100644 --- a/source/builders/sphere.cpp +++ b/source/builders/sphere.cpp @@ -80,7 +80,7 @@ void UvSphereBuilder::build(PrimitiveBuilder &builder) const // https://en.wikipedia.org/wiki/Regular_icosahedron#Cartesian_coordinates -float IcoSphereBuilder::base_vertices[12*3] = +const float IcoSphereBuilder::base_vertices[12*3] = { 0.0f, -0.5257311f, -0.8506508f, 0.0f, 0.5257311f, -0.8506508f, @@ -96,7 +96,7 @@ float IcoSphereBuilder::base_vertices[12*3] = 0.5257311f, 0.8506508f, 0.0f }; -unsigned IcoSphereBuilder::base_triangles[20*3] = +const unsigned IcoSphereBuilder::base_triangles[20*3] = { 0, 1, 6, 1, 0, 4, diff --git a/source/builders/sphere.h b/source/builders/sphere.h index b20ff541..47b89643 100644 --- a/source/builders/sphere.h +++ b/source/builders/sphere.h @@ -27,8 +27,8 @@ private: float radius; unsigned subdivision; - static float base_vertices[]; - static unsigned base_triangles[]; + static const float base_vertices[]; + static const unsigned base_triangles[]; static unsigned base_edges[]; static unsigned base_tri_edges[]; diff --git a/source/core/texture.cpp b/source/core/texture.cpp index bbda89b6..e607792c 100644 --- a/source/core/texture.cpp +++ b/source/core/texture.cpp @@ -13,7 +13,7 @@ using namespace std; namespace Msp { namespace GL { -int Texture::swizzle_orders[] = +const int Texture::swizzle_orders[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA, GL_RED, GL_RED, GL_RED, GL_ONE, diff --git a/source/core/texture.h b/source/core/texture.h index 80012f46..0377c022 100644 --- a/source/core/texture.h +++ b/source/core/texture.h @@ -64,7 +64,7 @@ protected: bool auto_gen_mipmap; std::string debug_name; - static int swizzle_orders[]; + static const int swizzle_orders[]; static Texture *scratch_binding; Texture(GLenum, ResourceManager * = 0); diff --git a/source/core/texturecube.cpp b/source/core/texturecube.cpp index 460c109e..516dca52 100644 --- a/source/core/texturecube.cpp +++ b/source/core/texturecube.cpp @@ -13,7 +13,7 @@ using namespace std; namespace Msp { namespace GL { -TextureCubeFace TextureCube::face_order[6] = +const TextureCubeFace TextureCube::face_order[6] = { POSITIVE_X, NEGATIVE_X, @@ -23,7 +23,7 @@ TextureCubeFace TextureCube::face_order[6] = NEGATIVE_Z }; -Vector3 TextureCube::directions[6] = +const Vector3 TextureCube::directions[6] = { Vector3(1, 0, 0), Vector3(-1, 0, 0), @@ -33,7 +33,7 @@ Vector3 TextureCube::directions[6] = Vector3(0, 0, -1) }; -unsigned TextureCube::orientations[12] = +const unsigned TextureCube::orientations[12] = { 5, 3, 4, 3, diff --git a/source/core/texturecube.h b/source/core/texturecube.h index b68210b0..0f83e29e 100644 --- a/source/core/texturecube.h +++ b/source/core/texturecube.h @@ -53,9 +53,9 @@ private: unsigned size; unsigned levels; - static TextureCubeFace face_order[6]; - static Vector3 directions[6]; - static unsigned orientations[12]; + static const TextureCubeFace face_order[6]; + static const Vector3 directions[6]; + static const unsigned orientations[12]; public: TextureCube(); diff --git a/source/effects/environmentmap.cpp b/source/effects/environmentmap.cpp index 8770aba5..87e4898d 100644 --- a/source/effects/environmentmap.cpp +++ b/source/effects/environmentmap.cpp @@ -186,7 +186,7 @@ void EnvironmentMap::set_debug_name(const string &name) #ifdef DEBUG env_tex.set_debug_name(name+"/environment.texcb"); depth_buf.set_debug_name(name+"/environment_depth.rbuf"); - static const char *face_names[] = { "X+", "X-", "Y+", "Y-", "Z+", "Z-" }; + static const char *const face_names[] = { "X+", "X-", "Y+", "Y-", "Z+", "Z-" }; for(unsigned i=0; i<6; ++i) { faces[i].fbo.set_debug_name(format("%s [FBO:%s]", name, face_names[i])); diff --git a/source/glsl/debug.cpp b/source/glsl/debug.cpp index 25434502..5b142019 100644 --- a/source/glsl/debug.cpp +++ b/source/glsl/debug.cpp @@ -315,7 +315,7 @@ void DumpTree::visit(BasicTypeDeclaration &type) void DumpTree::visit(ImageTypeDeclaration &type) { - static const char *dims[] = { "1D", "2D", "3D", "Cube" }; + static const char *const dims[] = { "1D", "2D", "3D", "Cube" }; append(type, format("%%%d typedef %s", get_label(type), type.name)); diff --git a/source/glsl/syntax.cpp b/source/glsl/syntax.cpp index 502c2748..bb8d7dab 100644 --- a/source/glsl/syntax.cpp +++ b/source/glsl/syntax.cpp @@ -460,7 +460,7 @@ Stage::Stage(Stage::Type t): const char *Stage::get_stage_name(Type type) { - static const char *names[] = { "shared", "vertex", "geometry", "fragment" }; + static const char *const names[] = { "shared", "vertex", "geometry", "fragment" }; return names[type]; } diff --git a/source/render/object.cpp b/source/render/object.cpp index 8a3963ee..479e77af 100644 --- a/source/render/object.cpp +++ b/source/render/object.cpp @@ -17,7 +17,7 @@ using namespace std; namespace Msp { namespace GL { -Matrix Object::identity_matrix; +const Matrix Object::identity_matrix; Object::Object(): lods(1), diff --git a/source/render/object.h b/source/render/object.h index b7b54953..ca41ffac 100644 --- a/source/render/object.h +++ b/source/render/object.h @@ -73,7 +73,7 @@ private: Geometry::BoundingSphere bounding_sphere; bool lod0_watched; - static Matrix identity_matrix; + static const Matrix identity_matrix; public: Object(); -- 2.45.2