view dmtext.c @ 49:033c660c25f5

Restructure module playing, removing 8bit sample mixing (output can still be 8bit, but samples are internally upconverted to 16bit after module loading.) Also prepare for floating point mixing support.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 01 Oct 2012 02:51:41 +0300
parents 32250b436bca
children f28cd66356f6
line wrap: on
line source

#include "dmlib.h"

void dmDrawTTFTextConst(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int x, int y, const char *fmt)
{
    SDL_Surface *text = TTF_RenderText_Blended(font, fmt, col);
    if (text)
    {
        SDL_Rect rect;
        rect.x = x;
        rect.y = y;
        rect.w = text->w;
        rect.h = text->h;
        SDL_BlitSurface(text, NULL, screen, &rect);
        SDL_FreeSurface(text);
    }
}

void dmDrawTTFTextVA(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int x, int y, const char *fmt, va_list ap)
{
    char *tmp = dm_strdup_vprintf(fmt, ap);
    if (tmp != NULL)
    {
        dmDrawTTFTextConst(screen, font, col, x, y, tmp);
        dmFree(tmp);
    }
}

void dmDrawTTFText(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int x, int y, const char *fmt, ...)
{
    va_list ap;
    
    va_start(ap, fmt);
    dmDrawTTFTextVA(screen, font, col, x, y, fmt, ap);
    va_end(ap);
}