Answer the question
In order to leave comments, you need to log in
What is each function responsible for?
I apologize in advance for stupid questions, it is important for me to understand what is happening in my code.
The situation is such that it is not always clear to me from the documentation what it says. It is often written in a language that is difficult for a beginner, and if, in addition, in English, then it is difficult to understand anything at all.
#include "pch.h"
#include <iostream>
#include <SFML\Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(720, 500), "Prompt");
sf::Texture OneWindow;
OneWindow.loadFromFile("Fon.jpg");
sf::Sprite OW;
OW.setTexture(OneWindow);
OW.setPosition(0, 0);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(OW);
window.display();
}
}
Answer the question
In order to leave comments, you need to log in
Well, again, we climb into the Internet, into the documentation...
display displays on the screen everything that was "drawn" during the rendering process. For example, we have several stages of "drawing", and we need to show only the final result.
void sf::Window::display ( )
Display on screen what has been rendered to the window so far.
This function is typically called after all OpenGL rendering has been done for the current frame, in order to show it on screen.
clear clears the "drawing" area. Otherwise, everything will be drawn on top of the previous picture. Imagine that you are drawing a second hand on a clock, and the old hand image is not erased.
void sf::RenderTarget::clear ( const Color & color = Color(0, 0, 0, 255) )
Clear the entire target with a single color.
This function is usually called once every frame, to clear the previous contents of the target.
Event handling is already a feature of WinApi. Each user object in Windows has an event queue, and the code must have a function for processing them, if you do not "consume" events (such as keystrokes, cursor movement), the queue "clogs" and such a rigmarole occurs with the loading icon.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question