[Scummvm-cvs-logs] CVS: residual bitmap.cpp,1.8,1.9 engine.cpp,1.9,1.10 model.cpp,1.4,1.5 model.h,1.2,1.3 screen.cpp,1.2,1.3

Vincent Hamm yazoo at users.sourceforge.net
Sat Aug 30 12:05:01 CEST 2003


Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1:/tmp/cvs-serv28358

Modified Files:
	bitmap.cpp engine.cpp model.cpp model.h screen.cpp 
Log Message:
more on the screenBlock thingy
Slow, but speed will be improved soon


Index: bitmap.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/bitmap.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- bitmap.cpp	24 Aug 2003 17:56:03 -0000	1.8
+++ bitmap.cpp	30 Aug 2003 19:04:06 -0000	1.9
@@ -167,7 +167,7 @@
     */
     for (int row = 0; row < height_; row++) {
       glRasterPos2i(x_, y_ + row + 1);
-      glDrawPixels(width_, 1, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, data_[curr_image_] + (2 * row * width_));
+    //  glDrawPixels(width_, 1, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, data_[curr_image_] + (2 * row * width_));
     }
     glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
     glDepthFunc(GL_LESS);

Index: engine.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/engine.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- engine.cpp	30 Aug 2003 17:58:33 -0000	1.9
+++ engine.cpp	30 Aug 2003 19:04:07 -0000	1.10
@@ -99,6 +99,8 @@
     // Draw the screen
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
+	screenBlocksDrawDebug();
+
 	screenBlocksBlitDirtyBlocks();
 
     Bitmap::prepareGL();
@@ -119,7 +121,6 @@
     }
     glDisable(GL_TEXTURE_2D);
 
-//	screenBlocksDrawDebug();
 
     // Draw text
     for (text_list_type::iterator i = textObjects_.begin();

Index: model.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/model.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- model.cpp	30 Aug 2003 17:58:33 -0000	1.4
+++ model.cpp	30 Aug 2003 19:04:07 -0000	1.5
@@ -128,6 +128,73 @@
   delete[] faces_;
 }
 
+void Model::Mesh::update() {
+  glPushMatrix();
+  glLoadIdentity();
+
+  GLdouble modelView[500];
+  GLdouble projection[500];
+  GLint viewPort[500];
+
+  glGetDoublev( GL_MODELVIEW_MATRIX, modelView );
+  glGetDoublev( GL_PROJECTION_MATRIX, projection );
+  glGetIntegerv( GL_VIEWPORT, viewPort);
+
+  GLdouble top = 1000;
+  GLdouble right = -1000;
+  GLdouble left = 1000;
+  GLdouble bottom = -1000;
+
+  for (int i = 0; i < numFaces_; i++)
+  {
+	  Vector3d v;
+	  Matrix4 tempMatrix = matrix_;
+	  float* pVertices;
+	  int j;
+      float bestDepth = 0;
+
+	  for( j =0; j< faces_[i].numVertices_; j++ )
+	  {
+			pVertices = vertices_ + 3 * faces_[i].vertices_[j];
+
+			v.set( *(pVertices), *(pVertices+1), *(pVertices+2) );
+
+			tempMatrix.rot_.transform( v );
+			v+= tempMatrix.pos_;
+
+			GLdouble winX;
+			GLdouble winY;
+			GLdouble winZ;
+			
+			gluProject( v.x(), v.y(), v.z(), modelView, projection, viewPort, &winX, &winY, &winZ);
+
+			if( winX > right )
+				right = winX;
+			if( winX < left )
+				left = winX;
+			if( winY < top )
+				top = winY;
+			if( winY > bottom )
+				bottom = winY;
+
+			if( winZ> bestDepth )
+				bestDepth = winZ;
+
+	  }
+
+	  screenBlocksAddRectangle( top, right, left, bottom, bestDepth );
+  }
+
+  glDisable(GL_DEPTH_TEST);
+  glPointSize( 3.f );
+  glColor4f( 1.f, 1.f, 0.f, 1.f );
+  glDisable(GL_TEXTURE_2D );
+
+  glEnable(GL_DEPTH_TEST);
+  glEnable(GL_TEXTURE_2D );
+  glPopMatrix();
+}
+
 void Model::Face::loadBinary(const char *&data, ResPtr<Material> *materials) {
   type_ = get_LE_uint32(data + 4);
   geo_ = get_LE_uint32(data + 8);
@@ -473,6 +540,7 @@
 	if( mesh_ != NULL )
 	{
 		mesh_->matrix_ = pivotMatrix;
+		mesh_->update();
 	}
 
 	if( child_ != NULL )
@@ -480,6 +548,8 @@
 		child_->setMatrix( matrix_ );
 		child_->update();
 	}
+
+
 }
 
 
@@ -540,62 +610,9 @@
   glEnable(GL_TEXTURE_2D );
 
 // Yaz: debug
