| author | dessaya
<dessaya> 2004-06-26 02:47:04 UTC |
| committer | dessaya
<dessaya> 2004-06-26 02:47:04 UTC |
| parent | 59760f5a9464c5b5b26e1cf3b2b62267aa66c463 |
| FP/src/include/output.h | +1 | -0 |
| FP/src/ker/kernel.c | +15 | -6 |
| FP/src/out/output.c | +15 | -6 |
diff --git a/FP/src/include/output.h b/FP/src/include/output.h index 2ace89b..962cbab 100644 --- a/FP/src/include/output.h +++ b/FP/src/include/output.h @@ -66,6 +66,7 @@ void outputDrawBitmap(SDL_Surface *screen, void* image,int x, int y); */ void outputClearScreen(SDL_Surface *screen); +void outputUpdateScreen(SDL_Surface *screen); /* Crears the screen */ diff --git a/FP/src/ker/kernel.c b/FP/src/ker/kernel.c index fc15541..ddd2334 100644 --- a/FP/src/ker/kernel.c +++ b/FP/src/ker/kernel.c @@ -44,7 +44,8 @@ int kernel(int optionflag,int level) { */ tData* testResource; - SDL_Surface *screen; + SDL_Surface *screen, *test; + SDL_Event e; int i; screen = outputInit(); @@ -66,13 +67,21 @@ int kernel(int optionflag,int level) { testResource->type ); - for (i=0;i<testResource->frames;i++) { - printf("frame %d\n",i); - outputDrawBitmap(screen, testResource->pFrames[i], 3, 3); - SDL_UpdateRect(screen, 0, 0, 320, 200); + test = outputLoadBitmap(NULL, 0, NULL, 100, 100, 1, 1); + if (test == NULL) { + printf("BMP NO CARGADO: %s\n", SDL_GetError()); + exit(1); + } +/* for (i=0;i<testResource->frames;i++) { */ + while (1) { + if (SDL_PollEvent(&e)) { + if (e.type == SDL_QUIT) break; + } + outputDrawBitmap(screen, /*testResource->pFrames[i]*/test, 3, 3); outputClearScreen(screen); - getchar(); + outputUpdateScreen(screen); } +/* } */ outputStop(); return 0; diff --git a/FP/src/out/output.c b/FP/src/out/output.c index ac5497f..6e57136 100644 --- a/FP/src/out/output.c +++ b/FP/src/out/output.c @@ -98,6 +98,7 @@ void* outputLoadBitmap(const unsigned char* data, int size, int i,j; Uint32 rmask, gmask, bmask, amask; + /*return (void*)SDL_LoadBMP("s.bmp");*/ printf("outputLoadBitmap: I'm creating an SDL structure :p\n"); printf("outputLoadBitmap: invert=%d. transparent=%d. size=%d\n", invert, firstColorTransparent, size); @@ -114,7 +115,7 @@ void* outputLoadBitmap(const unsigned char* data, int size, amask = 0xff000000; #endif - result = SDL_CreateRGBSurface(0, w, h, 8, rmask, gmask, bmask, amask); + result = SDL_CreateRGBSurface(0, w, h, 16, rmask, gmask, bmask, amask); if (!result) { fprintf(stderr, "CreateRGBSurface failed: %s\n", SDL_GetError()); @@ -144,10 +145,10 @@ void* outputLoadBitmap(const unsigned char* data, int size, } } - for (i = 0; i < w; i++) { - for (j = 0; j < h; j++) { - putpixel(result, i, j, - SDL_MapRGB(result->format, 0xff, 0xff, 0x00)); + for (i = 0; i < result->w; i++) { + for (j = 0; j < result->h; j++) { + putpixel(result, i, j, 0xFFFF00); + /*SDL_MapRGB(result->format, 0xff, 0xff, 0x00));*/ } } @@ -169,18 +170,26 @@ void outputDrawBitmap(SDL_Surface *screen, void* image, int x, int y) { /* Draws an abstract image */ SDL_Surface *s = (SDL_Surface *)image; /* SDL_Rect destrect = {x, y, s->w, s->h};*/ + if (SDL_MUSTLOCK(screen)) + SDL_LockSurface(screen); SDL_BlitSurface(s, NULL, screen, NULL); + if (SDL_MUSTLOCK(screen)) + SDL_UnlockSurface(screen); } void outputClearScreen(SDL_Surface *screen) { } +void outputUpdateScreen(SDL_Surface *screen) { + SDL_Flip(screen); +} + /* Initialization */ SDL_Surface *outputInit() { SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO); atexit(outputStop); - return SDL_SetVideoMode(320, 200, 8, 0); + return SDL_SetVideoMode(320, 200, 8, SDL_ANYFORMAT|SDL_DOUBLEBUF); } void outputStop()