#includeint main() { sf::RenderWindow window(sf::VideoMode(640, 480), "RenderWindow"); while (window.isOpen()) { sf::Event event; while (window.pollEvent(event)) { if (event.type == sf::Event::Closed) window.close(); } window.clear(); // draw objects here.. window.display(); } return 0; }
#includeIn both examples, the RenderWindow display is being updated by drawing or rendering objects in the window using graphic libraries. Package libraries to be installed to use RenderWindow class: - SFML library for C++ (SFML/Graphics.hpp) - OpenGL libraries (can vary depending on platform, GLUT is used in this example)void renderScene(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glBegin(GL_TRIANGLES); glVertex3f(-0.5,-0.5,0.0); glVertex3f(0.5,0.0,0.0); glVertex3f(0.0,0.5,0.0); glEnd(); glutSwapBuffers(); } int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); glutInitWindowPosition(100,100); glutInitWindowSize(640,480); glutCreateWindow("RenderWindow"); glutDisplayFunc(renderScene); glutMainLoop(); return 0; }