Sha256: 09bbec1d72e1814bef4875a689a66db1c4fdca747fde85249cf5c62606b20ab9
Contents?: true
Size: 982 Bytes
Versions: 4
Compression:
Stored size: 982 Bytes
Contents
// text.c #include "ruby2d.h" /* * Create a SDL_Surface that contains the pixel data to render text, given a font and message */ SDL_Surface *R2D_TextCreateSurface(TTF_Font *font, const char *message) { // `msg` cannot be an empty string or NULL for TTF_SizeText if (message == NULL || strlen(message) == 0) message = " "; SDL_Color color = {255, 255, 255}; SDL_Surface *surface = TTF_RenderUTF8_Blended(font, message, color); if (!surface) { R2D_Error("TTF_RenderUTF8_Blended", TTF_GetError()); return NULL; } // Re-pack surface for OpenGL // See: https://discourse.libsdl.org/t/sdl-ttf-2-0-18-surface-to-opengl-texture-not-consistent-with-ttf-2-0-15 Sint32 i; Uint32 len = surface->w * surface->format->BytesPerPixel; Uint8 *src = surface->pixels; Uint8 *dst = surface->pixels; for (i = 0; i < surface->h; i++) { SDL_memmove(dst, src, len); dst += len; src += surface->pitch; } surface->pitch = len; return surface; }
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
ruby2d-0.12.1 | ext/ruby2d/text.c |
ruby2d-0.12.0 | ext/ruby2d/text.c |
ruby2d-0.11.3 | ext/ruby2d/text.c |
ruby2d-0.11.2 | ext/ruby2d/text.c |