PureGDK - 3D Programming for PureBasic

Developed or developing a new product in PureBasic? Tell the world about it.
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

Did you try to use non exclusive full screen using the "old" method?

See here (I use it):

Code: Select all

Procedure SetResolution(Width, Height, Depth, Flag=#CDS_FULLSCREEN)
  Protected Result,dmScreenSettings.DEVMODE
  dmScreenSettings\dmSize=SizeOf(DEVMODE)
  dmScreenSettings\dmPelsWidth=Width
  dmScreenSettings\dmPelsHeight=Height
  dmScreenSettings\dmBitsPerPel=Depth
  dmScreenSettings\dmFields=#DM_PELSWIDTH|#DM_PELSHEIGHT|#DM_BITSPERPEL
  If ChangeDisplaySettings_(@dmScreenSettings, Flag)=#DISP_CHANGE_SUCCESSFUL
    Result=#True
  EndIf
  ProcedureReturn Result
EndProcedure 


; RECALL IT!!!
SetResolution(1280, 720, 32) 
hDBWnd=OpenDBWnd(null, 0, 0, 1280, 720)

I not yet tested it with this new PureGDK version, but it works very well.
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

Mistrel, one question (I even need a suggestion):

1) Which Newton Engine are you implmenting (I cannot find version number in your posts)?

2) I worked, until now, using Dark Physics Ageia, but I have serious problems in vehicles (I made some tests using Dark Basic Pro). In fact, there are some problems to import model. But (more critical for me) it seems, that even if PhysX engine works correctly, tires (and springs) no not react correctly in the model. In fact, If the model takes a bump, the physics model move the tire, but the "visual" model does not, but instead it moves slightly all the car!!

I made mant tests, and I asked a solution in DarkBasic forum, but it seems Darkbasic wrapping of PhysX is really limited, so no real solyution is possible.

I even wanted to try to wrap some commands in PureBasic, but the problem seems really big.

So I wanted to try to use Newton engine (even if, maybe, it is slower).

Thank you.
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Post by Olby »

As I said your snippet does not work, I seen it before on this thread. All it does is change the screens resolution, but what I need is a way to have fullscreen windowed mode just like DBPro has.
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

I talked with Mistrel some times ago.
I even red somewhere else in internet that full screen-exclusive mode is not really needed, since most graphic cards now work well in this mode.
The problem could be you are setting a resolution not well managed by your graphic card.

Try to "ask" to your card if a specific resolution is supported.
I will make a check to help you to find the right way to do it.

Just for testing, can you send me (zip file, already compiled) your test, so I try it in my pc?
I have Win Vista home premium, dual quad core, nVidia 8500GT, and 4Gb ram.
Maybe I can help you to detect the problem.

One hint: first of all, try to setup a "standard" resolution like 1024x768, then check if it works fast (even if stretched).
then try 16:9 and 16:10 standard resolutions (for example I work in 16:10 --> 1280x800).
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Post by Olby »

No, no, no. You misunderstood me! I will try to explain clearly.

I DON'T WANT to use full screen exclusive mode. I need same style of fullscreen windowed mode that is used in DBPro by default.

It is a window that is stretched all over the screen. It is kind a fake fullscreen mode. And what I like about it is that it doesn't change screen resolution at all. But your code tries to change it which I don't want to do.

I tried to take the same code that creates 640x480 windowed mode in all pGDK example and changed it so that it will maximize the window on start and set the resolution to users desktop resolution, but it turned out to be very very slow, slower than DBPro's full screen windowed mode.

[EDIT]

This is how it looks like. Imagine a window stretched all over the screen without changing the resolution of desktop - this is how DBPro works:
Image
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

Well, follow these steps...

1) You open a new window, and open it to cover all the screen.

If you do that, it means that if you have a screen resolution at 1680x1050 (my screen resolution), you will open a window so big (1680x1050).

2) Draw a 640x480 in a back-buffer, then show it on the screen.

This could be a solution, but in this way your image will be grained (try to take a small image, then resize it will a simple algorithm, just to stretch image).

3) This process could be slow on many cards, since you need to make it 60 times-per second (at 60FPS).

4) Fake-full screen (non exclusive) needs to change video resolution, and set it as the player decided.
If I play a game, I want to setup a different video mode than the one used in my desktop.

I think you should have to change resolution for the game, then restore the original one when game close (just my 2 cents opinion).
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

Olby wrote:I don't want to change end user's desktop resolution because when the app will crash it will certainly leave the changed resolution and mess up the icons and such.
You're changing the desktop resolution temporarily, not system-wide. If your application crashes the operating system knows to reset the resolution when it ends. The exception is if you're compiling with the debugger on. In this case the debugger halts the program before it actually ends which may cause the IDE to be off the screen. But your resolution will still be restored when you release it from the debugger.
Olby wrote:I cannot get PGDK to work perfectly in fullscreen windowed mode just like it should work in DBPro. I tried the example posted by Mistrel before but that didn't work. Then I tried to stretch window created by PB to my screen resolution, but that made the program to run very very slowly.
You'll need to be more specific, especially regarding the "run very slowly" part. A compilable example would help. By my examples the frame rate is equivalent to DBP when comparing simple examples such as this one:

