这两天在做一个视频分析软件需要用到SDL显示图像及文字,将阶段成果做一下总结:
SDL本身并没有实际文字的功能,需要用到其扩展库SDL_ttf,下载地址:
http://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf.html
闲话少说,请看代码(工程环境:VS2005):
#include "stdafx.h"
#pragma comment(lib,"SDL.lib")
#pragma comment(lib,"SDL2_image.lib")
#pragma comment(lib,"SDL_ttf.lib")
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <Windows.h>
#include "SDL.h"
#include "SDL_ttf.h"
/* 屏幕分辩率 */
#define SCREEN_WIDTH 720
#define SCREEN_HEIGHT 480
#define SCREEN_BPP 32
const SDL_Color RGB_Black = { 0, 0, 0 };
const SDL_Color RGB_Red = { 255, 0, 0 };
const SDL_Color RGB_White = { 2