Gfxprim
Threads by month
- ----- 2026 -----
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
February 2012
- 2 participants
- 48 discussions
[repo.or.cz] gfxprim.git branch master updated: 40ef6e9a083f24ff72acc2a52e0902cb35d5a768
by metan 19 Feb '12
by metan 19 Feb '12
19 Feb '12
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 40ef6e9a083f24ff72acc2a52e0902cb35d5a768 (commit)
via c1d7712882e1eebc596ebba1dbf597deb66a105a (commit)
from 95b8a1898cd06074a268d53022229875e689ed7b (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/40ef6e9a083f24ff72acc2a52e0902cb35d5…
commit 40ef6e9a083f24ff72acc2a52e0902cb35d5a768
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Feb 19 19:41:43 2012 +0100
backends: Add caption parameter.
diff --git a/demos/fbshow/fbshow.c b/demos/fbshow/fbshow.c
index 18554f2..96fdf47 100644
--- a/demos/fbshow/fbshow.c
+++ b/demos/fbshow/fbshow.c
@@ -172,7 +172,7 @@ static void *image_loader(void *ptr)
if (rat < 1) {
cpu_timer_start(&timer, "Blur");
callback.priv = "Blurring Image";
- if (GP_FilterGaussianBlur(img, img, 0.5/rat, 0.5/rat, &callback) == NULL)
+ if (GP_FilterGaussianBlur(img, img, 0.3/rat, 0.3/rat, &callback) == NULL)
return NULL;
cpu_timer_stop(&timer);
}
@@ -293,7 +293,7 @@ static void sighandler(int signo)
static void init_backend(const char *backend_opts)
{
- backend = GP_BackendInit(backend_opts, stderr);
+ backend = GP_BackendInit(backend_opts, "FBshow", stderr);
if (backend == NULL) {
fprintf(stderr, "Failed to initalize backend '%s'n", backend_opts);
diff --git a/demos/particle/particle_demo.c b/demos/particle/particle_demo.c
index b258956..82c8e74 100644
--- a/demos/particle/particle_demo.c
+++ b/demos/particle/particle_demo.c
@@ -51,20 +51,7 @@ 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");
- }
-
- 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);
- }
+ backend = GP_BackendInit(backend_opts, "Particles", stderr);
if (backend == NULL) {
fprintf(stderr, "Failed to initalize backend '%s'n", backend_opts);
@@ -74,7 +61,7 @@ static void init_backend(const char *backend_opts)
int main(int argc, char *argv[])
{
- const char *backend_opts = "fb";
+ const char *backend_opts = "SDL";
int opt;
int pause_flag = 0;
diff --git a/include/backends/GP_BackendInit.h b/include/backends/GP_BackendInit.h
index 3d34687..6fcc997 100644
--- a/include/backends/GP_BackendInit.h
+++ b/include/backends/GP_BackendInit.h
@@ -39,12 +39,16 @@
* "backend_name:backend_params"
*
* For example "SDL:FS" is string for fullscreen SDL backend.
+ *
+ * The caption parameter may, or may not be used. For example in windowed
+ * enviroment caption will become caption of a window. When running on
+ * framebuffer it may be ignored completly.
*
* 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.
*/
-GP_Backend *GP_BackendInit(const char *params, FILE *help);
+GP_Backend *GP_BackendInit(const char *params, const char *caption, FILE *help);
#endif /* BACKENDS_GP_BACKEND_INIT_H */
diff --git a/include/backends/GP_SDL.h b/include/backends/GP_SDL.h
index bd553b9..514f65d 100644
--- a/include/backends/GP_SDL.h
+++ b/include/backends/GP_SDL.h
@@ -24,7 +24,7 @@
#define BACKENDS_GP_SDL_H
#include <stdint.h>
-#include "GP_Backend.h"
+#include "backends/GP_Backend.h"
enum GP_BackendSDLFlags {
GP_SDL_FULLSCREEN = 0x01,
@@ -57,6 +57,7 @@ enum GP_BackendSDLFlags {
* Upon failure, or if SDL wasn't compiled in, NULL is returned.
*/
GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h,
- uint8_t bpp, uint8_t flags);
+ uint8_t bpp, uint8_t flags,
+ const char *caption);
#endif /* BACKENDS_GP_SDL_H */
diff --git a/include/input/GP_Event.h b/include/input/GP_Event.h
index db4166c..8f57588 100644
--- a/include/input/GP_Event.h
+++ b/include/input/GP_Event.h
@@ -250,7 +250,7 @@ typedef struct GP_Event {
/* event */
uint16_t type;
uint32_t code;
- union GP_EventValue val;
+ union GP_EventValue val;
/* input device id */
uint32_t dev_id;
diff --git a/libs/backends/GP_BackendInit.c b/libs/backends/GP_BackendInit.c
index c8224de..7b80816 100644
--- a/libs/backends/GP_BackendInit.c
+++ b/libs/backends/GP_BackendInit.c
@@ -67,10 +67,11 @@ static int sdl_params_to_flags(const char *param, GP_Size *w, GP_Size *h,
return 1;
}
-static GP_Backend *backend_sdl_init(const char *params, FILE *help)
+static GP_Backend *backend_sdl_init(const char *params, const char *caption,
+ FILE *help)
{
if (params == NULL)
- return GP_BackendSDLInit(0, 0, 0, 0);
+ return GP_BackendSDLInit(0, 0, 0, 0, caption);
GP_Size w = 0, h = 0;
uint8_t flags = 0;
@@ -90,7 +91,7 @@ static GP_Backend *backend_sdl_init(const char *params, FILE *help)
}
} while (*(s++) != '0');
- return GP_BackendSDLInit(w, h, 0, flags);
+ return GP_BackendSDLInit(w, h, 0, flags, caption);
}
static void backend_fb_help(FILE *help, const char *err)
@@ -106,11 +107,13 @@ static void backend_fb_help(FILE *help, const char *err)
"FB:[/dev/fbX]n");
}
-static GP_Backend *backend_fb_init(const char *params, FILE *help)
+static GP_Backend *backend_fb_init(const char *params, const char *caption,
+ FILE *help)
{
const char *fb = "/dev/fb0";
(void) help;
+ (void) caption;
if (params != NULL)
fb = params;
@@ -124,7 +127,7 @@ static const char *backend_names[] = {
NULL,
};
-static GP_Backend *(*backend_inits[])(const char *params, FILE *help) = {
+static GP_Backend *(*backend_inits[])(const char *, const char *, FILE *) = {
backend_sdl_init,
backend_fb_init,
NULL,
@@ -168,7 +171,8 @@ static int get_backend(const char *name)
return -1;
}
-static GP_Backend *init_backend(const char *name, const char *params, FILE *help)
+static GP_Backend *init_backend(const char *name, const char *params,
+ const char *caption, FILE *help)
{
int i = get_backend(name);
@@ -178,10 +182,10 @@ static GP_Backend *init_backend(const char *name, const char *params, FILE *help
return NULL;
}
- return backend_inits[i](params, help);
+ return backend_inits[i](params, caption, help);
}
-GP_Backend *GP_BackendInit(const char *params, FILE *help)
+GP_Backend *GP_BackendInit(const char *params, const char *caption, FILE *help)
{
if (params == NULL) {
print_help(help, NULL);
@@ -204,5 +208,5 @@ GP_Backend *GP_BackendInit(const char *params, FILE *help)
GP_DEBUG(1, "Have backend name '%s'", buf);
- return init_backend(buf, backend_params, help);
+ return init_backend(buf, backend_params, caption, help);
}
diff --git a/libs/backends/GP_SDL.c b/libs/backends/GP_SDL.c
index feabc9b..b88b3b5 100644
--- a/libs/backends/GP_SDL.c
+++ b/libs/backends/GP_SDL.c
@@ -134,7 +134,8 @@ int context_from_surface(GP_Context *context, SDL_Surface *surf)
return 0;
}
-GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h, uint8_t bpp, uint8_t flags)
+GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h, uint8_t bpp, uint8_t flags,
+ const char *caption)
{
/* SDL not yet initalized */
if (backend.context == NULL) {
@@ -152,7 +153,10 @@ GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h, uint8_t bpp, uint8_t flags)
sdl_flags |= SDL_RESIZABLE;
sdl_surface = SDL_SetVideoMode(w, h, bpp, sdl_flags);
-
+
+ if (caption != NULL)
+ SDL_WM_SetCaption(caption, caption);
+
if (sdl_surface == NULL) {
GP_DEBUG(1, "ERROR: SDL_SetVideoMode: %s", SDL_GetError());
SDL_Quit();
@@ -175,7 +179,8 @@ GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h, uint8_t bpp, uint8_t flags)
#else
-GP_Backend *GP_BackendSDLInit(void)
+GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h, uint8_t bpp, uint8_t flags,
+ const char *caption)
{
return NULL;
}
http://repo.or.cz/w/gfxprim.git/commit/c1d7712882e1eebc596ebba1dbf597deb66a…
commit c1d7712882e1eebc596ebba1dbf597deb66a105a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Feb 19 19:38:53 2012 +0100
demos: particle: fix typo.
diff --git a/demos/particle/space.c b/demos/particle/space.c
index 030f2e4..928798a 100644
--- a/demos/particle/space.c
+++ b/demos/particle/space.c
@@ -131,7 +131,7 @@ static void central_gravity(struct space *space, int time)
unsigned int i;
for (i = 0; i < space->particle_count; i++) {
- space->particles[i].vy += space->gax * time;
+ space->particles[i].vx += space->gax * time;
space->particles[i].vy += space->gay * time;
}
}
-----------------------------------------------------------------------
Summary of changes:
demos/fbshow/fbshow.c | 4 ++--
demos/particle/particle_demo.c | 17 ++---------------
demos/particle/space.c | 2 +-
include/backends/GP_BackendInit.h | 6 +++++-
include/backends/GP_SDL.h | 5 +++--
include/input/GP_Event.h | 2 +-
libs/backends/GP_BackendInit.c | 22 +++++++++++++---------
libs/backends/GP_SDL.c | 11 ++++++++---
8 files changed, 35 insertions(+), 34 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.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 95b8a1898cd06074a268d53022229875e689ed7b
by metan 19 Feb '12
by metan 19 Feb '12
19 Feb '12
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 95b8a1898cd06074a268d53022229875e689ed7b (commit)
from 2988715637a4e169cf766abe2f777c76600180c7 (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/95b8a1898cd06074a268d53022229875e689…
commit 95b8a1898cd06074a268d53022229875e689ed7b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Feb 19 18:45:10 2012 +0100
backends: Add more opts for SDL Backend Init.
diff --git a/libs/backends/GP_BackendInit.c b/libs/backends/GP_BackendInit.c
index a544600..c8224de 100644
--- a/libs/backends/GP_BackendInit.c
+++ b/libs/backends/GP_BackendInit.c
@@ -38,20 +38,59 @@ static void backend_sdl_help(FILE *help, const char *err)
fprintf(help, "libSDL backendn"
"--------------n"
- "SDL:[FS]n");
+ "SDL:[FS]:[WxH]n"
+ " FS - Full Screen moden"
+ " WxH - Display Sizen");
+}
+
+static int sdl_params_to_flags(const char *param, GP_Size *w, GP_Size *h,
+ uint8_t *flags, FILE *help)
+{
+ if (!strcasecmp(param, "FS")) {
+ *flags |= GP_SDL_FULLSCREEN;
+ return 0;
+ }
+
+ /*
+ * Accepts only string with format "intxint" or "intXint"
+ */
+ int sw, sh;
+ unsigned int n;
+
+ if (sscanf(param, "%i%*[xX]%i%n", &sw, &sh, &n) == 2 && n == strlen(param)) {
+ *w = sw;
+ *h = sh;
+ return 0;
+ }
+
+ backend_sdl_help(help, "SDL: Invalid parameters");
+ return 1;
}
static GP_Backend *backend_sdl_init(const char *params, FILE *help)
{
if (params == NULL)
return GP_BackendSDLInit(0, 0, 0, 0);
+
+ GP_Size w = 0, h = 0;
+ uint8_t flags = 0;
+
+ const char *s = params;
+
+ do {
+ switch (*s) {
+ case ':':
+ s = '0';
+ case '0':
+ if (sdl_params_to_flags(params, &w, &h, &flags, help))
+ return NULL;
+ s++;
+ params = s;
+ break;
+ }
+ } while (*(s++) != '0');
- if (!strcasecmp(params, "FS"))
- return GP_BackendSDLInit(0, 0, 0, GP_SDL_FULLSCREEN);
-
- backend_sdl_help(help, "SDL: Invalid parameters");
-
- return NULL;
+ return GP_BackendSDLInit(w, h, 0, flags);
}
static void backend_fb_help(FILE *help, const char *err)
-----------------------------------------------------------------------
Summary of changes:
libs/backends/GP_BackendInit.c | 51 +++++++++++++++++++++++++++++++++++----
1 files changed, 45 insertions(+), 6 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.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 2988715637a4e169cf766abe2f777c76600180c7
by metan 19 Feb '12
by metan 19 Feb '12
19 Feb '12
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.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 30ca8e94204a8e1d24346bedc088197b0e877846
by metan 19 Feb '12
by metan 19 Feb '12
19 Feb '12
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 30ca8e94204a8e1d24346bedc088197b0e877846 (commit)
via 8fd80e09adcbee684f691159ea96bb852c5d17a8 (commit)
from b2930cfac623e072342fd297ad3b82e28e2aba83 (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/30ca8e94204a8e1d24346bedc088197b0e87…
commit 30ca8e94204a8e1d24346bedc088197b0e877846
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Feb 19 15:35:35 2012 +0100
demos: fbshow add resampling option, SDL backend is default.
diff --git a/demos/fbshow/fbshow.c b/demos/fbshow/fbshow.c
index 83bed96..7fe0e36 100644
--- a/demos/fbshow/fbshow.c
+++ b/demos/fbshow/fbshow.c
@@ -22,7 +22,7 @@
/*
- Simple framebuffer image viewer.
+ Simple image viewer.
*/
@@ -47,6 +47,7 @@ static GP_Context *context = NULL;
static int abort_flag = 0;
static int rotate = 0;
static int show_progress = 0;
+static int resampling_method = GP_INTERP_LINEAR_LF_INT;
static int image_loader_callback(GP_ProgressCallback *self)
{
@@ -166,17 +167,20 @@ static void *image_loader(void *ptr)
GP_Context *ret;
-/* if (rat < 1) {
- cpu_timer_start(&timer, "Blur");
- callback.priv = "Blurring Image";
- if (GP_FilterGaussianBlur(img, img, 0.5/rat, 0.5/rat, &callback) == NULL)
- return NULL;
- cpu_timer_stop(&timer);
- } */
+ /* Do low pass filter */
+ if (resampling_method != GP_INTERP_LINEAR_LF_INT) {
+ if (rat < 1) {
+ cpu_timer_start(&timer, "Blur");
+ callback.priv = "Blurring Image";
+ if (GP_FilterGaussianBlur(img, img, 0.5/rat, 0.5/rat, &callback) == NULL)
+ return NULL;
+ cpu_timer_stop(&timer);
+ }
+ }
cpu_timer_start(&timer, "Resampling");
callback.priv = "Resampling Image";
- ret = GP_FilterResize(img, NULL, GP_INTERP_LINEAR_LF_INT, img->w * rat, img->h * rat, &callback);
+ ret = GP_FilterResize(img, NULL, resampling_method, img->w * rat, img->h * rat, &callback);
GP_ContextFree(img);
cpu_timer_stop(&timer);
@@ -314,12 +318,12 @@ int main(int argc, char *argv[])
{
GP_InputDriverLinux *drv = NULL;
const char *input_dev = NULL;
- const char *backend_opts = "fb";
+ const char *backend_opts = "SDL";
int sleep_sec = -1;
struct loader_params params = {NULL, 0, 0, 0};
int opt;
- while ((opt = getopt(argc, argv, "b:Ii:Ps:r:")) != -1) {
+ while ((opt = getopt(argc, argv, "b:cIi:Ps:r:")) != -1) {
switch (opt) {
case 'I':
params.show_info = 1;
@@ -333,6 +337,9 @@ int main(int argc, char *argv[])
case 's':
sleep_sec = atoi(optarg);
break;
+ case 'c':
+ resampling_method = GP_INTERP_CUBIC_INT;
+ break;
case 'r':
if (!strcmp(optarg, "90"))
rotate = 90;
http://repo.or.cz/w/gfxprim.git/commit/8fd80e09adcbee684f691159ea96bb852c5d…
commit 8fd80e09adcbee684f691159ea96bb852c5d17a8
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Feb 19 15:29:31 2012 +0100
demos: grinder padd output image name with enough zeroes.
diff --git a/demos/grinder/grinder.c b/demos/grinder/grinder.c
index 61ec494..2822bcf 100644
--- a/demos/grinder/grinder.c
+++ b/demos/grinder/grinder.c
@@ -901,7 +901,7 @@ int main(int argc, char *argv[])
for (i = optind; i < argc; i++) {
char buf[255];
- snprintf(buf, sizeof(buf), "out_%i.%s", i - optind + 1, out_fmt);
+ snprintf(buf, sizeof(buf), "out_%03i.%s", i - optind + 1, out_fmt);
fprintf(stderr, "Processing '%s' -> '%s'n", argv[i], buf);
progress_prefix = "Loading image";
-----------------------------------------------------------------------
Summary of changes:
demos/fbshow/fbshow.c | 29 ++++++++++++++++++-----------
demos/grinder/grinder.c | 2 +-
2 files changed, 19 insertions(+), 12 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.")
1
0
[repo.or.cz] gfxprim.git branch master updated: b2930cfac623e072342fd297ad3b82e28e2aba83
by metan 19 Feb '12
by metan 19 Feb '12
19 Feb '12
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 b2930cfac623e072342fd297ad3b82e28e2aba83 (commit)
from 07d8a923162114629fa898af720d16e41160285d (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/b2930cfac623e072342fd297ad3b82e28e2a…
commit b2930cfac623e072342fd297ad3b82e28e2aba83
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Feb 19 15:10:09 2012 +0100
demos: grinder fix resize algs, add output format switch.
diff --git a/demos/grinder/grinder.c b/demos/grinder/grinder.c
index 4df4004..61ec494 100644
--- a/demos/grinder/grinder.c
+++ b/demos/grinder/grinder.c
@@ -81,6 +81,8 @@ static void print_error(const char *error)
static const char *resize_algs[] = {
"nn",
+ "linear-int",
+ "linear-lf-int",
"cubic",
"cubic-int",
NULL
@@ -136,6 +138,8 @@ static GP_RetCode resize(GP_Context **c, const char *params)
static const char *scale_algs[] = {
"nn",
+ "linear-int",
+ "linear-lf-int",
"cubic",
"cubic-int",
NULL
@@ -781,6 +785,7 @@ static const char *app_help = {
"-h - prints this help n"
"-p - show filter progress n"
"-v int - sets gfxprim verbosity level n"
+ "-o fmt - output format, ppm, jpg, png n"
"-f params - apply filter, multiple filters may be usedn"
" n"
" Example usage n"
@@ -803,17 +808,58 @@ static void print_help(void)
print_filter_help();
}
+static const char *out_fmts[] = {
+ "ppm",
+ "jpg",
+ "png",
+ NULL
+};
+
+static void check_fmt(const char *fmt)
+{
+ unsigned int i;
+
+ for (i = 0; out_fmts[i] != NULL; i++)
+ if (!strcmp(out_fmts[i], fmt))
+ break;
+
+ fprintf(stderr, "Invalid output format '%s'n", fmt);
+}
+
+static void save_by_fmt(struct GP_Context *bitmap, const char *name, const char *fmt)
+{
+ GP_RetCode ret;
+
+ progress_prefix = "Saving Image";
+
+ if (!strcmp(fmt, "ppm"))
+ ret = GP_SavePPM(name, bitmap, "b");
+ else if (!strcmp(fmt, "jpg"))
+ ret = GP_SaveJPG(name, bitmap, progress_callback);
+ else if (!strcmp(fmt, "png"))
+ ret = GP_SavePNG(name, bitmap, progress_callback);
+
+ if (ret) {
+ fprintf(stderr, "Failed to save bitmap: %sn", GP_RetCodeName(ret));
+ exit(1);
+ }
+
+ if (progress_callback != NULL)
+ fprintf(stderr, " donen");
+}
+
int main(int argc, char *argv[])
{
GP_Context *bitmap;
GP_RetCode ret;
int opt, i;
+ const char *out_fmt = "ppm";
GP_ProgressCallback callback = {
.callback = show_progress,
};
- while ((opt = getopt(argc, argv, "f:hpv:")) != -1) {
+ while ((opt = getopt(argc, argv, "f:ho:pv:")) != -1) {
switch (opt) {
case 'h':
print_help();
@@ -831,6 +877,10 @@ int main(int argc, char *argv[])
GP_SetDebugLevel(i);
break;
+ case 'o':
+ out_fmt = optarg;
+ check_fmt(out_fmt);
+ break;
case 'f':
add_filter(optarg);
break;
@@ -847,11 +897,11 @@ int main(int argc, char *argv[])
fprintf(stderr, "ERROR: Expected bitmap filenamesn");
return 1;
}
-
+
for (i = optind; i < argc; i++) {
char buf[255];
- snprintf(buf, sizeof(buf), "out_%i.ppm", i - optind + 1);
+ snprintf(buf, sizeof(buf), "out_%i.%s", i - optind + 1, out_fmt);
fprintf(stderr, "Processing '%s' -> '%s'n", argv[i], buf);
progress_prefix = "Loading image";
@@ -867,12 +917,7 @@ int main(int argc, char *argv[])
apply_filters(&bitmap);
-
- if ((ret = GP_SavePPM(buf, bitmap, "b"))) {
- fprintf(stderr, "Failed to load bitmap: %sn", GP_RetCodeName(ret));
- return 1;
- }
-
+ save_by_fmt(bitmap, buf, out_fmt);
}
return 0;
-----------------------------------------------------------------------
Summary of changes:
demos/grinder/grinder.c | 63 ++++++++++++++++++++++++++++++++++++++++------
1 files changed, 54 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.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 07d8a923162114629fa898af720d16e41160285d
by metan 13 Feb '12
by metan 13 Feb '12
13 Feb '12
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 07d8a923162114629fa898af720d16e41160285d (commit)
via 567aafbadcf454ab32ea74f81d6dba8cd872e1d2 (commit)
via e0d46203381e3dd146a17fe0078af68a1d2e8b40 (commit)
via 923ee620ce7cc8acf847c29b9da82ba5899ae520 (commit)
from 6b71d7fd13d9e9f9bd596d75e07d196c8042205c (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/07d8a923162114629fa898af720d16e41160…
commit 07d8a923162114629fa898af720d16e41160285d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Feb 13 17:18:33 2012 +0100
demos: Particle demo update.
diff --git a/demos/particle/particle_demo.c b/demos/particle/particle_demo.c
index b8af396..b258956 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(300, 10<<8, 10<<8, (context->w - 10)<<8, (context->h - 10)<<8);
+ space = space_create(160, 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, 3);
+ space_time_tick(space, 1);
space_draw_particles(context, space);
GP_BackendFlip(backend);
}
diff --git a/demos/particle/space.c b/demos/particle/space.c
index c029b0b..030f2e4 100644
--- a/demos/particle/space.c
+++ b/demos/particle/space.c
@@ -20,6 +20,7 @@
* *
*****************************************************************************/
+#include <time.h>
#include "space.h"
struct space *space_create(unsigned int particle_count, int min_w, int min_h,
@@ -73,9 +74,55 @@ void space_draw_particles(GP_Context *context, struct space *space)
GP_Fill(context, 0x000000);
for (i = 0; i < space->particle_count; i++) {
- GP_Pixel color = GP_RGBToContextPixel(0xff, 0xff, 0xff, context);
+ GP_Pixel color;
- GP_PutPixelAA(context, space->particles[i].x, space->particles[i].y, color);
+ GP_Coord x = space->particles[i].x;
+ GP_Coord y = space->particles[i].y;
+ GP_Coord a1 = GP_FP_1 * 4;
+ GP_Coord a2 = GP_FP_1_2 * 2;
+
+/*
+ if (i == 0) {
+ x = GP_FP_1 * 10 + GP_FP_1_2;
+ y = GP_FP_1 * 10 + GP_FP_1_2;
+ }
+*/
+
+ color = GP_RGBToContextPixel(0xee, 0xee, 0xee, context);
+
+ GP_PutPixelAA(context, x, y, color);
+
+ int val = SQUARE(space->particles[i].vx) + SQUARE(space->particles[i].vy);
+
+ val = sqrt(val) + 0x40;
+
+ if (val > 255)
+ val = 255;
+
+ color = GP_RGBToContextPixel(val, val, 0x40, context);
+
+ /* Hexagons */
+ GP_LineAA(context, x - a2, y - a1, x + a2, y - a1, color);
+ // GP_LineAA(context, x + a2, y - a1, x + a1, y - a2, color);
+ GP_LineAA(context, x + a1, y - a2, x + a1, y + a2, color);
+ // GP_LineAA(context, x + a1, y + a2, x + a2, y + a1, color);
+ GP_LineAA(context, x + a2, y + a1, x - a2, y + a1, color);
+ // GP_LineAA(context, x - a2, y + a1, x - a1, y + a2, color);
+ GP_LineAA(context, x - a1, y + a2, x - a1, y - a2, color);
+ // GP_LineAA(context, x - a1, y - a2, x - a2, y - a1, color);
+/*
+ GP_PutPixelAA(context, x + a2, y - a1, 0xffffff);
+ GP_PutPixelAA(context, x + a1, y - a2, 0xffffff);
+
+ GP_PutPixelAA(context, x + a1, y + a2, 0xffffff);
+ GP_PutPixelAA(context, x + a2, y + a1, 0xffffff);
+
+ GP_PutPixelAA(context, x - a2, y + a1, 0xffffff);
+ GP_PutPixelAA(context, x - a1, y + a2, 0xffffff);
+
+ GP_PutPixelAA(context, x - a1, y - a2, 0xffffff);
+ GP_PutPixelAA(context, x - a2, y - a1, 0xffffff);
+*/
}
}
@@ -105,8 +152,11 @@ static void gravity_forces(struct space *space, int time)
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))
- dist = -dist;
+ if (dist < (2<<8))
+ dist = -(dist>>1);
+ else if (dist < (8<<8))
+ dist = dist>>1;
+
int a = GP_FP_DIV(space->mass_kappa, dist_squared) * time;
http://repo.or.cz/w/gfxprim.git/commit/567aafbadcf454ab32ea74f81d6dba8cd872…
commit 567aafbadcf454ab32ea74f81d6dba8cd872e1d2
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Feb 13 17:01:30 2012 +0100
gfx: Fix Anti Aliased primitives coordinate system
The middle of the pixel is now defined as integer coodinates + 0.5.
TODO: The general Anti Aliased Line doesn't work correctly with
this change yet.
diff --git a/libs/gfx/GP_HLineAA.gen.c.t b/libs/gfx/GP_HLineAA.gen.c.t
index 3b5d15b..c08f68b 100644
--- a/libs/gfx/GP_HLineAA.gen.c.t
+++ b/libs/gfx/GP_HLineAA.gen.c.t
@@ -17,6 +17,10 @@ void GP_HLineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1,
if (x1 < x0)
GP_SWAP(x1, x0);
+ x0 -= GP_FP_1_2;
+ x1 += GP_FP_1_2;
+ y -= GP_FP_1_2;
+
GP_Coord int_x0 = GP_FP_TO_INT(x0);
GP_Coord int_x1 = GP_FP_TO_INT(x1);
GP_Coord int_y = GP_FP_TO_INT(y);
diff --git a/libs/gfx/GP_PutPixelAA.gen.c.t b/libs/gfx/GP_PutPixelAA.gen.c.t
index 625af68..c7eeefe 100644
--- a/libs/gfx/GP_PutPixelAA.gen.c.t
+++ b/libs/gfx/GP_PutPixelAA.gen.c.t
@@ -17,6 +17,8 @@
void GP_PutPixelAA_Raw(GP_Context *context, GP_Coord x, GP_Coord y,
GP_Pixel pixel)
{
+ x -= GP_FP_1_2;
+ y -= GP_FP_1_2;
GP_Coord int_x = GP_FP_TO_INT(x);
GP_Coord int_y = GP_FP_TO_INT(y);
GP_Coord frac_x = GP_FP_FRAC(x);
diff --git a/libs/gfx/GP_VLineAA.gen.c.t b/libs/gfx/GP_VLineAA.gen.c.t
index 6a9663a..e754d3e 100644
--- a/libs/gfx/GP_VLineAA.gen.c.t
+++ b/libs/gfx/GP_VLineAA.gen.c.t
@@ -16,7 +16,11 @@ void GP_VLineAA_Raw(GP_Context *context, GP_Coord x, GP_Coord y0,
{
if (y1 < y0)
GP_SWAP(y1, y0);
-
+
+ y0 -= GP_FP_1_2;
+ y1 += GP_FP_1_2;
+ x -= GP_FP_1_2;
+
GP_Coord int_y0 = GP_FP_TO_INT(y0);
GP_Coord int_y1 = GP_FP_TO_INT(y1);
GP_Coord int_x = GP_FP_TO_INT(x);
http://repo.or.cz/w/gfxprim.git/commit/e0d46203381e3dd146a17fe0078af68a1d2e…
commit e0d46203381e3dd146a17fe0078af68a1d2e8b40
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Feb 13 15:38:20 2012 +0100
gfx: Add Anti Aliased HLine and VLine.
(Needed for correct Anti Aliased Line)
diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_Gfx.h
index 6c2b8f6..df86280 100644
--- a/include/gfx/GP_Gfx.h
+++ b/include/gfx/GP_Gfx.h
@@ -53,6 +53,8 @@
#include "GP_Symbol.h"
#include "GP_PutPixelAA.h"
+#include "GP_VLineAA.h"
+#include "GP_HLineAA.h"
#include "GP_LineAA.h"
#include "GP_RectAA.h"
diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_HLineAA.h
similarity index 64%
copy from include/gfx/GP_Gfx.h
copy to include/gfx/GP_HLineAA.h
index 6c2b8f6..6889840 100644
--- a/include/gfx/GP_Gfx.h
+++ b/include/gfx/GP_HLineAA.h
@@ -16,44 +16,37 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
/*
+
+ Anti Aliased Horizontal line.
- This is a main header for gfx part.
+ The coordinates are in XX.8 fixed point format, see core/GP_FixedPoint.h
+ for helper macros.
+
+ For RGB contexts gamma correction tables are used to generate correct
+ intensity for pixels.
*/
-#ifndef GP_GFX_H
-#define GP_GFX_H
+#ifndef GFX_GP_HLINE_AA_H
+#define GFX_GP_HLINE_AA_H
-/* basic definitions and structures */
#include "core/GP_Context.h"
-#include "core/GP_GetPutPixel.h"
-#include "core/GP_WritePixel.h"
-
-/* public drawing API */
-#include "GP_Fill.h"
-#include "GP_HLine.h"
-#include "GP_VLine.h"
-#include "GP_Line.h"
-#include "GP_Rect.h"
-#include "GP_Triangle.h"
-#include "GP_Tetragon.h"
-#include "GP_Circle.h"
-#include "GP_CircleSeg.h"
-#include "GP_Ellipse.h"
-#include "GP_Arc.h"
-#include "GP_Polygon.h"
-#include "GP_Symbol.h"
-
-#include "GP_PutPixelAA.h"
-#include "GP_LineAA.h"
-#include "GP_RectAA.h"
-
-#endif /* GP_GFX_H */
+
+/*
+ * Anti Aliased Horizontal Line respecting context rotation flags and with clipping.
+ */
+void GP_HLineAA(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y,
+ GP_Pixel pixel);
+
+/*
+ * Horizontal Line without contect rotation flags.
+ */
+void GP_HLineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1,
+ GP_Coord y, GP_Pixel pixel);
+
+#endif /* GFX_GP_HLINE_AA_H */
diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_VLineAA.h
similarity index 64%
copy from include/gfx/GP_Gfx.h
copy to include/gfx/GP_VLineAA.h
index 6c2b8f6..4bbce5a 100644
--- a/include/gfx/GP_Gfx.h
+++ b/include/gfx/GP_VLineAA.h
@@ -16,44 +16,37 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
/*
+
+ Anti Aliased Vertical line.
- This is a main header for gfx part.
+ The coordinates are in XX.8 fixed point format, see core/GP_FixedPoint.h
+ for helper macros.
+
+ For RGB contexts gamma correction tables are used to generate correct
+ intensity for pixels.
*/
-#ifndef GP_GFX_H
-#define GP_GFX_H
+#ifndef GFX_GP_VLINE_AA_H
+#define GFX_GP_VLINE_AA_H
-/* basic definitions and structures */
#include "core/GP_Context.h"
-#include "core/GP_GetPutPixel.h"
-#include "core/GP_WritePixel.h"
-
-/* public drawing API */
-#include "GP_Fill.h"
-#include "GP_HLine.h"
-#include "GP_VLine.h"
-#include "GP_Line.h"
-#include "GP_Rect.h"
-#include "GP_Triangle.h"
-#include "GP_Tetragon.h"
-#include "GP_Circle.h"
-#include "GP_CircleSeg.h"
-#include "GP_Ellipse.h"
-#include "GP_Arc.h"
-#include "GP_Polygon.h"
-#include "GP_Symbol.h"
-
-#include "GP_PutPixelAA.h"
-#include "GP_LineAA.h"
-#include "GP_RectAA.h"
-
-#endif /* GP_GFX_H */
+
+/*
+ * Anti Aliased Horizontal Line respecting context rotation flags and with clipping.
+ */
+void GP_VLineAA(GP_Context *context, GP_Coord x, GP_Coord y0, GP_Coord y1,
+ GP_Pixel pixel);
+
+/*
+ * Horizontal Line without contect rotation flags.
+ */
+void GP_VLineAA_Raw(GP_Context *context, GP_Coord x,
+ GP_Coord y0, GP_Coord y1, GP_Pixel pixel);
+
+#endif /* GFX_GP_VLINE_AA_H */
diff --git a/include/gfx/GP_Gfx.h b/libs/gfx/GP_HLineAA.c
similarity index 63%
copy from include/gfx/GP_Gfx.h
copy to libs/gfx/GP_HLineAA.c
index 6c2b8f6..01770f4 100644
--- a/include/gfx/GP_Gfx.h
+++ b/libs/gfx/GP_HLineAA.c
@@ -16,44 +16,41 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
-/*
-
- This is a main header for gfx part.
-
- */
+#include "core/GP_FnPerBpp.h"
+#include "core/GP_Transform.h"
-#ifndef GP_GFX_H
-#define GP_GFX_H
+#include "gfx/GP_HLineAA.h"
+#include "gfx/GP_VLineAA.h"
-/* basic definitions and structures */
-#include "core/GP_Context.h"
-#include "core/GP_GetPutPixel.h"
-#include "core/GP_WritePixel.h"
-
-/* public drawing API */
-#include "GP_Fill.h"
-#include "GP_HLine.h"
-#include "GP_VLine.h"
-#include "GP_Line.h"
-#include "GP_Rect.h"
-#include "GP_Triangle.h"
-#include "GP_Tetragon.h"
-#include "GP_Circle.h"
-#include "GP_CircleSeg.h"
-#include "GP_Ellipse.h"
-#include "GP_Arc.h"
-#include "GP_Polygon.h"
-#include "GP_Symbol.h"
-
-#include "GP_PutPixelAA.h"
-#include "GP_LineAA.h"
-#include "GP_RectAA.h"
-
-#endif /* GP_GFX_H */
+/*
+void GP_HLineXXYAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1,
+ GP_Coord y, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_FN_PER_BPP_CONTEXT(GP_HLine_Raw, context, context, x0, x1, y,
+ pixel);
+}
+*/
+
+void GP_HLineAA(GP_Context *context, GP_Coord x0, GP_Coord x1,
+ GP_Coord y, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ if (context->axes_swap) {
+ GP_TRANSFORM_Y_FP(context, x0);
+ GP_TRANSFORM_Y_FP(context, x1);
+ GP_TRANSFORM_X_FP(context, y);
+ GP_VLineAA_Raw(context, y, x0, x1, pixel);
+ } else {
+ GP_TRANSFORM_X_FP(context, x0);
+ GP_TRANSFORM_X_FP(context, x1);
+ GP_TRANSFORM_Y_FP(context, y);
+ GP_HLineAA_Raw(context, x0, x1, y, pixel);
+ }
+}
diff --git a/libs/gfx/GP_HLineAA.gen.c.t b/libs/gfx/GP_HLineAA.gen.c.t
new file mode 100644
index 0000000..3b5d15b
--- /dev/null
+++ b/libs/gfx/GP_HLineAA.gen.c.t
@@ -0,0 +1,58 @@
+%% extends "base.c.t"
+
+{% block descr %}Anti Aliased Horizontal Line{% endblock %}
+
+%% block body
+
+#include "core/GP_Context.h"
+#include "core/GP_MixPixels.h"
+#include "core/GP_FixedPoint.h"
+#include "core/GP_GammaCorrection.h"
+
+#define FP_TO_PERC(a) (GP_FP_ROUND_TO_INT((a) * 255))
+
+void GP_HLineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1,
+ GP_Coord y, GP_Pixel pixel)
+{
+ if (x1 < x0)
+ GP_SWAP(x1, x0);
+
+ GP_Coord int_x0 = GP_FP_TO_INT(x0);
+ GP_Coord int_x1 = GP_FP_TO_INT(x1);
+ GP_Coord int_y = GP_FP_TO_INT(y);
+
+ /* Line is shorter than two pixels */
+ if (int_x0 == int_x1) {
+ //TODO
+ return;
+ }
+
+ /* Draw the starting and ending pixel */
+ uint8_t perc;
+
+ perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(y), GP_FP_RFRAC(x0)));
+ GP_MixPixel_Raw_Clipped(context, int_x0, int_y, pixel, perc);
+
+ perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(y), GP_FP_RFRAC(x0)));
+ GP_MixPixel_Raw_Clipped(context, int_x0, int_y+1, pixel, perc);
+
+
+ perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(y), GP_FP_FRAC(x1)));
+ GP_MixPixel_Raw_Clipped(context, int_x1, int_y, pixel, perc);
+
+ perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(y), GP_FP_FRAC(x1)));
+ GP_MixPixel_Raw_Clipped(context, int_x1, int_y+1, pixel, perc);
+
+ /* Draw the middle pixels */
+ uint8_t up = FP_TO_PERC(GP_FP_RFRAC(y));
+ uint8_t lp = FP_TO_PERC(GP_FP_FRAC(y));
+
+ GP_Coord x;
+
+ for (x = int_x0 + 1; x < int_x1; x++) {
+ GP_MixPixel_Raw_Clipped(context, x, int_y, pixel, up);
+ GP_MixPixel_Raw_Clipped(context, x, int_y+1, pixel, lp);
+ }
+}
+
+%% endblock body
diff --git a/libs/gfx/GP_LineAA.gen.c.t b/libs/gfx/GP_LineAA.gen.c.t
index 2bf413f..c5796d5 100644
--- a/libs/gfx/GP_LineAA.gen.c.t
+++ b/libs/gfx/GP_LineAA.gen.c.t
@@ -9,8 +9,8 @@
#include "core/GP_FixedPoint.h"
#include "core/GP_GammaCorrection.h"
-#include "gfx/GP_HLine.h"
-#include "gfx/GP_VLine.h"
+#include "gfx/GP_HLineAA.h"
+#include "gfx/GP_VLineAA.h"
#define FP_TO_PERC(a) (GP_FP_ROUND_TO_INT((a) * 255))
@@ -121,16 +121,12 @@ void GP_LineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
int64_t dy = y1 - y0;
if (dy == 0) {
- //TODO!!!
- GP_HLine_Raw(context, GP_FP_ROUND_TO_INT(x0), GP_FP_ROUND_TO_INT(x1),
- GP_FP_ROUND_TO_INT(y0), pixel);
+ GP_HLineAA_Raw(context, x0, x1, y0, pixel);
return;
}
if (dx == 0) {
- //TODO!!!
- GP_VLine(context, GP_FP_ROUND_TO_INT(x0), GP_FP_ROUND_TO_INT(y0),
- GP_FP_ROUND_TO_INT(y1), pixel);
+ GP_VLineAA_Raw(context, x0, y0, y1, pixel);
return;
}
diff --git a/include/gfx/GP_Gfx.h b/libs/gfx/GP_VLineAA.c
similarity index 64%
copy from include/gfx/GP_Gfx.h
copy to libs/gfx/GP_VLineAA.c
index 6c2b8f6..6b5b1d4 100644
--- a/include/gfx/GP_Gfx.h
+++ b/libs/gfx/GP_VLineAA.c
@@ -16,44 +16,40 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
-/*
-
- This is a main header for gfx part.
-
- */
-
-#ifndef GP_GFX_H
-#define GP_GFX_H
-
-/* basic definitions and structures */
-#include "core/GP_Context.h"
#include "core/GP_GetPutPixel.h"
-#include "core/GP_WritePixel.h"
+#include "core/GP_FnPerBpp.h"
-/* public drawing API */
-#include "GP_Fill.h"
-#include "GP_HLine.h"
-#include "GP_VLine.h"
-#include "GP_Line.h"
-#include "GP_Rect.h"
-#include "GP_Triangle.h"
-#include "GP_Tetragon.h"
-#include "GP_Circle.h"
-#include "GP_CircleSeg.h"
-#include "GP_Ellipse.h"
-#include "GP_Arc.h"
-#include "GP_Polygon.h"
-#include "GP_Symbol.h"
+#include "gfx/GP_VLineAA.h"
+#include "gfx/GP_HLineAA.h"
-#include "GP_PutPixelAA.h"
-#include "GP_LineAA.h"
-#include "GP_RectAA.h"
-
-#endif /* GP_GFX_H */
+/*
+void GP_VLineXYY_Raw(GP_Context *context, GP_Coord x, GP_Coord y0,
+ GP_Coord y1, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_FN_PER_BPP_CONTEXT(GP_VLine, context, context, x, y0, y1, pixel);
+}
+*/
+
+void GP_VLineAA(GP_Context *context, GP_Coord x, GP_Coord y0,
+ GP_Coord y1, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ if (context->axes_swap) {
+ GP_TRANSFORM_Y_FP(context, x);
+ GP_TRANSFORM_X_FP(context, y0);
+ GP_TRANSFORM_X_FP(context, y1);
+ GP_HLineAA_Raw(context, y0, y1, x, pixel);
+ } else {
+ GP_TRANSFORM_X_FP(context, x);
+ GP_TRANSFORM_Y_FP(context, y0);
+ GP_TRANSFORM_Y_FP(context, y1);
+ GP_VLineAA_Raw(context, x, y0, y1, pixel);
+ }
+}
diff --git a/libs/gfx/GP_VLineAA.gen.c.t b/libs/gfx/GP_VLineAA.gen.c.t
new file mode 100644
index 0000000..6a9663a
--- /dev/null
+++ b/libs/gfx/GP_VLineAA.gen.c.t
@@ -0,0 +1,58 @@
+%% extends "base.c.t"
+
+{% block descr %}Anti Aliased Vertical Line{% endblock %}
+
+%% block body
+
+#include "core/GP_Context.h"
+#include "core/GP_MixPixels.h"
+#include "core/GP_FixedPoint.h"
+#include "core/GP_GammaCorrection.h"
+
+#define FP_TO_PERC(a) (GP_FP_ROUND_TO_INT((a) * 255))
+
+void GP_VLineAA_Raw(GP_Context *context, GP_Coord x, GP_Coord y0,
+ GP_Coord y1, GP_Pixel pixel)
+{
+ if (y1 < y0)
+ GP_SWAP(y1, y0);
+
+ GP_Coord int_y0 = GP_FP_TO_INT(y0);
+ GP_Coord int_y1 = GP_FP_TO_INT(y1);
+ GP_Coord int_x = GP_FP_TO_INT(x);
+
+ /* Line is shorter than two pixels */
+ if (int_y0 == int_y1) {
+ //TODO
+ return;
+ }
+
+ /* Draw the starting and ending pixel */
+ uint8_t perc;
+
+ perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(x), GP_FP_RFRAC(y0)));
+ GP_MixPixel_Raw_Clipped(context, int_x, int_y0, pixel, perc);
+
+ perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(x), GP_FP_RFRAC(y0)));
+ GP_MixPixel_Raw_Clipped(context, int_x+1, int_y0, pixel, perc);
+
+
+ perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(x), GP_FP_FRAC(y1)));
+ GP_MixPixel_Raw_Clipped(context, int_x, int_y1, pixel, perc);
+
+ perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(x), GP_FP_FRAC(y1)));
+ GP_MixPixel_Raw_Clipped(context, int_x+1, int_y1, pixel, perc);
+
+ /* Draw the middle pixels */
+ uint8_t up = FP_TO_PERC(GP_FP_RFRAC(x));
+ uint8_t lp = FP_TO_PERC(GP_FP_FRAC(x));
+
+ GP_Coord y;
+
+ for (y = int_y0 + 1; y < int_y1; y++) {
+ GP_MixPixel_Raw_Clipped(context, int_x, y, pixel, up);
+ GP_MixPixel_Raw_Clipped(context, int_x+1, y, pixel, lp);
+ }
+}
+
+%% endblock body
diff --git a/libs/gfx/Makefile b/libs/gfx/Makefile
index 3e7cb28..60a485b 100644
--- a/libs/gfx/Makefile
+++ b/libs/gfx/Makefile
@@ -1,6 +1,7 @@
TOPDIR=../..
CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c))
-GENSOURCES=GP_LineAA.gen.c GP_PutPixelAA.gen.c
+GENSOURCES=GP_LineAA.gen.c GP_PutPixelAA.gen.c GP_HLineAA.gen.c + GP_VLineAA.gen.c
LIBNAME=gfx
include $(TOPDIR)/gen.mk
http://repo.or.cz/w/gfxprim.git/commit/923ee620ce7cc8acf847c29b9da82ba5899a…
commit 923ee620ce7cc8acf847c29b9da82ba5899ae520
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Feb 13 14:44:05 2012 +0100
gfx: Added header for Anti Aliased line, finally.
diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_Gfx.h
index acc5fd2..6c2b8f6 100644
--- a/include/gfx/GP_Gfx.h
+++ b/include/gfx/GP_Gfx.h
@@ -52,7 +52,8 @@
#include "GP_Polygon.h"
#include "GP_Symbol.h"
-#include "GP_RectAA.h"
#include "GP_PutPixelAA.h"
+#include "GP_LineAA.h"
+#include "GP_RectAA.h"
#endif /* GP_GFX_H */
diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_LineAA.h
similarity index 65%
copy from include/gfx/GP_Gfx.h
copy to include/gfx/GP_LineAA.h
index acc5fd2..34ec028 100644
--- a/include/gfx/GP_Gfx.h
+++ b/include/gfx/GP_LineAA.h
@@ -16,43 +16,37 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
/*
+
+ Anti Aliased line.
- This is a main header for gfx part.
+ The coordinates are in XX.8 fixed point format, see core/GP_FixedPoint.h
+ for helper macros.
+
+ For RGB contexts gamma correction tables are used to generate correct
+ intensity for pixels.
*/
-#ifndef GP_GFX_H
-#define GP_GFX_H
+#ifndef GFX_GP_LINE_AA_H
+#define GFX_GP_LINE_AA_H
-/* basic definitions and structures */
#include "core/GP_Context.h"
-#include "core/GP_GetPutPixel.h"
-#include "core/GP_WritePixel.h"
-
-/* public drawing API */
-#include "GP_Fill.h"
-#include "GP_HLine.h"
-#include "GP_VLine.h"
-#include "GP_Line.h"
-#include "GP_Rect.h"
-#include "GP_Triangle.h"
-#include "GP_Tetragon.h"
-#include "GP_Circle.h"
-#include "GP_CircleSeg.h"
-#include "GP_Ellipse.h"
-#include "GP_Arc.h"
-#include "GP_Polygon.h"
-#include "GP_Symbol.h"
-
-#include "GP_RectAA.h"
-#include "GP_PutPixelAA.h"
-
-#endif /* GP_GFX_H */
+
+/*
+ * Anti Aliased Line respecting context rotation flags and with clipping.
+ */
+void GP_LineAA(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
+
+/*
+ * Line without contect rotation flags.
+ */
+void GP_LineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
+
+#endif /* GFX_GP_LINE_AA_H */
diff --git a/include/gfx/GP_Gfx.h b/libs/gfx/GP_LineAA.c
similarity index 72%
copy from include/gfx/GP_Gfx.h
copy to libs/gfx/GP_LineAA.c
index acc5fd2..6d30df0 100644
--- a/include/gfx/GP_Gfx.h
+++ b/libs/gfx/GP_LineAA.c
@@ -19,40 +19,33 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
-/*
-
- This is a main header for gfx part.
-
- */
-
-#ifndef GP_GFX_H
-#define GP_GFX_H
+#include "core/GP_Transform.h"
+#include "core/GP_FnPerBpp.h"
-/* basic definitions and structures */
-#include "core/GP_Context.h"
-#include "core/GP_GetPutPixel.h"
-#include "core/GP_WritePixel.h"
+#include "gfx/GP_LineAA.h"
-/* public drawing API */
-#include "GP_Fill.h"
-#include "GP_HLine.h"
-#include "GP_VLine.h"
-#include "GP_Line.h"
-#include "GP_Rect.h"
-#include "GP_Triangle.h"
-#include "GP_Tetragon.h"
-#include "GP_Circle.h"
-#include "GP_CircleSeg.h"
-#include "GP_Ellipse.h"
-#include "GP_Arc.h"
-#include "GP_Polygon.h"
-#include "GP_Symbol.h"
-
-#include "GP_RectAA.h"
-#include "GP_PutPixelAA.h"
-
-#endif /* GP_GFX_H */
+/*
+void GP_Line_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_FN_PER_BPP_CONTEXT(GP_Line_Raw, context, context, x0, y0, x1, y1,
+ pixel);
+}
+*/
+
+void GP_LineAA(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_TRANSFORM_POINT_FP(context, x0, y0);
+ GP_TRANSFORM_POINT_FP(context, x1, y1);
+
+ GP_LineAA_Raw(context, x0, y0, x1, y1, pixel);
+}
-----------------------------------------------------------------------
Summary of changes:
demos/particle/particle_demo.c | 4 +-
demos/particle/space.c | 58 +++++++++++++++++++++--
include/gfx/GP_Gfx.h | 5 ++-
include/gfx/{GP_PutPixelAA.h => GP_HLineAA.h} | 29 +++++-------
include/gfx/{GP_PutPixelAA.h => GP_LineAA.h} | 25 ++++------
include/gfx/{GP_PutPixelAA.h => GP_VLineAA.h} | 29 +++++-------
libs/gfx/{GP_Line.c => GP_HLineAA.c} | 42 +++++++++--------
libs/gfx/GP_HLineAA.gen.c.t | 62 +++++++++++++++++++++++++
libs/gfx/{GP_Line.c => GP_LineAA.c} | 21 ++++-----
libs/gfx/GP_LineAA.gen.c.t | 12 ++---
libs/gfx/GP_PutPixelAA.gen.c.t | 2 +
libs/{text/GP_Font.c => gfx/GP_VLineAA.c} | 61 ++++++++++---------------
libs/gfx/GP_VLineAA.gen.c.t | 62 +++++++++++++++++++++++++
libs/gfx/Makefile | 3 +-
14 files changed, 281 insertions(+), 134 deletions(-)
copy include/gfx/{GP_PutPixelAA.h => GP_HLineAA.h} (73%)
copy include/gfx/{GP_PutPixelAA.h => GP_LineAA.h} (76%)
copy include/gfx/{GP_PutPixelAA.h => GP_VLineAA.h} (73%)
copy libs/gfx/{GP_Line.c => GP_HLineAA.c} (67%)
create mode 100644 libs/gfx/GP_HLineAA.gen.c.t
copy libs/gfx/{GP_Line.c => GP_LineAA.c} (83%)
copy libs/{text/GP_Font.c => gfx/GP_VLineAA.c} (68%)
create mode 100644 libs/gfx/GP_VLineAA.gen.c.t
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.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 6b71d7fd13d9e9f9bd596d75e07d196c8042205c
by metan 13 Feb '12
by metan 13 Feb '12
13 Feb '12
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.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 188e3a319e7a0f9eb12cfd5d06a0ac7aa996d771
by metan 12 Feb '12
by metan 12 Feb '12
12 Feb '12
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.")
1
0
[repo.or.cz] gfxprim.git branch master updated: b3b9438ff87b573ce38bde2602edb0b07086560d
by metan 12 Feb '12
by metan 12 Feb '12
12 Feb '12
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 b3b9438ff87b573ce38bde2602edb0b07086560d (commit)
via 1434e01b44e30a1e00c7f10d92d87304ce7f8f3a (commit)
via 7d9c51d82767ee65ed41023f8851ba8e89d1e1e5 (commit)
via ef3231da764cd212ba973958aafd57ce1c286ce6 (commit)
from 584ef7b40c75f90ad55347dac6e4fd95a4ff54af (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/b3b9438ff87b573ce38bde2602edb0b07086…
commit b3b9438ff87b573ce38bde2602edb0b07086560d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Feb 12 23:01:55 2012 +0100
core: Small GP_Pixel.h cleanup.
diff --git a/include/core/GP_Pixel.h b/include/core/GP_Pixel.h
index b2f3804..a36c9bd 100644
--- a/include/core/GP_Pixel.h
+++ b/include/core/GP_Pixel.h
@@ -115,13 +115,11 @@ typedef struct {
/*
* Array of size GP_PIXEL_MAX describing known pixel types
*/
-
extern const GP_PixelTypeDescription const GP_PixelTypes[];
/*
* Convert pixel type to name.
*/
-
static inline const char *GP_PixelTypeName(GP_PixelType type)
{
GP_CHECK(type < GP_PIXEL_MAX);
@@ -131,7 +129,6 @@ static inline const char *GP_PixelTypeName(GP_PixelType type)
/*
* Returns number of bits per pixel.
*/
-
static inline uint32_t GP_PixelSize(GP_PixelType type)
{
GP_CHECK(type < GP_PIXEL_MAX);
http://repo.or.cz/w/gfxprim.git/commit/1434e01b44e30a1e00c7f10d92d87304ce7f…
commit 1434e01b44e30a1e00c7f10d92d87304ce7f8f3a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Feb 12 23:01:25 2012 +0100
core: Add Mixpixel to default includes.
diff --git a/include/core/GP_Core.h b/include/core/GP_Core.h
index 9bd927f..043e6ce 100644
--- a/include/core/GP_Core.h
+++ b/include/core/GP_Core.h
@@ -59,4 +59,7 @@
/* Color */
#include "core/GP_Color.h"
+/* Mix Pixel */
+#include "core/GP_MixPixels.h"
+
#endif /* GP_CORE_H */
http://repo.or.cz/w/gfxprim.git/commit/7d9c51d82767ee65ed41023f8851ba8e89d1…
commit 7d9c51d82767ee65ed41023f8851ba8e89d1e1e5
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Feb 12 23:00:21 2012 +0100
tests: Quick and dirty mixpixel test.
diff --git a/tests/SDL/Makefile b/tests/SDL/Makefile
index 8520abb..efb5272 100644
--- a/tests/SDL/Makefile
+++ b/tests/SDL/Makefile
@@ -7,7 +7,7 @@ LDLIBS+=-lGP -L$(TOPDIR)/build/ -lGP_SDL -lSDL
APPS=pixeltest fileview fonttest linetest randomshapetest shapetest sierpinsky symbolstest textaligntest trianglefps input blittest subcontext showimage- aatest
+ aatest mixpixeltest
include $(TOPDIR)/include.mk
include $(TOPDIR)/app.mk
diff --git a/tests/SDL/mixpixeltest.c b/tests/SDL/mixpixeltest.c
new file mode 100644
index 0000000..a7ecc66
--- /dev/null
+++ b/tests/SDL/mixpixeltest.c
@@ -0,0 +1,192 @@
+/*****************************************************************************
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <SDL/SDL.h>
+
+#include "GP.h"
+#include "GP_SDL.h"
+
+/* The surface used as a display (in fact it is a software surface). */
+SDL_Surface *display = NULL;
+GP_Context context;
+
+/* Timer used for refreshing the display */
+SDL_TimerID timer;
+
+/* An event used for signaling that the timer was triggered. */
+SDL_UserEvent timer_event;
+
+/* Values for color pixels in display format. */
+GP_Pixel red_pixel, green_pixel, blue_pixel, white_pixel;
+
+Uint32 timer_callback(__attribute__((unused)) Uint32 interval,
+ __attribute__((unused)) void *param)
+{
+ timer_event.type = SDL_USEREVENT;
+ SDL_PushEvent((SDL_Event *) &timer_event);
+ return 0;
+}
+
+void draw_pixels(void)
+{
+ unsigned int i;
+
+ GP_FillRect(&context, 0, 0, context.w, 50, white_pixel);
+
+ unsigned int y = 20;
+
+ for (i = 0; i <= 256; i++) {
+ GP_MixPixel_Raw(&context, i + 20, y + 0, 0, i);
+ GP_MixPixel_Raw(&context, i + 20, y + 1, 0, i);
+ 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);
+
+ if (i % 16 == 0)
+ GP_PutPixel(&context, i + 20, y + 5, 0);
+
+ if (i % 32 == 0)
+ GP_PutPixel(&context, i + 20, y + 6, 0);
+
+ if (i % 64 == 0) {
+ GP_PutPixel(&context, i + 20, y + 7, 0);
+ GP_Print(&context, NULL, i + 20, y + 12,
+ GP_ALIGN_CENTER | GP_VALIGN_BELOW,
+ 0, 0, "%u", i);
+ }
+
+ if (i % 128 == 0)
+ GP_PutPixel(&context, i + 20, y + 8, 0);
+ }
+
+ y = 60;
+
+ for (i = 0; i <= 256; i++) {
+ GP_MixPixel_Raw(&context, i + 20, y + 0, white_pixel, i);
+ GP_MixPixel_Raw(&context, i + 20, y + 1, white_pixel, i);
+ 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);
+
+ if (i % 16 == 0)
+ GP_PutPixel(&context, i + 20, y + 5, white_pixel);
+
+ if (i % 32 == 0)
+ GP_PutPixel(&context, i + 20, y + 6, white_pixel);
+
+ if (i % 64 == 0) {
+ GP_PutPixel(&context, i + 20, y + 7, white_pixel);
+ GP_Print(&context, NULL, i + 20, y + 12,
+ GP_ALIGN_CENTER | GP_VALIGN_BELOW,
+ white_pixel, 0, "%u", i);
+ }
+
+ if (i % 128 == 0)
+ GP_PutPixel(&context, i + 20, y + 8, white_pixel);
+ }
+
+
+}
+
+void event_loop(void)
+{
+ SDL_Event event;
+
+ while (SDL_WaitEvent(&event) > 0) {
+ switch (event.type) {
+ case SDL_USEREVENT:
+ draw_pixels();
+ SDL_Flip(display);
+ break;
+ case SDL_KEYDOWN:
+ case SDL_QUIT:
+ return;
+ }
+ }
+}
+
+int main(int argc, char **argv)
+{
+ int display_bpp = 0;
+
+ int i;
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-16") == 0) {
+ display_bpp = 16;
+ } else if (strcmp(argv[i], "-24") == 0) {
+ display_bpp = 24;
+ }
+ }
+
+ /* Initialize SDL */
+ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) {
+ fprintf(stderr, "Could not initialize SDL: %sn", SDL_GetError());
+ return 1;
+ }
+
+ /* Create a window with a software back surface */
+ display = SDL_SetVideoMode(320, 240, display_bpp, SDL_SWSURFACE);
+ if (display == NULL) {
+ fprintf(stderr, "Could not open display: %sn", SDL_GetError());
+ goto fail;
+ }
+
+
+ /* Print basic information about the surface */
+ printf("Display surface properties:n");
+ printf(" width: %4d, height: %4d, pitch: %4dn",
+ display->w, display->h, display->pitch);
+ printf(" bits per pixel: %2d, bytes per pixel: %2dn",
+ display->format->BitsPerPixel, display->format->BytesPerPixel);
+
+ /* Set up a clipping rectangle to test proper clipping of pixels */
+ SDL_Rect clip_rect = {10, 10, 300, 220};
+ SDL_SetClipRect(display, &clip_rect);
+
+ GP_SDL_ContextFromSurface(&context, display);
+
+ /* Load pixel values compatible with the display. */
+ red_pixel = GP_ColorToContextPixel(GP_COL_RED, &context);
+ green_pixel = GP_ColorToContextPixel(GP_COL_GREEN, &context);
+ blue_pixel = GP_ColorToContextPixel(GP_COL_BLUE, &context);
+ white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, &context);
+
+ /* Set up the refresh timer */
+ timer = SDL_AddTimer(30, timer_callback, NULL);
+ if (timer == 0) {
+ fprintf(stderr, "Could not set up timer: %sn", SDL_GetError());
+ goto fail;
+ }
+
+ /* Enter the event loop */
+ event_loop();
+
+ /* We're done */
+ SDL_Quit();
+ return 0;
+
+fail:
+ SDL_Quit();
+ return 1;
+}
http://repo.or.cz/w/gfxprim.git/commit/ef3231da764cd212ba973958aafd57ce1c28…
commit ef3231da764cd212ba973958aafd57ce1c286ce6
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Feb 12 22:59:42 2012 +0100
demos: Added particle interactions.
diff --git a/demos/particle/particle_demo.c b/demos/particle/particle_demo.c
index 5061397..3be671a 100644
--- a/demos/particle/particle_demo.c
+++ b/demos/particle/particle_demo.c
@@ -106,13 +106,13 @@ int main(int argc, char *argv[])
GP_BackendFlip(backend);
struct space *space;
- space = space_create(1000, 10<<8, 10<<8, (context->w - 10)<<8, (context->h - 10)<<8);
+ space = space_create(200, 10<<8, 10<<8, (context->w - 10)<<8, (context->h - 10)<<8);
for (;;) {
if (backend->Poll)
GP_BackendPoll(backend);
- usleep(5000);
+ usleep(1000);
/* Read and parse events */
GP_Event ev;
diff --git a/demos/particle/space.c b/demos/particle/space.c
index 6a244b7..a243f97 100644
--- a/demos/particle/space.c
+++ b/demos/particle/space.c
@@ -41,6 +41,7 @@ struct space *space_create(unsigned int particle_count, int min_w, int min_h,
new->gay = 0;
new->elasticity = (1<<8) - (1<<6);
+ new->mass_kappa = 1<<1;
unsigned int i;
@@ -49,6 +50,8 @@ struct space *space_create(unsigned int particle_count, int min_w, int min_h,
new->particles[i].y = random() % (max_h - min_h) + min_h;
new->particles[i].vx = random() % 40 - 20;
new->particles[i].vy = random() % 40 - 20;
+// new->particles[i].vx = 0;
+// new->particles[i].vy = 0;
}
return new;
@@ -59,17 +62,22 @@ void space_destroy(struct space *space)
free(space);
}
+#define SQUARE(x) ((x) * (x))
+
void space_draw_particles(GP_Context *context, struct space *space)
{
unsigned int i;
- GP_Fill(context, 0);
+ GP_Fill(context, 0x000000);
- for (i = 0; i < space->particle_count; i++)
- GP_PutPixelAA(context, space->particles[i].x, space->particles[i].y, 0xffffff);
+ for (i = 0; i < space->particle_count; i++) {
+ GP_Pixel color = GP_RGBToContextPixel(0xff, 0xff, 0xff, context);
+
+ GP_PutPixelAA(context, space->particles[i].x, space->particles[i].y, color);
+ }
}
-static void modify_speeds(struct space *space, int time)
+static void central_gravity(struct space *space, int time)
{
unsigned int i;
@@ -79,11 +87,38 @@ static void modify_speeds(struct space *space, int time)
}
}
+#define DIST_X(space, i, j) ((space)->particles[i].x - (space)->particles[j].x)
+#define DIST_Y(space, i, j) ((space)->particles[i].y - (space)->particles[j].y)
+#define SIGN(x) ((x) < 0 ? -1 : 1)
+
+static void gravity_forces(struct space *space, int time)
+{
+ unsigned int i, j;
+
+ for (i = 0; i < space->particle_count; i++)
+ for (j = 0; j < space->particle_count; j++) {
+ 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 = ((int)sqrt(dist_squared))<<4;
+
+ if (dist < (1<<9))
+ dist = -dist;
+
+ int a = GP_FP_DIV(space->mass_kappa, dist_squared) * time;
+
+ space->particles[i].vx -= (a * dist_x) / dist;
+ space->particles[i].vy -= (a * dist_y) / dist;
+ }
+}
+
void space_time_tick(struct space *space, int time)
{
unsigned int i;
- modify_speeds(space, time);
+ central_gravity(space, time);
+ gravity_forces(space, time);
for (i = 0; i < space->particle_count; i++) {
diff --git a/demos/particle/space.h b/demos/particle/space.h
index d4b01a5..9b58037 100644
--- a/demos/particle/space.h
+++ b/demos/particle/space.h
@@ -58,6 +58,9 @@ struct space {
/* elasticity at the boudaries */
int elasticity;
+ /* particle mass */
+ int mass_kappa;
+
struct particle particles[];
};
-----------------------------------------------------------------------
Summary of changes:
demos/particle/particle_demo.c | 4 +-
demos/particle/space.c | 45 +++++++++++++--
demos/particle/space.h | 3 +
include/core/GP_Core.h | 3 +
include/core/GP_Pixel.h | 3 -
tests/SDL/Makefile | 2 +-
tests/SDL/{pixeltest.c => mixpixeltest.c} | 87 ++++++++++++++++++-----------
7 files changed, 104 insertions(+), 43 deletions(-)
copy tests/SDL/{pixeltest.c => mixpixeltest.c} (72%)
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.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 584ef7b40c75f90ad55347dac6e4fd95a4ff54af
by metan 12 Feb '12
by metan 12 Feb '12
12 Feb '12
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 584ef7b40c75f90ad55347dac6e4fd95a4ff54af (commit)
via 565271d45d92a19f90b6f8ec637e8626fe8c1f0f (commit)
from 6e4677159b0d9febdd48f359e335277b53991093 (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/584ef7b40c75f90ad55347dac6e4fd95a4ff…
commit 584ef7b40c75f90ad55347dac6e4fd95a4ff54af
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Feb 12 19:43:18 2012 +0100
demos: Add simple particle demo.
diff --git a/demos/Makefile b/demos/Makefile
index eddfa9f..107f998 100644
--- a/demos/Makefile
+++ b/demos/Makefile
@@ -1,3 +1,3 @@
TOPDIR=..
-SUBDIRS=grinder fbshow
+SUBDIRS=grinder fbshow particle
include $(TOPDIR)/include.mk
diff --git a/demos/particle/particle_demo.c b/demos/particle/particle_demo.c
index 4615607..5061397 100644
--- a/demos/particle/particle_demo.c
+++ b/demos/particle/particle_demo.c
@@ -76,7 +76,7 @@ int main(int argc, char *argv[])
{
const char *backend_opts = "fb";
int opt;
- int pause_flag = 1;
+ int pause_flag = 0;
while ((opt = getopt(argc, argv, "b:Ii:Ps:r:")) != -1) {
switch (opt) {
@@ -105,7 +105,8 @@ int main(int argc, char *argv[])
GP_Fill(context, black_pixel);
GP_BackendFlip(backend);
- struct space *space = space_create(1000, context->w<<8, context->h<<8);
+ struct space *space;
+ space = space_create(1000, 10<<8, 10<<8, (context->w - 10)<<8, (context->h - 10)<<8);
for (;;) {
if (backend->Poll)
@@ -135,6 +136,12 @@ int main(int argc, char *argv[])
case GP_KEY_P:
pause_flag = !pause_flag;
break;
+ case GP_KEY_G:
+ space->gay = 1;
+ break;
+ case GP_KEY_T:
+ space->gay = 0;
+ break;
}
break;
}
diff --git a/demos/particle/space.c b/demos/particle/space.c
index bdf87e0..6a244b7 100644
--- a/demos/particle/space.c
+++ b/demos/particle/space.c
@@ -22,7 +22,8 @@
#include "space.h"
-struct space *space_create(unsigned int particle_count, int w, int h)
+struct space *space_create(unsigned int particle_count, int min_w, int min_h,
+ int max_w, int max_h)
{
struct space *new = malloc(sizeof(struct space) +
sizeof(struct particle) * particle_count);
@@ -31,14 +32,21 @@ struct space *space_create(unsigned int particle_count, int w, int h)
return NULL;
new->particle_count = particle_count;
- new->w = w;
- new->h = h;
+ new->min_w = min_w;
+ new->min_h = min_h;
+ new->max_w = max_w;
+ new->max_h = max_h;
+
+ new->gax = 0;
+ new->gay = 0;
+
+ new->elasticity = (1<<8) - (1<<6);
unsigned int i;
for (i = 0; i < particle_count; i++) {
- new->particles[i].x = random() % w;
- new->particles[i].y = random() % h;
+ new->particles[i].x = random() % (max_w - min_w) + min_w;
+ new->particles[i].y = random() % (max_h - min_h) + min_h;
new->particles[i].vx = random() % 40 - 20;
new->particles[i].vy = random() % 40 - 20;
}
@@ -63,12 +71,12 @@ void space_draw_particles(GP_Context *context, struct space *space)
static void modify_speeds(struct space *space, int time)
{
- unsigned int i, j;
+ unsigned int i;
for (i = 0; i < space->particle_count; i++) {
-// space->particles[i].vx += * time;
- space->particles[i].vy += time;
- }
+ space->particles[i].vy += space->gax * time;
+ space->particles[i].vy += space->gay * time;
+ }
}
void space_time_tick(struct space *space, int time)
@@ -78,11 +86,14 @@ void space_time_tick(struct space *space, int time)
modify_speeds(space, time);
for (i = 0; i < space->particle_count; i++) {
- if (space->particles[i].x <= 2 || space->particles[i].x >= space->w - 2)
- space->particles[i].vx *= -0.9;
+
+ if ((space->particles[i].x < space->min_w && space->particles[i].vx < 0) ||
+ (space->particles[i].x >= space->max_w && space->particles[i].vx > 0))
+ space->particles[i].vx = GP_FP_MUL(space->particles[i].vx, -space->elasticity);
- if (space->particles[i].y <= 2 || space->particles[i].y >= space->h - 2)
- space->particles[i].vy *= -0.9;
+ if ((space->particles[i].y < space->min_h && space->particles[i].vy < 0) ||
+ (space->particles[i].y >= space->max_h && space->particles[i].vy > 0))
+ space->particles[i].vy = GP_FP_MUL(space->particles[i].vy, -space->elasticity);
space->particles[i].x += space->particles[i].vx * time;
space->particles[i].y += space->particles[i].vy * time;
diff --git a/demos/particle/space.h b/demos/particle/space.h
index 0cb7c3f..d4b01a5 100644
--- a/demos/particle/space.h
+++ b/demos/particle/space.h
@@ -44,13 +44,25 @@ struct particle {
struct space {
unsigned int particle_count;
- int w;
- int h;
+ /* space is an rectanle */
+ int min_w;
+ int min_h;
+
+ int max_w;
+ int max_h;
+
+ /* gravitation vector */
+ int gax;
+ int gay;
+
+ /* elasticity at the boudaries */
+ int elasticity;
struct particle particles[];
};
-struct space *space_create(unsigned int particle_count, int w, int h);
+struct space *space_create(unsigned int particle_count, int min_w, int min_h,
+ int max_w, int max_h);
void space_destroy(struct space *space);
http://repo.or.cz/w/gfxprim.git/commit/565271d45d92a19f90b6f8ec637e8626fe8c…
commit 565271d45d92a19f90b6f8ec637e8626fe8c1f0f
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Feb 12 19:41:53 2012 +0100
gfx: Added PutPixelAA.
diff --git a/demos/particle/Makefile b/demos/particle/Makefile
new file mode 100644
index 0000000..9843284
--- /dev/null
+++ b/demos/particle/Makefile
@@ -0,0 +1,13 @@
+TOPDIR=../..
+
+CSOURCES=$(shell echo *.c)
+
+INCLUDE=
+LDLIBS+=-lGP -lGP_backends -lSDL -L$(TOPDIR)/build/
+
+APPS=particle_demo
+
+$(APPS): space.o
+
+include $(TOPDIR)/include.mk
+include $(TOPDIR)/app.mk
diff --git a/demos/particle/particle_demo.c b/demos/particle/particle_demo.c
new file mode 100644
index 0000000..4615607
--- /dev/null
+++ b/demos/particle/particle_demo.c
@@ -0,0 +1,153 @@
+/*****************************************************************************
+ * 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> *
+ * *
+ *****************************************************************************/
+
+ /*
+
+ Particle demo.
+
+ */
+
+#include <signal.h>
+#include <string.h>
+#include <GP.h>
+#include <backends/GP_Backends.h>
+
+#include "space.h"
+
+static GP_Pixel black_pixel;
+static GP_Pixel white_pixel;
+
+static GP_Backend *backend = NULL;
+static GP_Context *context = NULL;
+
+static void sighandler(int signo)
+{
+ if (backend != NULL)
+ GP_BackendExit(backend);
+
+ fprintf(stderr, "Got signal %in", signo);
+
+ exit(1);
+}
+
+static void init_backend(const char *backend_opts)
+{
+ if (!strcmp(backend_opts, "fb")) {
+ fprintf(stderr, "Initalizing framebuffer backendn");
+ backend = GP_BackendLinuxFBInit("/dev/fb0");
+ }
+
+ 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);
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ const char *backend_opts = "fb";
+ int opt;
+ int pause_flag = 1;
+
+ while ((opt = getopt(argc, argv, "b:Ii:Ps:r:")) != -1) {
+ switch (opt) {
+ case 'b':
+ backend_opts = optarg;
+ break;
+ default:
+ fprintf(stderr, "Invalid paramter '%c'n", opt);
+ }
+ }
+
+ GP_SetDebugLevel(10);
+
+ signal(SIGINT, sighandler);
+ signal(SIGSEGV, sighandler);
+ signal(SIGBUS, sighandler);
+ signal(SIGABRT, sighandler);
+
+ init_backend(backend_opts);
+
+ context = backend->context;
+
+ black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, context);
+ white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, context);
+
+ GP_Fill(context, black_pixel);
+ GP_BackendFlip(backend);
+
+ struct space *space = space_create(1000, context->w<<8, context->h<<8);
+
+ for (;;) {
+ if (backend->Poll)
+ GP_BackendPoll(backend);
+
+ usleep(5000);
+
+ /* Read and parse events */
+ GP_Event ev;
+
+ while (GP_EventGet(&ev)) {
+
+ GP_EventDump(&ev);
+
+ switch (ev.type) {
+ case GP_EV_KEY:
+ if (ev.code != GP_EV_KEY_DOWN)
+ continue;
+
+ switch (ev.val.key.key) {
+ case GP_KEY_ESC:
+ case GP_KEY_ENTER:
+ case GP_KEY_Q:
+ GP_BackendExit(backend);
+ return 0;
+ break;
+ case GP_KEY_P:
+ pause_flag = !pause_flag;
+ break;
+ }
+ break;
+ }
+ }
+
+ if (!pause_flag) {
+ space_time_tick(space, 2);
+ space_draw_particles(context, space);
+ GP_BackendFlip(backend);
+ }
+ }
+
+ GP_BackendExit(backend);
+
+ return 0;
+}
diff --git a/demos/particle/runtest.sh b/demos/particle/runtest.sh
new file mode 100755
index 0000000..0794707
--- /dev/null
+++ b/demos/particle/runtest.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+#
+# Run dynamically linked test.
+#
+
+PROG="$1"
+shift
+
+LD_LIBRARY_PATH=../../build/ ./$PROG "$@"
diff --git a/demos/particle/space.c b/demos/particle/space.c
new file mode 100644
index 0000000..bdf87e0
--- /dev/null
+++ b/demos/particle/space.c
@@ -0,0 +1,90 @@
+/*****************************************************************************
+ * 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 "space.h"
+
+struct space *space_create(unsigned int particle_count, int w, int h)
+{
+ struct space *new = malloc(sizeof(struct space) +
+ sizeof(struct particle) * particle_count);
+
+ if (new == NULL)
+ return NULL;
+
+ new->particle_count = particle_count;
+ new->w = w;
+ new->h = h;
+
+ unsigned int i;
+
+ for (i = 0; i < particle_count; i++) {
+ new->particles[i].x = random() % w;
+ new->particles[i].y = random() % h;
+ new->particles[i].vx = random() % 40 - 20;
+ new->particles[i].vy = random() % 40 - 20;
+ }
+
+ return new;
+}
+
+void space_destroy(struct space *space)
+{
+ free(space);
+}
+
+void space_draw_particles(GP_Context *context, struct space *space)
+{
+ unsigned int i;
+
+ GP_Fill(context, 0);
+
+ for (i = 0; i < space->particle_count; i++)
+ GP_PutPixelAA(context, space->particles[i].x, space->particles[i].y, 0xffffff);
+}
+
+static void modify_speeds(struct space *space, int time)
+{
+ unsigned int i, j;
+
+ for (i = 0; i < space->particle_count; i++) {
+// space->particles[i].vx += * time;
+ space->particles[i].vy += time;
+ }
+}
+
+void space_time_tick(struct space *space, int time)
+{
+ unsigned int i;
+
+ modify_speeds(space, time);
+
+ for (i = 0; i < space->particle_count; i++) {
+ if (space->particles[i].x <= 2 || space->particles[i].x >= space->w - 2)
+ space->particles[i].vx *= -0.9;
+
+ if (space->particles[i].y <= 2 || space->particles[i].y >= space->h - 2)
+ space->particles[i].vy *= -0.9;
+
+ space->particles[i].x += space->particles[i].vx * time;
+ space->particles[i].y += space->particles[i].vy * time;
+ }
+}
diff --git a/include/gfx/GP_Gfx.h b/demos/particle/space.h
similarity index 64%
copy from include/gfx/GP_Gfx.h
copy to demos/particle/space.h
index 54648a8..0cb7c3f 100644
--- a/include/gfx/GP_Gfx.h
+++ b/demos/particle/space.h
@@ -16,42 +16,46 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
-/*
+ /*
+
+ Particle demo.
+
+ */
+
+#ifndef PARTICLE_H
+#define PARTICLE_H
+
+#include <GP.h>
+
+struct particle {
+ /* fixed point coordinates */
+ int x;
+ int y;
+
+ /* fixed point speed */
+ int vx;
+ int vy;
+};
+
+struct space {
+ unsigned int particle_count;
- This is a main header for gfx part.
+ int w;
+ int h;
- */
+ struct particle particles[];
+};
-#ifndef GP_GFX_H
-#define GP_GFX_H
+struct space *space_create(unsigned int particle_count, int w, int h);
-/* basic definitions and structures */
-#include "core/GP_Context.h"
-#include "core/GP_GetPutPixel.h"
-#include "core/GP_WritePixel.h"
+void space_destroy(struct space *space);
-/* public drawing API */
-#include "GP_Fill.h"
-#include "GP_HLine.h"
-#include "GP_VLine.h"
-#include "GP_Line.h"
-#include "GP_Rect.h"
-#include "GP_Triangle.h"
-#include "GP_Tetragon.h"
-#include "GP_Circle.h"
-#include "GP_CircleSeg.h"
-#include "GP_Ellipse.h"
-#include "GP_Arc.h"
-#include "GP_Polygon.h"
-#include "GP_Symbol.h"
+void space_draw_particles(GP_Context *context, struct space *space);
-#include "GP_RectAA.h"
+void space_time_tick(struct space *space, int time);
-#endif /* GP_GFX_H */
+#endif /* PARTICLE_H */
diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_Gfx.h
index 54648a8..acc5fd2 100644
--- a/include/gfx/GP_Gfx.h
+++ b/include/gfx/GP_Gfx.h
@@ -53,5 +53,6 @@
#include "GP_Symbol.h"
#include "GP_RectAA.h"
+#include "GP_PutPixelAA.h"
#endif /* GP_GFX_H */
diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_PutPixelAA.h
similarity index 65%
copy from include/gfx/GP_Gfx.h
copy to include/gfx/GP_PutPixelAA.h
index 54648a8..7d697c7 100644
--- a/include/gfx/GP_Gfx.h
+++ b/include/gfx/GP_PutPixelAA.h
@@ -16,42 +16,42 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
/*
+
+ Puts an anti aliased pixel to context.
- This is a main header for gfx part.
+ The coordinates are in XX.8 fixed point format, see core/GP_FixedPoint.h
+ for helper macros.
+
+ For RGB contexts gamma correction tables are used to generate correct
+ intensity for pixels.
*/
-#ifndef GP_GFX_H
-#define GP_GFX_H
+#ifndef GFX_GP_PUT_PIXEL_AA_H
+#define GFX_GP_PUT_PIXEL_AA_H
-/* basic definitions and structures */
#include "core/GP_Context.h"
-#include "core/GP_GetPutPixel.h"
-#include "core/GP_WritePixel.h"
-
-/* public drawing API */
-#include "GP_Fill.h"
-#include "GP_HLine.h"
-#include "GP_VLine.h"
-#include "GP_Line.h"
-#include "GP_Rect.h"
-#include "GP_Triangle.h"
-#include "GP_Tetragon.h"
-#include "GP_Circle.h"
-#include "GP_CircleSeg.h"
-#include "GP_Ellipse.h"
-#include "GP_Arc.h"
-#include "GP_Polygon.h"
-#include "GP_Symbol.h"
-
-#include "GP_RectAA.h"
-
-#endif /* GP_GFX_H */
+
+/*
+ * Anti Aliased Put Pixel respecting context rotation flags and with clipping.
+ */
+void GP_PutPixelAA(GP_Context *context, GP_Coord x, GP_Coord y, GP_Pixel pixel);
+
+/*
+ * Anti Aliased Put Pixel with clipping.
+ */
+void GP_PutPixelAA_Raw_Clipped(GP_Context *context, GP_Coord x, GP_Coord y,
+ GP_Pixel pixel);
+
+/*
+ * Raw Put Pixel.
+ */
+void GP_PutPixelAA_Raw(GP_Context *context, GP_Coord x, GP_Coord y,
+ GP_Pixel pixel);
+
+#endif /* GFX_GP_PUT_PIXEL_AA_H */
diff --git a/libs/gfx/GP_PutPixelAA.gen.c.t b/libs/gfx/GP_PutPixelAA.gen.c.t
new file mode 100644
index 0000000..625af68
--- /dev/null
+++ b/libs/gfx/GP_PutPixelAA.gen.c.t
@@ -0,0 +1,53 @@
+%% extends "base.c.t"
+
+{% block descr %}Anti Aliased Put Pixel{% endblock %}
+
+%% block body
+
+#include "core/GP_Context.h"
+#include "core/GP_MixPixels.h"
+#include "core/GP_FixedPoint.h"
+#include "core/GP_GammaCorrection.h"
+
+#include "gfx/GP_HLine.h"
+#include "gfx/GP_VLine.h"
+
+#define FP_TO_PERC(a) (GP_FP_ROUND_TO_INT((a) * 255))
+
+void GP_PutPixelAA_Raw(GP_Context *context, GP_Coord x, GP_Coord y,
+ GP_Pixel pixel)
+{
+ GP_Coord int_x = GP_FP_TO_INT(x);
+ GP_Coord int_y = GP_FP_TO_INT(y);
+ GP_Coord frac_x = GP_FP_FRAC(x);
+ GP_Coord frac_y = GP_FP_FRAC(y);
+ uint8_t perc;
+
+ perc = FP_TO_PERC(GP_FP_MUL(GP_FP_1 - frac_x, GP_FP_1 - frac_y));
+ GP_MixPixel_Raw_Clipped(context, int_x, int_y, pixel, perc);
+
+ perc = FP_TO_PERC(GP_FP_MUL(frac_x, GP_FP_1 - frac_y));
+ GP_MixPixel_Raw_Clipped(context, int_x + 1, int_y, pixel, perc);
+
+ perc = FP_TO_PERC(GP_FP_MUL(GP_FP_1 - frac_x, frac_y));
+ GP_MixPixel_Raw_Clipped(context, int_x, int_y + 1, pixel, perc);
+
+ perc = FP_TO_PERC(GP_FP_MUL(frac_x, frac_y));
+ GP_MixPixel_Raw_Clipped(context, int_x + 1, int_y + 1, pixel, perc);
+}
+
+void GP_PutPixelAA_Raw_Clipped(GP_Context *context, GP_Coord x, GP_Coord y,
+ GP_Pixel pixel)
+{
+ GP_PutPixelAA_Raw(context, x, y, pixel);
+}
+
+void GP_PutPixelAA(GP_Context *context, GP_Coord x, GP_Coord y, GP_Pixel pixel)
+{
+ GP_TRANSFORM_POINT_FP(context, x, y);
+
+ GP_PutPixelAA_Raw_Clipped(context, x, y, pixel);
+}
+
+
+%% endblock body
diff --git a/libs/gfx/Makefile b/libs/gfx/Makefile
index 64fd479..3e7cb28 100644
--- a/libs/gfx/Makefile
+++ b/libs/gfx/Makefile
@@ -1,6 +1,6 @@
TOPDIR=../..
CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c))
-GENSOURCES=GP_LineAA.gen.c
+GENSOURCES=GP_LineAA.gen.c GP_PutPixelAA.gen.c
LIBNAME=gfx
include $(TOPDIR)/gen.mk
-----------------------------------------------------------------------
Summary of changes:
demos/Makefile | 2 +-
{tests/drivers => demos/particle}/Makefile | 5 +-
demos/particle/particle_demo.c | 160 +++++++++++++++++++++
demos/{fbshow => particle}/runtest.sh | 0
demos/particle/space.c | 101 +++++++++++++
demos/{fbshow/cpu_timer.h => particle/space.h} | 57 +++++---
include/gfx/GP_Gfx.h | 1 +
include/{loaders/GP_JPG.h => gfx/GP_PutPixelAA.h} | 45 +++---
libs/gfx/GP_PutPixelAA.gen.c.t | 53 +++++++
libs/gfx/Makefile | 2 +-
10 files changed, 382 insertions(+), 44 deletions(-)
copy {tests/drivers => demos/particle}/Makefile (76%)
create mode 100644 demos/particle/particle_demo.c
copy demos/{fbshow => particle}/runtest.sh (100%)
create mode 100644 demos/particle/space.c
copy demos/{fbshow/cpu_timer.h => particle/space.h} (68%)
copy include/{loaders/GP_JPG.h => gfx/GP_PutPixelAA.h} (66%)
create mode 100644 libs/gfx/GP_PutPixelAA.gen.c.t
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.")
1
0