changeset 51:c964110017c8

*** empty log message ***
author gongo
date Fri, 15 Feb 2008 19:44:23 +0900
parents 7927e00fb8e2
children e198c3e01cec
files TaskManager/Test/simple_render/Makefile TaskManager/Test/simple_render/viewer.cpp
diffstat 2 files changed, 33 insertions(+), 63 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Test/simple_render/Makefile	Fri Feb 15 19:36:08 2008 +0900
+++ b/TaskManager/Test/simple_render/Makefile	Fri Feb 15 19:44:23 2008 +0900
@@ -8,7 +8,7 @@
 TASK_OBJS = $(TASK_SRCS:.cpp=.o)
 
 CC      = g++
-CFLAGS  = -O9 -g -Wall -DDEBUG
+CFLAGS  = -O9 -g -Wall# -DDEBUG
 INCLUDE = -I../../../include/TaskManager -I.
 
 EXTRA_CFLAGS = `sdl-config --cflags` `xml2-config --cflags`\
--- a/TaskManager/Test/simple_render/viewer.cpp	Fri Feb 15 19:36:08 2008 +0900
+++ b/TaskManager/Test/simple_render/viewer.cpp	Fri Feb 15 19:44:23 2008 +0900
@@ -4,8 +4,6 @@
 #include <math.h>
 #include <unistd.h>
 #include "polygon.h"
-//#include "demonstration.h"
-//#include "scene.h"
 #include "viewer.h"
 #include "sys.h"
 using namespace std;
@@ -72,31 +70,20 @@
 }
 
 
-void Viewer::write_pixel(int x, int y,float z, Uint32 rgb) {
+void
+Viewer::write_pixel(int x, int y,float z, Uint32 rgb)
+{
     SDL_PixelFormat *pf;
     pf = screen->format;
-    //printf("x:%d y:%d z:%d\n",x,y,z);
-
-    //cout << "write_pixel" << endl;
-    //cout << x << "  " << y << endl;
-
-    //cout << SDL_MapRGB(pf,0,0,150) << endl;
-
     x += width/2;
     y += height/2;
 
     static int diffz,diffz1;
+
     diffz1 = diffz;
     diffz = (zRow[x][y]>z);
-    if(diffz != diffz1) {
-	//printf("diffz :%d zRow[%d][%d] = %f z = %f\n",diffz,x,y,zRow[x][y],z);
-    }
-    //printf("x:%d,y:%d,z:%f,zRow:%f\n",x,y,z,zRow[x][y]);
-    if(z < zRow[x][y]) { 
-//	 printf("x:%d,y:%d,z:%d\n",x,y,z,zRow);
-	if(x < width && x > 0 && y > 0 && y < height)
-	{
-	    //pixels[width*y + x] = SDL_MapRGB(pf,70,70,71);
+    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;
@@ -104,14 +91,10 @@
     }
 }
 
-void Viewer::write_line(float x1, float y1, float x2, float y2, Uint32 rgb)
+void
+Viewer::write_line(float x1, float y1, float x2, float y2, Uint32 rgb)
 {
-    //cout << "write_line("<< x1 << "," << y1 << "," << x2 << "," << y2 << ")"<< endl;
-
-    //Uint32 rgb = 9830400;
-
-    if(x1 > x2)
-    {
+    if (x1 > x2) {
 	float x=0;
 	float y=0;
 	x=x1;
@@ -121,71 +104,56 @@
 	x2 = x;
 	y2 = y;
     }
+
     float s = y1;
 
-    if((int)x1 == (int)x2)
-    {
-	if(y1 > y2)
-	{
+    if ((int)x1 == (int)x2) {
+	if (y1 > y2) {
 	    float y=0;
 	    y = y1;
 	    y1 = y2;
 	    y2 = y;
 	}
-	for(float i=y1; i<y2; i++)
-	{
+
+	for (float i=y1; i<y2; i++) {
 	    //write_pixel((int)x1,(int)i);
 	    write_pixel((int)x1,(int)i,0,rgb);
 	}
-    }
-    else 
-    {
+    } else {
 	float t = (y2 - y1)/(x2 - x1);
-	if(t < -1)
-	{
+	if (t < -1) {
 	    float f = 0;
-	    for(float i=x1; i<x2; i++)
-	    {
-		for(float a=(int)t; a<0; a++)
-		{
-		    //write_pixel((int)i,(int)s);
+	    for (float i=x1; i<x2; i++) {
+		for (float a=(int)t; a<0; a++) {
 		    write_pixel((int)i,(int)s,0,rgb);
 		    s--;
 		}
+
 		f += t-(int)t;
-		if(f <= -1)
-		{
-		    //write_pixel((int)i,(int)s);
+
+		if (f <= -1) {
 		    write_pixel((int)i,(int)s,0,rgb);
 		    f = 0;
 		    s--;
 		}
 	    }
-	}
-	else if(t <= 1)
-	{
-	    for(float i=x1; i<x2; i++)
-	    {
+	} else if (t <= 1) {
+	    for(float i=x1; i<x2; i++) {
 		//write_pixel((int)i,(int)s);
 		write_pixel((int)i,(int)s,0,rgb);
 		s += t;
 	    }
-	}
-	else
-	{
+	} else {
 	    float f = 0;
-	    for(float i=x1; i<x2; i++)
-	    {
-		for(float a=0; a<(int)t; a++)
-		{
-		    //write_pixel((int)i,(int)s);
+	    for (float i=x1; i<x2; i++) {
+		for (float a=0; a<(int)t; a++) {
 		    write_pixel((int)i,(int)s,0,rgb);
 		    s++;
 		}
+
 		f += t-(int)t;
-		if(f >= 1)
-		{
-		    //write_pixel((int)i,(int)s);
+
+		if (f >= 1) {
 		    write_pixel((int)i,(int)s,0,rgb);
 		    f = 0;
 		    s++;
@@ -255,6 +223,9 @@
     int fd;
 
     arg->start_time = get_ticks();
+    arg->this_time  = 0;
+    arg->frames     = 0;
+
     arg->pf         = screen->format;
     arg->background = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00);
     arg->p          = new Polygon;
@@ -337,7 +308,6 @@
     SDL_BlitSurface(arg->bitmap, NULL, screen, NULL);
     SDL_UpdateRect(screen, 0, 0, 0, 0);    
 
-    //swap_buffers();
     arg->frames++;
 
     fd = manager->open("ViewerRunLoop");