Got text rendering to work
This commit is contained in:
parent
107ac6b2db
commit
177f73f78a
25
bt.c
25
bt.c
@ -108,7 +108,7 @@ int main(void) {
|
||||
|
||||
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
|
||||
SDL_SetRenderDrawColor(renderer, 130, 163, 255, 1);
|
||||
|
||||
TTF_Init();
|
||||
TTF_Font* font = TTF_OpenFont( "./fira.ttf", 16);
|
||||
|
||||
struct winsize sz;
|
||||
@ -186,13 +186,6 @@ int main(void) {
|
||||
// sb.ypos += GetMouseWheelMoveV().y * scroll_speed;
|
||||
// sb.height = MeasureTextEx(*fontDefault, sb.buf, fontsize, 1).y;
|
||||
|
||||
SDL_Surface* surfaceMessage =
|
||||
TTF_RenderText_Solid(font, "put your text here", WHITE);
|
||||
|
||||
// now you can convert it into a texture
|
||||
SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, surfaceMessage);
|
||||
|
||||
|
||||
// TODO: This is probably related to the font height and scrolling up, we just need
|
||||
// the "fontsize" which I think is probably the height of the text
|
||||
if (new_read || new_char) {
|
||||
@ -217,6 +210,19 @@ int main(void) {
|
||||
new_read = true;
|
||||
}
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_Surface* surfaceMessage =
|
||||
TTF_RenderText_Blended(font, "put your text here", WHITE);
|
||||
|
||||
// now you can convert it into a texture
|
||||
SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, surfaceMessage);
|
||||
SDL_Rect rect;
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
rect.w = surfaceMessage->w;
|
||||
rect.h = surfaceMessage->h;
|
||||
|
||||
SDL_RenderCopy(renderer, texture, NULL, &rect);
|
||||
|
||||
SDL_Color current_color = WHITE;
|
||||
int col_max = 200;
|
||||
char row_buf[col_max];
|
||||
@ -224,7 +230,8 @@ int main(void) {
|
||||
int ncol = 0;
|
||||
int row_height = 18;
|
||||
float row_posx = 0;
|
||||
for (int c = 0; c <= sb.length; c++) {
|
||||
// for (int c = 0; c <= sb.length; c++) {
|
||||
for (int c = 0; c <= -1; c++) {
|
||||
if (sb.buf[c] == '\r') {
|
||||
continue;
|
||||
} else if (sb.buf[c] == '\n' || sb.buf[c] == '\0' || ncol >= col_max) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user