ScreenRes causes error when run from safe mode or VM

General FreeBASIC programming questions.
Dusty Venture
Posts: 4
Joined: Oct 04, 2008 20:57

ScreenRes causes error when run from safe mode or VM

Postby Dusty Venture » Oct 04, 2008 21:13

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
vdecampo
Posts: 2982
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Postby vdecampo » Oct 04, 2008 21:25

You should also be able to set the driver before setting the resolution like this...

Code: Select all

ScreenControl fb.set_driver_name,"gdi"


-Vince
www.iMakeGames.com
1000101
Posts: 2556
Joined: Jun 13, 2005 23:14
Location: SK, Canada

Postby 1000101 » Oct 04, 2008 22:35

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.
Sisophon2001
Posts: 1704
Joined: May 27, 2005 6:34
Location: Cambodia, Thailand, Lao, Ireland etc.
Contact:

Postby Sisophon2001 » Oct 05, 2008 7:22

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
Wine 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.


Garvan

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.
Dusty Venture
Posts: 4
Joined: Oct 04, 2008 20:57

Postby Dusty Venture » Oct 05, 2008 15:20

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 :( >
1000101
Posts: 2556
Joined: Jun 13, 2005 23:14
Location: SK, Canada

Postby 1000101 » Oct 05, 2008 15:24

Well, if it's a text based interface, why do you need the graphics library at all? ^.o
Dusty Venture
Posts: 4
Joined: Oct 04, 2008 20:57

Postby Dusty Venture » Oct 05, 2008 18:01

@ 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?
1000101
Posts: 2556
Joined: Jun 13, 2005 23:14
Location: SK, Canada

Postby 1000101 » Oct 05, 2008 19:09

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
Dusty Venture
Posts: 4
Joined: Oct 04, 2008 20:57

Postby Dusty Venture » Oct 05, 2008 19:23

Excellent, that works.
I like the way text looks in graphics mode better though, less flicker and no cursor.

I have to say I am really loving the FB community, the amount of feedback that I have received in the forum and IRC on this simple question has been amazing!
1000101
Posts: 2556
Joined: Jun 13, 2005 23:14
Location: SK, Canada

Postby 1000101 » Oct 06, 2008 0:10

You can turn the cursor on/off with the third parameter of the locate function.
counting_pine
Site Admin
Posts: 6245
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Postby counting_pine » Oct 06, 2008 15:32

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.
counting_pine
Site Admin
Posts: 6245
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Postby counting_pine » Oct 06, 2008 16:37

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.
DrV
Site Admin
Posts: 2116
Joined: May 27, 2005 18:39
Location: Midwestern USA
Contact:

Postby DrV » Oct 06, 2008 18:22

I only tested this on a Windows 2000 Terminal Services session (it previously crashed there), but it should hopefully work the same under safe mode or other environments without DX. Any other test results are welcome (and if it is a crash, it would be helpful if you could provide a backtrace).

Return to “General”

Who is online

Users browsing this forum: No registered users and 15 guests