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/b3b9438ff87b573ce38bde2602edb0b070865...
commit b3b9438ff87b573ce38bde2602edb0b07086560d Author: Cyril Hrubis metan@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/1434e01b44e30a1e00c7f10d92d87304ce7f8...
commit 1434e01b44e30a1e00c7f10d92d87304ce7f8f3a Author: Cyril Hrubis metan@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/7d9c51d82767ee65ed41023f8851ba8e89d1e...
commit 7d9c51d82767ee65ed41023f8851ba8e89d1e1e5 Author: Cyril Hrubis metan@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@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/ef3231da764cd212ba973958aafd57ce1c286...
commit ef3231da764cd212ba973958aafd57ce1c286ce6 Author: Cyril Hrubis metan@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@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.