ScreenRes causes error when run from safe mode or VM
-
- Posts: 4
- Joined: Oct 04, 2008 20:57
ScreenRes causes error when run from safe mode or VM
This is just to document in the forum, what I found out in IRC, because I have searched the forum and couldn't find a resolution here.
If you are setting a graphics mode in a program that will be running in safe mode or a VM it will likely fail because by default the libraries use the direct x interface. To get around this place the following at the beginning of your source.
SetEnviron("FBGFX=GDI")
This will cause the library to use the GDI interface rather than the direct X one.
Thanks To Luke L for this solution
If you are setting a graphics mode in a program that will be running in safe mode or a VM it will likely fail because by default the libraries use the direct x interface. To get around this place the following at the beginning of your source.
SetEnviron("FBGFX=GDI")
This will cause the library to use the GDI interface rather than the direct X one.
Thanks To Luke L for this solution
You should also be able to set the driver before setting the resolution like this...
-Vince
www.iMakeGames.com
Code: Select all
ScreenControl fb.set_driver_name,"gdi"
www.iMakeGames.com
I'm not sure that your generalization is accurate. I've had people run windows stuff under Wine and it worked fine without forcing GDI. I've run stuff under Windows (95, 2000, XP) in VirtualPC without specifying GDI. Please tell us what Virtual Machine or Windows Emulator you were using that failed. It could very well be that software.
-
- Posts: 1706
- Joined: May 27, 2005 6:34
- Location: Cambodia, Thailand, Lao, Ireland etc.
- Contact:
Wine implements some form of DirectX. I made a test with the sample given in the help file for screeninfo, and the DirectX driver was reported
From the wine HQ FAQ
EDIT: Some comparative timings
WindowsXP - fbgfx_test for 10000 loops (Laptop)
GDI Driver = 16.26 Seconds
DX Driver = 16.18 Seconds
Ubuntu 9.04 With wine 1.0 (Desktop)
X11 Driver = 35.87 Seconds
DX Driver = 36.72 Seconds
GDI Driver = 35.54 Seconds.
wine is not a bad option for running FB apps in Linux. Slower start-up, but they run just as well as natively compiled FB code.
From the wine HQ FAQ
GarvanWine itself provides a DirectX implementation that, although it has a few bugs left, should run fine. Wine supports DirectX 9.0c at this time. Plans for DirectX 10 are underway.
EDIT: Some comparative timings
WindowsXP - fbgfx_test for 10000 loops (Laptop)
GDI Driver = 16.26 Seconds
DX Driver = 16.18 Seconds
Ubuntu 9.04 With wine 1.0 (Desktop)
X11 Driver = 35.87 Seconds
DX Driver = 36.72 Seconds
GDI Driver = 35.54 Seconds.
wine is not a bad option for running FB apps in Linux. Slower start-up, but they run just as well as natively compiled FB code.
-
- Posts: 4
- Joined: Oct 04, 2008 20:57
The VM that I am running is virtual box, but I imagine that my utility will be getting used in a variety of VM's and safemode where DX will often not be available.
I was testing under virtual box which could be configured for DX but thats not what I need at the moment since this is a text based file utility.
@ vdecampo, Cool I can always use another way to skin the cat.
<poor kitty :( >
I was testing under virtual box which could be configured for DX but thats not what I need at the moment since this is a text based file utility.
@ vdecampo, Cool I can always use another way to skin the cat.
<poor kitty :( >
-
- Posts: 4
- Joined: Oct 04, 2008 20:57
@ 1000101, well I want to be able to use the view print and width commands, so I presume they require screenres be run first say screenres 640, 400.
Now I know there are other ways to set screen modes, but this is what worked easiest for me when I was writing my utility.
How would I set an appropriate text mode?
Now I know there are other ways to set screen modes, but this is what worked easiest for me when I was writing my utility.
How would I set an appropriate text mode?
The same way. Compile as a console application and use view print, width, etc. In fact, "view print" and "width" shouldn't do anything in a graphics mode (although they may in fb they didn't or did very little in qb).
Code: Select all
Width 80, 50
Locate 50, 1 : Print "Last line!";
Sleep
End
-
- Posts: 4
- Joined: Oct 04, 2008 20:57
You can turn the cursor on/off with the third parameter of the locate function.
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
It's also possible to reduce flickering by using pages in the console.
It's not currently well-documented in the wiki, but Screen can be used to set console pages. You can see an example of it under FreeBASIC\examples\misc\pcopy.bas
Note that Width and View Print do work in graphics mode. Width can be used to change the character size, and View Print, well, does pretty much what you'd expect.
It's not currently well-documented in the wiki, but Screen can be used to set console pages. You can see an example of it under FreeBASIC\examples\misc\pcopy.bas
Note that Width and View Print do work in graphics mode. Width can be used to change the character size, and View Print, well, does pretty much what you'd expect.
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
By the way, DrV committed this change recently, which may be of interest to you:
http://fbc.svn.sourceforge.net/viewvc/f ... ision=5149
So the next release of FB should more reliably fall back on the GDI driver in cases where the DirectX one isn't working.
http://fbc.svn.sourceforge.net/viewvc/f ... ision=5149
So the next release of FB should more reliably fall back on the GDI driver in cases where the DirectX one isn't working.