Code: Select all

Sync On

Make Object Cube 1,3

Repeat
   Inc x#,0.2: Inc y#,0.4: Inc z#,0.8
   Rotate Object 1,x#,y#,z#
   Text 15,15,Str$(screen fps())
   Sync
   Until InKey$()<>""
End
Olby wrote:You should really include a template for creating the same fullscreen windowed mode DBPro uses without affecting users desktop resolution. It utilizes a stretching to stretch small resolutions to fullscreen, but when used with users real desktop resolution there is no quality loss.
I think you're misunderstanding the example I provided previously. It was merely demonstrating how to change the resolution and show the DBP window. You can expand on this principal to obtain whatever kind of effect you're hoping to achieve.

For example, to set the window to the size and resolution of the desktop you don't need the resolution changing code. This would work just fine:

Code: Select all

ExamineDesktops()

;/ Show the PureGDK render window
OpenWindow(0,0,0,DesktopWidth(0),DesktopHeight(0),"DarkBasic Professional - PureGDK",#PB_Window_BorderLess)
hDBWnd=OpenDBWnd(WindowID(0),0,0,DesktopWidth(0),DesktopHeight(0))
dbsetdisplaymode(DesktopWidth(0),DesktopHeight(0),32,0)

;/ Set the window to the to the top of the z-order
SetWindowPos_(hDBWnd,#HWND_TOPMOST,0,0,0,0,#SWP_NOREPOSITION|#SWP_NOSIZE)

;/ Uncomment to limit the frame rate
;dbSyncRate(60)

dbMakeObjectCube(1,3)

;/ Rotate the cube and update the screen
Repeat
	;/ Uncomment this to reduce CPU usage
	;Delay(1)
	x.f+0.2: y.f+0.4: z.f+0.8
	dbRotateObject(1,x.f,y.f,z.f)
	dbText(15,15,Str(dbscreenfps()))
	dbSync()
Until WindowEvent()=#WM_CLOSE Or Not dbInKey()=""
End
Unlike DBP, PureGDK does not stretch the resolution of the render window by default. If you want to use a lower resolution at a higher screen size then you will have to resize the window yourself:

Code: Select all

ExamineDesktops()

;/ Show the PureGDK render window
OpenWindow(0,0,0,DesktopWidth(0),DesktopHeight(0),"DarkBasic Professional - PureGDK",#PB_Window_BorderLess)
hDBWnd=OpenDBWnd(WindowID(0),0,0,640,480)
MoveWindow_(hDBWnd,0,0,DesktopWidth(0),DesktopHeight(0),1)

;/ Set the window to the to the top of the z-order
SetWindowPos_(hDBWnd,#HWND_TOPMOST,0,0,0,0,#SWP_NOREPOSITION|#SWP_NOSIZE)

;/ Uncomment to limit the frame rate
;dbSyncRate(60)

dbMakeObjectCube(1,3)

;/ Rotate the cube and update the screen
Repeat
	;/ Uncomment this to reduce CPU usage
	;Delay(1)
	x.f+0.2: y.f+0.4: z.f+0.8
	dbRotateObject(1,x.f,y.f,z.f)
	dbText(15,15,Str(dbscreenfps()))
	dbSync()
Until WindowEvent()=#WM_CLOSE Or Not dbInKey()=""
End
Last edited by Mistrel on Sun Jan 25, 2009 9:05 pm, edited 1 time in total.
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Post by Olby »

@Mistrel:

This is exactly what I needed! You should definitely include these two snippets into help files, because people may get frustrated how to achieve these things if they come from DBPro (as I do for example).

Thank you again, this worked!

p.s. you did not understand the part about the speed problems I was talking about. I told that I had speed issues when creating fullscreen window but your code runs very fast. And speaking about general speed of PureGDK it is definitely as fast and even faster than DBPro. For example 3D Light example gives me a solid 40 to 60 FPS increase when compiled with PGDK. So as you see it gives not only a flexibility in coding but also a speed increase.

Cheers,
Last edited by Olby on Sun Jan 25, 2009 9:18 pm, edited 5 times in total.
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

Please try running the last example I provided. I think this is the effect you're looking for. Otherwise please provide a comparable example in DBP (please link .dbpro and .dba) and PureGDK. Also please list your frame rate in each.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

Olby wrote:Edit:

Didn't saw Mistrels post above.. :oops:
Foiled by your edit! Please let me know if it helps.
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Post by Olby »

We are all here answering so fast that it gets after other posts.. :D

Anyways check my previous post,... I updated it!
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

I'm glad to see that it worked for you. I will include these snippets in the help file. :)

The trick I used to resize the DBP window uses a function from the Win32 API. You can search MSDN for this kind of information. A lot of PureBasic users use the old Win32.hlp file because it's supported by PureBasic:

http://www.master-creating.de/purebasic ... /win32.zip

Drop it into your PureBaic\Help folder and you'll be able to F1 most API commands from the IDE (the commands with an underscore on the right).

PureGDK is written in PureBasic and utilizes the Win32 API heavily. It wouldn't have been possible without it!
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

ale870 wrote:Which Newton Engine are you implmenting (I cannot find version number in your posts)?
You can download Newton 1.3.2 here:

http://walaber.com/index.php?action=showitem&id=10

This information is listed in the PureGDK help file under "How to... -> How to use TCP plugins with PureGDK":
How to use TCP plugins with PureGDK

PureGDK is distributed with a number of pre-compiled framework libraries for commercial and popular user plugins. These libraries will not work without copying the original plugin DLL to the PureGDK application data folder.

To install a commercial plugin for use with PureGDK you may be required to have DarkBasic Professional installed. After the installation simply copy the plugin DLLs from the DarkBasic Professional compiler folder into its corresponding plugin folder (plugins-licensed or plugins-user) in the PureGDK appication data folder. You can also install them for DarkBasic Professional and run the PureGDK installer to copy them over. Plugins will work with PureGDK only if they have a corresponding framework library installed as a PureBasic userlibrary. For more information about how to create a userlibrary see the How to... -> How to use the PureGDK plugin framework section of the PureGDK documentation.

GDKTables and sources for the plugins supported by PureGDK are provided in the plugin-sdk\Supported Plugins folder of your PureGDK installation.

A command list for each plugin is provided in its corresponding Syntax.txt. See the plugin's folder in the plugin-sdk\Supported Plugins folder of your PureGDK installation for more information.

PureGDK provides framework user libraries for the following plugins:

Licensed Plugins:

2D Plugin Kit 1.1
3D Cloth & Particles Physics 6.2
Advanced Terrain
Dark Physics Beta 14-12-07
Dark AI 1.05
Dark Lights 1.02
Enhanced Animations 19-11-07
eXtends 1.4
EZ Rotate Enhanced 19-11-07
STYX 2.0
TextureMax 17-05-07
Unity 3.0

Free Plugins:

D3DFunc 3.6.6
DarkSide Starburst
DBP Collisions 2.04
DKAVM 12-07-06
DKSHOP 12-07-06
EZ Rotate Basic
Multisync 1.4.1
Newton Game Dynamics 1.3.2
zParticles 1.11

These user libraries may not include a conversion of the entire command set. Please refer to the Changes.txt and Syntax.txt for a list of supported commands and information on those commands which might have changed.

Each of these command libraries has been tested for functionality. Not every command has been tested and functionality of every command is not guaranteed. If you do encounter a problem getting any of these plugins to work with PureGDK please contact support@puregdk.com.
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Post by Olby »

Thanks for the WinApi tip,.. I will use it.

Here is a modified version of that code that stretches the window if it is smaller and also uses anti aliasing :)

Code: Select all

; Open the PureGDK render window --------------------------
  ExamineDesktops()
  app_win_width.w = 640; DesktopWidth( 0 )
  app_win_height.w = 480; DesktopHeight( 0 )
  app_win_depth.b = DesktopDepth( 0 )
  app_win_aa.b = 0 ;Antialiasing
  OpenWindow( 0, 0, 0, DesktopWidth( 0 ), DesktopHeight( 0 ), "DarkBasic Professional - PureGDK", #PB_Window_BorderLess )
  hDBWnd = OpenDBWnd( WindowID( 0 ), 0, 0, app_win_width, app_win_height )
  dbSetDisplayMode( app_win_width, app_win_height, app_win_depth, 0, app_win_aa, 0 )
  MoveWindow_( hDBWnd, 0, 0, DesktopWidth( 0 ), DesktopHeight( 0 ), 1 )
  SetWindowPos_( hDBWnd, #HWND_TOPMOST, 0, 0, 0, 0, #SWP_NOREPOSITION | #SWP_NOSIZE )
; ---------------------------------------------------------
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

I just remembered that there is a command to resize the DBP window. :)

Code: Select all

;/ Open a PureBasic window
OpenWindow(0,0,0,640,480,"DarkBasic Professional - PureGDK",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)

;/ Initialize the PureGDK screen as a child of window ID 0
hDBWnd=OpenDBWnd(WindowID(0),0,0,160,120)

;/ Resize the DBP window
dbSetWindowSize(640,480)

;/ Set the sync rate
dbSyncRate(60)

dbMakeObjectCube(1,3)

;/ Rotate the cube and update the screen
Repeat
 x.f+0.2: y.f+0.4: z.f+0.8
 dbRotateObject(1,x.f,y.f,z.f)
 dbSync()
Until WaitWindowEvent(1)=#PB_Event_CloseWindow
Post Reply