Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - vlad

Pages: [1]
1
Graphics / [Solved] Is the refreshing optimized?
« on: July 24, 2011, 09:30:10 pm »
Alright, my main question's been answered: I don't need to handle them dirty rectangles anymore :D

I too noticed that even though I didn't use the dirty rectangles method (damn, such a hassle, btw) my CPU was running at a very fair pace.

But I was wondering if it was because SFML handled the rectangles by itself or if it was a hardware matter (said hardware being either powerful enough to redraw the scene each time or smart enough to detect by itself which zones in the screen needed refreshing)

This is just to fulfill my curiosity, though; I'll ask Laurent some time in the future if I get the opportunity.

2
Graphics / [Solved] Is the refreshing optimized?
« on: July 24, 2011, 02:10:41 pm »
Hi,

I come from an SDL background and there, a certain method is used when, say, a character's moved on a certain area of a map but nothing else on the map has moved:
instead of refreshing the entire screen at the end of each iteration of the main loop, you just refresh a specific rectangle where changes have been made (i.e. the rectangle in which the character's moved).

I was wondering if SFML used this technique natively or if I had to design a refresh() function by myself like it's the case with SDL.

If you didn't understand what this was about, feel free to mention it and I will try to explain it a little better.

And sorry if this question has been answered 'cause I've sure been looking for it on the forum but since I can't put a name on this technique...

Edit: as said below, this technique is called the Dirty Rectangle Method

3
Window / [Solved] How to adjust the delays involved in KeyRepeat?
« on: July 15, 2011, 11:48:25 pm »
Agreed, the name "readInput" is ill-suited to what it actually does, but it used to actually just read the inputs.
I should mention that I'm currently just beginning to discover SFML, so this program is just me fooling around with no real structure yet.
When I'm skilled enough I may start a game; then I'm gonna do some serious structuring, probably by stealing ideas from a variety of pre-existing games and projects.

This being said, let's get back to this framerate business:
Got the sf::Window::GetFrameTime(), I'll use it right away.
I also checked out the Thor library, but I think I have no use for it right now. Maybe when I get down to a little more serious project.

I'll mark this topic as solved since I feel we've been through the issue.

4
Window / [Solved] How to adjust the delays involved in KeyRepeat?
« on: July 15, 2011, 09:38:51 pm »
Got it for sf::Sleep().

Quote from: "Nexus"
Quote from: "vlad"
A loop at the end of the main one ensures the refreshing rate is no less than 60 ms.
An alternative is to pass the frame time to your function and to move the player accordingly.
Sorry, but I don't get what you mean by "pass the frame time to [my] function" (which function?)

5
Window / [Solved] How to adjust the delays involved in KeyRepeat?
« on: July 15, 2011, 06:50:45 pm »
Contadotempo > I'm using SFML 1.6, I should have mentioned it in the first post.
I assure you I understand pretty well how sf::Input works and I've read the doc. The solution I expected simply isn't available in SFML. I started 2D programming with SDL, that's why I was hoping for an SDL-ish solution.

Nexus > As it turned out I didn't go with SDL for event handling, I just modified my main loop:

Old loop:
Code: [Select]
while(app.IsOpened())
{
Event event;
while(app.GetEvent(event))
{
if(event.Type == Event::Closed)
app.Close();
if(event.Type == Event::KeyPressed || event.Type == Event::KeyReleased)
{
// this function moves a character on the screen toward
// a certain direction given which keys are pressed
GameInput::readInput(&(app.GetInput()), &hero);
}
}
app.Clear();
hero.draw(app);
app.Display();
}


New loop:
Code: [Select]
while(app.IsOpened())
{
// clk is the loop's clock
clk.Reset();
Event event;
while(app.GetEvent(event))
{
if(event.Type == Event::Closed)
app.Close();
}
// this time, the main function is called at each iteration of the loop
// regardless of whether a key's been pressed
GameInput::readInput(&(app.GetInput()), &hero);
app.Clear();
hero.draw(app);
app.Display();
// this line ensures that one iteration takes no less than 60 ms.
while(clk.GetElapsedTime() < 0.060);
}


The problem with the old loop was that my character moved oddly, since the KeyRepeat parameters depend on the OS settings: each time I ordered him to move, he would make a first step, pause for a second, then resume walking at a reasonable pace. Exactly what happens when you hold a key while editing a text file.

I didn't like this behavior but liked even less the idea of having to change the Windows settings to make him walk smoothly.

The optimal solution would have been to modify the first delay involved in the KeyRepeat process, like it's possible in SDL. But as I said enough times, this feature isn't available in SFML, as Laurent confirmed in the second post:
Quote
SFML uses the OS settings, you can't change them in your program.


So instead I wrote a new loop which involves a solution where the key states are checked at each iteration of the main loop, whether a key's been pressed or not.
A loop at the end of the main one ensures the refreshing rate is no less than 60 ms.

It works pretty fine, but I consider this to be too much DIY for my taste and it seems to make the processor work harder.

A fine way to improve this solution would be to replace the last loop:
Code: [Select]
while(clk.GetElapsedTime() < 0.060); With something along the lines of
Code: [Select]
SleepUntil(clk.GetElapsedTime() < 0.060);

I'll check in the documentation if there a sleep() function, but it doesn't seem so. Perhaps by using threads?

6
Window / [Solved] How to adjust the delays involved in KeyRepeat?
« on: July 14, 2011, 10:20:45 pm »
I think I'll just go with SDL for event handling, or just recode my main loop so it checks the keyboard's state every 60 frames.

Laurent > Does the next version of SFML include the possibility to modify these delays?

7
Window / [Solved] How to adjust the delays involved in KeyRepeat?
« on: July 14, 2011, 08:18:24 pm »
I've looked pretty much everywhere sf::Input was mentioned, and still can't find a way to adjust these settings without using the clock. Do you have a more specific clue concerning the location of the solution?

8
Window / [Solved] How to adjust the delays involved in KeyRepeat?
« on: July 14, 2011, 05:34:13 pm »
Got it.

I'll try to find a way to make my character move smoothly then I'll post the solution in this topic.

9
Window / [Solved] How to adjust the delays involved in KeyRepeat?
« on: July 13, 2011, 09:50:58 pm »
Hi,

I assure you I've done some research on the subject in the documentation and this forum, but I still can't figure out how to adjust these two delays:

- the time you have to keep a key pressed for the system to understand that you want to repeat the input
- the time between two key repetitions

Does anyone have a clue?

Pages: [1]
anything