]> git.tdb.fi Git - libs/gl.git/commitdiff
Mark constant data as const
authorMikko Rasa <tdb@tdb.fi>
Sat, 18 Sep 2021 12:15:32 +0000 (15:15 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 18 Sep 2021 13:20:18 +0000 (16:20 +0300)
source/builders/sphere.cpp
source/builders/sphere.h
source/core/texture.cpp
source/core/texture.h
source/core/texturecube.cpp
source/core/texturecube.h
source/effects/environmentmap.cpp
source/glsl/debug.cpp
source/glsl/syntax.cpp
source/render/object.cpp
source/render/object.h

index f7e06eb7041de62564329a807236a3db799e5ae0..7873d3a2132d1407cf8cfd78626b4dbd7ed6ebc3 100644 (file)
@@ -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,
index b20ff5413954ce80048c03bdf2982d22957b18c8..47b896431eaf7c6202bdd23123ba0d5b27d5c62d 100644 (file)
@@ -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[];
 
index bbda89b622f78b51038b8e8fd6123274d24a4e14..e607792c9dc6f50103c2bd30d195343d107976b3 100644 (file)
@@ -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,
index 80012f46846a7bd11746ed182fc2a56a21c8dfc5..0377c022c30137898da1257571eba01c3dbfd543 100644 (file)
@@ -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);
index 460c109e91879b986129b4ea01ec36a6369c00e2..516dca5209c9e571c7dc1a19093712fdfda201e1 100644 (file)
@@ -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,
index b68210b05c98230d892e7dcb780a2331095b3124..0f83e29e138953e8d2e5c6c7595adb8323ea3a33 100644 (file)
@@ -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();
index 8770aba5f2e1fcf19a5de76599c0a5f77a7afb71..87e4898df21a48d07f9cf7346f3926d9b5523d87 100644 (file)
@@ -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]));
index 2543450212c4d4442005770cf7eb8ca5f8e34da3..5b142019150441f3fd7291f03db30473e401631b 100644 (file)
@@ -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));
 
index 502c274810074c00b488711e55cae6e15ae29c7c..bb8d7dab046f2ea1293927d93aa3e415818e12d4 100644 (file)
@@ -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];
 }
 
index 8a3963eebe992f9db802184b5f20b9d86b461ab7..479e77afa986ac124137a4726717d055af56910a 100644 (file)
@@ -17,7 +17,7 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
-Matrix Object::identity_matrix;
+const Matrix Object::identity_matrix;
 
 Object::Object():
        lods(1),
index b7b549536f4b92bd97c0ee9506e8ab3c48d42111..ca41ffac0a2f086633dcb7153046b08ef1554d3d 100644 (file)
@@ -73,7 +73,7 @@ private:
        Geometry::BoundingSphere<float, 3> bounding_sphere;
        bool lod0_watched;
 
-       static Matrix identity_matrix;
+       static const Matrix identity_matrix;
 
 public:
        Object();