Compiler Subsystem Details

Everything else that doesn't fall into one of the other PB categories.
User avatar
kenmo
Addict
Addict
Posts: 2083
Joined: Tue Dec 23, 2003 3:54 am

Compiler Subsystem Details

Post by kenmo »

The whole time I have been using PB, I have never been very clear on the different subsystems available in the compiler. I usually program on Windows, using the default subsystem (directx9 now?).

The 4.51 help file reads:

Code: Select all

Windows 
nt4 : uses DirectX3 only for any library that uses DirectX in order to be compatible to Windows NT 4. 
opengl : uses OpenGL for the 3D libraries. 

Linux 
gtk1 : uses Gtk1.2 instead of Gtk2 for the compilation. (requires the gtk1.2-dev package) 
Note that this subsystem is no longer maintained and some features may be missing. 

MacOSX 
There are currently no official subsystems for MacOSX.
I'm mainly interested in the Windows subsystems, including directx7 which isn't listed in the help (?). If anyone has any more details or experiences to share, the advantages/disadvantages of each, when or when NOT to use them, performance tradeoffs, bugs, etc. please mention them.

My motivation for asking is that I'm working on a decent-sized game and everything is drawn by the 2D drawing library in real-time. I'm developing on XP Pro and I get smooth 60 FPS gameplay. However the recent "2D drawing is slow as hell" thread has got me paranoid about future issues when porting to newer Windows, plus hopefully Mac, and possibly Linux. This might happen around New Years time, so 4.60 should be finished.

I've been experimenting with the available subsystems and getting bizarre results... here are some examples (all PB 4.60 RC 1):

XP Pro, default subsystem: game runs/draws smoothly, ~60 fps
XP Pro, directx7: game draws ~60 fps, but the collision system somehow becomes buggy and unreliable (collision code is independent of drawing code!) which reminds me of an old thread about the graphics subsystem affecting the floating-point operations somehow... I will try to find this.
XP Pro, nt4: game doesn't start, because OpenScreen() fails for me in 4.51+, or at least returns 0...
XP Pro, opengl: first I have to remove DisplayTranslucentSprite(), then I have to remove writing to the DrawingBuffer() because I get IMA crashes... then the game runs but the screen is all white. This also happens with some help examples, like the Direct Screen Drawing one.
Windows 7, default subsystem: game crashes with IMA, I will get more details when I have access to it again

I need to investigate all these problems... any insight? For what it's worth, I have Intel integrated laptop graphics, which seem to have their own issues, which I once brought up here: http://www.purebasic.fr/english/viewtop ... 13&t=45577 I hope my 5-year-old cheap graphics card / drivers are to blame for most of these problems here. I have seen commercial games that specifically say they will not run on Intel integrated graphics...

Anyway, I am busy with finishing school and job hunting right now, so this game won't even be near finished until 2012, so these issues aren't terribly urgent. :)
User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Compiler Subsystem Details

Post by J. Baker »

In my experience DirectX7 has pretty good 2D performance. But this isn't available on Windows 7.

I did a shotty example of zooming sprites without using Sprite3D(). In DirectX7 it performed better then DirectX9, on my pc anyway.
http://www.purebasic.fr/english/viewtop ... 12&t=47030

I have always been an OpenGL fan but drawing text will slow things down. You just have to convert your text to sprites. I really like the fact that it's cross platform too.

I don't have much use for DirectX3. But there may be advantages that I don't know about. Besides Windows NT.
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Compiler Subsystem Details

Post by Danilo »

J. Baker wrote:In my experience DirectX7 has pretty good 2D performance. But this isn't available on Windows 7.
Does it not work on your Win7 system, or did you hear that somewhere?

DirectX7 subsystem works fine here, Win7 64bit.
Try Waponez II example with subsystem DirectX7 on Windows 7.
Tested with 32bit and 64bit PureBasic.
User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Compiler Subsystem Details

Post by J. Baker »

Danilo wrote:
J. Baker wrote:In my experience DirectX7 has pretty good 2D performance. But this isn't available on Windows 7.
Does it not work on your Win7 system, or did you hear that somewhere?

