Skip to content

Commit

Permalink
double-buffered multithread working
Browse files Browse the repository at this point in the history
  • Loading branch information
rtv committed Dec 14, 2010
1 parent 047355a commit ac35755
Show file tree
Hide file tree
Showing 17 changed files with 257 additions and 258 deletions.
22 changes: 14 additions & 8 deletions libstage/block.cc
Expand Up @@ -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 )
Expand Down Expand Up @@ -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 );
Expand All @@ -388,10 +392,12 @@ void Block::DrawSolid()
// glPopMatrix();
// }
// else
{
DrawSides();
DrawTop();
}
{
if( ! topview )
DrawSides();

DrawTop();
}
}

void Block::Load( Worldfile* wf, int entity )
Expand Down
80 changes: 42 additions & 38 deletions libstage/blockgroup.cc
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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 );

Expand All @@ -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 );
Expand All @@ -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 );

Expand Down
5 changes: 3 additions & 2 deletions libstage/canvas.cc
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions libstage/canvas.hh
Expand Up @@ -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

0 comments on commit ac35755

Please sign in to comment.