Permalink
Browse files

double-buffered multithread working

  • Loading branch information...
1 parent 047355a commit ac3575574d7ff86343ade9ba478a522ea2abc4ea @rtv committed Dec 14, 2010
View
@@ -55,7 +55,11 @@ Block::Block( Model* mod,
Block::~Block()
{
- if( mapped ) UnMapAllLayers();
+ if( mapped )
+ {
+ UnMap(0);
+ UnMap(1);
+ }
}
void Block::Translate( double x, double y )
@@ -368,10 +372,10 @@ void Block::DrawFootPrint()
glEnd();
}
-void Block::DrawSolid()
+void Block::DrawSolid( bool topview )
{
-// if( wheel )
-// {
+// if( wheel )x
+ // {
// glPushMatrix();
// glRotatef( 90,0,1,0 );
@@ -388,10 +392,12 @@ void Block::DrawSolid()
// glPopMatrix();
// }
// else
- {
- DrawSides();
- DrawTop();
- }
+ {
+ if( ! topview )
+ DrawSides();
+
+ DrawTop();
+ }
}
void Block::Load( Worldfile* wf, int entity )
View
@@ -122,7 +122,7 @@ void BlockGroup::DrawSolid( const Geom & geom )
glTranslatef( -offset.x, -offset.y, -offset.z );
FOR_EACH( it, blocks )
- (*it)->DrawSolid();
+ (*it)->DrawSolid(false);
glPopMatrix();
}
@@ -156,16 +156,20 @@ void BlockGroup::BuildDisplayList( Model* mod )
displaylist = glGenLists(1);
CalcSize();
}
-
+
+
glNewList( displaylist, GL_COMPILE );
- Geom geom = mod->GetGeom();
+ // render each block as a polygon extruded into Z
+
+ Geom geom = mod->GetGeom();
+
Gl::pose_shift( geom.pose );
-
+
glScalef( geom.size.x / size.x,
- geom.size.y / size.y,
- geom.size.z / size.z );
+ geom.size.y / size.y,
+ geom.size.z / size.z );
glTranslatef( -offset.x, -offset.y, -offset.z );
@@ -175,22 +179,26 @@ void BlockGroup::BuildDisplayList( Model* mod )
mod->PushColor( mod->color );
+ //const bool topview = dynamic_cast<WorldGui*>(mod->world)->IsTopView();
+
FOR_EACH( it, blocks )
- {
- Block* blk = (*it);
+ {
+ Block* blk = (*it);
- if( (!blk->inherit_color) && (blk->color != mod->color) )
- {
- mod->PushColor( blk->color );
- blk->DrawSolid();
- mod->PopColor();
- }
- else
- blk->DrawSolid();
- }
+ if( (!blk->inherit_color) && (blk->color != mod->color) )
+ {
+ mod->PushColor( blk->color );
+ blk->DrawSolid(false);
+ mod->PopColor();
+ }
+ else
+ blk->DrawSolid(false);
+ }
mod->PopColor();
+ // outline each poly in a darker version of the same color
+
glDisable(GL_POLYGON_OFFSET_FILL);
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
@@ -201,29 +209,25 @@ void BlockGroup::BuildDisplayList( Model* mod )
c.g /= 2.0;
c.b /= 2.0;
mod->PushColor( c );
-
- //c.Print( "color" );
-
-
+
FOR_EACH( it, blocks )
- {
- Block* blk = *it;
+ {
+ Block* blk = *it;
- if( (!blk->inherit_color) && (blk->color != mod->color) )
- {
- Color c = blk->color;
- c.r /= 2.0;
- c.g /= 2.0;
- c.b /= 2.0;
- mod->PushColor( c );
- //c.Print( "bar" );
- blk->DrawSolid();
- mod->PopColor();
- }
- else
- blk->DrawSolid();
- }
-
+ if( (!blk->inherit_color) && (blk->color != mod->color) )
+ {
+ Color c = blk->color;
+ c.r /= 2.0;
+ c.g /= 2.0;
+ c.b /= 2.0;
+ mod->PushColor( c );
+ blk->DrawSolid(false);
+ mod->PopColor();
+ }
+ else
+ blk->DrawSolid(false);
+ }
+
glDepthMask(GL_TRUE);
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
View
@@ -357,12 +357,13 @@ void Canvas::CanvasToWorld( int px, int py,
GLfloat pz;
glReadPixels( px, h()-py, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &pz );
- gluUnProject( px, w()-py, pz, modelview, projection, viewport, wx,wy,wz );
-
+ gluUnProject( px, w()-py, pz, modelview, projection, viewport, wx,wy,wz );
}
int Canvas::handle(int event)
{
+ //printf( "cam %.2f %.2f\n", camera.yaw(), camera.pitch() );
+
switch(event)
{
case FL_MOUSEWHEEL:
View
@@ -155,6 +155,9 @@ namespace Stg
void Load( Worldfile* wf, int section );
void Save( Worldfile* wf, int section );
+
+ bool IsTopView(){ return( (fabs( camera.yaw() ) < 0.1) &&
+ (fabs( camera.pitch() ) < 0.1) ); }
};
} // namespace Stg
Oops, something went wrong.

0 comments on commit ac35755

Please sign in to comment.