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 0a5fbacf4887f8cf496cf45c9fa7121f091f1153 (commit)
from 40ef6e9a083f24ff72acc2a52e0902cb35d5a768 (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/0a5fbacf4887f8cf496cf45c9fa7121f091f…
commit 0a5fbacf4887f8cf496cf45c9fa7121f091f1153
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Feb 19 19:58:06 2012 +0100
backends: Fix backend Flip to respect context rotation.
diff --git a/include/backends/GP_Backend.h b/include/backends/GP_Backend.h
index a50065a..4ddda59 100644
--- a/include/backends/GP_Backend.h
+++ b/include/backends/GP_Backend.h
@@ -42,6 +42,7 @@
#ifndef BACKENDS_GP_BACKEND_H
#define BACKENDS_GP_BACKEND_H
+#include "core/GP_Transform.h"
#include "core/GP_Context.h"
struct GP_Backend;
@@ -127,10 +128,12 @@ static inline void GP_BackendFlip(GP_Backend *backend)
* Calls backend->UpdateRect().
*/
static inline void GP_BackendUpdateRect(GP_Backend *backend,
- GP_Coord x1, GP_Coord y1,
- GP_Coord x2, GP_Coord y2)
+ GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1)
{
- backend->UpdateRect(backend, x1, y1, x2, y2);
+ GP_TRANSFORM_POINT(backend->context, x0, y0);
+ GP_TRANSFORM_POINT(backend->context, x1, y1);
+ backend->UpdateRect(backend, x0, y0, x1, y1);
}
/*
-----------------------------------------------------------------------
Summary of changes:
include/backends/GP_Backend.h | 9 ++++++---
1 files changed, 6 insertions(+), 3 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 2988715637a4e169cf766abe2f777c76600180c7 (commit)
from 30ca8e94204a8e1d24346bedc088197b0e877846 (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/2988715637a4e169cf766abe2f777c766001…
commit 2988715637a4e169cf766abe2f777c76600180c7
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Feb 19 17:28:24 2012 +0100
libs: backends add simplified generic init.
diff --git a/demos/fbshow/fbshow.c b/demos/fbshow/fbshow.c
index 7fe0e36..18554f2 100644
--- a/demos/fbshow/fbshow.c
+++ b/demos/fbshow/fbshow.c
@@ -293,21 +293,8 @@ static void sighandler(int signo)
static void init_backend(const char *backend_opts)
{
- if (!strcmp(backend_opts, "fb")) {
- fprintf(stderr, "Initalizing framebuffer backendn");
- backend = GP_BackendLinuxFBInit("/dev/fb0");
- }
+ backend = GP_BackendInit(backend_opts, stderr);
- if (!strcmp(backend_opts, "SDL")) {
- fprintf(stderr, "Initalizing SDL backendn");
- backend = GP_BackendSDLInit(800, 600, 0, 0);
- }
-
- if (!strcmp(backend_opts, "SDL:FS")) {
- fprintf(stderr, "Initalizing SDL fullscreenn");
- backend = GP_BackendSDLInit(0, 0, 0, GP_SDL_FULLSCREEN);
- }
-
if (backend == NULL) {
fprintf(stderr, "Failed to initalize backend '%s'n", backend_opts);
exit(1);
diff --git a/include/backends/GP_Backend.h b/include/backends/GP_Backend.h
index 2e36bb9..a50065a 100644
--- a/include/backends/GP_Backend.h
+++ b/include/backends/GP_Backend.h
@@ -28,7 +28,7 @@
The GP_Backend is overall structure for API for managing
connection/mmaped memory/... to xserver window/framebuffer/... .
- In contrast to other graphics libraries we do not try to create overall
+ In contrast to other graphics libraries we do not try to create unified
initalization interface that would match specialities for every possible
backend. Rather than that we are trying to create API that is the same
for all backends, once initalization is done.
diff --git a/include/backends/GP_Backends.h b/include/backends/GP_BackendInit.h
similarity index 73%
copy from include/backends/GP_Backends.h
copy to include/backends/GP_BackendInit.h
index 284e2d7..3d34687 100644
--- a/include/backends/GP_Backends.h
+++ b/include/backends/GP_BackendInit.h
@@ -22,22 +22,29 @@
/*
- Catch all header for backends.
+ Simplified backend initalization interface good enough for most of the cases.
*/
-#ifndef BACKENDS_GP_BACKENDS_H
-#define BACKENDS_GP_BACKENDS_H
+#ifndef BACKENDS_GP_BACKEND_INIT_H
+#define BACKENDS_GP_BACKEND_INIT_H
-/*
- * Base backend definitions.
- */
-#include "GP_Backend.h"
+#include "backends/GP_Backend.h"
/*
- * Backends.
+ * Initalize backend by a string.
+ *
+ * The format is:
+ *
+ * "backend_name:backend_params"
+ *
+ * For example "SDL:FS" is string for fullscreen SDL backend.
+ *
+ * Returns initalized backend or NULL in case of failure.
+ *
+ * If initialization has failed or params is NULL and help is not NULL, help
+ * text is printed to a given file.
*/
-#include "GP_LinuxFB.h"
-#include "GP_SDL.h"
+GP_Backend *GP_BackendInit(const char *params, FILE *help);
-#endif /* BACKENDS_GP_BACKENDS_H */
+#endif /* BACKENDS_GP_BACKEND_INIT_H */
diff --git a/include/backends/GP_Backends.h b/include/backends/GP_Backends.h
index 284e2d7..0cd74f6 100644
--- a/include/backends/GP_Backends.h
+++ b/include/backends/GP_Backends.h
@@ -32,12 +32,17 @@
/*
* Base backend definitions.
*/
-#include "GP_Backend.h"
+#include "backends/GP_Backend.h"
/*
* Backends.
*/
-#include "GP_LinuxFB.h"
-#include "GP_SDL.h"
+#include "backends/GP_LinuxFB.h"
+#include "backends/GP_SDL.h"
+
+/*
+ * Simplified backend initalization.
+ */
+#include "backends/GP_BackendInit.h"
#endif /* BACKENDS_GP_BACKENDS_H */
diff --git a/libs/backends/GP_BackendInit.c b/libs/backends/GP_BackendInit.c
new file mode 100644
index 0000000..a544600
--- /dev/null
+++ b/libs/backends/GP_BackendInit.c
@@ -0,0 +1,169 @@
+/*****************************************************************************
+ * 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-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <string.h>
+
+#include "core/GP_Debug.h"
+
+#include "backends/GP_LinuxFB.h"
+#include "backends/GP_SDL.h"
+#include "backends/GP_BackendInit.h"
+
+static void backend_sdl_help(FILE *help, const char *err)
+{
+ if (help == NULL)
+ return;
+
+ if (err != NULL)
+ fprintf(help, "ERROR: %sn", err);
+
+ fprintf(help, "libSDL backendn"
+ "--------------n"
+ "SDL:[FS]n");
+}
+
+static GP_Backend *backend_sdl_init(const char *params, FILE *help)
+{
+ if (params == NULL)
+ return GP_BackendSDLInit(0, 0, 0, 0);
+
+ if (!strcasecmp(params, "FS"))
+ return GP_BackendSDLInit(0, 0, 0, GP_SDL_FULLSCREEN);
+
+ backend_sdl_help(help, "SDL: Invalid parameters");
+
+ return NULL;
+}
+
+static void backend_fb_help(FILE *help, const char *err)
+{
+ if (help == NULL)
+ return;
+
+ if (err != NULL)
+ fprintf(help, "ERROR: %sn", err);
+
+ fprintf(help, "LinuxFB backendn"
+ "--------------n"
+ "FB:[/dev/fbX]n");
+}
+
+static GP_Backend *backend_fb_init(const char *params, FILE *help)
+{
+ const char *fb = "/dev/fb0";
+
+ (void) help;
+
+ if (params != NULL)
+ fb = params;
+
+ return GP_BackendLinuxFBInit(fb);
+}
+
+static const char *backend_names[] = {
+ "SDL", /* libSDL */
+ "FB", /* Linux Framebuffer */
+ NULL,
+};
+
+static GP_Backend *(*backend_inits[])(const char *params, FILE *help) = {
+ backend_sdl_init,
+ backend_fb_init,
+ NULL,
+};
+
+static void (*backend_helps[])(FILE *help, const char *err) = {
+ backend_sdl_help,
+ backend_fb_help,
+ NULL,
+};
+
+static void print_help(FILE *help, char *err)
+{
+ int i;
+
+ if (help == NULL)
+ return;
+
+ if (err != NULL) {
+ fprintf(help, "ERROR: %sn", err);
+ fprintf(help, "n");
+ }
+
+ fprintf(help, "Backends usagen"
+ "--------------nn");
+
+ for (i = 0; backend_helps[i] != NULL; i++) {
+ backend_helps[i](help, NULL);
+ fprintf(help, "n");
+ }
+}
+
+static int get_backend(const char *name)
+{
+ int i;
+
+ for (i = 0; backend_names[i] != 0; i++)
+ if (!strcasecmp(name, backend_names[i]))
+ return i;
+
+ return -1;
+}
+
+static GP_Backend *init_backend(const char *name, const char *params, FILE *help)
+{
+ int i = get_backend(name);
+
+ if (i < 0) {
+ GP_DEBUG(1, "Invalid backend name '%s'", name);
+ print_help(help, "Invalid backend name");
+ return NULL;
+ }
+
+ return backend_inits[i](params, help);
+}
+
+GP_Backend *GP_BackendInit(const char *params, FILE *help)
+{
+ if (params == NULL) {
+ print_help(help, NULL);
+ return NULL;
+ }
+
+ /* parse backend name */
+ int i, len = strlen(params);
+ char buf[len+1], *backend_params = NULL;
+
+ strcpy(buf, params);
+
+ for (i = 0; i < len; i++) {
+ if (buf[i] == ':') {
+ buf[i] = '0';
+ backend_params = buf + i + 1;
+ break;
+ }
+ }
+
+ GP_DEBUG(1, "Have backend name '%s'", buf);
+
+ return init_backend(buf, backend_params, help);
+}
-----------------------------------------------------------------------
Summary of changes:
demos/fbshow/fbshow.c | 15 +--
include/backends/GP_Backend.h | 2 +-
.../backends/GP_BackendInit.h | 40 +++---
include/backends/GP_Backends.h | 11 +-
libs/backends/GP_BackendInit.c | 169 ++++++++++++++++++++
5 files changed, 199 insertions(+), 38 deletions(-)
copy demos/fbshow/cpu_timer.h => include/backends/GP_BackendInit.h (73%)
create mode 100644 libs/backends/GP_BackendInit.c
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 6b71d7fd13d9e9f9bd596d75e07d196c8042205c (commit)
from 188e3a319e7a0f9eb12cfd5d06a0ac7aa996d771 (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/6b71d7fd13d9e9f9bd596d75e07d196c8042…
commit 6b71d7fd13d9e9f9bd596d75e07d196c8042205c
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Feb 12 23:53:06 2012 +0100
tests: A better mixpixel test.
diff --git a/tests/SDL/mixpixeltest.c b/tests/SDL/mixpixeltest.c
index a7ecc66..0f0d179 100644
--- a/tests/SDL/mixpixeltest.c
+++ b/tests/SDL/mixpixeltest.c
@@ -50,9 +50,9 @@ Uint32 timer_callback(__attribute__((unused)) Uint32 interval,
void draw_pixels(void)
{
- unsigned int i;
+ unsigned int i, j, k;
- GP_FillRect(&context, 0, 0, context.w, 50, white_pixel);
+ GP_FillRect(&context, 0, 0, context.w, 120, white_pixel);
unsigned int y = 20;
@@ -62,25 +62,44 @@ void draw_pixels(void)
GP_MixPixel_Raw(&context, i + 20, y + 2, 0, i);
GP_MixPixel_Raw(&context, i + 20, y + 3, 0, i);
GP_MixPixel_Raw(&context, i + 20, y + 4, 0, i);
+
+ GP_MixPixel_Raw(&context, i + 20, y + 5, red_pixel, i);
+ GP_MixPixel_Raw(&context, i + 20, y + 6, red_pixel, i);
+ GP_MixPixel_Raw(&context, i + 20, y + 7, red_pixel, i);
+
+ GP_MixPixel_Raw(&context, i + 20, y + 8, green_pixel, i);
+ GP_MixPixel_Raw(&context, i + 20, y + 9, green_pixel, i);
+ GP_MixPixel_Raw(&context, i + 20, y + 10, green_pixel, i);
+
+ GP_MixPixel_Raw(&context, i + 20, y + 11, blue_pixel, i);
+ GP_MixPixel_Raw(&context, i + 20, y + 12, blue_pixel, i);
+ GP_MixPixel_Raw(&context, i + 20, y + 13, blue_pixel, i);
+
if (i % 16 == 0)
- GP_PutPixel(&context, i + 20, y + 5, 0);
+ GP_PutPixel(&context, i + 20, y + 14, 0);
if (i % 32 == 0)
- GP_PutPixel(&context, i + 20, y + 6, 0);
+ GP_PutPixel(&context, i + 20, y + 15, 0);
if (i % 64 == 0) {
- GP_PutPixel(&context, i + 20, y + 7, 0);
- GP_Print(&context, NULL, i + 20, y + 12,
+ GP_PutPixel(&context, i + 20, y + 16, 0);
+ GP_Print(&context, NULL, i + 20, y + 20,
GP_ALIGN_CENTER | GP_VALIGN_BELOW,
0, 0, "%u", i);
}
if (i % 128 == 0)
- GP_PutPixel(&context, i + 20, y + 8, 0);
+ GP_PutPixel(&context, i + 20, y + 17, 0);
}
-
- y = 60;
+
+ for (i = 0; i < 7; i++)
+ for (j = 0; j < 32; j++)
+ for (k = 0; k < 32; k++)
+ GP_MixPixel_Raw(&context, (225 * i) / 6 + j + 20,
+ y + k + 40, 0, (255 * i) / 6);
+
+ y = 140;
for (i = 0; i <= 256; i++) {
GP_MixPixel_Raw(&context, i + 20, y + 0, white_pixel, i);
@@ -88,24 +107,41 @@ void draw_pixels(void)
GP_MixPixel_Raw(&context, i + 20, y + 2, white_pixel, i);
GP_MixPixel_Raw(&context, i + 20, y + 3, white_pixel, i);
GP_MixPixel_Raw(&context, i + 20, y + 4, white_pixel, i);
+
+ GP_MixPixel_Raw(&context, i + 20, y + 5, red_pixel, i);
+ GP_MixPixel_Raw(&context, i + 20, y + 6, red_pixel, i);
+ GP_MixPixel_Raw(&context, i + 20, y + 7, red_pixel, i);
+
+ GP_MixPixel_Raw(&context, i + 20, y + 8, green_pixel, i);
+ GP_MixPixel_Raw(&context, i + 20, y + 9, green_pixel, i);
+ GP_MixPixel_Raw(&context, i + 20, y + 10, green_pixel, i);
+
+ GP_MixPixel_Raw(&context, i + 20, y + 11, blue_pixel, i);
+ GP_MixPixel_Raw(&context, i + 20, y + 12, blue_pixel, i);
+ GP_MixPixel_Raw(&context, i + 20, y + 13, blue_pixel, i);
if (i % 16 == 0)
- GP_PutPixel(&context, i + 20, y + 5, white_pixel);
+ GP_PutPixel(&context, i + 20, y + 14, white_pixel);
if (i % 32 == 0)
- GP_PutPixel(&context, i + 20, y + 6, white_pixel);
+ GP_PutPixel(&context, i + 20, y + 15, white_pixel);
if (i % 64 == 0) {
- GP_PutPixel(&context, i + 20, y + 7, white_pixel);
- GP_Print(&context, NULL, i + 20, y + 12,
+ GP_PutPixel(&context, i + 20, y + 16, white_pixel);
+ GP_Print(&context, NULL, i + 20, y + 20,
GP_ALIGN_CENTER | GP_VALIGN_BELOW,
white_pixel, 0, "%u", i);
}
if (i % 128 == 0)
- GP_PutPixel(&context, i + 20, y + 8, white_pixel);
+ GP_PutPixel(&context, i + 20, y + 17, white_pixel);
}
-
+
+ for (i = 0; i < 7; i++)
+ for (j = 0; j < 32; j++)
+ for (k = 0; k < 32; k++)
+ GP_MixPixel_Raw(&context, (225 * i) / 6 + j + 20,
+ y + k + 40, white_pixel, (255 * i) / 6);
}
-----------------------------------------------------------------------
Summary of changes:
tests/SDL/mixpixeltest.c | 66 +++++++++++++++++++++++++++++++++++----------
1 files changed, 51 insertions(+), 15 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 188e3a319e7a0f9eb12cfd5d06a0ac7aa996d771 (commit)
from b3b9438ff87b573ce38bde2602edb0b07086560d (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/188e3a319e7a0f9eb12cfd5d06a0ac7aa996…
commit 188e3a319e7a0f9eb12cfd5d06a0ac7aa996d771
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Feb 12 23:49:28 2012 +0100
demos: Particle demo, fix rounding error.
diff --git a/demos/particle/particle_demo.c b/demos/particle/particle_demo.c
index 3be671a..b8af396 100644
--- a/demos/particle/particle_demo.c
+++ b/demos/particle/particle_demo.c
@@ -106,7 +106,7 @@ int main(int argc, char *argv[])
GP_BackendFlip(backend);
struct space *space;
- space = space_create(200, 10<<8, 10<<8, (context->w - 10)<<8, (context->h - 10)<<8);
+ space = space_create(300, 10<<8, 10<<8, (context->w - 10)<<8, (context->h - 10)<<8);
for (;;) {
if (backend->Poll)
@@ -148,7 +148,7 @@ int main(int argc, char *argv[])
}
if (!pause_flag) {
- space_time_tick(space, 2);
+ space_time_tick(space, 3);
space_draw_particles(context, space);
GP_BackendFlip(backend);
}
diff --git a/demos/particle/space.c b/demos/particle/space.c
index a243f97..c029b0b 100644
--- a/demos/particle/space.c
+++ b/demos/particle/space.c
@@ -45,6 +45,8 @@ struct space *space_create(unsigned int particle_count, int min_w, int min_h,
unsigned int i;
+ srandom(time(NULL));
+
for (i = 0; i < particle_count; i++) {
new->particles[i].x = random() % (max_w - min_w) + min_w;
new->particles[i].y = random() % (max_h - min_h) + min_h;
@@ -100,7 +102,7 @@ static void gravity_forces(struct space *space, int time)
int dist_x = DIST_X(space, i, j);
int dist_y = DIST_Y(space, i, j);
- int dist_squared = (SQUARE(dist_x>>8) + SQUARE(dist_y>>8)) + (1<<8);
+ int dist_squared = (SQUARE((dist_x + (1<<7))>>8) + SQUARE((dist_y + (1<<7))>>8)) + (1<<8);
int dist = ((int)sqrt(dist_squared))<<4;
if (dist < (1<<9))
-----------------------------------------------------------------------
Summary of changes:
demos/particle/particle_demo.c | 4 ++--
demos/particle/space.c | 4 +++-
2 files changed, 5 insertions(+), 3 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.")