summaryrefslogtreecommitdiff
path: root/meme
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2014-09-14 11:59:25 -0300
committerWerner Almesberger <werner@almesberger.net>2014-09-14 11:59:25 -0300
commit57e0603cd3cf68f8adaefb32eec7efd17c43f99b (patch)
tree4de1a8e635bbf0f0ab295a8d971daaab69082b1a /meme
parente2dc06ebc066399e7274a6627127f725e1f07b17 (diff)
downloadmisc-57e0603cd3cf68f8adaefb32eec7efd17c43f99b.tar.gz
misc-57e0603cd3cf68f8adaefb32eec7efd17c43f99b.tar.bz2
misc-57e0603cd3cf68f8adaefb32eec7efd17c43f99b.zip
meme/: use SDL_GetVideoInfo to set up SDL_AllocSurface, instead of SDL_DisplayFormat
Diffstat (limited to 'meme')
-rw-r--r--meme/Makefile2
-rw-r--r--meme/gui.c16
-rw-r--r--meme/text.c7
3 files changed, 7 insertions, 18 deletions
diff --git a/meme/Makefile b/meme/Makefile
index abbd6a8..f3b771f 100644
--- a/meme/Makefile
+++ b/meme/Makefile
@@ -13,7 +13,7 @@
include Makefile.c-common
CFLAGS = -Wall -Wshadow -g -O9
-OBJS = main.o stl.o mesh.o gui.o time.o plane.o text.o
+OBJS = main.o stl.o mesh.o gui.o time.o plane.o text.o gaux.o
CFLAGS += $(shell sdl-config --cflags)
LDLIBS = $(shell sdl-config --libs) -lSDL_gfx -lSDL_Pango -lm
diff --git a/meme/gui.c b/meme/gui.c
index 2e562b4..8298970 100644
--- a/meme/gui.c
+++ b/meme/gui.c
@@ -21,6 +21,7 @@
#include "time.h"
#include "mesh.h"
#include "plane.h"
+#include "gaux.h"
#include "text.h"
@@ -226,7 +227,6 @@ static struct change {
static void change(SDL_Surface *s, int x, int y, int w, int h)
{
struct change *c;
- SDL_Surface *tmp;
if (x < 0) {
w += x;
@@ -241,22 +241,12 @@ static void change(SDL_Surface *s, int x, int y, int w, int h)
if (y+h >= yres)
h = yres-y-1;
- /*
- * @@@ this seems weird. do we really have no direct way to create
- * a surface that's compatible with the display ?
- */
c = alloc_type(struct change);
- tmp = SDL_CreateRGBSurface(SDL_SURFACE, w, h, 0, 0, 0, 0, 0);
- if (!tmp) {
- fprintf(stderr, "SDL_CreateRGBSurface failed\n");
- exit(1);
- }
- c->s = SDL_DisplayFormat(tmp);
+ c->s = sdl_surface(SDL_SURFACE, w, h);
if (!c->s) {
- fprintf(stderr, "SDL_DisplayFormat failed\n");
+ fprintf(stderr, "sdl_surface failed\n");
exit(1);
}
- SDL_FreeSurface(tmp);
c->r.x = x;
c->r.y = y;
diff --git a/meme/text.c b/meme/text.c
index 4a4f33c..c01eec0 100644
--- a/meme/text.c
+++ b/meme/text.c
@@ -17,6 +17,7 @@
#include "SDL.h"
#include "SDL_Pango.h"
+#include "gaux.h"
#include "text.h"
@@ -45,7 +46,7 @@ void text_color(Uint32 rgba)
SDL_Surface *text(const char *s)
{
SDLPango_Context *pango;
- SDL_Surface *tmp, *surf;
+ SDL_Surface *surf;
int w, h;
pango = SDLPango_CreateContext_GivenFontDesc(text_font);
@@ -58,9 +59,7 @@ SDL_Surface *text(const char *s)
w = SDLPango_GetLayoutWidth(pango);
h = SDLPango_GetLayoutHeight(pango);
- tmp = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 0, 0, 0, 0, 0);
- surf = SDL_DisplayFormat(tmp);
- SDL_FreeSurface(tmp);
+ surf = sdl_surface(SDL_SWSURFACE, w, h);
SDLPango_Draw(pango, surf, 0, 0);