本文整理汇总了C++中osg::GLUTWindowRecPtr::getWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ GLUTWindowRecPtr::getWidth方法的具体用法?C++ GLUTWindowRecPtr::getWidth怎么用?C++ GLUTWindowRecPtr::getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::GLUTWindowRecPtr
的用法示例。
在下文中一共展示了GLUTWindowRecPtr::getWidth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: motion
void motion(int x, int y)
{
OSG::Real32 w = clientWindow->getWidth(), h = clientWindow->getHeight();
OSG::Real32 a = -2. * ( lastx / w - .5 ),
b = -2. * ( .5 - lasty / h ),
c = -2. * ( x / w - .5 ),
d = -2. * ( .5 - y / h );
if ( mouseb & ( 1 << GLUT_LEFT_BUTTON ) )
{
tball.updateRotation( a, b, c, d );
}
else if ( mouseb & ( 1 << GLUT_MIDDLE_BUTTON ) )
{
tball.updatePosition( a, b, c, d );
}
else if ( mouseb & ( 1 << GLUT_RIGHT_BUTTON ) )
{
tball.updatePositionNeg( a, b, c, d );
}
lastx = x;
lasty = y;
glutPostRedisplay();
}
示例2: displayInfo
/*! Simple show text function
*/
void displayInfo(int x, int y)
{
int len, i;
#ifdef WIN32
#ifdef OSG_WIN32_CL
void *font = (void *) 2;
#else
void *font = 2;
#endif
#else
#ifdef OSG_DEBUG_OLD_C_CASTS
void *font = glutBitmap9By15;
#else
void *font = GLUT_BITMAP_9_BY_15;
#endif
#endif
char text[1024];
sprintf(text,
"FPS: %12.1f\n"
"Positions: %12u\n"
"Triangles: %12u\n"
"Geometries: %12u",
1.0/frame_time,
sum_positions,
sum_triangles,
sum_geometries);
glPushAttrib(GL_ALL_ATTRIB_BITS);
glDisable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0,clientWindow->getWidth(),0,clientWindow->getHeight());
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
int x1=x-5;
int x2=x1+24*9+10;
int y1=y+14;
int y2=y1-4*20;
glBegin(GL_QUADS);
glColor4f(.1f, .1f, .7f, .5f);
glVertex2i(x1,y1);
glVertex2i(x1,y2);
glVertex2i(x2,y2);
glVertex2i(x2,y1);
glEnd();
glBegin(GL_LINE_LOOP);
glColor3f(1.0, 1.0, 0.0);
glVertex2i(x1,y1);
glVertex2i(x1,y2);
glVertex2i(x2,y2);
glVertex2i(x2,y1);
glEnd();
glColor3f(1.0, 1.0, 0.0);
glRasterPos2f(x, y);
len = int(strlen(text));
for (i = 0; i < len; i++) {
if(text[i] == '\n')
{
y-=20;
glRasterPos2f(x, y);
}
else
glutBitmapCharacter(font, text[i]);
}
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glPopAttrib();
}