-// this compute the dirty rect for the mesh
-
-  glPushMatrix();
-  glLoadIdentity();
-
-  GLdouble modelView[500];
-  GLdouble projection[500];
-  GLint viewPort[500];
-
-  glGetDoublev( GL_MODELVIEW_MATRIX, modelView );
-  glGetDoublev( GL_PROJECTION_MATRIX, projection );
-  glGetIntegerv( GL_VIEWPORT, viewPort);
-
-  GLdouble top = 1000;
-  GLdouble right = -1000;
-  GLdouble left = 1000;
-  GLdouble bottom = -1000;
-
-  for (int i = 0; i < numFaces_; i++)
-  {
-	  Vector3d v;
-	  Matrix4 tempMatrix = matrix_;
-	  float* pVertices;
-	  int j;
-      float bestDepth = 0;
-
-	  for( j =0; j< faces_[i].numVertices_; j++ )
-	  {
-			pVertices = vertices_ + 3 * faces_[i].vertices_[j];
-
-			v.set( *(pVertices), *(pVertices+1), *(pVertices+2) );
-
-			tempMatrix.rot_.transform( v );
-			v+= tempMatrix.pos_;
-
-			GLdouble winX;
-			GLdouble winY;
-			GLdouble winZ;
-			
-			gluProject( v.x(), v.y(), v.z(), modelView, projection, viewPort, &winX, &winY, &winZ);
-
-			if( winX > right )
-				right = winX;
-			if( winX < left )
-				left = winX;
-			if( winY < top )
-				top = winY;
-			if( winY > bottom )
-				bottom = winY;
+// this compute the dirty rect for the mesh*/
 
-			if( winZ> bestDepth )
-				bestDepth = winZ;
 
-	  }
-
-	  screenBlocksAddRectangle( top, right, left, bottom, bestDepth );
 /*
 	  if( faces_[i].numVertices_ == 3 ) // triangle
 	  {
@@ -628,14 +645,9 @@
 	  {
 		  printf("Bad primitive !\n");
 	  } */
-/*  }
-
-  glDisable(GL_DEPTH_TEST);
-  glPointSize( 3.f );
-  glColor4f( 1.f, 1.f, 0.f, 1.f );
-  glDisable(GL_TEXTURE_2D );
+//  }
 
-  glBegin(GL_LINES);
+/*  glBegin(GL_LINES);
 
   GLdouble objx;
   GLdouble objy;
@@ -665,10 +677,8 @@
   gluUnProject( right, bottom, 1.f, modelView, projection, viewPort, &objx, &objy, &objz );
   glVertex3f( objx, objy, objz );
 
-  glEnd();
-  glEnable(GL_DEPTH_TEST);
-  glEnable(GL_TEXTURE_2D );
-  glPopMatrix();*/
+  glEnd();*/
+
 }
 
 void Model::Face::draw(float *vertices, float *vertNormals,

Index: model.h
===================================================================
RCS file: /cvsroot/scummvm/residual/model.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- model.h	28 Aug 2003 01:55:48 -0000	1.2
+++ model.h	30 Aug 2003 19:04:07 -0000	1.3
@@ -85,6 +85,7 @@
     void loadBinary(const char *&data, ResPtr<Material> *materials);
     void loadText(TextSplitter &ts, ResPtr<Material> *materials);
     void draw() const;
+	void update();
     ~Mesh();
 
     char name_[32];

Index: screen.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/screen.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- screen.cpp	30 Aug 2003 18:05:48 -0000	1.2
+++ screen.cpp	30 Aug 2003 19:04:07 -0000	1.3
@@ -228,13 +228,21 @@
 	int i;
 	int j;
 
+	glMatrixMode(GL_PROJECTION);
+	glLoadIdentity();
+	glOrtho(0, 640, 480, 0, 0, 1);
+	glMatrixMode(GL_MODELVIEW);
+	glLoadIdentity();
+	glMatrixMode(GL_TEXTURE);
+	glLoadIdentity();
+
 	for(i=0;i<40;i++)
 	{
 		for(j=0;j<30;j++)
 		{
-//			if(screenBlockData[i][j].isDirty)
+			if(screenBlockData[i][j].isDirty)
 			{
-				glRasterPos2i(j*16, i*16);
+				glRasterPos2i(i*16, j*16);
 				glEnable(GL_DEPTH_TEST);
 				glDepthFunc(GL_ALWAYS);
 				glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); 
@@ -244,8 +252,8 @@
 				*/
 				for (int y = 0; y < 16; y++)
 				{
-					glRasterPos2i(j*16, i*16 + y + 1);
-					glDrawPixels(16, 1, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, dataTemp+((i*16 +y +1) * 640)+(j*16));
+					glRasterPos2i(j*16, i*16 + y);
+					glDrawPixels(16, 1, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, dataTemp+((j*16 +y) * 640)+(i*16));
 				}
 				glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
 				glDepthFunc(GL_LESS);





More information about the Scummvm-git-logs mailing list