本文整理汇总了C++中GLFrame::ApplyCameraTransform方法的典型用法代码示例。如果您正苦于以下问题:C++ GLFrame::ApplyCameraTransform方法的具体用法?C++ GLFrame::ApplyCameraTransform怎么用?C++ GLFrame::ApplyCameraTransform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLFrame
的用法示例。
在下文中一共展示了GLFrame::ApplyCameraTransform方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RenderScene
// Called to draw scene
void RenderScene(void)
{
// Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
frameCamera.ApplyCameraTransform();
// Position light before any other transformations
glLightfv(GL_LIGHT0, GL_POSITION, fLightPos);
// Draw the ground
glColor3f(0.60f, .40f, .10f);
DrawGround();
// Draw shadows first
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glPushMatrix();
glMultMatrixf(mShadowMatrix);
DrawInhabitants(1);
glPopMatrix();
glEnable(GL_LIGHTING);
glEnable(GL_DEPTH_TEST);
// Draw inhabitants normally
DrawInhabitants(0);
glPopMatrix();
// Do the buffer Swap
glutSwapBuffers();
glutPostRedisplay();
}
示例2: RenderScene
// Called to draw scene
void RenderScene(void)
{
// Clear the window
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
frameCamera.ApplyCameraTransform(); // Move the camera about
// Sky Box is manually textured
glActiveTexture(GL_TEXTURE0);
glDisable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE1);
glEnable(GL_TEXTURE_CUBE_MAP);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_GEN_R);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
DrawSkyBox();
// Use texgen to apply cube map
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glPushMatrix();
glTranslatef(0.0f, 0.0f, -3.0f);
glActiveTexture(GL_TEXTURE1);
glMatrixMode(GL_TEXTURE);
glPushMatrix();
// Invert camera matrix (rotation only) and apply to
// texture coordinates
M3DMatrix44f m, invert;
frameCamera.GetCameraOrientation(m);
m3dInvertMatrix44(invert, m);
glMultMatrixf(invert);
glColor3f(1.0f, 1.0f, 1.0f);
gltDrawSphere(0.75f, 41, 41);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glPopMatrix();
// Do the buffer Swap
glutSwapBuffers();
}
示例3: RenderScene
void RenderScene()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
GLdouble ar = (GLdouble)windowWidth/(GLdouble)windowHeight;
gluPerspective(45.0, ar, 1.0, 1000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//试着使用GLFrame的方式替换它
gluLookAt(cameraPos[0], cameraPos[1], cameraPos[2], 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
glViewport(0, 0, windowWidth, windowHeight);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
camera.ApplyCameraTransform(true);
DrawModels();
glutSwapBuffers();
}
示例4: RenderScene
// Called to draw scene
void RenderScene(void)
{
int i;
static GLfloat yRot = 0.0f; // Rotation angle for animation
yRot += 0.5f;
// Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
frameCamera.ApplyCameraTransform();
// Draw the ground
DrawGround();
// Draw the randomly located spheres
for(i = 0; i < NUM_SPHERES; i++)
{
glPushMatrix();
spheres[i].ApplyActorTransform();
glutSolidSphere(0.1f, 13, 26);
glPopMatrix();
}
glPushMatrix();
glTranslatef(0.0f, 0.0f, -2.5f);
glPushMatrix();
glRotatef(-yRot * 2.0f, 0.0f, 1.0f, 0.0f);
glTranslatef(1.0f, 0.0f, 0.0f);
glutSolidSphere(0.1f, 13, 26);
glPopMatrix();
glRotatef(yRot, 0.0f, 1.0f, 0.0f);
gltDrawTorus(0.35, 0.15, 40, 20);
glPopMatrix();
glPopMatrix();
// Do the buffer Swap
glutSwapBuffers();
}
示例5: RenderScene
// Called to draw scene
void RenderScene(void)
{
// Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glPushMatrix();
frameCamera.ApplyCameraTransform();
// Position light before any other transformations
glLightfv(GL_LIGHT0, GL_POSITION, fLightPos);
// Draw the ground
glColor3f(1.0f, 1.0f, 1.0f);
DrawGround();
// Draw shadows first
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_STENCIL_TEST);
glPushMatrix();
glMultMatrixf(mShadowMatrix);
DrawInhabitants(1);
glPopMatrix();
glDisable(GL_STENCIL_TEST);
glDisable(GL_BLEND);
glEnable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);
// Draw inhabitants normally
DrawInhabitants(0);
glPopMatrix();
// Do the buffer Swap
glutSwapBuffers();
}
示例6: RenderScene
//////////////////////////////////////////////////
// Draw everything
void RenderScene(void)
{
static int iFrames = 0; // Count frames to calculate fps ever 100 frames
static float fps = 0.0f; // Calculated fps
// Clear the window
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glPushMatrix();
frameCamera.ApplyCameraTransform();
// Position light before any other transformations
glLightfv(GL_LIGHT0, GL_POSITION, fLightPos);
// Draw the ground
glColor3f(1.0f, 1.0f, 1.0f);
DrawGround();
// Draw shadows first
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_STENCIL_TEST);
glPushMatrix();
glMultMatrixf(mShadowMatrix);
DrawInhabitants(1);
glPopMatrix();
glDisable(GL_STENCIL_TEST);
glDisable(GL_BLEND);
glEnable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);
// Draw inhabitants normally
DrawInhabitants(0);
glPopMatrix();
// Calculate Frame Rate, once every 100 frames
iFrames++;
if(iFrames == 100)
{
float fTime;
// Get the current count
LARGE_INTEGER lCurrent;
QueryPerformanceCounter(&lCurrent);
fTime = (float)(lCurrent.QuadPart - FPSCount.QuadPart) /
(float)CounterFrequency.QuadPart;
fps = (float)iFrames / fTime;
// Reset frame count and timer
iFrames = 0;
QueryPerformanceCounter(&FPSCount);
}
// If we have the window position extension, display
// the frame rate, and tell if multisampling was enabled
// and if the VSync is turned on.
if(glWindowPos2i != NULL)
{
int iRow = 10;
char cBuffer[64];
// Turn off depth test, lighting, and texture mapping
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glColor3f(1.0f, 1.0f, 1.0f);
// Set position and display message
glWindowPos2i(0, iRow);
glListBase(nFontList);
glCallLists (13, GL_UNSIGNED_BYTE, "OpenGL Rocks!");
iRow+= 20;
// Display the frame rate
sprintf(cBuffer,"FPS: %.1f", fps);
glWindowPos2i(0, iRow);
glCallLists(strlen(cBuffer), GL_UNSIGNED_BYTE, cBuffer);
iRow += 20;
// MultiSampled?
if(startupOptions.bFSAA == TRUE && startupOptions.nPixelFormatMS != 0)
{
glWindowPos2i(0, iRow);
glCallLists(25 ,GL_UNSIGNED_BYTE,"Multisampled Frame Buffer");
iRow += 20;
}
// VSync?
if(wglSwapIntervalEXT != NULL && startupOptions.bVerticalSync == TRUE)
{
//.........这里部分代码省略.........
示例7: RenderScene
// Called to draw scene
void RenderScene(void)
{
// Angle of revolution around the Sun
static float fPElect1 = 0.0f;
static float fPElect2 = 0.0f;
static float fPElect3 = 0.0f;
static float fPElect4 = 0.0f;
static float fPElect5 = 0.0f;
static float fPElect6 = 0.0f;
static float fPElect7 = 0.0f;
static float fPElect8 = 0.0f;
// Angle of revolution around the Planets
static float fMElect1 = 0.0f;
static float fMElect2 = 0.0f;
static float fMElect3 = 0.0f;
static float fMElect4 = 0.0f;
static float fMElect5 = 0.0f;
static float fMElect6 = 0.0f;
static float fMElect7 = 0.0f;
static float fMElect8 = 0.0f;
// Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Red Nucleus
glPushMatrix();
frameCamera.ApplyCameraTransform();
glColor3ub(0, 50, 0);
//Grid lines...
glDisable(GL_LIGHTING);
glBegin(GL_LINES);
for(GLfloat iLine = -500.0f; iLine <= 500.0f; iLine += 10.0f)
{
glVertex3f(500.0f, 0.0f, iLine); // Draw Z lines
glVertex3f(-500.0f, 0.0f, iLine);
glVertex3f(iLine, 0.0f, 500.0f);
glVertex3f(iLine, 0.0f, -500.0f);
}
glEnd();
//Sun Light...
glLightfv(GL_LIGHT0,GL_DIFFUSE,sourceLight);
glLightfv(GL_LIGHT0,GL_POSITION,lightPos);
glColor3ub(200, 255, 200);
glutSolidSphere(12.0f, 15, 15);
//Will be added when the torus's stop moving around-------------
//Planets Orbit lines...
glColor3ub(0,0,50);
//Planet Orbit one
glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
glPushMatrix();
glTranslatef(0.0f, 0.0f, 0.0f);
glRotatef(fPElect1, 0.0f, 0.0f, 1.0f);
glutSolidTorus(20.0f+(PSV11*4)-((1.0f+PSV11)/2)+0.2f,0.2f, 150, 15);
glPopMatrix();
//Planet Orbit two
glPushMatrix();
glTranslatef(0.0f, 0.0f, 0.0f);
glRotatef(fPElect2, 0.0f, 1.0f, 0.0f + (PSV22/3));
glutSolidTorus(35.0f+(PSV22*4)-((1.0f+PSV22)/2)+0.2f,0.2f, 150, 15);
glPopMatrix();
//Planet Orbit three
glPushMatrix();
glTranslatef(0.0f, 0.0f, 1.0f);
glRotatef(fPElect3, 0.0f, 0.0f, 0.0f + (PSV33/3));
glutSolidTorus(50.0f+(PSV33*4)-((1.0f+PSV33)/2)+0.2f,0.2f, 150, 15);
glPopMatrix();
//Planet Orbit four
glPushMatrix();
glTranslatef(0.0f, 0.0f, 0.0f);
glRotatef(fPElect4, 0.0f, 1.0f, 0.0f + (PSV44/3));
glutSolidTorus(65.0f+(PSV44*4)-((1.0f+PSV44)/2)+0.2f,0.2f, 150, 15);
glPopMatrix();
//Planet Orbit five
glPushMatrix();
glTranslatef(0.0f, 0.0f, 0.0f);
glRotatef(fPElect5, 0.0f, 1.0f, 0.0f + (PSV55/3));
glutSolidTorus(80.0f+(PSV55*4)-((1.0f+PSV55)/2)+0.2f,0.2f, 150, 15);
glPopMatrix();
//Planet Orbit six
glPushMatrix();
glTranslatef(0.0f, 0.0f, 0.0f);
glRotatef(fPElect6, 0.0f, 1.0f, 0.0f + (PSV66/3));
glutSolidTorus(95.0f+(PSV66*4)-((1.0f+PSV66)/2)+0.2f,0.2f, 150, 15);
glPopMatrix();
//Planet Orbit seven
glPushMatrix();
glTranslatef(0.0f, 0.0f, 0.0f);
glRotatef(fPElect7, 0.0f, 1.0f, 0.0f + (PSV77/3));
glutSolidTorus(110.0f+(PSV77*4)-((1.0f+PSV77)/2)+0.2f,0.2f, 150, 15);
glPopMatrix();
//Planet Orbit eight
glPushMatrix();
glTranslatef(0.0f, 0.0f, 0.0f);
glRotatef(fPElect8, 0.0f, 1.0f, 0.0f + (PSV88/3));
glutSolidTorus(125.0f+(PSV88*4)-((1.0f+PSV88)/2)+0.2f,0.2f, 150, 15);
//.........这里部分代码省略.........
示例8: RenderScene
// Called to draw scene
void RenderScene(void)
{
static int iFrames = 0; // Frame count
static CStopWatch frameTimer; // Render time
// Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glPushMatrix();
frameCamera.ApplyCameraTransform();
// Position light before any other transformations
glLightfv(GL_LIGHT0, GL_POSITION, fLightPos);
// Draw the ground
glColor3f(1.0f, 1.0f, 1.0f);
if(iMethod == 0)
DrawGround();
else
glCallList(groundList);
// Draw shadows first
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_STENCIL_TEST);
glPushMatrix();
glMultMatrixf(mShadowMatrix);
DrawInhabitants(1);
glPopMatrix();
glDisable(GL_STENCIL_TEST);
glDisable(GL_BLEND);
glEnable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);
// Draw inhabitants normally
DrawInhabitants(0);
glPopMatrix();
// Do the buffer Swap
glutSwapBuffers();
// Increment the frame count
iFrames++;
// Do periodic frame rate calculation
if(iFrames == 100)
{
float fps;
char cBuffer[64];
fps = 100.0f / frameTimer.GetElapsedSeconds();
if(iMethod == 0)
sprintf(cBuffer,"OpenGL SphereWorld without Display Lists %.1f fps", fps);
else
sprintf(cBuffer,"OpenGL SphereWorld with Display Lists %.1f fps", fps);
glutSetWindowTitle(cBuffer);
frameTimer.Reset();
iFrames = 0;
}
}