add some const keyword

This commit is contained in:
Mylloon 2023-05-23 12:56:32 +02:00
parent 1bd16eae68
commit fc1e5e40f9
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
9 changed files with 24 additions and 21 deletions

View file

@ -9,13 +9,13 @@
extern GLuint _dims[];
// Scène de manifestation
void manif(int);
void manif(const int);
// Scène du tag sur le mur
void tag(int);
void tag(const int);
// Crédits de fin
void credits(int);
void credits(const int);
// Initialisation des transitions
void transitions_init(void);

View file

@ -11,7 +11,7 @@
* Renvoie 2 en cas de problème de chargement de la police
*
* Renvoie 0 en cas de succès */
int initFont(TTF_Font **, char *, int);
int initFont(TTF_Font **, const char *, const int);
/* Ecris un texte sur une texture
*
@ -20,7 +20,8 @@ int initFont(TTF_Font **, char *, int);
* Renvoie 2 en cas de problème de surface avec la SDL
*
* Renvoie 0 en cas de succès */
int writeText(GLuint *, TTF_Font *, const char *, SDL_Color, GLuint *);
int writeText(GLuint *, TTF_Font *, const char *, const SDL_Color,
const GLuint *);
// Libère une police de la mémoire
void freeFont(TTF_Font *);

View file

@ -7,7 +7,7 @@
#include <string.h>
// Récupère un delta-temps
double get_dt(double *, GLboolean);
double get_dt(double *, const GLboolean);
// Bind and load a matrix
void bindAndLoadf(const char *name);
@ -25,15 +25,15 @@ void bindAndLoadf(const char *name);
* `+z` => move closer
*
* `-z` => move away */
void move(GLfloat x, GLfloat y, GLfloat z);
void move(const GLfloat x, const GLfloat y, const GLfloat z);
// Rotate a vector XYZ
void rotate_vec(GLfloat *, GLfloat);
void rotate_vec(GLfloat *, const GLfloat);
// Load an image into a GL texture
void load_img(const char *filename, GLuint texture);
void load_img(const char *filename, const GLuint texture);
// Copy a texture
void copy_texture(GLuint, GLuint);
void copy_texture(const GLuint, const GLuint);
#endif

2
main.c
View file

@ -11,7 +11,7 @@ GLuint _dims[] = {1280, 720};
static void init(void);
static void closure(void);
int main(int argc, char *argv[]) {
int main(const int argc, char *argv[]) {
if (!gl4duwCreateWindow(argc, argv, "Demo API8 2023", GL4DW_POS_CENTERED,
GL4DW_POS_CENTERED, _dims[0], _dims[1],
GL4DW_OPENGL | GL4DW_SHOWN)) {

View file

@ -11,7 +11,7 @@ static void init(void);
static void draw(void);
static void deinit(void);
void credits(int state) {
void credits(const int state) {
switch (state) {
case GL4DH_INIT:
init();

View file

@ -1,6 +1,6 @@
#include "../includes/font.h"
int initFont(TTF_Font **font, char *filename, int size) {
int initFont(TTF_Font **font, const char *filename, const int size) {
if (TTF_Init() == -1) {
fprintf(stderr, "Erreur TTF : %s\n", TTF_GetError());
return 1;
@ -15,7 +15,7 @@ int initFont(TTF_Font **font, char *filename, int size) {
}
int writeText(GLuint *_textTexId, TTF_Font *font, const char *text,
SDL_Color color, GLuint *backgroundTextureId) {
const SDL_Color color, const GLuint *backgroundTextureId) {
SDL_Surface *d, *s;
// Create text
if (!(d = TTF_RenderUTF8_Blended_Wrapped(font, text, color, 0))) {

View file

@ -13,7 +13,7 @@ static const char *matrix_view = "view";
static void init(void);
static void draw(void);
void manif(int state) {
void manif(const int state) {
switch (state) {
case GL4DH_INIT:
init();

View file

@ -12,7 +12,7 @@ static void init(void);
static void draw(void);
static void deinit(void);
void tag(int state) {
void tag(const int state) {
switch (state) {
case GL4DH_INIT:
init();

View file

@ -1,6 +1,6 @@
#include "../includes/utils.h"
double get_dt(double *t0, GLboolean override_t0) {
double get_dt(double *t0, const GLboolean override_t0) {
double t = gl4dGetElapsedTime(), dt = (t - *t0) / 1000.0;
if (override_t0) {
*t0 = t;
@ -14,9 +14,11 @@ void bindAndLoadf(const char *name) {
gl4duLoadIdentityf();
}
void move(GLfloat x, GLfloat y, GLfloat z) { gl4duTranslatef(x, y, z); }
void move(const GLfloat x, const GLfloat y, const GLfloat z) {
gl4duTranslatef(x, y, z);
}
void rotate_vec(GLfloat *vec, GLfloat angle) {
void rotate_vec(GLfloat *vec, const GLfloat angle) {
GLfloat y = vec[1];
GLfloat z = vec[2];
@ -27,7 +29,7 @@ void rotate_vec(GLfloat *vec, GLfloat angle) {
vec[2] = y * sinTheta + z * cosTheta;
}
void load_img(const char *filename, GLuint texture) {
void load_img(const char *filename, const GLuint texture) {
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@ -51,7 +53,7 @@ void load_img(const char *filename, GLuint texture) {
glBindTexture(GL_TEXTURE_2D, 0);
}
void copy_texture(GLuint src, GLuint dst) {
void copy_texture(const GLuint src, const GLuint dst) {
if (!(src || dst)) {
fprintf(stderr,
"Erreur copie texture: Source/Destination pas initalisée\n");