I apologize for the sloppy coding, I just threw this together. It's taking 2.5 milliseconds on average here to render a curve 10 pixels wide on the 640*480 screen. If 2.5 ms is fast enough for your purposes, this should work:
Code: Select all
OpenLibrary(1, "msimg32.dll")
CreateImage(0, 640,480,32)
Macro ARGB(RGB=0,Transparency=255) ; by einander
Blue(RGB)|Green(RGB)<<8|Red(RGB)<<16|Transparency<<24
EndMacro
Structure POINTF
x.f
y.f
EndStructure
Global Dim PointArray.POINTF(100)
For i=0 To 100
PointArray(i)\x = 30*i+0.5*i
pointArray(i)\y = 50+i*1.1*i
Next
Global *token, *surface, *redpen5
CompilerIf Defined(GdiplusStartupInput, #PB_Structure) = 0
Structure GdiplusStartupInput
GdiPlusVersion.l
*DebugEventCallback.Debug_Event
SuppressBackgroundThread.l
SuppressExternalCodecs.l
EndStructure
CompilerEndIf
Procedure DrawCurve()
hdc = StartDrawing(ImageOutput(0))
Box(0,0,640,480,#Black)
CallFunction(0, "GdipCreateFromHDC", hdc, @*surface)
CallFunction(0, "GdipDrawCurve", *surface, *redpen5, PointArray(), 100)
CallFunction(0, "GdipDeleteGraphics", *surface)
StopDrawing()
dc = GetWindowDC_(#Null)
imagedc = CreateCompatibleDC_(dc)
SelectObject_(imagedc, ImageID(0))
hdc = StartDrawing(ScreenOutput())
CallFunction(1, "TransparentBlt", hdc, 0, 0, 640,480, imagedc, 0, 0, 640,480,0)
StopDrawing()
ReleaseDC_(0, dc)
DeleteDC_(imagedc)
EndProcedure
input.GdiplusStartupInput
input\GdiPlusVersion = 1
OpenLibrary(0, "gdiplus.dll")
CallFunction(0, "GdiplusStartup", @*token, @input, #Null)
CallFunction(0, "GdipCreatePen1", ARGB(#Red, 180), 10.0, 2, @*redpen5)
InitSprite()
OpenWindow(0,0,0,640,480,"gdiplus curves",$CA0001)
OpenWindowedScreen(WindowID(0), 0,0,640,480,0,0,0)
Repeat
EventID = WindowEvent()
ClearScreen(#Black)
DrawCurve()
FlipBuffers()
Delay(1)
Until EventID = #WM_CLOSE
CallFunction(0, "GdipDeletePen", *redpen5)
CallFunction(0, "GdiplusShutdown", *token)
CloseLibrary(0)
CloseLibrary(1)