DirectX7 subsystem works fine here, Win7 64bit.
Try Waponez II example with subsystem DirectX7 on Windows 7.
Tested with 32bit and 64bit PureBasic.
I read that. I guess I shouldn't believe everything I read. Or maybe I just misunderstood what I read. I apologize for the bad information. :oops:
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
Kuron
Addict
Addict
Posts: 1626
Joined: Sat Oct 17, 2009 10:51 pm
Location: Pacific Northwest

Re: Compiler Subsystem Details

Post by Kuron »

J. Baker wrote:I read that. I guess I shouldn't believe everything I read. Or maybe I just misunderstood what I read. I apologize for the bad information. :oops:
You have nothing to apologize for. You should not be using DX7 under Vista or 7. DirectX 7 is not supported on Vista or Windows 7, it is emulated at runtime. The emulation is far from perfect. DD7 does fairly good, but D3D7 (what Sprite3D would use) is very problematic. It is much better to use modern APIs than trying to use dead and deprecated APIs (that are over 10 years old) on modern hardware and operating systems.
Best wishes to the PB community. Thank you for the memories. ♥️
User avatar
kenmo
Addict
Addict
Posts: 2083
Joined: Tue Dec 23, 2003 3:54 am

Re: Compiler Subsystem Details

Post by kenmo »

So is Directx7 only useful for targeting older (XP or previous) Windows? (And even more so for nt4.)

I'm not drawing any text in my current program, so maybe OpenGL will give as good performance as Directx9. I just have to solve the blank screen issue. I don't think it's a PureBasic issue, just a combination of my graphics card / drivers / OpenGL. I think this has happened in the past while playing other non-PB games, but I don't remember any solutions. If I find anything I will post it here.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: Compiler Subsystem Details

Post by Polo »

Just don't use DirectX 7 anymore. It doesn't make sense to support OS before XP now, and as far as DirectX is concerned, version 9 really is the lowest you should use.
User avatar
Kuron
Addict
Addict
Posts: 1626
Joined: Sat Oct 17, 2009 10:51 pm
Location: Pacific Northwest

Re: Compiler Subsystem Details

Post by Kuron »

kenmo wrote:So is Directx7 only useful for targeting older (XP or previous) Windows? (And even more so for nt4.)
DX7 isn't supported on NT4 (NT4 will only support up to DX3). Although DX7 will work on XP or older, it is not a good idea to use it for XP. The API is deprecated for a reason. Most XP systems (unless the graphics card is 10 years old) would have DX9 compatible graphics cards. Video card manufacturers are increasingly not providing DX7 compliant drivers, there are obscure issues popping up. DirectX 9 fully supports XP, and most XP systems will have DX9 compatible graphics cards due to how old DirectX 9 is. Nowadays, DX7 is only beneficial for 98-ME/2000.

That said, Vista and 7 do not ship with complete DirectX 9 support. DirectX 9 must be downloaded and installed separately and MS has not released an update for DX9 in over a year.

For Windows, I will only use OpenGL. It works on all versions of Windows (95-7) and is well supported even on crappy Intel video chips and you do not have to deal with all of the DX problems.

kenmo wrote:I'm not drawing any text in my current program, so maybe OpenGL will give as good performance as Directx9.
The drawing text issue can affect OpenGL and DirectX and is often a driver issue. That said, you should always use bitmapped fonts for DX/OGL games.
Best wishes to the PB community. Thank you for the memories. ♥️
User avatar
kenmo
Addict
Addict
Posts: 2083
Joined: Tue Dec 23, 2003 3:54 am

Re: Compiler Subsystem Details

Post by kenmo »

This is all useful information, thank you guys.

It looks like I will stick to DX9 and/or OpenGL, maybe release two executables.

Although OpenGL is not working for me... I just updated my graphics drivers (restarted) and tested again before posting.
1. Does DisplayTranslucentSprite() not exist with OpenGL enabled?
2. Direct-access drawing (DrawingBuffer() etc) should work in OpenGL right? It crashes here, but I haven't fully investigated.
3. The entire screen shows up blank white, when Start/StopDrawing is used. I have even narrowed it down to this simple code:

Code: Select all

CompilerIf (Subsystem("opengl") = 0)
  CompilerError "Compile with the 'opengl' subsystem"
CompilerEndIf

; Clear a (green) screen
InitSprite()
OpenScreen(800, 600, 32, "Test")
ClearScreen(RGB(0,255,0))

