Window that serves as a target for OpenGL rendering.
1 // Declare and create a new window 2 auto window = new Window(VideoMode(800, 600), "DSFML window"); 3 * 4 // Limit the framerate to 60 frames per second (this step is optional) 5 window.setFramerateLimit(60); 6 * 7 // The main loop - ends as soon as the window is closed 8 while (window.isOpen()) 9 { 10 // Event processing 11 Event event; 12 while (window.pollEvent(event)) 13 { 14 // Request for closing the window 15 if (event.type == Event.EventType.Closed) 16 window.close(); 17 } 18 * 19 // Activate the window for OpenGL rendering 20 window.setActive(); 21 * 22 // OpenGL drawing commands go here... 23 * 24 // End the current frame and display its contents on screen 25 window.display(); 26 }
$(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. *