本文整理汇总了C++中sf::Window::isOpen方法的典型用法代码示例。如果您正苦于以下问题:C++ Window::isOpen方法的具体用法?C++ Window::isOpen怎么用?C++ Window::isOpen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::Window
的用法示例。
在下文中一共展示了Window::isOpen方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveImage
void video::saveImage(sf::Window &app, int framerate)
{
if (!app.isOpen())
return ;
sf::Vector2u size = app.getSize();
if (videoTexture.getSize().y != size.y)
videoTexture.create(size.x, size.y);
if (videoTimer.getElapsedTime().asMilliseconds() > 1000/framerate)
{
videoTimer.restart();
std::ostringstream videoFramePath;
videoFramePath << "/tmp/gl-engine-"
<< std::setw(5)
<< std::setfill('0')
<< currentVideoFrame
<< ".jpg";
videoTexture.update(app);
sf::Image videoImage = videoTexture.copyToImage();
videoImage.saveToFile(videoFramePath.str());
currentVideoFrame++;
}
}
示例2: main
int main()
{
init();
while (window.isOpen())
{
step();
pollEvents();
}
cleanUp();
return 0;
}
示例3: 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;
}
示例4: 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();
}
}