diff --git a/Pontu/include/engine/Button.h b/Pontu/include/engine/Button.h index 5ccfb91..72a8cdb 100644 --- a/Pontu/include/engine/Button.h +++ b/Pontu/include/engine/Button.h @@ -32,11 +32,11 @@ typedef struct * \pre At least text or texture must be defined, or an error will be printed in STDERR. * \return a button created with the specs passed as params, or NULL if there was an error. */ -P_Button createButton(const SDL_Texture* texture, const int coordx, const int coordy, const int sizex, const int sizey, void (*onClick)(void)); +P_Button createButton(SDL_Texture* texture, const int coordx, const int coordy, const int sizex, const int sizey, void (*onClick)(void)); // texture: design du bouton, si rien n'est passer, le bouton sera générer dans la fonction. void changeButtonTexture(P_Button* button, const SDL_Texture* texture); -SDL_bool drawButtonOnRenderer(SDL_Renderer* renderer, P_Button* button); +SDL_bool drawButtonOnRenderer(SDL_Renderer* renderer, const P_Button* button); // function isHover(int x,int y) : bool, dit si le bouton est survolé en donnant les coordonnées x,y #endif diff --git a/Pontu/src/engine/Button.c b/Pontu/src/engine/Button.c index d426eed..4526565 100644 --- a/Pontu/src/engine/Button.c +++ b/Pontu/src/engine/Button.c @@ -4,7 +4,7 @@ /* * Return : a button within written , placed in (; ), sized x. The button returned will do when it will be clicked - * If texture is not define, the function will return NULL and an error is printed in STDERR. + * If texture is not define, the function will return NULL and an error is printed in STDERR. * * Params : texture => image for the button * coordx => placement in width @@ -15,7 +15,7 @@ * * Finality : Create a brand new button with specs */ -P_Button createButton(const SDL_Texture* texture, const int coordx, +P_Button createButton(SDL_Texture* texture, const int coordx, const int coordy, const int sizex, const int sizey, void (*onClick)(void)) { @@ -24,6 +24,12 @@ P_Button createButton(const SDL_Texture* texture, const int coordx, assert(texture != NULL && "WARNING: Button created without texture"); + b.texture = texture; + return b; } -//SDL_bool drawButtonOnRenderer(SDL_Renderer* renderer, P_Button* button) {} + +SDL_bool drawButtonOnRenderer(SDL_Renderer* renderer,const P_Button* button) +{ + SDL_RenderCopy(renderer,button->texture,NULL,&(button->rect)); +}