sdl-ttf

SDL_ttf - Font directory/Where do fonts go?

会有一股神秘感。 提交于 2020-01-24 18:39:24
问题 I've been noodling around with SDL and OpenGL (in C++), and decided to get some text into my game. I've followed a few tutorials, but I always get the same error: "Couldn't find .ttf" I'm sure it's been asked before, but where should you place the font, and what should you write in the TTF_OpenFont's first parameter? Here's the TTF part so far. if (TTF_Init() != 0) { cerr << "TTF_Init() Failed: " << TTF_GetError() << endl; SDL_Quit(); exit(1); } TTF_Font *font; font = TTF_OpenFont("FreeSans

Text in OpenGL using SDL_TTF

我们两清 提交于 2020-01-17 05:58:19
问题 I'm a beginner in OpenGL and I've created a function to write text in OpenGL using SDL_TTF. Here is the code for my function: #define WINDOW_WIDTH 832 #define WINDOW_HEIGHT 487 #define glVertex2px(x,y) glVertex2d((double)(x) * 2.0 / (double)WINDOW_WIDTH - 1.0, 1.0 - (double)(y) * 2.0 / (double)WINDOW_HEIGHT); void glWriteText2d(TTF_Font *font,const char *text,SDL_Color color,const int x,const int y){ GLuint texture; SDL_Surface *surface; surface = TTF_RenderText_Blended(font,text,color);

How do I check for SDL2_ttf in CMakeLists.txt?

和自甴很熟 提交于 2020-01-13 19:55:10
问题 I am currently writing an SDL2 program with the SDL2-ttf library and wanted to add a check for it in CMakeLists.txt. How do I do that? I am using CMake 3.1. 回答1: FindSDL_ttf.cmake is part of cmake 3.x just use find_package(SDL_ttf REQUIRED) 回答2: The FindSDL_ttf doesn't work with SDL2, so you'll have to use a third party option. I've used this and it works: https://raw.githubusercontent.com/Deraen/ohj2710/master/cmake_modules/FindSDL2TTF.cmake Just put it in a directory included by set(CMAKE

How do I check for SDL2_ttf in CMakeLists.txt?

Deadly 提交于 2020-01-13 19:55:07
问题 I am currently writing an SDL2 program with the SDL2-ttf library and wanted to add a check for it in CMakeLists.txt. How do I do that? I am using CMake 3.1. 回答1: FindSDL_ttf.cmake is part of cmake 3.x just use find_package(SDL_ttf REQUIRED) 回答2: The FindSDL_ttf doesn't work with SDL2, so you'll have to use a third party option. I've used this and it works: https://raw.githubusercontent.com/Deraen/ohj2710/master/cmake_modules/FindSDL2TTF.cmake Just put it in a directory included by set(CMAKE

How to render fonts and text with SDL2 efficiently?

本小妞迷上赌 提交于 2019-12-17 22:47:03
问题 Saw this post here about using SDL_ttf to render text in a game. However that approach requires calling SDL_CreateTextureFromSurface(), along with the SDL_FreeSurface() and SDL_DestroyTexture() every single frame. Is creating textures (and probably subsequently having to send them to the GPU) every frame something that can significally impact my performance? would it be wiser to use SDL_ttf only to create a texture with my whole rendered charset and then to blit from there myself, character

Getting SDL_ttf to play nice with SDL2

耗尽温柔 提交于 2019-12-07 08:20:49
问题 I've recently started migrating from using SDL (1.2.15) to SDL2 (2.0.0), and had previously depended on using the extension library SDL_ttf (2.0.11) to render fonts. When I try to use the same text library I used with version one SDL with SDL2 (admittedly not yet officially released), it compiles just fine. When I run the executable, though (I'm using VS2012 for Desktop at the moment), I get the following error: Unhandled exception at 0x6C7D8C24 (SDL2.dll) in test.exe: 0xC0000005: Access

Using SDL_ttf and OpenGL, TTF_RenderUTF8_Blended print Red rectangle

流过昼夜 提交于 2019-12-01 04:42:58
问题 When I render my text using TTF_RenderUTF8_Blended I obtain a solid rectangle on the screen. The color depends on the one I choose, in my case the rectangle is red. My question What am I missing? It seems like I'm not getting the proper Alpha values from the surface generated with SDL_DisplayFormatAlpha(TTF_RenderUTF8_Blended( ... )) , or am I? Does anyone recognize or know the problem? Additionnal informations If I use TTF_RenderUTF8_Solid or TTF_RenderUTF8_Shaded the text is drawn properly,

Using SDL_ttf with OpenGL

£可爱£侵袭症+ 提交于 2019-11-27 18:02:15
I'm using OpenGL and SDL to create a window in my program. How do I use SDL_ttf with an OpenGL window? For example I want to load a font and render some text. I want to draw the text using an SDL OpenGL surface. Here's how to do it: Initialize SDL and SDL_ttf, and create a window using SDL_SetVideoMode() . Make sure you pass the SDL_OPENGL flag. Initialize your OpenGL scene ( glViewport() , glMatrixMode() etc.). Render your text with SDL_ttf using e.g. TTF_RenderUTF8_Blended() . The render functions return an SDL_surface, which you have to convert into an OpenGL texture by passing a pointer to

Using SDL_ttf with OpenGL

天涯浪子 提交于 2019-11-26 22:39:37
问题 I'm using OpenGL and SDL to create a window in my program. How do I use SDL_ttf with an OpenGL window? For example I want to load a font and render some text. I want to draw the text using an SDL OpenGL surface. 回答1: Here's how to do it: Initialize SDL and SDL_ttf, and create a window using SDL_SetVideoMode() . Make sure you pass the SDL_OPENGL flag. Initialize your OpenGL scene ( glViewport() , glMatrixMode() etc.). Render your text with SDL_ttf using e.g. TTF_RenderUTF8_Blended() . The