This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via ff6f39694f9b44497c6ec7f4d3b9c27ab180510a (commit)
via 3f9f0c9b1e899fb28031ea3f11671f9bce3c1caa (commit)
from 5109c64bfb2ac61e8fe89114c3843c0782e22543 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/ff6f39694f9b44497c6ec7f4d3b9c27ab180…
commit ff6f39694f9b44497c6ec7f4d3b9c27ab180510a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Jan 30 13:34:20 2013 +0100
spiv: A few fixes for -zf (fixed zoom mode).
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 6059199..f681b1a 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -528,15 +528,10 @@ static void show_image(struct loader_params *params, const char *path)
}
}
-static void zoom_offset_horiz(struct loader_params *params, int size)
+static void set_zoom_offset(struct loader_params *params, int dx, int dy)
{
- params->zoom_x_offset += size;
- show_image(params, NULL);
-}
-
-static void zoom_offset_vert(struct loader_params *params, int size)
-{
- params->zoom_y_offset += size;
+ params->zoom_x_offset += dx;
+ params->zoom_y_offset += dy;
show_image(params, NULL);
}
@@ -863,7 +858,6 @@ int main(int argc, char *argv[])
GP_Fill(context, black_pixel);
GP_BackendFlip(backend);
-
struct image_list *list = image_list_create((const char**)argv + optind);
params.show_progress_once = 1;
@@ -892,6 +886,12 @@ int main(int argc, char *argv[])
if (ev.val.val < 0)
goto prev;
break;
+ case GP_EV_REL_POS:
+ if (GP_EventGetKey(&ev, GP_BTN_LEFT))
+ set_zoom_offset(¶ms,
+ ev.val.rel.rx,
+ ev.val.rel.ry);
+ break;
}
break;
case GP_EV_KEY:
@@ -992,12 +992,12 @@ int main(int argc, char *argv[])
next:
case GP_KEY_RIGHT:
if (shift_flag) {
- zoom_offset_horiz(¶ms, 10);
+ set_zoom_offset(¶ms, 10, 0);
break;
}
case GP_KEY_UP:
if (shift_flag) {
- zoom_offset_vert(¶ms, -10);
+ set_zoom_offset(¶ms, 0, -10);
break;
}
case GP_KEY_SPACE:
@@ -1007,12 +1007,12 @@ int main(int argc, char *argv[])
prev:
case GP_KEY_LEFT:
if (shift_flag) {
- zoom_offset_horiz(¶ms, -10);
+ set_zoom_offset(¶ms, -10, 0);
break;
}
case GP_KEY_DOWN:
if (shift_flag) {
- zoom_offset_vert(¶ms, 10);
+ set_zoom_offset(¶ms, 0, 10);
break;
}
case GP_KEY_BACKSPACE:
@@ -1047,9 +1047,11 @@ int main(int argc, char *argv[])
resize_backend(¶ms, 9, shift_flag);
break;
case GP_KEY_DOT:
+ params.show_progress_once = 1;
zoom_mul(¶ms, 1.5);
break;
case GP_KEY_COMMA:
+ params.show_progress_once = 1;
zoom_mul(¶ms, 1/1.5);
break;
}
@@ -1062,6 +1064,7 @@ int main(int argc, char *argv[])
GP_BackendResizeAck(backend);
GP_Fill(backend->context, 0);
params.show_progress_once = 1;
+ GP_EventSetScreenSize(ev.val.sys.w, ev.val.sys.h);
show_image(¶ms, NULL);
break;
case GP_EV_SYS_QUIT:
http://repo.or.cz/w/gfxprim.git/commit/3f9f0c9b1e899fb28031ea3f11671f9bce3c…
commit 3f9f0c9b1e899fb28031ea3f11671f9bce3c1caa
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Jan 30 13:32:34 2013 +0100
spiv: image_cache: Store at least one image.
This fixes memory leaks and crashes when
image is too big to be stored in image
cache maximal size.
diff --git a/demos/spiv/image_cache.c b/demos/spiv/image_cache.c
index 00712c9..496489e 100644
--- a/demos/spiv/image_cache.c
+++ b/demos/spiv/image_cache.c
@@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -229,8 +229,12 @@ int image_cache_put(struct image_cache *self, GP_Context *ctx, const char *path,
size = image_size2(ctx, path);
- if (assert_size(self, size))
- return 1;
+ /*
+ * We try to create room for the image. If this fails we add the image
+ * anyway because we need to store it while we are showing it (and it
+ * will be removed from cache by next image for sure).
+ */
+ assert_size(self, size);
struct image *img = malloc(sizeof(struct image) + strlen(path) + 1);
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/image_cache.c | 10 +++++++---
demos/spiv/spiv.c | 31 +++++++++++++++++--------------
2 files changed, 24 insertions(+), 17 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via 5109c64bfb2ac61e8fe89114c3843c0782e22543 (commit)
from 1a93c45d484a05a1e5e8ca1cf1a0046e10d3398d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/5109c64bfb2ac61e8fe89114c3843c0782e2…
commit 5109c64bfb2ac61e8fe89114c3843c0782e22543
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Jan 29 22:43:35 2013 +0100
demos: Start bogoman.
diff --git a/demos/Makefile b/demos/Makefile
index ec4885b..1943f91 100644
--- a/demos/Makefile
+++ b/demos/Makefile
@@ -1,3 +1,3 @@
TOPDIR=..
-SUBDIRS=grinder spiv particle ttf2img c_simple
+SUBDIRS=grinder spiv particle ttf2img c_simple bogoman
include $(TOPDIR)/post.mk
diff --git a/demos/bogoman/Makefile b/demos/bogoman/Makefile
new file mode 100644
index 0000000..e90de8e
--- /dev/null
+++ b/demos/bogoman/Makefile
@@ -0,0 +1,15 @@
+TOPDIR=../..
+
+CSOURCES=$(shell echo *.c)
+
+INCLUDE=
+LDFLAGS+=-L$(TOPDIR)/build/
+LDLIBS+=`$(TOPDIR)/gfxprim-config --libs --libs-backends`
+
+APPS=bogoman
+
+bogoman: bogoman_map.o bogoman_debug.o bogoman_loader.o bogoman_render.o
+
+include $(TOPDIR)/pre.mk
+include $(TOPDIR)/app.mk
+include $(TOPDIR)/post.mk
diff --git a/demos/bogoman/bogoman.c b/demos/bogoman/bogoman.c
new file mode 100644
index 0000000..f6f969b
--- /dev/null
+++ b/demos/bogoman/bogoman.c
@@ -0,0 +1,149 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <GP.h>
+
+#include "bogoman_debug.h"
+#include "bogoman_map.h"
+#include "bogoman_loader.h"
+#include "bogoman_render.h"
+
+#define ELEM_SIZE 33
+
+static void save_png(struct bogoman_map *map, unsigned int elem_size,
+ const char *filename)
+{
+ GP_Context *ctx;
+ unsigned int rx, ry;
+
+ rx = elem_size * map->w;
+ ry = elem_size * map->h;
+
+ ctx = GP_ContextAlloc(rx, ry, GP_PIXEL_RGB888);
+
+ if (ctx == NULL)
+ return;
+
+ struct bogoman_render render = {
+ .map = map,
+ .map_x_offset = 0,
+ .map_y_offset = 0,
+ .ctx = ctx,
+ .map_elem_size = elem_size,
+ };
+
+ bogoman_render(&render, BOGOMAN_RENDER_ALL);
+
+ GP_SavePNG(ctx, filename, NULL);
+ GP_ContextFree(ctx);
+}
+
+static struct GP_Backend *backend;
+
+static void event_loop(struct bogoman_map *map)
+{
+ while (GP_EventsQueued()) {
+ GP_Event ev;
+
+ GP_EventGet(&ev);
+
+ switch (ev.type) {
+ case GP_EV_KEY:
+ if (ev.code != GP_EV_KEY_DOWN)
+ break;
+
+ switch (ev.val.val) {
+ case GP_KEY_ESC:
+ GP_BackendExit(backend);
+ exit(0);
+ break;
+ case GP_KEY_RIGHT:
+ bogoman_map_player_move(map, 1, 0);
+ break;
+ case GP_KEY_LEFT:
+ bogoman_map_player_move(map, -1, 0);
+ break;
+ case GP_KEY_UP:
+ bogoman_map_player_move(map, 0, -1);
+ break;
+ case GP_KEY_DOWN:
+ bogoman_map_player_move(map, 0, 1);
+ break;
+ }
+ break;
+ }
+ }
+
+
+}
+
+int main(int argc, char *argv[])
+{
+ struct bogoman_map *map;
+
+ bogoman_set_dbg_level(10);
+
+ if (argc > 1)
+ map = bogoman_load(argv[1]);
+ else
+ map = bogoman_load("map.txt");
+
+ if (map == NULL) {
+ fprintf(stderr, "Failed to load map");
+ return 1;
+ }
+
+ bogoman_map_dump(map);
+
+ unsigned int cw = map->w * ELEM_SIZE;
+ unsigned int ch = map->h * ELEM_SIZE;
+
+ backend = GP_BackendX11Init(NULL, 0, 0, cw, ch, "Bogoman", 0);
+
+ if (backend == NULL) {
+ fprintf(stderr, "Failed to initialize backend");
+ return 1;
+ }
+
+ struct bogoman_render render = {
+ .map = map,
+ .map_x_offset = 0,
+ .map_y_offset = 0,
+ .ctx = backend->context,
+ .map_elem_size = ELEM_SIZE,
+ };
+
+ bogoman_render(&render, BOGOMAN_RENDER_ALL);
+ GP_BackendFlip(backend);
+
+ for (;;) {
+ GP_BackendPoll(backend);
+ event_loop(map);
+
+ bogoman_render(&render, BOGOMAN_RENDER_DIRTY);
+ GP_BackendFlip(backend);
+
+ usleep(100000);
+ }
+
+ return 0;
+}
diff --git a/demos/bogoman/bogoman_common.h b/demos/bogoman/bogoman_common.h
new file mode 100644
index 0000000..39367a5
--- /dev/null
+++ b/demos/bogoman/bogoman_common.h
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#ifndef __BOGOMAN_COMMON_H__
+#define __BOGOMAN_COMMON_H__
+
+#define SWAP(a, b) do { + typeof(a) tmp = b; + b = a; + a = tmp; +} while (0)
+
+#define SIGN(a) ({ + typeof(a) tmp = a; + (tmp < 0) ? -1 : (tmp > 0) ? 1 : 0; +})
+
+#endif /* __BOGOMAN_COMMON_H__ */
diff --git a/demos/bogoman/bogoman_debug.c b/demos/bogoman/bogoman_debug.c
new file mode 100644
index 0000000..d5ee213
--- /dev/null
+++ b/demos/bogoman/bogoman_debug.c
@@ -0,0 +1,51 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <stdarg.h>
+#include <stdio.h>
+
+#include "bogoman_debug.h"
+
+static unsigned int dbg_level = 0;
+
+void bogoman_dbg_print(unsigned int level, const char *file, const char *fn,
+ unsigned int line, const char *fmt, ...)
+{
+ if (level > dbg_level)
+ return;
+
+ if (level == 0)
+ fprintf(stderr, "WARNING: %s:%s:%int", file, fn, line);
+ else
+ fprintf(stderr, "DEBUG %i:%s:%s:%i:nt", level, file, fn, line);
+
+ va_list va;
+
+ va_start(va, fmt);
+ vfprintf(stderr, fmt, va);
+ va_end(va);
+}
+
+void bogoman_set_dbg_level(unsigned int level)
+{
+ dbg_level = level;
+}
diff --git a/demos/bogoman/bogoman_debug.h b/demos/bogoman/bogoman_debug.h
new file mode 100644
index 0000000..b84729a
--- /dev/null
+++ b/demos/bogoman/bogoman_debug.h
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#ifndef __BOGOMAN_DEBUG_H__
+#define __BOGOMAN_DEBUG_H__
+
+#define DEBUG(level, ...) + bogoman_dbg_print(level, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
+
+#define WARN(...) + bogoman_dbg_print(0, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
+
+
+void bogoman_dbg_print(unsigned int level, const char *file, const char *fn,
+ unsigned int line, const char *fmt, ...)
+ __attribute__ ((format (printf, 5, 6)));
+
+void bogoman_set_dbg_level(unsigned int level);
+
+#endif /* __BOGOMAN_DEBUG_H__ */
diff --git a/demos/bogoman/bogoman_loader.c b/demos/bogoman/bogoman_loader.c
new file mode 100644
index 0000000..e1f3eed
--- /dev/null
+++ b/demos/bogoman/bogoman_loader.c
@@ -0,0 +1,220 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "bogoman_debug.h"
+#include "bogoman_common.h"
+#include "bogoman_loader.h"
+
+/*
+ * Counts map w and h by reading number of lines and maximal size of line till
+ * first empty line or EOF.
+ */
+static void get_map_info(FILE *f, unsigned int *w, unsigned int *h)
+{
+ unsigned int curw = 0;
+ int ch;
+
+ *w = 0;
+ *h = 0;
+
+ while ((ch = getc(f)) != EOF) {
+ switch (ch) {
+ case 'n':
+ if (*w < curw)
+ *w = curw;
+
+ if (curw == 0) {
+ rewind(f);
+ return;
+ }
+
+ curw = 0;
+ (*h)++;
+ break;
+ default:
+ curw++;
+ }
+ }
+
+ rewind(f);
+}
+
+static enum bogoman_map_elem_id id_from_char(const char ch)
+{
+ switch (ch) {
+ case ' ':
+ return BOGOMAN_NONE;
+ case '@':
+ return BOGOMAN_PLAYER;
+ case '-':
+ case '|':
+ case '+':
+ case '/':
+ case '\':
+ return BOGOMAN_WALL;
+ case '$':
+ return BOGOMAN_DIAMOND;
+ case 'M':
+ return BOGOMAN_MOVEABLE;
+ case 'E':
+ return BOGOMAN_EDIBLE;
+ }
+
+ WARN("Unknown map character '%c'", ch);
+
+ return BOGOMAN_NONE;
+}
+
+#define LINE_MAX 256
+
+struct line {
+ unsigned int len;
+ unsigned char line[LINE_MAX];
+};
+
+static void get_line(FILE *f, struct line *l)
+{
+ int ch;
+
+ l->len = 0;
+
+ while ((ch = getc(f)) != EOF) {
+ switch (ch) {
+ case 'n':
+ return;
+ default:
+ l->line[l->len++] = id_from_char(ch);
+ break;
+ }
+ }
+}
+
+static void load_map(FILE *f, struct bogoman_map *map)
+{
+ struct line line_a, line_b;
+ struct line *line_cur, *line_next;
+ unsigned int y = 0;
+ unsigned int player_found = 0;
+
+ line_cur = &line_a;
+ line_next = &line_b;
+
+ get_line(f, line_cur);
+ get_line(f, line_next);
+
+ while (line_cur->len != 0) {
+ unsigned int x;
+
+ for (x = 0; x < line_cur->len; x++) {
+ struct bogoman_map_elem *elem;
+
+ elem = bogoman_get_map_elem(map, x, y);
+
+ elem->id = line_cur->line[x];
+
+ switch (elem->id) {
+ /* Compute wall continuations */
+ case BOGOMAN_WALL:
+ if (x > 0 &&
+ line_cur->line[x - 1] == BOGOMAN_WALL)
+ elem->flags |= BOGOMAN_WALL_LEFT;
+
+ if (x + 1 < line_cur->len &&
+ line_cur->line[x + 1] == BOGOMAN_WALL)
+ elem->flags |= BOGOMAN_WALL_RIGHT;
+
+ if (y > 0 &&
+ bogoman_map_is_id(map, x, y-1, BOGOMAN_WALL))
+ elem->flags |= BOGOMAN_WALL_UP;
+
+ if (x < line_next->len &&
+ line_next->line[x] == BOGOMAN_WALL)
+ elem->flags |= BOGOMAN_WALL_DOWN;
+
+ break;
+ case BOGOMAN_PLAYER:
+ if (player_found)
+ WARN("Duplicated player at %ux%u previously at %ux%un",
+ x, y, map->player_x, map->player_y);
+
+ map->player_x = x;
+ map->player_y = y;
+
+ player_found = 1;
+ break;
+ case BOGOMAN_DIAMOND:
+ map->diamonds_total++;
+ break;
+ default:
+ break;
+ }
+ }
+
+ SWAP(line_cur, line_next);
+ get_line(f, line_next);
+ y++;
+ }
+
+ if (!player_found)
+ WARN("No player found in mapn");
+}
+
+struct bogoman_map *bogoman_load(const char *path)
+{
+ FILE *f = fopen(path, "r");
+
+ if (f == NULL)
+ return NULL;
+
+ unsigned int w, h;
+
+ get_map_info(f, &w, &h);
+
+ DEBUG(1, "Have map %ux%un", w, h);
+
+ struct bogoman_map *map;
+ size_t map_size;
+
+ map_size = sizeof(struct bogoman_map) +
+ w * h * sizeof(struct bogoman_map_elem);
+
+ map = malloc(map_size);
+
+ if (map == NULL)
+ goto err0;
+
+ memset(map, 0, map_size);
+
+ map->w = w;
+ map->h = h;
+
+ load_map(f, map);
+
+ return map;
+err0:
+ fclose(f);
+ return NULL;
+}
diff --git a/demos/bogoman/bogoman_loader.h b/demos/bogoman/bogoman_loader.h
new file mode 100644
index 0000000..027efd4
--- /dev/null
+++ b/demos/bogoman/bogoman_loader.h
@@ -0,0 +1,30 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#ifndef __BOGOMAN_LOADER_H__
+#define __BOGOMAN_LOADER_H__
+
+#include "bogoman_map.h"
+
+struct bogoman_map *bogoman_load(const char *path);
+
+#endif /* __BOGOMAN_LOADER_H__ */
diff --git a/demos/bogoman/bogoman_map.c b/demos/bogoman/bogoman_map.c
new file mode 100644
index 0000000..2f62c64
--- /dev/null
+++ b/demos/bogoman/bogoman_map.c
@@ -0,0 +1,245 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <stdio.h>
+
+#include "bogoman_common.h"
+#include "bogoman_debug.h"
+
+#include "bogoman_map.h"
+
+static void print_wall(struct bogoman_map_elem *elem)
+{
+ switch (elem->flags) {
+ case BOGOMAN_WALL_LEFT:
+ case BOGOMAN_WALL_RIGHT:
+ case BOGOMAN_WALL_LEFT | BOGOMAN_WALL_RIGHT:
+ printf("-");
+ break;
+ case BOGOMAN_WALL_UP:
+ case BOGOMAN_WALL_DOWN:
+ case BOGOMAN_WALL_UP | BOGOMAN_WALL_DOWN:
+ printf("|");
+ break;
+ case BOGOMAN_WALL_UP | BOGOMAN_WALL_RIGHT:
+ case BOGOMAN_WALL_DOWN | BOGOMAN_WALL_LEFT:
+ printf("\");
+ break;
+ case BOGOMAN_WALL_UP | BOGOMAN_WALL_LEFT:
+ case BOGOMAN_WALL_DOWN | BOGOMAN_WALL_RIGHT:
+ printf("/");
+ break;
+ default:
+ printf("+");
+ break;
+ }
+}
+
+void bogoman_map_dump(struct bogoman_map *map)
+{
+ unsigned int x, y;
+
+ for (y = 0; y < map->h; y++) {
+ for (x = 0; x < map->w; x++) {
+ struct bogoman_map_elem *elem;
+
+ elem = bogoman_get_map_elem(map, x, y);
+
+ switch (elem->id) {
+ case BOGOMAN_NONE:
+ printf(" ");
+ break;
+ case BOGOMAN_PLAYER:
+ printf("@");
+ break;
+ case BOGOMAN_DIAMOND:
+ printf("$");
+ break;
+ case BOGOMAN_MOVEABLE:
+ printf("M");
+ break;
+ case BOGOMAN_EDIBLE:
+ printf("E");
+ break;
+ case BOGOMAN_WALL:
+ print_wall(elem);
+ break;
+ }
+ }
+
+ printf("n");
+ }
+
+ printf("Player at %ux%u diamonds total %un",
+ map->player_x, map->player_y, map->diamonds_total);
+}
+
+static void copy_block(struct bogoman_map *map,
+ int dst_x, int dst_y,
+ int src_x, int src_y)
+{
+ struct bogoman_map_elem *src, *dst;
+
+ src = bogoman_get_map_elem(map, src_x, src_y);
+ dst = bogoman_get_map_elem(map, dst_x, dst_y);
+
+ *dst = *src;
+
+ dst->dirty = 1;
+}
+
+static void clear_block(struct bogoman_map *map,
+ unsigned int x, unsigned int y)
+{
+ struct bogoman_map_elem *block;
+
+ block = bogoman_get_map_elem(map, x, y);
+
+ block->id = BOGOMAN_NONE;
+ block->dirty = 1;
+}
+
+/*
+ * Removes diamond when player has stepped on it.
+ */
+static void move_get_diamond(struct bogoman_map *map,
+ unsigned int x, unsigned int y)
+{
+ clear_block(map, x, y);
+
+ map->player_diamonds++;
+
+ DEBUG(1, "Diamond taken, yet to collect %un",
+ map->diamonds_total - map->player_diamonds);
+}
+
+/*
+ * Moves block to empty space, only one of dx or dy can be set
+ * to nonzero value and the value could only be 1 or -1.
+ */
+static int try_move_block(struct bogoman_map *map,
+ int x, int y, int dx, int dy)
+{
+ struct bogoman_map_elem *elem = bogoman_get_map_elem(map, x, y);
+
+ int new_x = (int)x + dx;
+ int new_y = (int)y + dy;
+
+ if (bogoman_coord_in_map(map, new_x, new_y)) {
+
+ if (!bogoman_is_empty(map, new_x, new_y))
+ return 0;
+
+ copy_block(map, new_x, new_y, x, y);
+ } else {
+ DEBUG(1, "Block moved out of screen %ux%u -> %ix%i",
+ x, y, new_x, new_y);
+ }
+
+ clear_block(map, x, y);
+ return 1;
+}
+
+void bogoman_map_player_move(struct bogoman_map *map, int x, int y)
+{
+ if (x != 0 && y != 0) {
+ WARN("Player can move only in one directionn");
+ return;
+ }
+
+ int new_x = map->player_x + x;
+ int new_y = map->player_y + y;
+
+ if (new_x < 0 || new_x >= (int)map->w ||
+ new_y < 0 || new_y >= (int)map->h) {
+ WARN("Player can move only in screen got %ix%in",
+ new_x, new_y);
+ return;
+ }
+
+ int player_x = map->player_x;
+ int player_y = map->player_y;
+
+ DEBUG(1, "Player %ix%i -> %ix%in", player_x, player_y, new_x, new_y);
+
+ while (player_x != new_x || player_y != new_y) {
+ int dx = SIGN(new_x - player_x);
+ int dy = SIGN(new_y - player_y);
+
+ int px = map->player_x + dx;
+ int py = map->player_y + dy;
+
+ switch (bogoman_get_map_elem_id(map, px, py)) {
+ case BOGOMAN_NONE:
+ break;
+ case BOGOMAN_DIAMOND:
+ move_get_diamond(map, px, py);
+ break;
+ case BOGOMAN_MOVEABLE:
+ if (!try_move_block(map, px, py, dx, dy))
+ goto finish_move;
+ break;
+ case BOGOMAN_EDIBLE:
+ clear_block(map, px, py);
+ break;
+ default:
+ goto finish_move;
+ }
+
+ player_x = px;
+ player_y = py;
+ }
+
+ /* Update the map */
+ struct bogoman_map_elem *player, *space;
+
+finish_move:
+
+ player = bogoman_get_map_elem(map, map->player_x, map->player_y);
+ space = bogoman_get_map_elem(map, player_x, player_y);
+
+ *player = map->under_player;
+ map->under_player = *space;
+ space->id = BOGOMAN_PLAYER;
+
+ map->player_x = player_x;
+ map->player_y = player_y;
+
+ /* turn on dirty flags */
+ player->dirty = 1;
+ space->dirty = 1;
+}
+
+void bogoman_map_timer_tick(struct bogoman_map *map)
+{
+ unsigned int x, y;
+
+ for (y = 0; y < map->h; y++) {
+ for (x = 0; x < map->w; x++) {
+ struct bogoman_map_elem *elem;
+
+ elem = bogoman_get_map_elem(map, x, y);
+
+ //TODO
+ }
+ }
+}
diff --git a/demos/bogoman/bogoman_map.h b/demos/bogoman/bogoman_map.h
new file mode 100644
index 0000000..b178dcf
--- /dev/null
+++ b/demos/bogoman/bogoman_map.h
@@ -0,0 +1,124 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#ifndef __BOGOMAN_MAP_H__
+#define __BOGOMAN_MAP_H__
+
+enum bogoman_map_elem_id {
+ /* empty walkable space */
+ BOGOMAN_NONE = 0x00,
+ /* player */
+ BOGOMAN_PLAYER = 0x01,
+ /* wall */
+ BOGOMAN_WALL = 0x02,
+ /* diamons to collect */
+ BOGOMAN_DIAMOND = 0x03,
+ /* like a wall but player moveable */
+ BOGOMAN_MOVEABLE = 0x04,
+ /* like a diamond but doesn't counts to points */
+ BOGOMAN_EDIBLE = 0x05,
+
+ BOGOMAN_MAX = BOGOMAN_EDIBLE,
+};
+
+/*
+ * Wall cal be applied as bitflags. Each bitflag determines wall continuation
+ * in particular direction.
+ */
+enum bogoman_wall_flags {
+ BOGOMAN_WALL_LEFT = 0x01,
+ BOGOMAN_WALL_RIGHT = 0x02,
+ BOGOMAN_WALL_UP = 0x04,
+ BOGOMAN_WALL_DOWN = 0x08,
+};
+
+struct bogoman_map_elem {
+ unsigned char id;
+ unsigned char flags;
+
+ /* the element changed, needs to be redrawn */
+ unsigned char dirty:1;
+};
+
+struct bogoman_map {
+ unsigned int w;
+ unsigned int h;
+
+ unsigned int diamonds_total;
+
+ /* player data */
+ unsigned int player_x;
+ unsigned int player_y;
+ unsigned int player_diamonds;
+ /* used to save element player steps on */
+ struct bogoman_map_elem under_player;
+
+ struct bogoman_map_elem map[];
+};
+
+static inline struct bogoman_map_elem *
+ bogoman_get_map_elem(struct bogoman_map *map,
+ unsigned int x, unsigned int y)
+{
+ return &(map->map[x + y * map->w]);
+}
+
+static inline enum bogoman_map_elem_id
+ bogoman_get_map_elem_id(struct bogoman_map *map,
+ unsigned int x, unsigned int y)
+{
+ struct bogoman_map_elem *elem = bogoman_get_map_elem(map, x, y);
+
+ return elem->id;
+}
+
+static inline int bogoman_map_is_id(struct bogoman_map *map,
+ unsigned int x, unsigned int y,
+ enum bogoman_map_elem_id id)
+{
+ struct bogoman_map_elem *elem = bogoman_get_map_elem(map, x, y);
+
+ return elem->id == id;
+}
+
+static inline int bogoman_coord_in_map(struct bogoman_map *map, int x, int y)
+{
+ return (x >= 0) && ((unsigned)x < map->w) &&
+ (y >= 0) && ((unsigned)y < map->w);
+}
+
+static inline int bogoman_is_empty(struct bogoman_map *map,
+ unsigned int x, unsigned int y)
+{
+ return bogoman_get_map_elem_id(map, x, y) == BOGOMAN_NONE;
+}
+
+void bogoman_map_player_move(struct bogoman_map *map, int x, int y);
+
+void bogoman_map_timer_tick(struct bogoman_map *map);
+
+/*
+ * Dumps map into the stdout.
+ */
+void bogoman_map_dump(struct bogoman_map *map);
+
+#endif /* __BOGOMAN_MAP_H__ */
diff --git a/demos/bogoman/bogoman_render.c b/demos/bogoman/bogoman_render.c
new file mode 100644
index 0000000..43a09bd
--- /dev/null
+++ b/demos/bogoman/bogoman_render.c
@@ -0,0 +1,198 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <GP.h>
+
+#include "bogoman_map.h"
+#include "bogoman_debug.h"
+
+#include "bogoman_render.h"
+
+struct render_colors {
+ /* global background */
+ GP_Pixel bg;
+
+ /* player color */
+ GP_Pixel player;
+
+ /* frames around things */
+ GP_Pixel frames;
+
+ /* diamod color */
+ GP_Pixel diamond;
+
+ /* wall color */
+ GP_Pixel wall;
+
+ /* moveable color */
+ GP_Pixel moveable;
+
+ /* edible color */
+ GP_Pixel edible;
+};
+
+static struct render_colors colors;
+
+static void init_colors(GP_Context *ctx, struct render_colors *colors)
+{
+ colors->bg = GP_RGBToContextPixel(0xee, 0xee, 0xee, ctx);
+ colors->player = GP_RGBToContextPixel(0x00, 0xee, 0x00, ctx);
+ colors->frames = GP_RGBToContextPixel(0x00, 0x00, 0x00, ctx);
+ colors->diamond = GP_RGBToContextPixel(0x00, 0x00, 0xee, ctx);
+ colors->wall = GP_RGBToContextPixel(0x66, 0x66, 0x66, ctx);
+ colors->moveable = GP_RGBToContextPixel(0xff, 0xff, 0x60, ctx);
+ colors->edible = GP_RGBToContextPixel(0xff, 0x7f, 0x50, ctx);
+}
+
+static void render_none(struct bogoman_render *render,
+ unsigned int x, unsigned int y,
+ struct bogoman_map_elem *elem)
+{
+ unsigned int w = render->map_elem_size;
+
+ (void) elem;
+
+ GP_FillRectXYWH(render->ctx, x, y, w, w, colors.bg);
+}
+
+static void render_player(struct bogoman_render *render,
+ unsigned int x, unsigned int y,
+ struct bogoman_map_elem *elem)
+{
+ unsigned int w = render->map_elem_size;
+
+ (void) elem;
+
+ GP_FillRectXYWH(render->ctx, x, y, w, w, colors.bg);
+ GP_FillCircle(render->ctx, x + w/2, y + w/2, w/2 - 1, colors.player);
+ GP_Circle(render->ctx, x + w/2, y + w/2, w/2 - 1, colors.frames);
+}
+
+static void render_wall(struct bogoman_render *render,
+ unsigned int x, unsigned int y,
+ struct bogoman_map_elem *elem)
+{
+ unsigned int w = render->map_elem_size;
+
+ GP_FillRectXYWH(render->ctx, x, y, w, w, colors.wall);
+
+ if (!(elem->flags & BOGOMAN_WALL_LEFT))
+ GP_VLineXYH(render->ctx, x, y, w, colors.frames);
+
+ if (!(elem->flags & BOGOMAN_WALL_RIGHT))
+ GP_VLineXYH(render->ctx, x + w - 1, y, w, colors.frames);
+
+ if (!(elem->flags & BOGOMAN_WALL_UP))
+ GP_HLineXYW(render->ctx, x, y, w, colors.frames);
+
+ if (!(elem->flags & BOGOMAN_WALL_DOWN))
+ GP_HLineXYW(render->ctx, x, y + w - 1, w, colors.frames);
+}
+
+static void render_diamond(struct bogoman_render *render,
+ unsigned int x, unsigned int y,
+ struct bogoman_map_elem *elem)
+{
+ unsigned int w = render->map_elem_size;
+
+ GP_FillRectXYWH(render->ctx, x, y, w, w, colors.bg);
+
+ GP_FillTetragon(render->ctx, x + w/2, y, x + w - 1, y + w/2,
+ x + w/2, y + w - 1, x, y + w/2, colors.diamond);
+
+ GP_Tetragon(render->ctx, x + w/2, y, x + w - 1, y + w/2,
+ x + w/2, y + w - 1, x, y + w/2, colors.frames);
+}
+
+static void render_moveable(struct bogoman_render *render,
+ unsigned int x, unsigned int y,
+ struct bogoman_map_elem *elem)
+{
+ unsigned int w = render->map_elem_size;
+
+ GP_FillRectXYWH(render->ctx, x, y, w, w, colors.bg);
+
+ GP_FillRectXYWH(render->ctx, x + 1, y + 1, w - 2, w - 2, colors.moveable);
+ GP_RectXYWH(render->ctx, x + 1, y + 1, w - 2, w - 2, colors.frames);
+}
+
+static void render_edible(struct bogoman_render *render,
+ unsigned int x, unsigned int y,
+ struct bogoman_map_elem *elem)
+{
+ unsigned int w = render->map_elem_size;
+
+ GP_FillRectXYWH(render->ctx, x, y, w, w, colors.bg);
+
+ GP_FillRectXYWH(render->ctx, x + 1, y + 1, w - 2, w - 2, colors.edible);
+}
+
+static void (*renders[])(struct bogoman_render *render,
+ unsigned int x, unsigned int y,
+ struct bogoman_map_elem *elem) =
+{
+ render_none,
+ render_player,
+ render_wall,
+ render_diamond,
+ render_moveable,
+ render_edible,
+};
+
+static void render_elem(struct bogoman_render *render,
+ unsigned int x, unsigned int y,
+ int flags)
+{
+ struct bogoman_map_elem *elem;
+ unsigned int cx, cy;
+
+ elem = bogoman_get_map_elem(render->map, x, y);
+
+ if (elem->dirty) {
+ elem->dirty = 0;
+ } else {
+ if (flags & BOGOMAN_RENDER_DIRTY)
+ return;
+ }
+
+ cx = (x - render->map_x_offset) * render->map_elem_size;
+ cy = (y - render->map_y_offset) * render->map_elem_size;
+
+ if (elem->id > BOGOMAN_MAX)
+ WARN("Invalid elem ID %u at %ux%un", elem->id, x, y);
+ else
+ renders[elem->id](render, cx, cy, elem);
+}
+
+void bogoman_render(struct bogoman_render *render, int flags)
+{
+ unsigned int x, y;
+
+ //TODO: Hack
+ init_colors(render->ctx, &colors);
+
+ for (y = render->map_x_offset; y < render->map->h; y++) {
+ for (x = render->map_x_offset; x < render->map->w; x++) {
+ render_elem(render, x, y, flags);
+ }
+ }
+}
diff --git a/demos/bogoman/bogoman_render.h b/demos/bogoman/bogoman_render.h
new file mode 100644
index 0000000..72c6a48
--- /dev/null
+++ b/demos/bogoman/bogoman_render.h
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#ifndef __BOGOMAN_RENDER_H__
+#define __BOGOMAN_RENDER_H__
+
+struct bogoman_map;
+struct GP_Context;
+
+struct bogoman_render {
+ /* both in map elements */
+ unsigned int map_x_offset;
+ unsigned int map_y_offset;
+
+ /* current map */
+ struct bogoman_map *map;
+
+ /* context to be used for rendering */
+ struct GP_Context *ctx;
+
+ /* elem size in pixels */
+ unsigned int map_elem_size;
+};
+
+enum bogonam_render_flags {
+ /* renders all map elements, not only dirty ones */
+ BOGOMAN_RENDER_ALL = 0x00,
+ BOGOMAN_RENDER_DIRTY = 0x01,
+};
+
+void bogoman_render(struct bogoman_render *render, int flags);
+
+#endif /* __BOGOMAN_RENDER_H__ */
diff --git a/demos/bogoman/levels/01-warmup.txt b/demos/bogoman/levels/01-warmup.txt
new file mode 100644
index 0000000..f0cc034
--- /dev/null
+++ b/demos/bogoman/levels/01-warmup.txt
@@ -0,0 +1,7 @@
+/-------+| M$$$M |
+|M$M$M$M|
+|$M$@$M$|
+|M$M$M$M|
+| M$$$M |
+-------/
diff --git a/demos/bogoman/map.txt b/demos/bogoman/map.txt
new file mode 100644
index 0000000..337d07c
--- /dev/null
+++ b/demos/bogoman/map.txt
@@ -0,0 +1,8 @@
++---------+ +----+
+| | | | | $ |
+| +----+ |
+| E @ |
++--M----------------+
+| M |
+| |$|$|$| |
++----------+-+-+-+--+
diff --git a/demos/bogoman/runtest.sh b/demos/bogoman/runtest.sh
new file mode 100755
index 0000000..0794707
--- /dev/null
+++ b/demos/bogoman/runtest.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+#
+# Run dynamically linked test.
+#
+
+PROG="$1"
+shift
+
+LD_LIBRARY_PATH=../../build/ ./$PROG "$@"
-----------------------------------------------------------------------
Summary of changes:
demos/Makefile | 2 +-
demos/{spiv => bogoman}/Makefile | 6 +-
demos/bogoman/bogoman.c | 149 ++++++++++++
.../GP_Filter.h => demos/bogoman/bogoman_common.h | 26 +-
.../bogoman/bogoman_debug.c | 44 ++--
.../bogoman/bogoman_debug.h | 32 +--
demos/bogoman/bogoman_loader.c | 220 ++++++++++++++++++
.../histogram.h => bogoman/bogoman_loader.h} | 12 +-
demos/bogoman/bogoman_map.c | 245 ++++++++++++++++++++
demos/bogoman/bogoman_map.h | 124 ++++++++++
demos/bogoman/bogoman_render.c | 198 ++++++++++++++++
.../bogoman/bogoman_render.h | 53 +++--
demos/bogoman/levels/01-warmup.txt | 7 +
demos/bogoman/map.txt | 8 +
demos/{c_simple => bogoman}/runtest.sh | 0
15 files changed, 1036 insertions(+), 90 deletions(-)
copy demos/{spiv => bogoman}/Makefile (52%)
create mode 100644 demos/bogoman/bogoman.c
copy include/filters/GP_Filter.h => demos/bogoman/bogoman_common.h (80%)
copy libs/filters/GP_Cubic.gen.c.t => demos/bogoman/bogoman_debug.c (74%)
copy libs/filters/GP_Cubic.gen.c.t => demos/bogoman/bogoman_debug.h (74%)
create mode 100644 demos/bogoman/bogoman_loader.c
copy demos/{grinder/histogram.h => bogoman/bogoman_loader.h} (87%)
create mode 100644 demos/bogoman/bogoman_map.c
create mode 100644 demos/bogoman/bogoman_map.h
create mode 100644 demos/bogoman/bogoman_render.c
copy libs/filters/GP_Cubic.gen.c.t => demos/bogoman/bogoman_render.h (73%)
create mode 100644 demos/bogoman/levels/01-warmup.txt
create mode 100644 demos/bogoman/map.txt
copy demos/{c_simple => bogoman}/runtest.sh (100%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via b1fbf0820773aebe6c2c0d79d5ea71417e3ec754 (commit)
from 6b41a423d6fe40825bbd57f9900df5c767d30e11 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/b1fbf0820773aebe6c2c0d79d5ea71417e3e…
commit b1fbf0820773aebe6c2c0d79d5ea71417e3ec754
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jan 27 15:10:29 2013 +0100
backends: SDL: Add resize event notification.
diff --git a/libs/backends/GP_SDL.c b/libs/backends/GP_SDL.c
index d3afcca..951511f 100644
--- a/libs/backends/GP_SDL.c
+++ b/libs/backends/GP_SDL.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -30,6 +30,7 @@
#ifdef HAVE_LIBSDL
#include "input/GP_InputDriverSDL.h"
+#include "input/GP_Input.h"
#include "GP_Backend.h"
#include "GP_SDL.h"
@@ -149,6 +150,9 @@ static int sdl_set_attributes(struct GP_Backend *self __attribute__((unused)),
if (w != 0 && h != 0) {
sdl_surface = SDL_SetVideoMode(w, h, 0, sdl_flags);
context_from_surface(&context, sdl_surface);
+
+ /* Send event that resize was finished */
+ GP_EventPushResize(w, h, NULL);
}
SDL_mutexV(mutex);
-----------------------------------------------------------------------
Summary of changes:
libs/backends/GP_SDL.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via 6b41a423d6fe40825bbd57f9900df5c767d30e11 (commit)
from 28f97c18a478cfe9e9144c3b9c151c1f784887d1 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/6b41a423d6fe40825bbd57f9900df5c767d3…
commit 6b41a423d6fe40825bbd57f9900df5c767d30e11
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jan 27 14:02:29 2013 +0100
filters: Add missing GPL headers.
diff --git a/libs/filters/GP_Cubic.gen.c.t b/libs/filters/GP_Cubic.gen.c.t
index 4d66517..e5f5cf4 100644
--- a/libs/filters/GP_Cubic.gen.c.t
+++ b/libs/filters/GP_Cubic.gen.c.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "base.c.t"
{% block descr %}Table for fixed point cubic coeficients for A=0.5{% endblock %}
diff --git a/libs/filters/GP_FloydSteinberg.gen.c.t b/libs/filters/GP_FloydSteinberg.gen.c.t
index df22cfb..e10a326 100644
--- a/libs/filters/GP_FloydSteinberg.gen.c.t
+++ b/libs/filters/GP_FloydSteinberg.gen.c.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "common.c.t"
{% block descr %}Floyd Steinberg dithering RGB888 -> any pixel{% endblock %}
diff --git a/libs/filters/GP_GaussianNoise.gen.c.t b/libs/filters/GP_GaussianNoise.gen.c.t
index 1d8c8a6..bc37bdf 100644
--- a/libs/filters/GP_GaussianNoise.gen.c.t
+++ b/libs/filters/GP_GaussianNoise.gen.c.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "filter.c.t"
{% block descr %}Gaussian Noise{% endblock %}
diff --git a/libs/filters/GP_HilbertPeano.gen.c.t b/libs/filters/GP_HilbertPeano.gen.c.t
index 2157580..f718105 100644
--- a/libs/filters/GP_HilbertPeano.gen.c.t
+++ b/libs/filters/GP_HilbertPeano.gen.c.t
@@ -1,3 +1,26 @@
+
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "base.c.t"
{% block descr %}Hilbert Peano dithering RGB888 -> any pixel{% endblock %}
diff --git a/libs/filters/GP_Histogram.gen.c.t b/libs/filters/GP_Histogram.gen.c.t
index cd519d6..a71a644 100644
--- a/libs/filters/GP_Histogram.gen.c.t
+++ b/libs/filters/GP_Histogram.gen.c.t
@@ -1,8 +1,28 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "filter.stats.c.t"
-%% block descr
-Histogram filter -- Compute image histogram.
-%% endblock
+{% block descr %}Histogram filter -- Compute image histogram{% endblock %}
%% block body
diff --git a/libs/filters/GP_MirrorV.gen.c.t b/libs/filters/GP_MirrorV.gen.c.t
index 03f4bb6..b2d4b86 100644
--- a/libs/filters/GP_MirrorV.gen.c.t
+++ b/libs/filters/GP_MirrorV.gen.c.t
@@ -1,8 +1,28 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "base.c.t"
-%% block descr
-Vertical Mirror alogorithm
-%% endblock
+{% block descr %}Vertical Mirror alogorithm{% endblock %}
%% block body
@@ -51,4 +71,5 @@ int GP_FilterMirrorV_Raw(const GP_Context *src, GP_Context *dst,
GP_FN_RET_PER_BPP_CONTEXT(GP_MirrorV_Raw, src, src, dst, callback);
return 1;
}
+
%% endblock body
diff --git a/libs/filters/GP_ResizeCubic.gen.c.t b/libs/filters/GP_ResizeCubic.gen.c.t
index d8400d5..a515a2d 100644
--- a/libs/filters/GP_ResizeCubic.gen.c.t
+++ b/libs/filters/GP_ResizeCubic.gen.c.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "filter.c.t"
{% block descr %}Cubic resampling{% endblock %}
diff --git a/libs/filters/GP_ResizeNN.gen.c.t b/libs/filters/GP_ResizeNN.gen.c.t
index cf364a0..65d12bb 100644
--- a/libs/filters/GP_ResizeNN.gen.c.t
+++ b/libs/filters/GP_ResizeNN.gen.c.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "filter.c.t"
{% block descr %}Nearest Neighbour resampling{% endblock %}
diff --git a/libs/filters/GP_Rotate.gen.c.t b/libs/filters/GP_Rotate.gen.c.t
index ee6e6a4..709a60d 100644
--- a/libs/filters/GP_Rotate.gen.c.t
+++ b/libs/filters/GP_Rotate.gen.c.t
@@ -1,8 +1,28 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "base.c.t"
-%% block descr
-Vertical Mirror alogorithm
-%% endblock
+{% block descr %}Vertical Mirror alogorithm{% endblock %}
%% block body
-----------------------------------------------------------------------
Summary of changes:
libs/filters/GP_Cubic.gen.c.t | 22 ++++++++++++++++++++++
libs/filters/GP_FloydSteinberg.gen.c.t | 22 ++++++++++++++++++++++
libs/filters/GP_GaussianNoise.gen.c.t | 22 ++++++++++++++++++++++
libs/filters/GP_HilbertPeano.gen.c.t | 23 +++++++++++++++++++++++
libs/filters/GP_Histogram.gen.c.t | 26 +++++++++++++++++++++++---
libs/filters/GP_MirrorV.gen.c.t | 27 ++++++++++++++++++++++++---
libs/filters/GP_ResizeCubic.gen.c.t | 22 ++++++++++++++++++++++
libs/filters/GP_ResizeNN.gen.c.t | 22 ++++++++++++++++++++++
libs/filters/GP_Rotate.gen.c.t | 26 +++++++++++++++++++++++---
9 files changed, 203 insertions(+), 9 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via 28f97c18a478cfe9e9144c3b9c151c1f784887d1 (commit)
via 52a9dbdc6a7f20fabdcbe29d4ed576624e11351d (commit)
from ccc06e628a27ed616222e32e32f0378644e0aae0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/28f97c18a478cfe9e9144c3b9c151c1f7848…
commit 28f97c18a478cfe9e9144c3b9c151c1f784887d1
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Jan 26 16:52:03 2013 +0100
tests: framework: New python runtests script.
Now the json result files are collected correctly.
diff --git a/tests/core/runtest.sh b/tests/core/runtest.sh
deleted file mode 100755
index 7e20739..0000000
--- a/tests/core/runtest.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-
-#
-# By default the glibc __libc_message() writes to /dev/tty before calling
-# the abort(). Exporting this macro makes it to use stderr instead.
-#
-# The main usage of the function are malloc assertions, so this makes us catch
-# the malloc error message by catching stderr output.
-#
-export LIBC_FATAL_STDERR_=1
-
-LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./WritePixel_testsuite.gen "$@"
-LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Context "$@"
-LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./GetPutPixel.gen "$@"
diff --git a/tests/core/test_list.txt b/tests/core/test_list.txt
new file mode 100644
index 0000000..458f6e4
--- /dev/null
+++ b/tests/core/test_list.txt
@@ -0,0 +1,4 @@
+# Core testsuite
+WritePixel_testsuite.gen
+Context
+GetPutPixel.gen
diff --git a/tests/gfx/runtest.sh b/tests/gfx/runtest.sh
deleted file mode 100755
index 2dc6ddf..0000000
--- a/tests/gfx/runtest.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-
-#
-# By default the glibc __libc_message() writes to /dev/tty before calling
-# the abort(). Exporting this macro makes it to use stderr instead.
-#
-# The main usage of the function are malloc assertions, so this makes us catch
-# the malloc error message by catching stderr output.
-#
-export LIBC_FATAL_STDERR_=1
-
-#LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./gfx_benchmark "$@"
-LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./HLine "$@"
-LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./VLine "$@"
-LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Line "$@"
-LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Circle "$@"
-LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./FillCircle "$@"
-LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Ellipse "$@"
-LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./CircleSeg "$@"
-LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Polygon "$@"
-
-LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./PutPixelAA "$@"
-LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./HLineAA "$@"
-LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./LineAA "$@"
diff --git a/tests/gfx/test_list.txt b/tests/gfx/test_list.txt
new file mode 100644
index 0000000..0368b0f
--- /dev/null
+++ b/tests/gfx/test_list.txt
@@ -0,0 +1,14 @@
+# GFX test list
+
+HLine
+VLine
+Line
+Circle
+FillCircle
+Ellipse
+CircleSeg
+Polygon
+
+PutPixelAA
+HLineAA
+LineAA
diff --git a/tests/loaders/runtest.sh b/tests/loaders/runtest.sh
deleted file mode 100755
index e92c0c4..0000000
--- a/tests/loaders/runtest.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh
-
-#
-# By default the glibc __libc_message() writes to /dev/tty before calling
-# the abort(). Exporting this macro makes it to use stderr instead.
-#
-# The main usage of the function are malloc assertions, so this makes us catch
-# the malloc error message by catching stderr output.
-#
-export LIBC_FATAL_STDERR_=1
-
-LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./loaders_suite "$@"
-LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./PNG "$@"
diff --git a/tests/loaders/test_list.txt b/tests/loaders/test_list.txt
new file mode 100644
index 0000000..f4a8fe1
--- /dev/null
+++ b/tests/loaders/test_list.txt
@@ -0,0 +1,3 @@
+# Loaders testsuite
+loaders_suite
+PNG
diff --git a/tests/runtests.py b/tests/runtests.py
new file mode 100755
index 0000000..9f3704e
--- /dev/null
+++ b/tests/runtests.py
@@ -0,0 +1,117 @@
+#!/usr/bin/env python
+#
+# This is a simple glue script to run the tests and collect the results
+#
+
+#
+# We expect simple structure i.e. the tests_dir contains directories with
+# tests, each directory that contains tests has test_list.txt with a list of
+# tests to run. The structure is then mirrored in the results_dir filled with
+# json logs.
+#
+
+import os
+import datetime
+
+#
+# Relative path to root directory containing tests
+#
+tests_dir='.'
+
+#
+# Results directory prefix
+#
+results_dir='results'
+
+#
+# Relative path to the directory with GP libraries to run tests against
+#
+build_dir='../../build'
+
+#
+# By default the glibc __libc_message() writes to /dev/tty before calling
+# the abort(). Exporting this macro makes it to use stderr instead.
+#
+# The main usage of the function are malloc assertions, so this makes us catch
+# the malloc error message by catching stderr output.
+#
+runline_prep='export LIBC_FATAL_STDERR_=1;'
+
+#
+# Relative path, from the current directory, to the framework preload library.
+#
+framework_lib='framework/libtst_preload.so'
+
+debug = 0
+
+def globpath(path):
+ return os.getcwd() + '/' + path
+
+#
+# Reads test_list.txt test file and executes tests one after another
+#
+def run_test(resdir, tstdir, runtest):
+ f = open(runtest, 'r')
+ lines = f.readlines()
+ f.close()
+
+ for line in lines:
+ # ignore comments
+ if (line[0] == '#'):
+ continue
+ # and blanks
+ if (line.isspace()):
+ continue
+
+ line = line.strip();
+
+ #
+ # This is a little hairy but what it does is to constructs correct
+ # paths to preload and dynamic libraries and runs the test.
+ #
+ runline = runline_prep + ' '
+ runline += 'export LD_PRELOAD="' + globpath(framework_lib) + '"; '
+ runline += 'export LD_LIBRARY_PATH="' + globpath(build_dir) + '"; '
+ runline += 'cd ' + tstdir + ' && ./' + line + ' -o "' + globpath(resdir) + '"'
+
+ if debug >= 2:
+ print(" LINE: %s" % runline)
+
+ os.system(runline)
+
+#
+# Discovers tests in directories.
+#
+def run_tests(resdir, testsdir):
+
+ if debug >= 1:
+ print('Looking for tests in "%s"' % testsdir)
+
+ for root, dirs, _ in os.walk(testsdir):
+ for name in dirs:
+
+ path = root + '/' + name
+
+ if debug >= 2:
+ print('Looking into dir "%s"' % path)
+
+ runtest = path + '/test_list.txt'
+
+ if (os.access(runtest, os.R_OK)):
+ # Create result directory
+ curresdir = resdir + '/' + name
+ os.mkdir(curresdir)
+ # Run tests
+ run_test(curresdir, path, runtest)
+
+def main():
+ now = datetime.datetime.now()
+ resdir = '%s_%i-%02i-%02i_%02i-%02i-%02i' % (results_dir, now.year, now.month,
+ now.day, now.hour, now.minute, now.second)
+ print('Creating result directory "%s"' % resdir)
+ os.mkdir(resdir)
+
+ run_tests(resdir, tests_dir)
+
+if __name__ == '__main__':
+ main()
diff --git a/tests/runtests.sh b/tests/runtests.sh
deleted file mode 100755
index f15668b..0000000
--- a/tests/runtests.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-DIRS="core loaders gfx"
-
-for i in $DIRS; do
- cd $i
- ./runtest.sh $@
- cd ..
-done
http://repo.or.cz/w/gfxprim.git/commit/52a9dbdc6a7f20fabdcbe29d4ed576624e11…
commit 52a9dbdc6a7f20fabdcbe29d4ed576624e11351d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Jan 26 16:40:27 2013 +0100
tests: framework: Add log output dir option.
diff --git a/tests/framework/tst_main.c b/tests/framework/tst_main.c
index d1c6474..a45b2c6 100644
--- a/tests/framework/tst_main.c
+++ b/tests/framework/tst_main.c
@@ -30,6 +30,7 @@ extern const struct tst_suite tst_suite;
/* defined in tst_suite.c */
extern int tst_suite_verbose;
+extern const char *tst_log_dir;
void print_help(void)
{
@@ -38,6 +39,7 @@ void print_help(void)
fprintf(stderr, "-l list all testsn");
fprintf(stderr, "-t name runs single test by namen");
fprintf(stderr, "-v turns on verbose moden");
+ fprintf(stderr, "-o test log output dirn");
fprintf(stderr, "without any option, all tests are executedn");
}
@@ -45,7 +47,7 @@ int main(int argc, char *argv[])
{
int opt;
- while ((opt = getopt(argc, argv, "hlt:v")) != -1) {
+ while ((opt = getopt(argc, argv, "hlo:t:v")) != -1) {
switch (opt) {
case 'l':
tst_list_suite(&tst_suite);
@@ -62,6 +64,9 @@ int main(int argc, char *argv[])
case 'v':
tst_suite_verbose = 1;
break;
+ case 'o':
+ tst_log_dir = optarg;
+ break;
default:
print_help();
return 1;
diff --git a/tests/framework/tst_suite.c b/tests/framework/tst_suite.c
index 924be43..2bb8455 100644
--- a/tests/framework/tst_suite.c
+++ b/tests/framework/tst_suite.c
@@ -36,6 +36,7 @@
#define NAME_PADD 35
int tst_suite_verbose = 0;
+const char *tst_log_dir = NULL;
static void test_job_report(const struct tst_job *job)
{
@@ -127,7 +128,8 @@ static int run_test(const struct tst_test *test, FILE *json)
* child and parent and the lines in the resulting
* file would be repeated several times.
*/
- fflush(json);
+ if (json)
+ fflush(json);
tst_job_run(&job);
tst_job_wait(&job);
@@ -135,7 +137,8 @@ static int run_test(const struct tst_test *test, FILE *json)
/* report result into stdout */
test_job_report(&job);
- tst_log_append(&job, json);
+ if (json)
+ tst_log_append(&job, json);
/* Free the test message store */
tst_msg_clear(&job.store);
@@ -152,8 +155,14 @@ void tst_run_suite(const struct tst_suite *suite, const char *tst_name)
fprintf(stderr, "Running e[1;37m%se[0mnn", suite->suite_name);
- //TODO:
- FILE *json = tst_log_open(suite, "log.json");
+ FILE *json = NULL;
+
+ if (tst_log_dir) {
+ char buf[512];
+ snprintf(buf, sizeof(buf), "%s/%s.json",
+ tst_log_dir, suite->suite_name);
+ json = tst_log_open(suite, buf);
+ }
for (i = 0; suite->tests[i].name != NULL; i++) {
if (tst_name == NULL || !strcmp(tst_name, suite->tests[i].name)) {
@@ -165,7 +174,8 @@ void tst_run_suite(const struct tst_suite *suite, const char *tst_name)
}
}
- tst_log_close(json);
+ if (json)
+ tst_log_close(json);
float percents;
-----------------------------------------------------------------------
Summary of changes:
tests/core/runtest.sh | 14 -----
tests/core/test_list.txt | 4 ++
tests/framework/tst_main.c | 7 ++-
tests/framework/tst_suite.c | 20 ++++++--
tests/gfx/runtest.sh | 24 ---------
tests/gfx/test_list.txt | 14 +++++
tests/loaders/runtest.sh | 13 -----
tests/loaders/test_list.txt | 3 +
tests/runtests.py | 117 +++++++++++++++++++++++++++++++++++++++++++
tests/runtests.sh | 9 ---
10 files changed, 159 insertions(+), 66 deletions(-)
delete mode 100755 tests/core/runtest.sh
create mode 100644 tests/core/test_list.txt
delete mode 100755 tests/gfx/runtest.sh
create mode 100644 tests/gfx/test_list.txt
delete mode 100755 tests/loaders/runtest.sh
create mode 100644 tests/loaders/test_list.txt
create mode 100755 tests/runtests.py
delete mode 100755 tests/runtests.sh
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")