; If Start/StopDrawing is used, whole screen shows up white
; Comment out both (or just StopDrawing) and screen shows up green
If (StartDrawing(ScreenOutput()))
  ;Box(10, 10, 80, 80, RGB(255, 0, 0)) ; Draw a test box (not needed)
  StopDrawing()
EndIf

; Display for 2 seconds
FlipBuffers()
Delay(2000)
End
Any ideas to resolve Start/StopDrawing blanking my screen, or just update all drivers / get a new computer :)
Last edited by kenmo on Mon Oct 03, 2011 12:43 am, edited 1 time in total.
User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Compiler Subsystem Details

Post by J. Baker »

I'm seeing green without editing your code on Mac. What graphics card are you using?
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Compiler Subsystem Details

Post by J. Baker »

On Windows using OpenGL, try this...

Code: Select all

; Clear a (green) screen
InitSprite()
InitKeyboard()
OpenScreen(800, 600, 32, "Test")

; If Start/StopDrawing is used, whole screen shows up white
; Comment out both (or just StopDrawing) and screen shows up green

StartTime = ElapsedMilliseconds()

Repeat
  
FlipBuffers() 
 ClearScreen(RGB(0,255,0))
ExamineKeyboard()
  
If (StartDrawing(ScreenOutput()))
  Box(10, 10, 80, 80, RGB(255, 0, 0)) ; Draw a test box (not needed)
  StopDrawing()
EndIf

ElapsedTime = ElapsedMilliseconds()-StartTime

Until ElapsedTime = 5000 Or KeyboardPushed(#PB_Key_Escape)

End
EDIT: Sorry had to fix the code. Works fine now. ;)
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
kenmo
Addict
Addict
Posts: 2083
Joined: Tue Dec 23, 2003 3:54 am

Re: Compiler Subsystem Details

Post by kenmo »

Still shows up white.

I believe this is my gfx card: http://www.intel.com/support/graphics/i ... 021517.htm

It says it should support OpenGL, although it says drivers from Windows Update typically don't.... but their update utility says my driver is up to date.

EDIT: Also, it's not just 2D Drawing that shows up white... if I try some of PB's sprite examples, that don't call Start/StopDrawing, then the background (ClearScreen color) shows up fine but the sprites all show up blank white... I tried this a couple hours ago.
User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Compiler Subsystem Details

Post by J. Baker »

kenmo wrote:Still shows up white.

I believe this is my gfx card: http://www.intel.com/support/graphics/i ... 021517.htm

It says it should support OpenGL, although it says drivers from Windows Update typically don't.... but their update utility says my driver is up to date.

EDIT: Also, it's not just 2D Drawing that shows up white... if I try some of PB's sprite examples, that don't call Start/StopDrawing, then the background (ClearScreen color) shows up fine but the sprites all show up blank white... I tried this a couple hours ago.
I understand now. Intel chips are usually not supported by most games or 3D editors as they are not up to par with Nvidia or ATI. I take it you are on a laptop, being that it's a mobile chip?
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
Kuron
Addict
Addict
Posts: 1626
Joined: Sat Oct 17, 2009 10:51 pm
Location: Pacific Northwest

Re: Compiler Subsystem Details

Post by Kuron »

kenmo wrote:1. Does DisplayTranslucentSprite() not exist with OpenGL enabled?
When using a 3D subsystem, it is best to use Sprite3D functions wherever possible.
kenmo wrote:2. Direct-access drawing (DrawingBuffer() etc) should work in OpenGL right? It crashes here, but I haven't fully investigated.
Does it work when using DX9? I am not sure if modern graphics cards/chips support this feature.
Best wishes to the PB community. Thank you for the memories. ♥️
User avatar
Kuron
Addict
Addict
Posts: 1626
Joined: Sat Oct 17, 2009 10:51 pm
Location: Pacific Northwest

Re: Compiler Subsystem Details

Post by Kuron »

kenmo wrote:but their update utility says my driver is up to date.
No matter what graphics card you have, never use the drivers provided by Microsoft. It is best to download the graphics card drivers directly from the vendor who actually makes the hardware, which in your case is Intel. You should manually download the proper drivers for your graphics card here:

http://downloadcenter.intel.com/default.aspx

Because you are not using the proper drivers you are forcing OpenGL to use the shitty software rendering which ships with Windows.
Best wishes to the PB community. Thank you for the memories. ♥️
Post Reply