Apply const correctness to project

This commit is contained in:
2016-06-08 17:29:16 +10:00
parent a01c597340
commit 60fcecab0e
10 changed files with 182 additions and 168 deletions
+4 -4
View File
@@ -29,13 +29,13 @@ public:
Game(i32 width, i32 height);
~Game();
void init(Dengine::AssetManager *assetManager);
void init(Dengine::AssetManager *const assetManager);
void processInput(f32 dt);
void update(f32 dt);
void processInput(const f32 dt);
void update(const f32 dt);
void render();
private:
Dengine::Shader *shader;
const Dengine::Shader *shader;
Dengine::Sprite player;
};
}
+6 -5
View File
@@ -19,13 +19,14 @@ public:
~AssetManager();
/* Texture */
Texture *getTexture(std::string name);
i32 loadTextureImage(std::string path, std::string name);
const Texture *getTexture(const std::string name);
const i32 loadTextureImage(const std::string path, const std::string name);
/* Shaders */
Shader *getShader(std::string name);
i32 loadShaderFiles(std::string vertexPath, std::string fragmentPath,
std::string name);
const Shader *getShader(const std::string name);
const i32 loadShaderFiles(const std::string vertexPath,
const std::string fragmentPath,
const std::string name);
private:
std::map<std::string, Texture> mTextures;
+1 -1
View File
@@ -17,7 +17,7 @@ public:
i32 loadProgram(GLuint vertexShader, GLuint fragmentShader);
void use();
void use() const;
};
}
+3 -3
View File
@@ -13,12 +13,12 @@ public:
Sprite();
~Sprite();
b32 loadSprite(Texture *tex, glm::vec2 pos);
const b32 loadSprite(const Texture *tex, const glm::vec2 pos);
void render(Shader *shader);
void render(const Shader *shader) const;
private:
glm::vec2 pos;
Texture *tex;
const Texture *tex;
GLuint vbo;
GLuint vao;
};
+29 -22
View File
@@ -9,35 +9,42 @@ namespace Dengine
class Texture
{
public:
// Holds the ID of the texture object, used for all texture operations to
// reference to this particlar texture
GLuint mId;
// Texture image dimensions
GLuint mWidth;
GLuint mHeight;
// Texture Format
GLuint mInternalFormat; // Format of texture object
GLuint mImageFormat; // Format of loaded image
// Texture configuration
GLuint mWrapS; // Wrapping mode on S axis
GLuint mWrapT; // Wrapping mode on T axis
// Filtering mode if texture pixels < screen pixels
GLuint mFilterMinification;
// Filtering mode if texture pixels > screen pixels
GLuint mFilterMagnification;
// Constructor (sets default texture modes)
Texture();
// Generates texture from image data
void generate(GLuint width, GLuint height, unsigned char *data);
void generate(const GLuint width, const GLuint height,
const u8 *const image);
// Binds the texture as the current active GL_TEXTURE_2D texture object
void bind() const;
inline const GLuint getWidth() const { return this->width; }
inline const GLuint getHeight() const { return this->height; }
inline const GLuint getID() const { return this->id; }
private:
// Holds the ID of the texture object, used for all texture operations to
// reference to this particlar texture
GLuint id;
// Texture image dimensions
GLuint width;
GLuint height;
// Texture Format
GLuint internalFormat; // Format of texture object
GLuint imageFormat; // Format of loaded image
// Texture configuration
GLuint wrapS; // Wrapping mode on S axis
GLuint wrapT; // Wrapping mode on T axis
// Filtering mode if texture pixels < screen pixels
GLuint filterMinification;
// Filtering mode if texture pixels > screen pixels
GLuint filterMagnification;
};
}
#endif