本文整理汇总了C++中WorldState::getCurrentTime方法的典型用法代码示例。如果您正苦于以下问题:C++ WorldState::getCurrentTime方法的具体用法?C++ WorldState::getCurrentTime怎么用?C++ WorldState::getCurrentTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorldState
的用法示例。
在下文中一共展示了WorldState::getCurrentTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: display
/*
Draw a single frame
*/
void display(WorldState & state)
{
// Clear the color bits in the display buffer
glClear(GL_COLOR_BUFFER_BIT);
// Use a simple shader to render the line
glUseProgram(shaderProg);
checkGLError("useProgram");
//use the vertex array
glBindVertexArray(vertexArray);
//get uniform slot id
//TODO: send a uniform value to the shader
GLint timeSlot = glGetUniformLocation(shaderProg, "timeVal");
glUniform1f(timeSlot, state.getCurrentTime());
GLint mousexSlot = glGetUniformLocation(shaderProg, "mousexVal");
glUniform1i(mousexSlot, state.getMousePosx());
checkGLError("uniform");
// Render using vertex attributes (data already on GPU) (~2008, 3.0)
// https://web.archive.org/web/20150225192608/http://www.arcsynthesis.org/gltut/Basics/Tut01%20Following%20the%20Data.html
// Tell OpenGL we want to use a buffer on the GPU
glBindBuffer(GL_ARRAY_BUFFER, positionBuffer);
checkGLError("bind pos buffer");
// Tell OpenGL what shader data slot we want to use
glEnableVertexAttribArray(positionSlot);
checkGLError("enable pos slot");
// Tell OpenGL how to interpret the data
glVertexAttribPointer(positionSlot, 2, GL_FLOAT, GL_FALSE, 0, 0);
checkGLError("vertex attrib pos");
// Do the same thing for colors
glBindBuffer(GL_ARRAY_BUFFER, colorBuffer);
glEnableVertexAttribArray(colorSlot);
glVertexAttribPointer(colorSlot, 3, GL_FLOAT, GL_FALSE, 0, 0);
checkGLError("color array setup");
glBindBuffer(GL_ARRAY_BUFFER, sizeBuffer);
checkGLError("bind size buffer");
glEnableVertexAttribArray(sizeSlot);
checkGLError("enable size slot");
glVertexAttribPointer(sizeSlot, 1, GL_FLOAT, GL_FALSE, 0, 0);
checkGLError("size array setup");
// Draw some primitives as: glDrawArrays(type, first, count)
//TODO: replace these with your draw calls
glDrawArrays(GL_TRIANGLES, 0, 12);
glDrawArrays(GL_POINTS, 12, 1);
//done with the vertex array
glBindVertexArray(0);
// Tell OpenGL we are done with the buffer
glBindBuffer(GL_ARRAY_BUFFER, 0);
// Tell OpenGL we are done with the shader
glUseProgram(0);
checkGLError("unbind");
}
示例2: handleEvents
void handleEvents(sf::Window & window, WorldState & state)
{
sf::Event event;
while (window.pollEvent(event))
{
// Close window : exit
if (event.type == sf::Event::Closed)
state.setRunning(false);
// Escape key : exit
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
state.setRunning(false);
if (event.type == sf::Event::TextEntered) {
Model const & model = state.getModel();
float time = state.getCurrentTime();
RenderEngine render = RenderEngine(render);
switch (static_cast<char>(event.key.code)) {
case 'q':
printf("'q' should scale\n");
// scale = true.
//if(!state.scaleEnabled())
state.toggleScale();
break;
case 'w':
printf("'w' should enable bouncing\n");
state.toggleTranslate();
break;
case 'e':
printf("'e' should enable z rotation\n");
// rotZ = true.
state.toggleRotZ();
break;
case 'r':
printf("'r' should enable y rotation\n");
// rotY = true.
state.toggleRotY();
break;
default:
printf("nothing\n");
break;
}
}
// std::cout << "Your Input: " << static_cast<char>(event.key.code) << std::endl;
//TODO add event handlers for qwer
//'q' should scale
//'w' should enable bouncing
//'e' should enable z rotation
//'r' should enable y rotation
}
}