This article applies to:
E-Prime 3.0
E-Prime 2.0
Detail
E-Prime offers the ability to use display flipping to perform any drawing operations. The use of flipping is recommended especially for larger displays to reduce the possibility of display tearing (when part of the new/old screen appear at the same time).
Use of flipping requires a PreRelease value approximately of one refresh duration for the object that preceeds the drawing object to ensure proper scheduling. Without ample PreRelease, the object schedules for the following refresh period. This is reflected in the OnseTime and OnsetDelay properties.
To turn off this feature, perform one of the following:
In E-Basic:
Display.FlippingEnabled = False
In the E-Studio interface:
- Open the Experiment Object.
- Navigate to the Devices tab.
- Open the Display device properties.
- Select No in the the FlippingEnabled dropdown.
- Click OK to accept all changes.
NOTE: When flipping is enabled, all E-Basic Canvas calls targeting the on-screen canvas internally wait for the vertical blank refresh period. The use of Display.WaitForVerticalBlank is not necessary and if used causes the Canvas operation to draw a refresh later. Whether using flipping or not, we recommend performing any drawing commands on an offscreen canvas. Then use the Canvas.Copy operation to update the screen.
Flipping is required for Windows 8 and later
Since Microsoft made changes in their support of DirectX 7 under Windows 8 and beyond, E-Prime 3.0 uses DirectX 11 hardware acceleration for proper compatibility and timing accuracy. The use of DirectX 11 requires that display flipping must be enabled when running E-Prime 3.0 in a Windows 8 (or later) environment to maintain timing accuracy. Runtime error 11111 occurs if you are not running with Flipping enabled.
Display flipping is enabled by default for all new experiments created within E-Prime 3.0. However, when an experiment that was created in a prior version of E-Prime (such as E-Prime 2.0 SP2), E-Prime 3.0 keeps the display flipping settings of the original file. Therefore, E-Prime 3.0 has added a protocol which determines if the machine is operating in Windows 8 or beyond. If the criterion is met, E-Prime determines if display flipping has been enabled.
See Also:
AV: Windows 8 or DirectX 11 or greater detected (Formerly KB 19543 & 5577) [23888]
Comments
2 comments
I have found that FlippingEnabled interferes with the use of MsgBox under E-Prime 2 -- after running any visual display object that uses flipping, MsgBox will not appear on the Display, and holds up further program execution until the MsgBox gets a response, which you must enter blindly. Apparently MsgBox writes to the video backbuffer, but then E-Prime never gets or produces a signal to flip the backbuffer into the front in order to show the MsgBox.
Using inline code to temporarily set Display.FlippingEnabled to False and then True again later does not reliably fix this. Simply setting FlippingEnabled to False for the whole experiment does fix this, but then you lose the advantage of page flipping; furthermore, Windows 10 does not allow running EP2 with FlippingEnabled disabled at all. Presumably the same problem applies to AskBox, InputBox, and the like, but I have not systematically checked this.
I did, however, stumble upon a workaround while investigating this. It turns out that if you precede MsgBox with a Draw of some fresh TextDisplay, the MsgBox will work. E.g.,
Dim DummyText As TextDisplay
Set DummyText = New TextDisplay
DummyText.BackStyle = "transparent" ' important!
DummyText.Width = 1: DummyText.Height = 1 ' optional
DummyText.Draw
MsgBox "Your message here!"
Set DummyText = Nothing
In order to generalize this, you might package it into a Sub or Function in the global User script area, thus:
Sub MssgBox( mssg As String )
' Workaround to present MsgBox when Display.FlippingEnabled is True.
' Simply Draw some fresh dummy TextDisplay before runnng the MsgBox.
Dim DummyText As TextDisplay
Set DummyText = New TextDisplay
DummyText.BackStyle = "transparent" ' important!
DummyText.Width = 1: DummyText.Height = 1 ' optional
DummyText.Draw
MsgBox mssg
Set DummyText = Nothing
End Sub
or finally, if you wish to be a little more selective in when E-Prime applies this workaround,
Sub MssgBox( mssg As String )
' Workaround to present MsgBox when Display.FlippingEnabled is True.
' Simply Draw some fresh dummy TextDisplay before runnng the MsgBox.
Dim DummyText As TextDisplay
If Display.FlippingEnabled Then
Set DummyText = New TextDisplay
DummyText.BackStyle = "transparent" ' important!
DummyText.Width = 1: DummyText.Height = 1 ' optional
DummyText.Draw
End If
MsgBox mssg
Set DummyText = Nothing
End Sub
Then in inline code you could use MssgBox in place of MsgBox. You might also do something like this for AskBox, InputBox, etc.
Note that E-Prime 3 offers DisplayDevice.MsgBox and similar methods as replacements to MsgBox, etc., which should fix this problem for users of EP3. Note, however, that DisplayDevice.MsgBox and its cousins have their own peculiarities.
Turns out my first workaround falls short in some cases. So I made a new workaround using a TextDisplay for the message, using Keyboard Device directly for response, and using an offscreen Canvas to preserve & restore the existing Display. With slight modification you could use this to also return a response. Here it is:
Sub MsgDisplay( mssg As String )
' MsgBox does not work well with Display.FlippingEnabled. This workaround
' presents a message using a TextDisplay object. It uses an offscreen Canvas to
' preserve and restore the existing Display, uses TextDisplay.Draw so as not to
' disturb object timing, and uses direct access to the Keyboard Device to wait
' for a response without disturbing any running input mask.
Const ExitKey As String = "{ENTER}"
Dim kbdCount As Integer
Dim tempCnvs As Canvas
Dim MsgText As TextDisplay
' preserve current Display ...
Set tempCnvs = Display.CreateCanvas
tempCnvs.Copy Display.Canvas
' set up message ...
Set MsgText = New TextDisplay
MsgText.ForeColor = CColor("black"): MsgText.BackColor = CColor("white")
MsgText.Width = "40%": MsgText.Height = "25%"
MsgText.BorderWidth = 3
MsgText.FontSize = 14
MsgText.Text = mssg & "\n\n(press Enter)"
MsgText.Draw ' display message
' wait for exit key ...
kbdCount = Keyboard.History.Count
Do
Do Until (kbdCount < Keyboard.History.Count)
Loop
kbdCount = kbdCount + 1
Loop Until Keyboard.History(kbdCount).RESP = ExitKey
''? Loop Until Keyboard.History(kbdCount).RESP <> "" ' allow any key
Display.Canvas.Copy tempCnvs ' restore Display
' cleanup ...
Set tempCnvs = Nothing
Set MsgText = Nothing
End Sub
Please sign in to leave a comment.