add text rendering
This commit is contained in:
+1
-1
@@ -26,6 +26,6 @@ set(SRC
|
||||
# add the executable
|
||||
add_executable(FLOPPE_FION ${SRC})
|
||||
|
||||
target_link_libraries(FLOPPE_FION SDL2 SDL_image)
|
||||
target_link_libraries(FLOPPE_FION SDL2 SDL_image SDL_ttf)
|
||||
|
||||
set_property(TARGET FLOPPE_FION PROPERTY C_STANDARD 23)
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ typedef struct MonitorSize {
|
||||
int width, height;
|
||||
} MonitorSize_t;
|
||||
|
||||
RenderItem_t renderer_renderObject(RenderObject_t *);
|
||||
RenderItem_t renderer_renderObject(RenderObject_t);
|
||||
void renderer_removeObject(RenderItem_t);
|
||||
|
||||
MonitorSize_t renderer_getMonitorSize();
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
#include "text.h"
|
||||
|
||||
RenderObject_t text_renderText(Position position, SDL_Color color, TTF_Font* font, char* format, ...){
|
||||
|
||||
char text[100];
|
||||
va_list args;
|
||||
|
||||
memset(&text, '\0', sizeof(text));
|
||||
|
||||
va_start(args, format);
|
||||
vsprintf(text, format, args);
|
||||
va_end(args);
|
||||
|
||||
|
||||
RenderObject_t renderObject;
|
||||
SDL_Surface* surface = TTF_RenderText_Blended(font, text, color);
|
||||
|
||||
|
||||
renderObject.x = position.x;
|
||||
renderObject.y = position.y;
|
||||
renderObject.z = position.z;
|
||||
renderObject.surface = surface;
|
||||
return renderObject;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
#include <SDL/SDL_ttf.h>
|
||||
#include "renderer.h"
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
} Position;
|
||||
|
||||
|
||||
RenderObject_t text_renderText(Position position, SDL_Color color, TTF_Font* font, char* format, ...);
|
||||
Reference in New Issue
Block a user