drawButton doesn't return value anymore, and exit when there is an error

merge-requests/1/merge
Mathis RIBEMONT 4 years ago
parent 9cfebbe920
commit 1a7dd39a3e

@ -39,9 +39,8 @@ P_Button createButton(SDL_Texture* texture, const int coordx, const int coordy,
* \param[in] renderer the renderer you want to draw the button on
* \param[in] button the button you want to draw
* \pre At least text or texture must be defined, or an error will be printed in STDERR.
* \return SDL_FALSE if the function failed, else SDL_TRUE
*/
SDL_bool drawButtonOnRenderer(SDL_Renderer* renderer, const P_Button* button);
void drawButtonOnRenderer(SDL_Renderer* renderer, const P_Button* button);
/**
* \brief Test if a point is on a button

@ -9,16 +9,20 @@ P_Button createButton(SDL_Texture* texture, const int coordx,
// Declarations
P_Button b = { .rect = { .x = coordx, .y = coordy, .w = sizex, .h = sizey }, .onClick = onClick };
assert(texture != NULL && "WARNING: Button created without texture");
assert(texture != NULL && "ERROR: Button created without texture");
b.texture = texture;
return b;
}
SDL_bool drawButtonOnRenderer(SDL_Renderer* renderer,const P_Button* button)
void drawButtonOnRenderer(SDL_Renderer* renderer,const P_Button* button)
{
return SDL_RenderCopy(renderer,button->texture,NULL,&(button->rect));
if(SDL_RenderCopy(renderer,button->texture,NULL,&(button->rect)))
{
fprintf(stderr,"Error: %s\n",SDL_GetError());
exit(1);
}
}
SDL_bool isHover(const P_Button button,const int x,const int y)

Loading…
Cancel
Save