本文整理汇总了C++中SolarSystem::render方法的典型用法代码示例。如果您正苦于以下问题:C++ SolarSystem::render方法的具体用法?C++ SolarSystem::render怎么用?C++ SolarSystem::render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SolarSystem
的用法示例。
在下文中一共展示了SolarSystem::render方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: display
void display(void)
{
// update the logic and simulation
time += timeSpeed;
solarSystem.calculatePositions(time);
if (controls.forward) camera.forward(); if (controls.backward) camera.backward();
if (controls.left) camera.left(); if (controls.right) camera.right();
if (controls.yawLeft) camera.yawLeft(); if (controls.yawRight) camera.yawRight();
if (controls.rollLeft) camera.rollLeft(); if (controls.rollRight) camera.rollRight();
if (controls.pitchUp) camera.pitchUp(); if (controls.pitchDown) camera.pitchDown();
// clear the buffers
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
// set up the perspective matrix for rendering the 3d world
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(70.0f, (float)screenWidth / (float)screenHeight, 0.001f, 500.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// perform the camera orientation transform
camera.transformOrientation();
// draw the skybox
glBindTexture(GL_TEXTURE_2D, stars->getTextureHandle());
drawCube();
// perform the camera translation transform
camera.transformTranslation();
GLfloat lightPosition[] = { 0.0, 0.0, 0.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
// render the solar system
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
solarSystem.render();
glDisable(GL_LIGHTING);
// possibly render orbits
if (showOrbits)
solarSystem.renderOrbits();
glDisable(GL_DEPTH_TEST);
// set up ortho matrix for showing the UI (help dialogue)
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, (GLdouble) screenWidth, (GLdouble) screenHeight, 0.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// draw the help dialogue
if (helpDialogue)
{
glBindTexture(GL_TEXTURE_2D, help->getTextureHandle());
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex2f(512.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex2f(512.0f, 512.0f);
glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, 512.0f);
glEnd();
}
glFlush();
glutSwapBuffers();
}