diff TaskManager/Test/simple_render/viewer.cpp @ 99:57bac9e07662

rotate cube only polygon
author gongo
date Fri, 29 Feb 2008 05:20:23 +0900
parents 588ab5f0e659
children c31499d11926
line wrap: on
line diff
--- a/TaskManager/Test/simple_render/viewer.cpp	Thu Feb 28 21:45:13 2008 +0900
+++ b/TaskManager/Test/simple_render/viewer.cpp	Fri Feb 29 05:20:23 2008 +0900
@@ -94,11 +94,11 @@
     diffz1 = diffz;
     diffz = (zRow[x][y]>z);
     if (z < zRow[x][y]) { 
-	if (x < width && x > 0 && y > 0 && y < height) {
-	    zRow[x][y] = z;
-	    y = height - y;
-	    pixels[width*y + x] = rgb;
-	}
+	 if (x < width && x > 0 && y > 0 && y < height) {
+	      zRow[x][y] = z;
+	      y = height - y;
+	      pixels[width*y + x] = rgb;
+	 }
     }
 }
 
@@ -225,9 +225,11 @@
 DmaBuffer *pp_buff;
 DmaBuffer *ssl_buff;
 
-SPANPACK send_pack[10] __attribute__((aligned(16)));
+SPANPACK send_pack[6][10] __attribute__((aligned(16)));
 unsigned int fbdev_addr;
 
+void *__texture;
+
 extern int get_fbdev_addr(void);
 
 void
@@ -279,7 +281,7 @@
 
     pixels = new Uint32[width*height];
     
-    graph_line();
+    //graph_line();
 
     bitmap = SDL_CreateRGBSurfaceFrom((void *)pixels, width, height, 32,
 				      width*4, redMask, greenMask,
@@ -288,6 +290,12 @@
     fd = manager->open("ViewerRunLoop");
     task = manager->create_task(fd, 0, 0, 0, NULL);      
     task->spawn();
+    
+    posix_memalign((void**)&__texture, 16, 128*128*3);
+    memcpy(__texture, polygon->texture_image->pixels, 128*128*3);
+    HTaskPtr task_init_tex = manager->create_task(0, 0, (uint32)__texture, 0, NULL);
+    task_init_tex->set_cpu(CPU_SPE);
+    task_init_tex->spawn();
 
     fbdev_addr = get_fbdev_addr();
 }
@@ -325,7 +333,7 @@
     //zRow_init();
 
     // これ自身、一つのタスクとして回す方がよいか
-    graph_line();
+    //graph_line();
 
     fd_update_sgp = manager->open("UpdateSGP");
     fd_create_pp  = manager->open("CreatePP");
@@ -387,38 +395,42 @@
  * 本当はタスクとして TestDraw を選ぶ
  */
 
-//#define DRAW_POLYGON
-#define DRAW_SPANPACK
+#define DRAW_POLYGON
+//#define DRAW_SPANPACK
 //#define DRAW_SPUSPAN
 void
 Viewer::run_draw(void)
 {
     HTaskPtr task;
-    HTaskPtr task_draw[10];
+    HTaskPtr task_draw[6][10];
     int fd;
 
     fd = manager->open("ViewerRunLoop");
     task = manager->create_task(fd, 0, 0, 0, NULL);
 
-    for (int i = 0; i < 10; i++) {
-	memcpy(&send_pack[i], &ssl->ss[0].spp[i], sizeof(SPANPACK));
-	task_draw[i]
-	    = manager->create_task(0, sizeof(SPANPACK),
-				   (uint32)&send_pack[i], fbdev_addr, NULL);
-	task_draw[i]->set_cpu(CPU_SPE);
-	task->set_depend(task_draw[i]);
-	task_draw[i]->spawn();
+#if 1
+    for (int j = 0; j < 6; j++) {
+	 for (int i = 0; i < 10; i++) {
+	      if (ssl->ss[j].spp[i].info.size < 1) continue;
+	      memcpy(&send_pack[j][i], &ssl->ss[j].spp[i], sizeof(SPANPACK));
+	      task_draw[j][i]
+		   = manager->create_task(1, sizeof(SPANPACK),
+					  (uint32)&send_pack[j][i], fbdev_addr, NULL);
+	      task_draw[j][i]->set_cpu(CPU_SPE);
+	      task->set_depend(task_draw[j][i]);
+	      task_draw[j][i]->spawn();
+	 }
     }
-
+#endif
     task->spawn();
 
     SDL_BlitSurface(bitmap, NULL, screen, NULL);
     SDL_UpdateRect(screen, 0, 0, 0, 0);    
 
     frames++;
-
+    
     return;
-
+    
 #if 0 // USE DOUBLE BUFFER
     PolygonPack *pp;
     SPUSPANLIST *ssl;
@@ -449,6 +461,8 @@
     polygon->draw(&ssl->ss[5]);
 #  endif
 #endif
+
+    return;
 }
 
 #if 0
@@ -475,6 +489,8 @@
     delete polygon;
     //delete sgp_buff;
     //delete pp_buff;
+
+    free(__texture);
     quit();
 }