高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】can i draw opengl list directly in exgsopenglvectorizedevice
can i draw opengl list directly in exgsopenglvectorizedevice
can i draw opengl list directly in exgsopenglvectorizedevice (odamfcapp) ?
hi, i'm david.lee.
i want to draw a grid line. so i generate a display list for grid line.
but it's line is unnatural. oddbentity's line is breaked.
i attached the picture, test.jpg.
void exgsopenglvectorizedevice::update(odgsdcrect* pupdatedrect)
{
if (!m_hglrc)
createcontext();
//
odgsdcrect rect;
rect.m_max.x = rect.m_max.y = 0;
rect.m_min.x = rect.m_min.y = 0;
odgsopenglvectorizedevice::update(&rect);
//
glmatrixmode(gl_modelview);
glpushmatrix();
{
::glcolor4ub(255, 0, 0, 0)
glcalllist(m_glgrid); --> grid line's display list
}
glpopmatrix();
odgsopenglvectorizedevice::update(pupdatedrect);
if (m_bdoublebufferenabled && !usergicontext()->regenabort())
{
::swapbuffers(m_hdc);
::glfinish();
}
}
please let me know how to solve this problem.
have a nice day! thank you!
attached images
hi,
i tried to add grid drawable to gs in odamfcapp. and it works fine for me. winopengl.gs creates display list internally for this drawable (if gs model is on).
sample grid drawable implementation:
code:
class griddrawable : public odgidrawableimpl<odgidrawable>
{
protected:
griddrawable() { }
public:
oduint32 setattributes(odgidrawabletraits* ptraits) const
{
return kdrawableisanentity;
}
bool worlddraw(odgiworlddraw* pwd) const
{
pwd->subentitytraits().setcolor(7);
odgepoint3d pts[2];
for(int i=0; i<41; ++i)
{
for(int j=0; j<41; ++j)
{
pts[0].x =
pts[1].x = i * 25;
pts[0].y = 0.0;
pts[1].y = 1000;
pwd->geometry().polyline(2, pts, &odgevector3d::kzaxis);
pts[0].y =
pts[1].y = i * 25;
pts[0].x = 0.0;
pts[1].x = 1000;
pwd->geometry().polyline(2, pts, &odgevector3d::kzaxis);
}
}
return true;
}
void viewportdraw(odgiviewportdraw* ) const
{
}
};
adding grid drawables to model space views (blue code added into cdwgviewer::createdevice() ):
code:
m_pdevice = oddbgsmanager::setupactivelayoutviews(pdevice, this);
odgspaperlayouthelperptr ppshelper = odgspaperlayouthelper::cast(m_pdevice);
for(int i=0; i<m_pdevice->numviews(); ++i)
{
odgsview* pview = m_pdevice->viewat(i);
if(ppshelper.isnull() || ppshelper->overallview().get() != pview)
{
odsmartptr<griddrawable> pgrid =
odrxobjectimpl<griddrawable>::createobject();
oddbobjectptr pms = database()->getmodelspaceid().safeopenobject();
// place grid "under" ms geometry:
pview->erase(pms);
pview->add(pgrid, m_pdevice->gsmodel());
pview->add(pms, m_pdevice->gsmodel());
}
}
due to bug in gs, non-persistent drawables should be deleted from view prior to deleting this view (it will be fixed in next release).
so next lines should be added to cdwgviewer::destroydevice() to workaround this bug:
code:
for(int i=0; i<m_pdevice->numviews(); ++i)
{
m_pdevice->viewat(i)->eraseall();
}
note: entity overlapping could be controlled manipulating their order only in 2d-optimized mode. in other modes overlapping is determined by entity's position in z-buffer.
attached images (11.3 kb, 12 views)
last edited by dmitry a. novikov; 25th january 2007 at 03:37 amfff">.
thank you very much.
thank you very much.
|