Window that serves as a target for OpenGL rendering.
// Declare and create a new window auto window = new Window(VideoMode(800, 600), "DSFML window"); // Limit the framerate to 60 frames per second (this step is optional) window.setFramerateLimit(60); // The main loop - ends as soon as the window is closed while (window.isOpen()) { // Event processing Event event; while (window.pollEvent(event)) { // Request for closing the window if (event.type == Event.EventType.Closed) window.close(); } // Activate the window for OpenGL rendering window.setActive(); // OpenGL drawing commands go here... // End the current frame and display its contents on screen window.display(); }
$(U Window) is the main class of the Window module. It defines an OS window that is able to receive an OpenGL rendering.
A $(U Window) can create its own new window, or be embedded into an already existing control using the create(handle) function. This can be useful for embedding an OpenGL rendering area into a view which is part of a bigger GUI with existing windows, controls, etc. It can also serve as embedding an OpenGL rendering area into a window created by another (probably richer) GUI library like Qt or wxWidgets.
The $(U Window) class provides a simple interface for manipulating the window: move, resize, show/hide, control mouse cursor, etc. It also provides event handling through its pollEvent() and waitEvent() functions.
Note that OpenGL experts can pass their own parameters (antialiasing level bits for the depth and stencil buffers, etc.) to the OpenGL context attached to the window, with the $(CONTEXTSETTINGS_LINK) structure which is passed as an optional argument when creating the window.