$(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):
// Declare and create a new render-windowautowindow = newRenderWindow(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 closedwhile (window.isOpen())
{
// Event processingEventevent;
while (window.pollEvent(event))
{
// Request for closing the windowif (event.type == Event.Type.Closed)
window.close();
}
// Clear the whole window before rendering a new framewindow.clear();
// Draw some graphical entitieswindow.draw(sprite);
window.draw(circle);
window.draw(text);
// End the current frame and display its contents on screenwindow.display();
}
$(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.)
// Create the render windowautowindow = newRenderWindow(VideoMode(800, 600), "DSFML OpenGL");
// Create a sprite and a text to displayautosprite = newSprite();
autotext = newText();
...
// Perform OpenGL initializationsglMatrixMode(GL_PROJECTION);
...
// Start the rendering loopwhile (window.isOpen())
{
// Process events
...
// Draw a background spritewindow.pushGLStates();
window.draw(sprite);
window.popGLStates();
// Draw a 3D object using OpenGLglBegin(GL_QUADS);
glVertex3f(...);
...
glEnd();
// Draw text on top of the 3D objectwindow.pushGLStates();
window.draw(text);
window.popGLStates();
// Finally, display the rendered frame on screenwindow.display();
}
$(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.)