Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

exact number of refreshes (Real Studio games Mailinglist archive)

Back to the thread list
Previous thread: Right-Click problems
Next thread: Realtime editing of a trimesh from an object3D


[ANN] Preview of RBD 2.4   -   Marc Zeedar
  exact number of refreshes   -   Robert Ward
   Re: exact number of refreshes   -   Frank Condello
    Re: exact number of refreshes   -   Robert Ward
     Re: exact number of refreshes   -   Frank Condello

exact number of refreshes
Date: 28.09.05 15:50 (Wed, 28 Sep 2005 15:50:51 +0100)
From: Robert Ward
I need to present a series of images for an exactly specified number of
screen refreshes. I've had good success in OS X using agl declares to
swap in new images during the vertical blanking. So I can get flicker-
free presentations, swapping cleanly between 2 images at the screen's
refresh rate. That's the first part. But now I want to, for example,
present image1 for exactly 2 refreshes, followed by image2 for exactly 3
refreshes.

What I'd really like to do is to be able to count the number of blanking
intervals. Is there an agl declare or some other method that allows that?

The alternatives I can think of:
1. Use the clock and wait for a number of microseconds equal to the time
of the desired number of refreshes. But I'm afraid that will tend to get
out of sync occasionally.

2. Currently I can swap images every refresh (e.g. flicker back and forth
between two images 72 times a second). In that case, I know that each
image is on for exactly 1 refresh. What I could do I suppose is make sure
that I'm load multiple copies of an image for each desired refresh. That
is if I want image2 for exactly 3 refreshes, I load the image 3 times,
swapping at every refresh. That sounds ok, but kind of awkward.

I hope that makes sense, but also that someone has some better ideas?
Rob

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: exact number of refreshes
Date: 28.09.05 20:53 (Wed, 28 Sep 2005 15:53:37 -0400)
From: Frank Condello
On 28-Sep-05, at 10:50 AM, Robert Ward wrote:

> I need to present a series of images for an exactly specified
> number of
> screen refreshes. I've had good success in OS X using agl declares to
> swap in new images during the vertical blanking. So I can get flicker-
> free presentations, swapping cleanly between 2 images at the screen's
> refresh rate. That's the first part. But now I want to, for example,
> present image1 for exactly 2 refreshes, followed by image2 for
> exactly 3
> refreshes.
>
> What I'd really like to do is to be able to count the number of
> blanking
> intervals. Is there an agl declare or some other method that allows
> that?

Assuming your framerate is always maxed out to the refresh rate you
should be able to just call aglSwapBuffers multiple times for each
image. Each buffer swap will block until the next refresh when VBL
sync is enabled, so just swap buffers twice for image1 and swap three
times for image2...

The only problems you might encounter with this are when frame take
longer than 1 swap interval to draw (the previous frame may stay up
longer in that case) and dealing with different refresh rates, unless
you can guarantee 72 Hz is always available.

Frank.
–––––––––––––––––––––––––––––––––
Open Source RB Goodies and Shareware
<http://developer.chaoticbox.com/>
<http://www.chaoticbox.com/>
–––––––––––––––––––––––––––––––––

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: exact number of refreshes
Date: 29.09.05 13:17 (Thu, 29 Sep 2005 13:17:04 +0100)
From: Robert Ward
>Assuming your framerate is always maxed out to the refresh rate you
>should be able to just call aglSwapBuffers multiple times for each image.
>Each buffer swap will block until the next refresh when VBL sync is
>enabled, so just swap buffers twice for image1 and swap three times for
>image2...

Thanks, that sounds great. Can I just clarify a bit?

According to Apple, aglSwapBuffers swaps the 'front' and 'back' buffers.
The front buffer is presumably what's being displayed, but I'm wondering
what I do to set the back buffer to the same image?

Currently I load an Object3d with multiple images. Then loop through the
indices of the obj, setting shape appropriately and waiting. Something like:

for i = 0 to UBound(images_to_present)
obj3d.shape = i
rb3dspace1.update
' start timer and get response
start = microseconds
while microseconds < start + TIME_TO_DISPLAY_IMAGE
wend
next

Are you suggesting a solution something like:

for i = 0 to UBound(images_to_present)
obj3d.shape = i
rb3dspace1.update
for j = 1 to REFRESHES_TO_PRESENT
aglSwapBuffers(aglGetCurrentContext())
next
next

>The only problems you might encounter with this are when frame take
>longer than 1 swap interval to draw (the previous frame may stay up
>longer in that case) and dealing with different refresh rates, unless you
>can guarantee 72 Hz is always available.

I can ensure that the image will be less than the refresh time, and that
the refresh time is known in advance.

Thanks again,
Rob

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: exact number of refreshes
Date: 30.09.05 05:54 (Fri, 30 Sep 2005 00:54:04 -0400)
From: Frank Condello
On 29-Sep-05, at 8:17 AM, Robert Ward wrote:

>> Assuming your framerate is always maxed out to the refresh rate you
>> should be able to just call aglSwapBuffers multiple times for each
>> image.
>> Each buffer swap will block until the next refresh when VBL sync is
>> enabled, so just swap buffers twice for image1 and swap three
>> times for
>> image2...
>
> Thanks, that sounds great. Can I just clarify a bit?
>
> According to Apple, aglSwapBuffers swaps the 'front' and 'back'
> buffers.
> The front buffer is presumably what's being displayed, but I'm
> wondering
> what I do to set the back buffer to the same image?

Typically when you're using a double buffered context, OpenGL will be
drawing on the back buffer. You only see an image when you "swap" the
back buffer to the front. Swap is a poor description though, you're
actually just replacing the front buffer with the image on the back
buffer, and the back buffer remains as-is. So "swapping" twice just
copies the same back buffer image to the front buffer twice - no need
to re-render the scene if it hasn't changed.

> Are you suggesting a solution something like:
>
> for i = 0 to UBound(images_to_present)
> obj3d.shape = i
> rb3dspace1.update
> for j = 1 to REFRESHES_TO_PRESENT
> aglSwapBuffers(aglGetCurrentContext())
> next
> next

I was assuming you were talking to OpenGL/AGL directly rather than
going through Rb3D, but this *should* work. The fact that you have no
control over what goes on inside rb3dspace1.update should scare you
just a little bit though ;)

Frank.
–––––––––––––––––––––––––––––––––
Open Source RB Goodies and Shareware
<http://developer.chaoticbox.com/>
<http://www.chaoticbox.com/>
–––––––––––––––––––––––––––––––––

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>