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 54a1f43dff8349c620ab43306651236f9143e5ee (commit) via 06eae5a43e1b6e46979c1e42e392475cbde92947 (commit) from 5f13bc0a920bfb4b903a6982b66a091825c4228e (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/54a1f43dff8349c620ab43306651236f9143e...
commit 54a1f43dff8349c620ab43306651236f9143e5ee Author: Cyril Hrubis metan@ucw.cz Date: Fri Oct 19 21:49:18 2012 +0200
demos: c_simple: Port linetest to backends.
diff --git a/demos/c_simple/Makefile b/demos/c_simple/Makefile index 2c03ec8..f703dd1 100644 --- a/demos/c_simple/Makefile +++ b/demos/c_simple/Makefile @@ -9,7 +9,7 @@ LDLIBS+=-lrt `$(TOPDIR)/gfxprim-config --libs --libs-backends` APPS=backend_example loaders_example loaders filters_symmetry gfx_koch virtual_backend_example meta_data meta_data_dump tmp_file showimage v4l2_show v4l2_grab convolution weighted_median shapetest koch input- fileview + fileview linetest
v4l2_show: LDLIBS+=-lGP_grabbers v4l2_grab: LDLIBS+=-lGP_grabbers diff --git a/demos/c_simple/linetest.c b/demos/c_simple/linetest.c new file mode 100644 index 0000000..9e7078b --- /dev/null +++ b/demos/c_simple/linetest.c @@ -0,0 +1,137 @@ +/***************************************************************************** + * 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-2010 Jiri "BlueBear" Dluhos * + * jiri.bluebear.dluhos@gmail.com * + * * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#include <math.h> + +#include <GP.h> + +/* Values for color pixels in display format. */ +static GP_Pixel black, white; + +static double start_angle = 0.0; + +static int aa_flag = 0; +static int pause_flag = 0; + +static GP_Backend *win; + +void redraw_screen(void) +{ + double angle; + int x, y; + int w = win->context->w; + int h = win->context->h; + int xcenter = w/2; + int ycenter = h/2; + + GP_Fill(win->context, black); + + for (angle = 0.0; angle < 2*M_PI; angle += 0.1) { + x = (int) (w/2 * cos(start_angle + angle)); + y = (int) (h/2 * sin(start_angle + angle)); + + int r = 127.0 + 127.0 * cos(start_angle + angle); + int b = 127.0 + 127.0 * sin(start_angle + angle); + + GP_Pixel pixel; + pixel = GP_RGBToPixel(r, 0, b, win->context->pixel_type); + + if (aa_flag) { + GP_LineAA_Raw(win->context, GP_FP_FROM_INT(xcenter), GP_FP_FROM_INT(ycenter), + GP_FP_FROM_INT(xcenter + x), GP_FP_FROM_INT(ycenter + y), pixel); + } else { + GP_Line(win->context, xcenter + x, ycenter + y, xcenter, ycenter, pixel); + GP_Line(win->context, xcenter, ycenter, xcenter + x, ycenter + y, pixel); + } + } + + GP_BackendFlip(win); + + /* axes */ +// GP_HLineXYW(&context, 0, ycenter, display->w, white); +// GP_VLineXYH(&context, xcenter, 0, display->h, white); +} + +void event_loop(void) +{ + GP_Event ev; + + while (GP_EventGet(&ev)) { + switch (ev.type) { + case GP_EV_KEY: + if (ev.code != GP_EV_KEY_DOWN) + continue; + + switch (ev.val.key.key) { + case GP_KEY_A: + aa_flag = !aa_flag; + break; + case GP_KEY_ESC: + GP_BackendExit(win); + exit(0); + break; + case GP_KEY_P: + pause_flag = !pause_flag; + break; + } + } + } +} + +int main(void) +{ + const char *backend_opts = "X11"; + + win = GP_BackendInit(backend_opts, "Line Test", stderr); + + if (win == NULL) { + fprintf(stderr, "Failed to initalize backend '%s'n", + backend_opts); + return 1; + } + + white = GP_ColorToContextPixel(GP_COL_WHITE, win->context); + black = GP_ColorToContextPixel(GP_COL_BLACK, win->context); + + redraw_screen(); + + for (;;) { + GP_BackendPoll(win); + event_loop(); + + usleep(20000); + + if (pause_flag) + continue; + + redraw_screen(); + GP_BackendFlip(win); + + start_angle += 0.01; + if (start_angle > 2*M_PI) { + start_angle = 0.0; + } + } +} diff --git a/tests/SDL/Makefile b/tests/SDL/Makefile index 9dd15e9..1002fcb 100644 --- a/tests/SDL/Makefile +++ b/tests/SDL/Makefile @@ -7,7 +7,7 @@ LDLIBS+=-lGP -L$(TOPDIR)/build/ -lGP_SDL -lSDL ifeq ($(HAVE_LIBSDL),yes) CSOURCES=$(shell echo *.c)
-APPS=pixeltest fonttest linetest randomshapetest+APPS=pixeltest fonttest randomshapetest symbolstest textaligntest blittest subcontext aatest mixpixeltest endif diff --git a/tests/SDL/linetest.c b/tests/SDL/linetest.c deleted file mode 100644 index 5a2e082..0000000 --- a/tests/SDL/linetest.c +++ /dev/null @@ -1,167 +0,0 @@ -/***************************************************************************** - * 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-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * - * * - *****************************************************************************/ - -#include <math.h> -#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 black, white; - -Uint32 timer_callback(__attribute__((unused)) Uint32 interval, - __attribute__((unused)) void * param) -{ - timer_event.type = SDL_USEREVENT; - SDL_PushEvent((SDL_Event *) &timer_event); - return 30; -} - -double start_angle = 0.0; - -static int aa_flag = 0; -static int pause_flag = 0; - -void redraw_screen(void) -{ - double angle; - int x, y; - int xcenter = display->w/2; - int ycenter = display->h/2; - - SDL_LockSurface(display); - GP_Fill(&context, black); - - for (angle = 0.0; angle < 2*M_PI; angle += 0.1) { - x = (int) (display->w/2 * cos(start_angle + angle)); - y = (int) (display->h/2 * sin(start_angle + angle)); - - Uint8 r = 127.0 + 127.0 * cos(start_angle + angle); - Uint8 b = 127.0 + 127.0 * sin(start_angle + angle); - - GP_Pixel pixel; - pixel = GP_RGBToPixel(r, 0, b, context.pixel_type); - - if (aa_flag) { - GP_LineAA_Raw(&context, GP_FP_FROM_INT(xcenter), GP_FP_FROM_INT(ycenter), - GP_FP_FROM_INT(xcenter + x), GP_FP_FROM_INT(ycenter + y), pixel); - } else { - GP_Line(&context, xcenter + x, ycenter + y, xcenter, ycenter, pixel); - GP_Line(&context, xcenter, ycenter, xcenter + x, ycenter + y, pixel); - } - } - - /* axes */ -// GP_HLineXYW(&context, 0, ycenter, display->w, white); -// GP_VLineXYH(&context, xcenter, 0, display->h, white); - - SDL_UnlockSurface(display); -} - -void event_loop(void) -{ - SDL_Event event; - - while (SDL_WaitEvent(&event) > 0) { - switch (event.type) { - case SDL_USEREVENT: - redraw_screen(); - SDL_Flip(display); - - if (pause_flag) - continue; - - start_angle += 0.01; - if (start_angle > 2*M_PI) { - start_angle = 0.0; - } - break; - case SDL_KEYDOWN: - switch (event.key.keysym.sym) { - case SDLK_a: - aa_flag = !aa_flag; - break; - case SDLK_p: - pause_flag = !pause_flag; - break; - default: - return; - } - break; - case SDL_QUIT: - return; - } - } -} - -int main(int argc, char **argv) -{ - GP_RetCode retcode; - retcode = GP_SDL_VideoInit(&context, 640, 480, argc, argv); - if (retcode != GP_ESUCCESS) { - fprintf(stderr, "Video initialization failed: %sn", - GP_RetCodeName(retcode)); - return 1; - } - - display = SDL_GetVideoSurface(); - GP_SDL_ContextFromSurface(&context, display); - - /* Load colors in display format */ - black = GP_ColorToContextPixel(GP_COL_BLACK, &context); - white = 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/06eae5a43e1b6e46979c1e42e392475cbde92...
commit 06eae5a43e1b6e46979c1e42e392475cbde92947 Author: Cyril Hrubis metan@ucw.cz Date: Fri Oct 19 21:43:02 2012 +0200
input: Make use of GP_WARN().
diff --git a/libs/input/GP_Event.c b/libs/input/GP_Event.c index fe118ff..eab6b2e 100644 --- a/libs/input/GP_Event.c +++ b/libs/input/GP_Event.c @@ -24,7 +24,9 @@ #include <string.h> #include <stdlib.h>
-#include "GP_Common.h" +#include <core/GP_Debug.h> +#include <core/GP_Common.h> + #include "GP_Event.h"
/* Screen size for clipping the cursor possition */ @@ -202,7 +204,7 @@ static void event_put(struct GP_Event *ev) uint32_t next = (queue_last + 1) % GP_EVENT_QUEUE_SIZE;
if (next == queue_first) { - fprintf(stderr, "Event queue full, dropping eventn"); + GP_WARN("Event queue full, dropping event."); return; } @@ -359,7 +361,7 @@ void GP_EventPushKey(uint32_t key, uint8_t code, struct timeval *time) case GP_EV_KEY_REPEAT: break; default: - fprintf(stderr, "Invalid key event code %un", code); + GP_WARN("Invalid key event code %u", code); return; }
diff --git a/libs/input/GP_InputDriverSDL.c b/libs/input/GP_InputDriverSDL.c index 04cf416..18da085 100644 --- a/libs/input/GP_InputDriverSDL.c +++ b/libs/input/GP_InputDriverSDL.c @@ -24,7 +24,7 @@
#ifdef HAVE_LIBSDL
-#include "core/GP_Debug.h" +#include <core/GP_Debug.h>
#include "GP_Event.h" #include "GP_InputDriverSDL.h" @@ -138,7 +138,7 @@ void GP_InputDriverSDLEventPut(SDL_Event *ev) key = keysym_table2[keysym - 256];
if (key == 0) { - fprintf(stderr, "Unmapped SDL keysym %un", keysym); + GP_WARN("Unmapped SDL keysym %u", keysym); return; }
-----------------------------------------------------------------------
Summary of changes: demos/c_simple/Makefile | 2 +- demos/c_simple/linetest.c | 137 ++++++++++++++++++++++++++++++++ libs/input/GP_Event.c | 8 +- libs/input/GP_InputDriverSDL.c | 4 +- tests/SDL/Makefile | 2 +- tests/SDL/linetest.c | 167 ---------------------------------------- 6 files changed, 146 insertions(+), 174 deletions(-) create mode 100644 demos/c_simple/linetest.c delete mode 100644 tests/SDL/linetest.c
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.