after a quick mess around here is it working.
; Structure Type
; Type.TimerType
;
; Frequency As LARGE_INTEGER
; LiStart As LARGE_INTEGER
; LiStop As LARGE_INTEGER
; LlTimeDiff As LONGLONG
; MDuration As Double
;
; End Type
Declare RenderLine(StartX,StartY,EndX,EndY,Col)
Declare RenderIntoUdgBuffer()
Declare RenderUdg(Xpos,Ypos,WdthX,HghtY)
Declare OpenPtcWindow()
Declare RenderCircle(Xpos,Ypos,Radi.f,WdthX,HghtY,ColourR,ColourG,ColourB)
Global Dim Buffer.l(800*640)
ptc_setdialog(1,"",1,0)
ptc_allowclose(1)
ptc_open("TinyPTCExt",800,640)
Global WidthX = 800
Global HeightY = 640
Global Dim BackBuffer.l(WidthX*HeightY)
For i=0 To WidthX*HeightY
BackBuffer(i)=$402020
Next
Global UdgWidth = 100
Global UdgHeight = 80
Global Dim UdgBuffer.l(UdgWidth*UdgHeight)
Global Angle, Zoom = 5
Global Dim udgptr.l(WidthX*HeightY)
Global Dim Buffer.l(WidthX*HeightY)
;OpenPtcWindow()
Xpos=1
XAngle.f = 0.1
; Global StepY
; Global YPos
;While ( GetAsyncKeyState( VK_ESCAPE ) <> -32767 )
Repeat
;Dim Y,X
;this draws into an object udg buffer of size x=100 y=80
RenderIntoUdgBuffer()
; Xpos+(Sin(XAngle*0.8)*13.0)
; XAngle + 0.1
;this does a blit of our just generated udg into the back buffer at 300,200
RenderUdg(Xpos, 0, UdgWidth, UdgHeight )
;this flips the back buffer
; ptc_update( ;@BackBuffer(0) )
ptc_update( @BackBuffer(0) )
;this clears the back buffer
For x = 0 To (WidthX-1)*(HeightY-1)
BackBuffer(X) = RGB( 60, 0, 0 )
Next
ForEver
Procedure RenderUdg(Xpos,Ypos,WdthX,HghtY)
; ; GetObject_(ImageID(img), SizeOf(BITMAP), @bmp.BITMAP)
; ; Protected imagesize = bmp\bmWidthBytes * bmp\bmHeight
; ; Protected *bits = bmp\bmBits
; blit and upscale udg into back buffer
StepY=Ypos
For Y = 0 To HghtY-1
For Ry = StepY To StepY+4
For X = 0 To WdthX-1
For Rx = StepX To StepX+4
If UdgPtr(X+Y*WdthX)<>$0
; If PeekI(*bits+X+Y*WdthX)<>$0
;Debug "hit"
;BackBuffer( (Xpos+X+Rx)+(Y+Ypos+Ry)*WidthX ) = PeekB(*bits+X+Y*WdthX)
BackBuffer( (Xpos+X+Rx)+(Y+Ypos+Ry)*WidthX ) = UdgPtr(X+Y*WdthX)
EndIf
Next
StepX+4
Next
StepX=0
Next
StepY+4
Next
EndProcedure
Procedure OpenPtcWindow()
ptc_allowclose(0)
ptc_setdialog(1,"udg test"+"FullScreen",1,0)
ptc_setflip(0)
ptc_open("udg", WidthX, HeightY)
; End - 1
;EndIf
EndProcedure
Procedure RenderCircle(Xpos,Ypos,Radi.f,WdthX,HghtY,ColourR,ColourG,ColourB)
Radi2.f
; Z
; Dim W As Double
; Dim X As Integer
If Radi>0
Radi2 = ( Radi * Radi )
For Z=-Radi To Radi
W = Sqr( Radi2 - Z * Z )
If ( Z + Ypos ) < HghtY - 1 And ( Z + Ypos ) > 1
For X = Xpos - W To Xpos + W
If X < WdthX - 1 And X > 1
; Buffer[ ( Z + Ypos ) * WdthX + X ] = Colour
pos=(Z+Ypos)*WdthX+X
Udgptr(pos) = (ColourR << 16) | (ColourG << 8) | (ColourB)
; Debug Colour
EndIf
Next
EndIf
Next
EndIf
EndProcedure
Procedure RenderIntoUdgBuffer()
Protected.I sS,Cs
Protected.I x,Y,Radius
sS=(Sin(Angle*0.5)*10.0)
cS=(Cos(Angle*0.5))
Angle+0.51
For Radius = 25 To 0 Step -1
; RenderCircle(@UdgBuffer(0), 35, 35, Radius-zoom,UdgWidth,UdgHeight, RGB(Random(255,1), Random(255,1), Random(255,1)))
RenderCircle( 35, 35, Radius-zoom,UdgWidth,UdgHeight, Random(255,1), Random(255,1), Random(255,1))
; RenderCircle(@UdgBuffer(0), 35, 35, Radius-zoom,UdgWidth,UdgHeight,RGB(255,255,255))
Next
zoom-1
If zoom<0
zoom=25
EndIf
EndProcedure
now i have stripped it back too a basic level as you can see so if you very carefully take it from here it will work the way you had it.
one thing too note is that your pointers were getting messed up while being passed through the functions.
if you have an allocated pointer such as udgptr you dont pass this through as @someptr(0) you just pass it through as someptr, in your function decleration you will probably want too let it know that a ptr is going too be coming so something like
function thisfunction( someptr as ptr,width,height,x,y)
the too call this you would just do thisfunction( someptr,200,100,0,0);