From 17ac705a29fdd0b14a776282b9d9eca0ea222930 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathis=20Rib=C3=A9mont?= Date: Mon, 6 Dec 2021 11:54:11 +0100 Subject: [PATCH] button drawable --- Pontu/include/engine/Button.h | 4 ++-- Pontu/src/engine/Button.c | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) 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 bf57c3d..9233dce 100644 --- a/Pontu/src/engine/Button.c +++ b/Pontu/src/engine/Button.c @@ -2,7 +2,7 @@ #include #include -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)) { @@ -11,7 +11,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)); +}