Code: Select all
Structure PB_2DDrawingInfo
*hDC
; There is more stuff here, but we try to keep this private
EndStructure
Import "kernel32.lib" ; It's not in the kernel32.lib, but it's the one always linked :)
PB_2DDrawing_GlobalStructure.PB_2DDrawingInfo ; For non-threaded
PB_2DDrawing_Globals ; For threadedsafe mode
PB_Object_GetThreadMemory(*Globals)
EndImport
Procedure StartDrawingEx(hWindow)
CompilerIf #PB_Compiler_Thread
*Globals.PB_2DDrawingInfo = PB_Object_GetThreadMemory(PB_2DDrawing_Globals)
*Globals\hDC = GetDC_(hWindow)
CompilerElse
PB_2DDrawing_GlobalStructure\hDC = GetDC_(hWindow)
CompilerEndIf
ProcedureReturn 1
EndProcedure
Procedure StopDrawingEx(hWindow)
CompilerIf #PB_Compiler_Thread
*Globals.PB_2DDrawingInfo = PB_Object_GetThreadMemory(PB_2DDrawing_Globals)
ReleaseDC_(hWindow, *Globals\hDC)
CompilerElse
ReleaseDC_(hWindow, PB_2DDrawing_GlobalStructure\hDC)
CompilerEndIf
EndProcedure
OpenWindow(0, 0, 0, 640, 480, "Test")
Repeat
StartDrawingEx(WindowID(0))
Box(10, 10, 400, 300, RGB(255, 0, 0))
LineXY(200, 100, 250, 300, RGB(255, 255, 0))
StopDrawingEx(WindowID(0))
Delay(10)
Until WindowEvent() = #PB_Event_CloseWindow