text stuff, I forgot
This commit is contained in:
parent
7018500555
commit
8a29955b1f
3 changed files with 9 additions and 8 deletions
|
|
@ -11,8 +11,6 @@ extern "C" {
|
|||
#include "arc/math/point.h"
|
||||
#include "arc/std/string.h"
|
||||
|
||||
void ARC_TTF_Init();
|
||||
|
||||
typedef struct ARC_Text ARC_Text;
|
||||
|
||||
void ARC_Text_Create(ARC_Text **text, ARC_String *path, int32_t size, ARC_Color color);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
#include "arc/input/sdl/keyboard.h"
|
||||
#include <SDL.h>
|
||||
#include <SDL_video.h>
|
||||
#include <SDL2/SDL_ttf.h>
|
||||
#elif ARC_OPENGL
|
||||
#include "arc/graphics/opengl/window.h"
|
||||
#include "arc/graphics/opengl/renderer.h"
|
||||
|
|
@ -39,6 +40,10 @@ void ARC_EngineData_Create(ARC_EngineData **data, ARC_Handler_CleanDataFn cleanf
|
|||
ARC_KeyboardInfo keyboardInfo;
|
||||
|
||||
(*data)->windowSize = windowSize;
|
||||
//TEMP
|
||||
#ifdef ARC_SDL
|
||||
TTF_Init();
|
||||
#endif
|
||||
|
||||
#ifdef ARC_SDL
|
||||
windowInfo = (ARC_WindowInfo){ "title", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, (*data)->windowSize.x, (*data)->windowSize.y, 0 };
|
||||
|
|
|
|||
|
|
@ -7,10 +7,6 @@
|
|||
|
||||
#include <SDL2/SDL_ttf.h>
|
||||
|
||||
void ARC_TTF_Init(){
|
||||
TTF_Init();
|
||||
}
|
||||
|
||||
void ARC_Text_Create(ARC_Text **text, ARC_String *path, int32_t size, ARC_Color color){
|
||||
*text = (ARC_Text *)malloc(sizeof(ARC_Text));
|
||||
ARC_String_Copy(&(*text)->name, path);
|
||||
|
|
@ -31,9 +27,11 @@ void ARC_Text_Destroy(ARC_Text *font){
|
|||
void ARC_Text_SetString(ARC_Text *text, ARC_Renderer *renderer, ARC_String *string){
|
||||
TTF_Font *ttfont = TTF_OpenFont(text->name->data, text->size);
|
||||
SDL_Color textColor = (SDL_Color){ text->color.r, text->color.g, text->color.b, text->color.a };
|
||||
SDL_Surface *surface = TTF_RenderText_Blended(ttfont, string->data, textColor);
|
||||
SDL_Surface *surface = TTF_RenderText_Blended_Wrapped(ttfont, string->data, textColor, 0);
|
||||
|
||||
text->bounds.w = surface->w;
|
||||
text->bounds.h = surface->h;
|
||||
|
||||
TTF_SizeText(ttfont, string->data, &(text->bounds.w), &(text->bounds.h));
|
||||
text->texture = SDL_CreateTextureFromSurface((SDL_Renderer *)renderer, surface);
|
||||
|
||||
SDL_FreeSurface(surface);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue