参考http://www.52vr.com/bbs/viewthre ... &extra=page%3D2
通道的Subscribers里面画线(GL_LINES):
void OpenglSubscribers::notify(vsChannel::Event event, const vsChannel *chan, vrDrawContext *context)
{
switch(event) {
case vsChannel::EVENT_POST_DRAW:
{
vrTransform::ElementProjection m_projectionElement;
context->pushElements(true);
int nFullWidth=GetSystemMetrics(SM_CXSCREEN);//
int nFullHeight=GetSystemMetrics(SM_CYSCREEN);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0,nFullWidth,0.0,nFullHeight,-1.0,1.0);//
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
int x,y,w,h;
chan->getVrChannel()->getViewport(&x,&y,&w,&h);
glDisable(GL_BLEND);
glColor3f(1.0,0.0,0.0);
//画箭头分划
int l,r,b,t;
vpWindow *win = *vpWindow::begin();
//chan->getDrawArea(&l,&r,&b,&t);
win->getOrigin(&l,&b);
int width;
int height;
win->getSize(&width,&height);
r = l + width;
t = b + height;
glLineWidth( 1.5 ); //
glColor3f(0,0,0);
glBegin(GL_LINES);
//画大十字线
//glVertex2f(l + (width - height)/2.0f - 8 ,b + height/2);
//glVertex2f(r - (width - height)/2.0f + 8 ,b + height/2);
//glVertex2f(l + width/2,b);
//glVertex2f(l + width/2,t);
//画箭头及刻度
glVertex2f(l + width /2.0f - 10 ,b + height/2 - 20);
glVertex2f(l + width/2.0f,b + height/2);
glVertex2f(l + width /2.0f + 10 ,b + height/2 - 20);
glVertex2f(l + width/2.0f,b + height/2);
//......
glEnd();
context->setElement(vrTransform::ElementProjection::Id,&m_projectionElement);
context->popElements();
}// end of postdraw event
break;
}// end of switch
} |