Hmm, I don't understand this part! I am passing the TXT file with the commands as stated in the manual - the GDKTable.txt, the empty PB file (?) and the dll it self. As I understand it should output the PB source so that it can be later compiled into pb library using tailbite? Where the .ġdt or .gdd files come from? This is hard to understand for me currentlyMistrel wrote:The first change is that only the GDK table is required now. The syntax is slightly different as well. The first line of the .gdt file (note the extension) has two strings separated by a percent (%). The first is the library name and the second is the dependency string (some DBP function from the library).
Everything else is the same. You can drag the .gdt file on top of the library builder, use the command line, or a shortcut. Just make sure that your current directory is where you want the output files to go. Two folders will be created, a "Sources" and a "Dependencies" folder with your .pb and .gde (formerly .d) files.
PureGDK - 3D Programming for PureBasic
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
Save this file as Lib-P_AdvanedTerrain.gdt and pass it to the library builder. Then compile with TailBite. That's it. 
You'll need to compile twice with TailBite, once for a normal library and another for a ThreadSafe library. Make sure you don't mix up where you put these otherwise you'll get a compile error.
Notice the change to the first line and the new extension to the file.
You'll need to compile twice with TailBite, once for a normal library and another for a ThreadSafe library. Make sure you don't mix up where you put these otherwise you'll get a compile error.
Notice the change to the first line and the new extension to the file.
Code: Select all
AdvancedTerrain.dll%SET TERRAIN SPLIT 0,0
dbSetTerrainScale%LFFF%?SetTerrainScale@@YAXHMMM@Z%TerrainID, x.f, y.f, z.f
dbSetTerrainSplit%LL%?SetTerrainSplit@@YAXHH@Z%TerrainID, Split
dbSetTerrainTiling%LL%?SetTerrainTiling@@YAXHH@Z%TerrainID, Tile
dbSetTerrainHeightMap%LS%?SetTerrainHeightMap@@YAXHK@Z%TerrainID, Filename.s
dbSetTerrainLight%LFFFFFFF%?SetTerrainLight@@YAXHMMMMMMM@Z%TerrainID, xDirection.f, yDirection.f, zDirection.f, Red.f, Green.f, Blue.f, Scale.f
dbBuildTerrain%L%?BuildTerrain@@YAXH@Z%TerrainID
dbUpdateTerrain%0%?UpdateTerrain@@YAXXZ%
dbSetTerrainTexture%LLL%?SetTerrainTexture@@YAXHHH@Z%TerrainID, BaseImage, DetailImage
dbMakeObjectTerrain%L%?MakeObjectTerrain@@YAXH@Z%TerrainID
dbGetTerrainGroundHeight[%FLFF%?GetTerrainGroundHeight@@YAKHMM@Z%TerrainID, x.f, z.f
dbLoadTerrain%SL%?LoadTerrain@@YAXKH@Z%Filename.s, TerrainID
dbSaveTerrain%SL%?SaveTerrain@@YAXKH@Z%Filename.s, TerrainID
dbGetTerrainXSize[%FL%?GetTerrainXSize@@YAKH@Z%TerrainID
dbGetTerrainZSize[%FL%?GetTerrainZSize@@YAKH@Z%TerrainID
dbDestroyTerrain%L%?DeleteTerrain@@YAXH@Z%TerrainID
; UPDATE TERRAIN%L%?UpdateTerrainNoCull@@YAXH@Z
; BUILD TERRAIN%LL%?BuildTerrainEx@@YAXHH@ZOk, thanks Mistrel, I got my lib compiled and working as far as I can tell 
I wanted to point out that the PureGDK compiler does not highlight error line it reports. It just shows the compiler GUI with the text but the IDE does not jump to the corresponding line. Is it possible to fix this. It does so in the default IDE.
I wanted to point out that the PureGDK compiler does not highlight error line it reports. It just shows the compiler GUI with the text but the IDE does not jump to the corresponding line. Is it possible to fix this. It does so in the default IDE.
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
Ahh, I see. Now that I know that it works only in debug mode I could get those error lines back to work.
Could you please tell, why this does not work ?
I mean it should obviously exit the application when I press escape, but for me all those db input commands like dbspacekey() dbescapkey() etc. do not work.
I'm completely screwed these few days, I cannot get a damn thing to work on my computer... I guess this is just a small period of my life!
Could you please tell, why this does not work ?
Code: Select all
; Open the PureGDK render window
OpenWindow( 0, 0, 0, 640, 480, "DarkBasic Professional - PureGDK", #PB_Window_SystemMenu | #PB_Window_ScreenCentered )
hDBWnd = OpenDBWnd( WindowID( 0 ), 0, 0, 640, 480 )
dbMakeObjectCube(1,200)
Repeat
dbSync()
Until dbEscapeKey()=1
EndI'm completely screwed these few days, I cannot get a damn thing to work on my computer... I guess this is just a small period of my life!
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
If you don't use WindowEvent() or WaitWindowEvent() then no message processing is possible and your window will lock up. Notice how you can't drag the window either.
This functionality is different in PureGDK 1.1 that it was previously where the DBP screen had its own window (watch out for old code snippets). It's just a display now and relies upon the message processing of its parent to receive input.
This is a fundamental difference between DBP which does message processing for you. In PureBasic it's your responsibility. See this example where forgetting to process window events will lock up the window:
This functionality is different in PureGDK 1.1 that it was previously where the DBP screen had its own window (watch out for old code snippets). It's just a display now and relies upon the message processing of its parent to receive input.
Code: Select all
Repeat
dbSync()
Until WindowEvent()=#PB_Event_CloseWindow Or dbEscapeKey()Code: Select all
OpenWindow(0,0,0,320,240,"",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
Repeat
ForEverI think it is better this way so that the DB and PB integrates better. Thanks for explaining. I also just noticed that the LOAD EFFECT has an additional parameter:
PureGDK documentation/compiler does not include this!
Code: Select all
LOAD EFFECT Filename, Effect Number, Texture Flag, DoNotGenerateExtraDataIntel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
Yes these are all documented in DBPro help files.
Here is another one you've missed:
PureGDK includes only first 4 parameters, dropping the last two.
Here is another one you've missed:
Code: Select all
SET CAMERA TO IMAGE Camera Number, Image Number, Width, Height, Generate Alpha Mode, D3D FormatIntel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
Sorry to bother you about such silly things but how I can convert from those binary (?) virtual key codes to those that I can pass directly to dbKeyState() ? For example when I enter (0x50) it says I need a valid decimal number. Thanks.
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
Hex in PureBasic is like this: $50. 0x50 in hex to binary would be: Bin($50).
You use the function by passing one of the constants listed, for example:
You use the function by passing one of the constants listed, for example:
Code: Select all
If dbKeyState(#VK_ESCAPE)
End
EndIfHere 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.
http://puregdk.com/files/upload/aspect-ratio.zip
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.
http://puregdk.com/files/upload/aspect-ratio.zip
Code: Select all
Structure Glob_Globstruct
RenderThreadID.i
ProgramEnding.l
PauseThread.l
DefaultAspectRatio.f
DefaultFOV.f
MaxFOV.f
EndStructure
Global Glob_Globstruct.Glob_Globstruct
Declare WinCallback(hWnd, uMsg, wParam, lParam)
Declare D3DDeviceLost()
Declare D3DDeviceReset()
Declare GDKRenderThread(Null)
ExamineDesktops()
Procedure WinCallback(hWnd, uMsg, wParam, lParam)
Static OldWidth.l, OldHeight.l, FirstRun
Protected NewWidth.l, NewHeight.l
If Not FirstRun
OldWidth=WindowWidth(1)
OldHeight=WindowHeight(1)
FirstRun=1
EndIf
Select uMsg
Case #WM_ERASEBKGND
;/ Don't erase the background to elminate resize flickering
ProcedureReturn 1
Case #WM_SIZING, #WM_WINDOWPOSCHANGING, #WM_SIZE, #WM_WINDOWPOSCHANGED
dbSetWindowSize(WindowWidth(1),WindowHeight(1))
Case #WM_EXITSIZEMOVE
;/ Handle window resizing
If InterlockedCompareExchange_(@Glob_Globstruct\PauseThread,1,0)=0
NewWidth=WindowWidth(1)
NewHeight=WindowHeight(1)
If ((Not NewWidth=OldWidth) Or (Not OldHeight=NewHeight)) And NewWidth>0 And NewHeight>0
Repeat: Delay(1)
Until Glob_Globstruct\PauseThread=2
dbSetDisplayMode(NewWidth,NewHeight)
D3DDeviceReset()
OldWidth=NewWidth
OldHeight=NewHeight
;/ Reset camera aspect ratio
DefaultAspectRatio=Glob_Globstruct\DefaultAspectRatio
DefaultFOV=Glob_Globstruct\DefaultFOV
MaxFOV=Glob_Globstruct\MaxFOV
AspectRatio.f=(NewWidth*DefaultAspectRatio)/(NewHeight*DefaultAspectRatio)
FOV.f=MaxFOV-(AspectRatio.f*100.0)
If FOV.f<DefaultFOV
FOV.f=DefaultFOV
EndIf
If FOV.f>MaxFOV
FOV.f=MaxFOV
EndIf
dbSetCameraAspect(AspectRatio.f,dbCurrentCamera())
dbSetCameraFOV(FOV.f,dbCurrentCamera())
EndIf
;/ Set PauseThread to 0
InterlockedExchange_(@Glob_Globstruct\PauseThread,0)
EndIf
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
Procedure D3DDeviceLost()
;/ Notify the render thread that the render device has been lost
If Not Glob_Globstruct\PauseThread
InterlockedExchange_(@Glob_Globstruct\PauseThread,1)
EndIf
EndProcedure
Procedure D3DDeviceReset()
;/ Wait until the render thread is ready for the device to be reset
Repeat: Delay(1)
Until InterlockedCompareExchange_(@Glob_Globstruct\PauseThread,3,2)=2
;/ Reload project data here
dbMakeObjectCube(1,3)
dbScaleObject(1,88,88,88)
dbColorBackdrop(RGB(Random(255),Random(255),Random(255)))
;/ Set PauseThread to 0
InterlockedExchange_(@Glob_Globstruct\PauseThread,0)
EndProcedure
Procedure GDKRenderThread(Null)
Repeat
Delay(1) ;/ Don't use all of the cpu
dbXRotateObject(1,dbWrapValue(dbObjectAngleX(1)+0.3))
dbYRotateObject(1,dbWrapValue(dbObjectAngleY(1)+0.5))
;/ Render the backbuffer
dbSync()
;/ Check for suspend notificatons
If InterlockedCompareExchange_(@Glob_Globstruct\PauseThread,2,1)=1
Repeat: Delay(1)
dbSync()
Until Not Glob_Globstruct\PauseThread
EndIf
Until Glob_Globstruct\ProgramEnding
EndProcedure
;/ Show the PureGDK render window
OpenWindow(0,0,0,640,480,"DarkBasic Professional - PureGDK",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
MDIGadget(0,0,0,640,480,0,0)
AddGadgetItem(0,1,"Render window",0,#PB_Window_TitleBar|#PB_Window_SizeGadget)
hDBWnd=OpenDBWnd(WindowID(1),0,0,WindowWidth(1),WindowHeight(1))
;/ Set the default aspect ratio and FOV
Glob_Globstruct\DefaultAspectRatio=640.0/480.0
Glob_Globstruct\DefaultFOV=61.9621391296
Glob_Globstruct\MaxFOV=164.0
;/ Set the window callback for window 0
SetWindowCallback(@WinCallback(),1)
;/ Set D3D device callbacks
dbSetD3DDeviceCallback(@D3DDeviceLost(),#GDK_Callback_DeviceLost)
dbSetD3DDeviceCallback(@D3DDeviceReset(),#GDK_Callback_DeviceReset)
;/ Load media
dbMakeObjectCube(1,3)
dbScaleObject(1,88,88,88)
dbColorBackdrop(RGB(0,0,0))
;/ Create render thread
Glob_Globstruct\RenderThreadID=CreateThread(@GDKRenderThread(),0)
;/ Program loop
Repeat
Event=WaitWindowEvent()
Until Event=#PB_Event_CloseWindow ;Or dbKeyState(#VK_ESCAPE)
;/ Cleanup
Glob_Globstruct\ProgramEnding=1
WaitThread(Glob_Globstruct\RenderThreadID)
End
