[Gfxprim] [repo.or.cz] gfxprim.git branch generate updated: 3223defa8a39310a0b60f6ce933e0cca072068d8

metan metan at ucw.cz
Sat Aug 20 20:32:51 CEST 2011


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, generate has been updated
       via  3223defa8a39310a0b60f6ce933e0cca072068d8 (commit)
       via  b384b2242443491008ebbda84b8d2aa06d9faf75 (commit)
       via  e8932538556c9864d5f0cd4e2a1b113a66282a58 (commit)
      from  2cd6436b86198dce6fbbbfa48c9b8831144ea4ea (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/3223defa8a39310a0b60f6ce933e0cca072068d8

commit 3223defa8a39310a0b60f6ce933e0cca072068d8
Author: Cyril Hrubis <metan at ucw.cz>
Date:   Sat Aug 20 20:32:36 2011 +0200

    Cleaned up the blittest code.

diff --git a/tests/SDL/blittest.c b/tests/SDL/blittest.c
index fe92757..2e34564 100644
--- a/tests/SDL/blittest.c
+++ b/tests/SDL/blittest.c
@@ -27,13 +27,15 @@
 #include <stdlib.h>
 #include <SDL/SDL.h>
 
+#include "GP.h"
 #include "GP_SDL.h"
 
 static GP_Pixel black;
+static GP_Pixel white;
 
 SDL_Surface *display = NULL;
 GP_Context context;
-GP_Context *bitmap;
+GP_Context *bitmap, *bitmap_raw, *bitmap_conv;
 
 SDL_TimerID timer;
 
@@ -51,6 +53,7 @@ Uint32 timer_callback(__attribute__((unused)) Uint32 interval,
 	return 10;
 }
 
+static char text_buf[255];
 
 void redraw_screen(void)
 {
@@ -82,13 +85,29 @@ void redraw_screen(void)
 
 	SDL_LockSurface(display);
 
+	GP_Text(&context, NULL, 20, 20, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, text_buf, white);
 	GP_Blit_Naive(bitmap, 0, 0, bitmap->w, bitmap->h, &context, bitmap_x, bitmap_y);
 
 	SDL_UpdateRect(display, bitmap_x, bitmap_y, bitmap->w, bitmap->h);
+	SDL_UpdateRect(display, 20, 20, 300, 50);
 
 	SDL_UnlockSurface(display);
 }
 
+static void change_bitmap(void)
+{
+	if (bitmap == bitmap_raw)
+		bitmap = bitmap_conv;
+	else
+		bitmap = bitmap_raw;
+	
+	snprintf(text_buf, sizeof(text_buf), "Blitting '%s' -> '%s'",
+	         GP_PixelTypes[bitmap->pixel_type].name,
+		 GP_PixelTypes[context.pixel_type].name);
+
+	GP_FillRectXYWH(&context, 20, 20, 300, 50, black);
+}
+
 void event_loop(void)
 {
 	SDL_Event event;
@@ -100,12 +119,14 @@ void event_loop(void)
 		case SDL_USEREVENT:
 			redraw_screen();
 			break;
-
 		case SDL_KEYDOWN:
 			switch (event.key.keysym.sym) {
 			case SDLK_p:
 				pause_flag = !pause_flag;
 			break;
+			case SDLK_SPACE:
+				change_bitmap();
+			break;
 			case SDLK_ESCAPE:
 				return;
 
@@ -143,11 +164,11 @@ int main(int argc, char *argv[])
 
 	GP_RetCode ret;
 
-	if (ret = GP_LoadPGM("ball.pgm", &bitmap)) {
-		fprintf(stderr, "Failed to load fractal: %sn", GP_RetCodeName(ret));
+	if ((ret = GP_LoadPGM("ball.pgm", &bitmap_raw))) {
+		fprintf(stderr, "Failed to load bitmap: %sn", GP_RetCodeName(ret));
 		return 1;
 	}
-
+	
 	/* Initialize SDL */
 	if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) {
 		fprintf(stderr, "Could not initialize SDL: %sn", SDL_GetError());
@@ -162,8 +183,12 @@ int main(int argc, char *argv[])
 	}
 
 	GP_SDL_ContextFromSurface(&context, display);
+	
+	bitmap_conv = GP_ContextConvert(bitmap_raw, context.pixel_type);
+	change_bitmap();
 
 	black = GP_ColorToPixel(&context, GP_COL_BLACK);
+	white = GP_ColorToPixel(&context, GP_COL_WHITE);
 
 	/* Set up the refresh timer */
 	timer = SDL_AddTimer(60, timer_callback, NULL);

http://repo.or.cz/w/gfxprim.git/commit/b384b2242443491008ebbda84b8d2aa06d9faf75

commit b384b2242443491008ebbda84b8d2aa06d9faf75
Author: Cyril Hrubis <metan at ucw.cz>
Date:   Sat Aug 20 20:31:51 2011 +0200

    Added loaders into GP.h.

diff --git a/include/GP.h b/include/GP.h
index 14acffc..2d72546 100644
--- a/include/GP.h
+++ b/include/GP.h
@@ -41,4 +41,7 @@
 /* input and events */
 #include "input/GP_Event.h"
 
+/* bitmap loaders */
+#include "loaders/GP_Loaders.h"
+
 #endif /* GP_H */

http://repo.or.cz/w/gfxprim.git/commit/e8932538556c9864d5f0cd4e2a1b113a66282a58

commit e8932538556c9864d5f0cd4e2a1b113a66282a58
Author: Cyril Hrubis <metan at ucw.cz>
Date:   Sat Aug 20 20:31:32 2011 +0200

    Added naive context conversion (based on blit).

diff --git a/include/core/GP_Context.h b/include/core/GP_Context.h
index cf65432..4c620b8 100644
--- a/include/core/GP_Context.h
+++ b/include/core/GP_Context.h
@@ -102,6 +102,14 @@ GP_Context *GP_ContextAlloc(uint32_t w, uint32_t h, GP_PixelType type);
 GP_Context *GP_ContextCopy(GP_Context *context, int flag);
 
 /*
+ * Converts context to different pixel type.
+ *
+ * This is naive implementation that doesn't do any ditherings or error
+ * diffusions.
+ */
+GP_Context *GP_ContextConvert(const GP_Context *context, GP_PixelType res_type);
+
+/*
  * Free context.
  */
 void GP_ContextFree(GP_Context *context);
diff --git a/libs/core/GP_Context.c b/libs/core/GP_Context.c
index 58c6a0b..af6ef26 100644
--- a/libs/core/GP_Context.c
+++ b/libs/core/GP_Context.c
@@ -24,6 +24,7 @@
  *****************************************************************************/
 
 #include "GP_Core.h"
+#include "GP_Blit.h"
 
 #include <string.h>
 
@@ -99,6 +100,18 @@ GP_Context *GP_ContextAlloc(uint32_t w, uint32_t h, GP_PixelType type)
 	return context;
 }
 
+GP_Context *GP_ContextConvert(const GP_Context *context, GP_PixelType res_type)
+{
+	GP_Context *ret = GP_ContextAlloc(context->w, context->h, res_type);
+
+	if (ret == NULL)
+		return NULL;
+
+	GP_Blit_Naive(context, 0, 0, context->w, context->h, ret, 0, 0);
+
+	return ret;
+}
+
 void GP_ContextFree(GP_Context *context)
 {
 	free(context->pixels);

-----------------------------------------------------------------------

Summary of changes:
 include/GP.h              |    3 +++
 include/core/GP_Context.h |    8 ++++++++
 libs/core/GP_Context.c    |   13 +++++++++++++
 tests/SDL/blittest.c      |   35 ++++++++++++++++++++++++++++++-----
 4 files changed, 54 insertions(+), 5 deletions(-)


repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos at gmail.com
if you want to unsubscribe, or site admin admin at repo.or.cz if you receive
no reply.
-- 
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")



More information about the Gfxprim mailing list