本文整理汇总了C++中CStopWatch::delta方法的典型用法代码示例。如果您正苦于以下问题:C++ CStopWatch::delta方法的具体用法?C++ CStopWatch::delta怎么用?C++ CStopWatch::delta使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStopWatch
的用法示例。
在下文中一共展示了CStopWatch::delta方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SpecialKeys
/**
* Respond to arrow keys by moving the camera frame of reference
*/
void SpecialKeys(int key, int x, int y)
{
static CStopWatch timer;
float fTime = timer.delta();
float linear = fTime / 100;
if (key == GLUT_KEY_UP) { // Increase the scene exposure
if ((exposure + linear) < 20.0f) {
exposure += linear;
}
}
else if (key == GLUT_KEY_DOWN) { // Decrease the scene exposure
if ((exposure - linear) > 0.01f)
exposure -= linear;
}
}
示例2: SpecialKeys
/**
* Respond to arrow keys by moving the camera frame of reference
*/
void SpecialKeys(int key, int x, int y)
{
static CStopWatch cameraTimer;
float fTime = cameraTimer.delta();
cameraTimer.reset();
float linear = fTime * 3.0f;
float angular = fTime * float(m3dDegToRad(60.0f));
if (key == GLUT_KEY_LEFT)
{
worldAngle += angular * 50;
if (worldAngle > 360)
worldAngle -= 360;
}
if (key == GLUT_KEY_RIGHT)
{
worldAngle -= angular * 50;
if (worldAngle < 360)
worldAngle += 360;
}
}
示例3: RenderScene
/**
* Called to draw scene
*/
void RenderScene(void)
{
static CStopWatch animationTimer;
float yRot = animationTimer.delta() * 60.0f;
// first, draw to FBO at full FBO resolution
// bind FBO with 8b attachment
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fboName);
glViewport(0, 0, hdrTexturesWidth[curHDRTex], hdrTexturesHeight[curHDRTex]);
glClear(GL_COLOR_BUFFER_BIT);
// bind texture with HDR image
glBindTexture(GL_TEXTURE_2D, hdrTextures[curHDRTex]);
// render pass, downsample to 8b using selected program
projectionMatrix.setMatrix(fboOrthoMatrix);
SetupHDRProg();
fboQuad.draw();
// then draw the resulting image to the screen, maintain image proporions
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glViewport(0, 0, screenWidth, screenHeight);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
// attach 8b texture with HDR image
glBindTexture(GL_TEXTURE_2D, fboTextures[0]);
// draw screen sized, proportional quad with 8b texture
projectionMatrix.setMatrix(orthoMatrix);
SetupStraightTexProg();
screenQuad.draw();
// Perform the buffer swap to display back buffer
glutSwapBuffers();
glutPostRedisplay();
}
示例4: RenderScene
/**
* Called to draw scene
*/
void RenderScene(void)
{
static GLfloat vFloorColor[] = { 1.0f, 1.0f, 1.0f, 0.75f };
static CStopWatch rotTimer;
float yRot = rotTimer.delta() * 60.0f;
// Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
modelViewMatrix.push();
M3DMatrix44f mCamera;
cameraFrame.GetCameraMatrix(mCamera);
modelViewMatrix.MultMatrix(mCamera);
// draw the world upside down
modelViewMatrix.push();
modelViewMatrix.scaleTo(1.0f, -1.0f, 1.0f); // flips the Y axis
modelViewMatrix.moveTo(0.0f, 0.8f, 0.0f); // scootch the world down a bit...
glFrontFace(GL_CW);
DrawSongAndDance(yRot);
glFrontFace(GL_CCW); // restore it
modelViewMatrix.pop();
// draw the solid ground
glEnable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, uiTextures[0]);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
shaderManager.useStockShader(GLT_SHADER_TEXTURE_MODULATE,
transformPipeline.GetMVPMatrix(),
vFloorColor,
0);
floorBatch.draw();
glDisable(GL_BLEND);
DrawSongAndDance(yRot);
modelViewMatrix.pop();
// Render the overlay
// Creating this matrix really doesn't need to be done every frame. I'll leave it here
// so all the pertenant code is together
M3DMatrix44f mScreenSpace;
m3dMakeOrthographicMatrix(mScreenSpace, 0.0f, 800.0f, 0.0f, 600.0f, -1.0f, 1.0f);
// turn blending on, and dephth testing off
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glUseProgram(rectReplaceShader);
glUniform1i(locRectTexture, 0);
glUniformMatrix4fv(locRectMVP, 1, GL_FALSE, mScreenSpace);
glBindTexture(GL_TEXTURE_RECTANGLE, uiTextures[3]);
logoBatch.draw();
// restore no blending and depth test
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
// Perform the buffer swap to display back buffer
glutSwapBuffers();
glutPostRedisplay();
}