PureGDK - 3D Programming for PureBasic

Developed or developing a new product in PureBasic? Tell the world about it.
Onyx
User
User
Posts: 31
Joined: Mon Aug 07, 2006 10:19 pm

RE: EZRotate

Post by Onyx »

Thanks for the example code, Mistrel!

Yes, it does seem to drift quite badly.


One other thing-

Since I will be resizing my parent window, how would I resize the DB window? Is this something I have to do through the Windows API?

PureBasic uses the ResizeWindow command, but I don't see anything to resize the DB window.
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Post by Olby »

Mistrel wrote:
Olby wrote:Yeah I saw that thread right before I posted here. But they are documented in the DBPro help files so sooner or later I think they will be fixed. Anyways I got another question, yes I am a boring person :)

In DBPro we could use syntax like this to mask the objects, but PB says it's incorrect:

Code: Select all

dbSetObjectMask(drDirectLightObject, 2^(drDeferredCamera+2) )
What should I change ?
There is no "^" operator. Try this:

Code: Select all

dbSetObjectMask(drDirectLightObject, Pow((drDeferredCamera+2,2)) )
Ahh, I see. Gotta learn PB faster. Thanks that works.
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 »

dbSetWindowSize() will stretch the screen pixels to whatever size you want.

Changing the actual resolution is a lot trickier. Whenever you change the resolution of the Direct3D render device you have to reload all of your assets. Luckily, PureGDK has a solution for this too. Using special callbacks you can recover from invalidated render devices with ease (albeit you still have to reload your assets).

Have a look at the d3d callbacks example included with the samples from the latest beta:

http://puregdk.com/files/upload/PureGDK ... -1.1b3.zip

I also recently provided a complete example on how to apply these functions to a more complex program:
Here is an example of how to tie in recovery for an invalid render device with changing the display resolution. This is useful for windowed applications that want to reset the device resolution after resizing the window.

This example also demonstrates how to safely handle rendering in a thread and also how to maintain a given aspect ratio when altering the device resolution.
See here:

http://www.purebasic.fr/english/viewtop ... 398#278398
Onyx
User
User
Posts: 31
Joined: Mon Aug 07, 2006 10:19 pm

Window Resizing

Post by Onyx »

Mistrel,


So if I create the Main window and the DB render window at the largest size initially, then resize down from there, will I still be able to resize back to the largest size and maintain quality?


In other words, if you start out creating the DB render window at the largest size you want to allow, will the quality of the window be maintained if I resize down, then resize back up at a later time?
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

That would work, yes. But you'll run into various scaling problems in text output, and aliasing.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

For those who don't read the newsletter, the commercial DarkBasic Professional plugin for 3D cloth and particle effects is being released for free in the next update. PureGDK will be sure to support these new functions when they become available. :)

Image Image Image

http://www.thegamecreators.com/data/new ... _74.html#5
http://darkbasicpro.thegamecreators.com ... dparticles
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Post by Olby »

Are you also going to wait until the 7.2 update is finished ?
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 »

Finished? It's already been released. There's nothing in it that would affect PureGDK.

http://darkbasicpro.thegamecreators.com/?f=upgrade_7_2
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Post by Olby »

Sorry I meant the 7.3 that was mentioned in the newsletter. From what I understand you are going to wait until the 7.3 is released and then put out PGDK final/stable release? I am just curious... I am not waiting for the 3d Cloth & Particle - I have it already, I just want to see what new stuff 7.3 brings to DBP. Need to check if there is an beta thread for 7.3 alredy... :wink:
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 »

It won't be a major update and I already have test examples for cloth to verify the new commands. It won't put the beta on hold, unless it comes out before it ends. Then I might extend it by a week.
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Post by Olby »

Mistrel wrote:I already have test examples for cloth to verify the new commands.
You mean there will be some new commands added to the 3d cloth & particles or they are the same as before just integrated with DBPro as an update?
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 »

Core libraries are integrated differently than framework libraries so there is a chance for bugs. That's what I mean by it will require testing.
Last edited by Mistrel on Mon Mar 02, 2009 4:31 pm, edited 1 time in total.
Onyx
User
User
Posts: 31
Joined: Mon Aug 07, 2006 10:19 pm

MouseZ functions

Post by Onyx »

Mistrel,

It appears at least some of the MouseZ functions do not work. I converted a very basic DarkBasic example (less the mouse icon routines) over to test. Here's the PureBasic+PureGDK code:

Code: Select all

OpenWindow(0,0,0,640,480,"DarkBasic Professional - PureGDK",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
hDBWnd=OpenDBWnd(WindowID(0),0,0,640,480)
dbSyncRate(60)
dbBackdropOn()
dbColorBackdrop(dbRGB(0,0,0))

Repeat
    
    dbText(0,10,"mousemovex "+Str(dbMouseMoveX()))    
    dbText(0,20,"mousemovey "+Str(dbMouseMoveY()))    
    dbText(0,30,"mousemovez "+Str(dbMouseMoveZ()))    
    dbText(0,40,"mouse position x "+Str(dbMouseX()))
    dbText(0,50,"mouse position y "+Str(dbMouseY()))
    dbText(0,60,"mouse position z "+Str(dbMouseZ()))
    dbText(0,70,"Press 1 to hide mouse")
    dbText(0,80,"Press 2 to show mouse")
    dbText(0,90,"Press 5 to position mouse to top of screen")
    If dbInKey()="1"
       dbHideMouse()
    EndIf
    If dbInKey()="2"
      dbShowMouse()
    EndIf
    If dbInKey()="5"
      dbPositionMouse(dbMouseX(),0)
    EndIf
    If dbMouseClick()=1
      dbText(0,100,"left mouse button")
    EndIf
    If dbMouseClick()=2
      dbText(0,100,"right mouse button")
    EndIf
    dbSync()
Until WindowEvent()=#PB_Event_CloseWindow Or dbKeyState(#VK_ESCAPE)
End
When I run this, all the functions seem to work except for the mousepositionz and mousemovez. Neither of them seem to function when I use my mouse wheel.

To verify, here's the DB code to run in DarkBasic:

Code: Select all

do
cls
print "mousemovex "+str$(mousemovex())
print "mousemovey "+str$(mousemovey())
print "mousemovez "+str$(mousemovez())
print "mouse position x "+str$(mousex())
print "mouse position y "+str$(mousey())
print "mouse position z "+str$(mousez())
print "Press 1 to hide mouse"
print "Press 2 to show mouse"
print "Press 3 to change mouse image"
print "Press 4 to change mouse image back"
print "Press 5 to position mouse to top of screen"
if scancode()=2 then hide mouse
if scancode()=3 then show mouse
if scancode()=4 then change mouse 1
if scancode()=5 then change mouse 0
if scancode()=6 then position mouse mousex(),0
if mouseclick()=1 then print "left mouse button"
if mouseclick()=2 then print "right mouse button"
loop
end
When I run the DarkBasic Version, I see changes in the mousemovez and mousepositionz listings.

This appears to be a PureGDK bug.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

Fixed this for the next release. Thanks for the bug report. :)
Onyx
User
User
Posts: 31
Joined: Mon Aug 07, 2006 10:19 pm

New Release?

Post by Onyx »

Any news on when the next release will be out?
Post Reply