#define SCR_HEIGHT 800
#define SCR_WIDTH 480
#define SCR_BPP 32
#include <SDL/SDL.h>
#include <SDL/SDL_draw.h>
#include <SDL/SDL_ttf.h>
#include <iostream>
#include <ctime>
using namespace std;
SDL_Surface *initSDL() {
if (SDL_Init(SDL_INIT_EVERYTHING) == -1) {
return 0;
}
return SDL_SetVideoMode(SCR_WIDTH, SCR_HEIGHT, SCR_BPP, SDL_SWSURFACE);
}
SDL_Surface *loadText(TTF_Font * font, const char *text, SDL_Color color) {
return TTF_RenderText_Solid(font, text, color);
}
void renderText(SDL_Surface * textSurface, int x, int y, SDL_Surface * dist) {
SDL_Rect area;
area.x = x;
area.y = y;
area.w = textSurface->w;
area.h = textSurface->h;
SDL_UpperBlit(textSurface, NULL, dist, &area);
}
int main(int argc, char *argv[]) {
SDL_Surface *screen = 0;
if ((screen = initSDL()) == 0) {
return 1;
}
TTF_Font *font = TTF_OpenFont("/mnt/sdcard/consola.ttf", 30);
if (font == 0) {
return 1;
}
SDL_Event event;
SDL_Surface *textSurface = loadText(font, "Hello world", { 0xff, 0xff, 0xff });
renderText(textSurface, 30, 30, screen);
SDL_Flip(screen);
bool run = true;
int frames = 0;
clock_t sTime = clock();
while (run) {
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
run = false;
break;
default:
break;
}
if (clock() - sTime >= CLOCKS_PER_SEC) {
frames = 0;
sTime = clock();
}
}
}
TTF_CloseFont(font);
SDL_Quit();
TTF_Quit();
return 0;
}
#define SCR_WIDTH 480
#define SCR_BPP 32
#include <SDL/SDL.h>
#include <SDL/SDL_draw.h>
#include <SDL/SDL_ttf.h>
#include <iostream>
#include <ctime>
using namespace std;
SDL_Surface *initSDL() {
if (SDL_Init(SDL_INIT_EVERYTHING) == -1) {
return 0;
}
return SDL_SetVideoMode(SCR_WIDTH, SCR_HEIGHT, SCR_BPP, SDL_SWSURFACE);
}
SDL_Surface *loadText(TTF_Font * font, const char *text, SDL_Color color) {
return TTF_RenderText_Solid(font, text, color);
}
void renderText(SDL_Surface * textSurface, int x, int y, SDL_Surface * dist) {
SDL_Rect area;
area.x = x;
area.y = y;
area.w = textSurface->w;
area.h = textSurface->h;
SDL_UpperBlit(textSurface, NULL, dist, &area);
}
int main(int argc, char *argv[]) {
SDL_Surface *screen = 0;
if ((screen = initSDL()) == 0) {
return 1;
}
TTF_Font *font = TTF_OpenFont("/mnt/sdcard/consola.ttf", 30);
if (font == 0) {
return 1;
}
SDL_Event event;
SDL_Surface *textSurface = loadText(font, "Hello world", { 0xff, 0xff, 0xff });
renderText(textSurface, 30, 30, screen);
SDL_Flip(screen);
bool run = true;
int frames = 0;
clock_t sTime = clock();
while (run) {
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
run = false;
break;
default:
break;
}
if (clock() - sTime >= CLOCKS_PER_SEC) {
frames = 0;
sTime = clock();
}
}
}
TTF_CloseFont(font);
SDL_Quit();
TTF_Quit();
return 0;
}