本文整理汇总了C++中sf::Window::display方法的典型用法代码示例。如果您正苦于以下问题:C++ Window::display方法的具体用法?C++ Window::display怎么用?C++ Window::display使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::Window
的用法示例。
在下文中一共展示了Window::display方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start
void start() {
std::chrono::time_point<std::chrono::system_clock> startTime=std::chrono::system_clock::now();
//Event thread (main thread)
bool running = true;
while (running) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::KeyPressed) {
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) {
window.close();
running=false;
}
}
else if (event.type == sf::Event::Closed) {
window.close();
running = false;
}
}
std::chrono::duration<double> elapsed_seconds = std::chrono::system_clock::now() - startTime;
double time=elapsed_seconds.count();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(0.0, 30.0, -65.0, //Camera position in World Space
0.0, 5.0, 0.0, //Camera looks towards this position
0.0, 1.0, 0.0); //Up
glPushMatrix();
glRotatef(-time*50.0, 0.0, 1.0, 0.0);
glTranslatef(20.0, 0.0, 0.0);
unanimatedAstroBoy.draw();
glPopMatrix();
glPushMatrix();
glRotatef(-time*50.0+90.0, 0.0, 1.0, 0.0);
glTranslatef(20.0, 0.0, 0.0);
astroBoy.drawFrame(time);
glPopMatrix();
glPushMatrix();
glRotatef(-time*50.0+180.0, 0.0, 1.0, 0.0);
glTranslatef(20.0, 0.0, 0.0);
astroBoyMovingGlasses.drawFrame(time);
glPopMatrix();
glRotatef(-time*50.0+270.0, 0.0, 1.0, 0.0);
glTranslatef(20.0, 0.0, 0.0);
astroBoyHeadBanging.drawFrame(time);
//Swap buffer (show result)
window.display();
}
}
示例2: renderLoop
void renderLoop(sf::Window & window)
{
sf::Clock time;
WorldState state;
while (state.isRunning())
{
this->handleEvents(window, state);
state.timeStep( time.getElapsedTime().asSeconds() );
engine.display(state);
window.display();
}
window.close();
}
示例3: step
void step()
{
// Clear to black
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
InputManager::Update();
// Get delta time since the last frame
float dt = timer.getElapsedTime().asSeconds();
timer.restart();
CameraManager::Update(dt);
RenderManager::Update(dt);
teapot->Update(dt);
RenderManager::Draw(CameraManager::ViewProjMat());
// Swap buffers
window.display();
}
示例4: main
int main (int argc, char **argv)
{
//Init with start Position
xpos=9;
ypos=9;
zpos=15;
xrot=50; //80°
yrot=135; //135°
// Set the color and depth clear values
glClearDepth(1.f);
glClearColor(0.f, 0.f, 0.f, 0.f);
// Enable Z-buffer read and writeca
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
// Setup a perspective projection
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
perspectiveGL(40.f, (1.f * xres / yres), 1.f, 500.f);
LoadTextures();
while (DSWindow.isOpen()) // Game loop
{
//calculate Time
maintimer.stop();
difTime = maintimer.getElapsedTimeInSec();
if (difTime > 0.1) difTime = 0; //remove first time
gesTime += difTime;
maintimer.start();
//Clear Screen and set OpenGL Settings
DSWindow.setActive();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClearColor (0.0,0.0,0.0,1.0); //clear the screen to black
enableGlOptions(); //enable graphic-settings
inputmanager(difTime); //mve camera etc
world(); //draw the "World
// levelDrawer1.drawAntMap(0);
levelDrawer1.drawBlocks();
if(gameStart)
{
antHill1.ki();
antHill1.antanimation();
}
DrawHUD(); //draw the HUD
// Finally, display the rendered frame on screen
DSWindow.display();
}
return EXIT_SUCCESS;
}
示例5: draw
void draw() {
//Activate the window's context
window.setActive();
//Various settings
glClearColor(0.5, 0.5, 0.5, 0.0f);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glClearDepth(1.0f);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glEnable(GL_TEXTURE_2D);
//Lighting
GLfloat light_color[] = {0.9, 0.9, 0.9, 1.f};
glMaterialfv(GL_FRONT, GL_DIFFUSE, light_color);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
//Setup projection matrix
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
GLfloat ratio = float(window.getSize().x) / window.getSize().y;
glFrustum(-ratio, ratio, -1.0, 1.0, 1.0, 500.0);
//Store start time
std::chrono::time_point<std::chrono::system_clock> startTime=std::chrono::system_clock::now();
//The rendering loop
glMatrixMode(GL_MODELVIEW);
while (window.isOpen()) {
std::chrono::duration<double> elapsed_seconds = std::chrono::system_clock::now() - startTime;
double time=elapsed_seconds.count();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f, -20.0f, -45.0f);
glPushMatrix();
glRotatef(-time*50.0, 0.0, 1.0, 0.0);
glTranslatef(20.0, 0.0, 0.0);
unanimatedAstroBoy.draw();
glPopMatrix();
glPushMatrix();
glRotatef(-time*50.0+90.0, 0.0, 1.0, 0.0);
glTranslatef(20.0, 0.0, 0.0);
astroBoy.drawFrame(time);
glPopMatrix();
glPushMatrix();
glRotatef(-time*50.0+180.0, 0.0, 1.0, 0.0);
glTranslatef(20.0, 0.0, 0.0);
astroBoyMovingGlasses.drawFrame(time);
glPopMatrix();
glRotatef(-time*50.0+270.0, 0.0, 1.0, 0.0);
glTranslatef(20.0, 0.0, 0.0);
astroBoyHeadBanging.drawFrame(time);
//Swap buffer (show result)
window.display();
}
}