$(U RenderWindow) is the main class of the Graphics package. It defines an OS
window that can be painted using the other classes of the graphics module.
$(U RenderWindow) is derived from $(WINDOW_LINK), thus it inherits all its
features : events, window management, OpenGL rendering, etc. See the
documentation of $(WINDOW_LINK) for a more complete description of all these
features, as well as code examples.
On top of that, $(U RenderWindow) adds more features related to 2D drawing
with the graphics module (see its base class $(RENDERTARGET_LINK) for more
details).
Here is a typical rendering and event loop with a $(U RenderWindow):
1 // Declare and create a new render-window2 autowindow = newRenderWindow(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 closed8 while (window.isOpen())
9 {
10 // Event processing11 Eventevent;
12 while (window.pollEvent(event))
13 {
14 // Request for closing the window15 if (event.type == Event.EventType.Closed)
16 window.close();
17 }
18 19 // Clear the whole window before rendering a new frame20 window.clear();
21 22 // Draw some graphical entities23 window.draw(sprite);
24 window.draw(circle);
25 window.draw(text);
26 27 // End the current frame and display its contents on screen28 window.display();
29 }
$(PARA Like $(WINDOW_LINK), $(U RenderWindow) is still able to render direct
OpenGL stuff. It is even possible to mix together OpenGL calls and regular
DSFML drawing commands.)
1 // Create the render window2 autowindow = newRenderWindow(VideoMode(800, 600), "DSFML OpenGL");
3 4 // Create a sprite and a text to display5 autosprite = newSprite();
6 autotext = newText();
7 ...
8 9 // Perform OpenGL initializations10 glMatrixMode(GL_PROJECTION);
11 ...
12 13 // Start the rendering loop14 while (window.isOpen())
15 {
16 // Process events17 ...
18 19 // Draw a background sprite20 window.pushGLStates();
21 window.draw(sprite);
22 window.popGLStates();
23 24 // Draw a 3D object using OpenGL25 glBegin(GL_QUADS);
26 glVertex3f(...);
27 ...
28 glEnd();
29 30 // Draw text on top of the 3D object31 window.pushGLStates();
32 window.draw(text);
33 window.popGLStates();
34 35 // Finally, display the rendered frame on screen36 window.display();
37 }
$(U RenderWindow) is the main class of the Graphics package. It defines an OS window that can be painted using the other classes of the graphics module.
$(U RenderWindow) is derived from $(WINDOW_LINK), thus it inherits all its features : events, window management, OpenGL rendering, etc. See the documentation of $(WINDOW_LINK) for a more complete description of all these features, as well as code examples.
On top of that, $(U RenderWindow) adds more features related to 2D drawing with the graphics module (see its base class $(RENDERTARGET_LINK) for more details).
Here is a typical rendering and event loop with a $(U RenderWindow):
$(PARA Like $(WINDOW_LINK), $(U RenderWindow) is still able to render direct OpenGL stuff. It is even possible to mix together OpenGL calls and regular DSFML drawing commands.)