diff test/nds-test-progs/sprite2/source/testsprite2.c @ 2695:c04a266c277a gsoc2008_nds

More sprite-driven texture work in the render/video drivers.
author Darren Alton <dalton@stevens.edu>
date Sun, 17 Aug 2008 09:50:28 +0000
parents c1c7cb1b5a47
children e1da92da346c
line wrap: on
line diff
--- a/test/nds-test-progs/sprite2/source/testsprite2.c	Sat Aug 16 12:58:36 2008 +0000
+++ b/test/nds-test-progs/sprite2/source/testsprite2.c	Sun Aug 17 09:50:28 2008 +0000
@@ -7,6 +7,8 @@
 #include <fat.h>
 #include "common.h"
 
+#include "icon_bmp_bin.h"
+
 #define NUM_SPRITES	10
 #define MAX_SPEED 	1
 
@@ -79,6 +81,24 @@
     return (0);
 }
 
+int LoadSprite2(const u8* ptr, int size) {
+    int i;
+    SDL_Rect r = {0,0,32,32};
+    for (i = 0; i < state->num_windows; ++i) {
+        SDL_SelectRenderer(state->windows[i]);
+        sprites[i] = SDL_CreateTexture(SDL_PIXELFORMAT_ABGR1555,
+                                       SDL_TEXTUREACCESS_STATIC, r.w, r.h);
+        if (!sprites[i]) {
+            fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
+            return -1;
+        }
+        SDL_UpdateTexture(sprites[i], &r, ptr, r.w*2);
+        SDL_SetTextureBlendMode(sprites[i], blendMode);
+        SDL_SetTextureScaleMode(sprites[i], scaleMode);
+    }
+    return 0;
+}
+
 void
 MoveSprites(SDL_WindowID window, SDL_TextureID sprite)
 {
@@ -236,7 +256,8 @@
         SDL_SelectRenderer(state->windows[i]);
         SDL_RenderFill(0xA0, 0xA0, 0xA0, 0xFF, NULL);
     }
-    if (LoadSprite("icon.bmp") < 0) {
+    if (LoadSprite2(icon_bmp_bin, icon_bmp_bin_size) < 0) {
+        printf("errored.\n");
         quit(2);
     }