Problem when using GetWindowPos (screencontrol) without a sleep after SetWindowPos
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: Problem when using GetWindowPos (screencontrol) without a sleep after SetWindowPos
Why do you need to set the window position ?
Do you call it more than once to move the window around with SET_WINDOW_POS ?
Joshy
Do you call it more than once to move the window around with SET_WINDOW_POS ?
Joshy
-
- Posts: 2958
- Joined: Jun 02, 2015 16:24
Re: Problem when using GetWindowPos (screencontrol) without a sleep after SetWindowPos
In fact, it was just an idea that I will probably not use. I'm thinking of adding a blob (a big sprite) thanks to the second screen allowed when you call a screenres from a dll. If it's a shaped window, it could be a good foreground big sprite at no cost for the main process. To synchronise the position between the main process screen and the dll screen it would be important to know how to use correctly the screencontrol set and get. That's where I am :)D.J.Peters wrote:Why do you need to set the window position ?
Do you call it more than once to move the window around with SET_WINDOW_POS ?
Joshy
Re: Problem when using GetWindowPos (screencontrol) without a sleep after SetWindowPos
I hope you understand what you want, because I don't understand any of the above :-)Tourist Trap wrote:In fact, it was just an idea that I will probably not use. I'm thinking of adding a blob (a big sprite) thanks to the second screen allowed when you call a screenres from a dll. If it's a shaped window, it could be a good foreground big sprite at no cost for the main process. To synchronise the position between the main process screen and the dll screen it would be important to know how to use correctly the screencontrol set and get. That's where I am :)
But it sounds like you need an fb.image (via ImageCreate).
-
- Posts: 2958
- Joined: Jun 02, 2015 16:24
Re: Problem when using GetWindowPos (screencontrol) without a sleep after SetWindowPos
Ahah, in fact I'm using images of course, but I'm justwondering if I wont put too much stuff at screen for my main loop. It's just speculation because I have not my game world ready for testing right now. In any case, we can easily put a second screen to deal with something like weather effect say, or big elements we don't want to blit in the main loop.badidea wrote: I hope you understand what you want, because I don't understand any of the above :-)
But it sounds like you need an fb.image (via ImageCreate).
You will understand the idea if you jump to this thread:
viewtopic.php?f=8&t=24780&p=221230#p221230
As I said, I don't think I will use the trick for now. But if I had so, the problem with the screencontrol set\get would become annoying.
Re: Problem when using GetWindowPos (screencontrol) without a sleep after SetWindowPos
I have not read the other topic yet, but made something funny:
with sleep 1, I get ~470 fps, so at 60 fps enough time for other stuff.
Code: Select all
#include "fbgfx.bi"
const as integer SW = 800, SH = 600
screenres SW, SH, 32
var pImageBg = imagecreate(SW * 2, Sh * 2, 0)
var pImageFg = imagecreate(SW * 2, Sh * 2, &h00ff00ff)
dim as integer i, x, y, r
for i = 0 to 99
x = int(rnd * SW * 2)
y = int(rnd * SH * 2)
r = int(rnd * 100) + 20
circle pImageBg, (x, y), r \ 2, &h0000AA77
circle pImageFg, (x, y), r, &h000077AA
next
dim as single a
dim as double t = timer
dim as integer fps = 0, lastFps = 0
while not multikey(1)
x = cos(a) * 200
y = sin(a) * 200
screenlock
put (0, 0), pImageBg, (x + 300, y + 300)-step(SW-1, SH-1), pset
put (0, 0), pImageFg, (-x + 300, -y + 300)-step(SW-1, SH-1), trans
locate 1,1: print lastFps
screenunlock
a += .005
fps += 1
if timer > t + 1 then
t = timer
lastFps = fps
fps = 0
end if
sleep 16
wend
-
- Posts: 2958
- Joined: Jun 02, 2015 16:24
Re: Problem when using GetWindowPos (screencontrol) without a sleep after SetWindowPos
With sleep 1, I get 65 fps here ..badidea wrote: with sleep 1, I get ~470 fps, so at 60 fps enough time for other stuff.
Re: Problem when using GetWindowPos (screencontrol) without a sleep after SetWindowPos
Probably because your OS does not do sleep 1 by default but 15.6 ms.Tourist Trap wrote:With sleep 1, I get 65 fps here ..badidea wrote: with sleep 1, I get ~470 fps, so at 60 fps enough time for other stuff.
It can be changed, see e.g.: viewtopic.php?f=15&t=27219&start=15#p255498 and https://docs.microsoft.com/en-us/window ... eginperiod
-
- Posts: 2958
- Joined: Jun 02, 2015 16:24
Re: Problem when using GetWindowPos (screencontrol) without a sleep after SetWindowPos
Oh thank you! I missed that. So now sleep 1 is meaning about 480 fps. Not bad.badidea wrote:Probably because your OS does not do sleep 1 by default but 15.6 ms.Tourist Trap wrote:With sleep 1, I get 65 fps here ..badidea wrote: with sleep 1, I get ~470 fps, so at 60 fps enough time for other stuff.
It can be changed, see e.g.: viewtopic.php?f=15&t=27219&start=15#p255498 and https://docs.microsoft.com/en-us/window ... eginperiod
Weirdly, if I use 999 rather than 99 circles before the loop, I loose 100 fps...
When I use 99999 , this means not black color left, my fps is again around 500.
Re: Problem when using GetWindowPos (screencontrol) without a sleep after SetWindowPos
I don't see a large difference here.Tourist Trap wrote:Weirdly, if I use 999 rather than 99 circles before the loop, I loose 100 fps...
When I use 99999 , this means not black color left, my fps is again around 500.
The put pImageFg using 'transparency' will be a bit slower I think, more to draw. But that does not explain the 99999 case.
-
- Posts: 2958
- Joined: Jun 02, 2015 16:24
Re: Problem when using GetWindowPos (screencontrol) without a sleep after SetWindowPos
Right, if I pset all, I can reach 600 now. Really interesting.badidea wrote: The put pImageFg using 'transparency' will be a bit slower I think, more to draw. But I don't see a large difference here.
No it's understandable. Too much circle son no room left for transparency. That's the case with a little number of circles that shouldn't be so fast. This, I don't see why with trans.badidea wrote:But that does not explain the 99999 case.
Re: Problem when using GetWindowPos (screencontrol) without a sleep after SetWindowPos
I don't know. The main point is that with sleep 1 and 500 fps, the cpu (1 core) is 50% sleeping, 50% active.
This is confirmed by my system monitor, although the cores seem to take turns here.
At 60 fps, the drawing load would be less then 10% leaving enough cpu power for other stuff.
A custom version of put, using a screenPtr and imagePtr, will probably be even faster.
Flipping screen pages might improve speed some more. Less stuff needed between screenlock/unlock.
This is confirmed by my system monitor, although the cores seem to take turns here.
At 60 fps, the drawing load would be less then 10% leaving enough cpu power for other stuff.
A custom version of put, using a screenPtr and imagePtr, will probably be even faster.
Flipping screen pages might improve speed some more. Less stuff needed between screenlock/unlock.