Sa marche putain!

This commit is contained in:
Marc
2023-01-21 10:15:27 +01:00
parent 2d62bfc599
commit 2f0a199e95
7 changed files with 73 additions and 36 deletions
+8 -3
View File
@@ -1,5 +1,6 @@
#include <SDL2/SDL_error.h>
#include <unistd.h>
#include "renderer.h"
#include "text.h"
#include <SDL2/SDL_log.h>
@@ -22,7 +23,7 @@ void text_freeFontCache(void){
}
}
int text_renderText(RenderObject_t* renderObject, float x, float y, int z, SDL_Color color, const char* fontFilename, int fontSize, char* format, ...){
int text_renderText(RenderObject_t* renderObject, float x, float y, int z, float scale, SDL_Color color, const char* fontFilename, int fontSize, char* format, ...){
if(access(fontFilename, F_OK) != 0) {
fprintf(stderr, "Font file not found: %s\n", fontFilename);
return -1;
@@ -62,12 +63,16 @@ int text_renderText(RenderObject_t* renderObject, float x, float y, int z, SDL_C
SDL_Surface* surface = TTF_RenderText_Blended(font, text, color);
int h, w;
TTF_SizeText(font, text, &w, &h);
MonitorSize_t monitor = renderer_getMonitorSize();
renderObject->x = x;
renderObject->y = y;
renderObject->z = z;
renderObject->width = strlen(text) * fontSize;
renderObject->height = fontSize;
renderObject->width = w * scale / 500;
renderObject->height = h * scale / 500;
renderObject->angle_degre = 0;
renderObject->surface = surface;