Uses "TBGL"
%s = 25 ' SIZE OF RECTANGLE DRAWN
Long xDesk, yDesk,bitDepth
Long xMin, yMin, xMax, yMax
Long x,y
Long r1, r2, r3
' GRAB DESKTOP SIZE
'TBGL_GetDesktopInfo(xDesk,yDesk,bitDepth) ' -- Not sure if your GPU can manage, feel free to experiment
xDesk = 512
yDesk = 512
DWord hWin = TBGL_CreateWindowEx("Try", xDesk, yDesk, 32, %TBGL_WS_WINDOWED)
TBGL_ShowWindow
' NOW SET DRAW AREA
xMin= 1
yMin= 1
xMax= xDesk - Max(12, %s + 2) ' MAKE SURE THERE IS ENOUGH SPACE FOR RECTANGLES @ RIGHT MARGIN
yMax= yDesk - Max(12, %s + 2) ' MAKE SURE THERE IS ENOUGH SPACE FOR RECTANGLES @ BOTTOM MARGIN
Long i
TBGL_RenderMatrix2D
TBGL_BackColor(255, 255, 255)
Type AdditiveDrawing
_textureSlot As Long
_width As Long
_height As Long
Init As Function
DrawLast As Function
Update As Function
End Type
Dim drawing As AdditiveDrawing
drawing.Init(hWin, 1)
While TBGL_IsWindow(hWin)
TBGL_ClearFrame
' -- Draw previous stuff
drawing.drawLast()
' -- Draw new stuff
For i = 1 To 10
x=Rnd(xMin,xMax)
y=Rnd(xMin,yMax)
r1=Rnd(100,200)
TBGL_Color r1, 0, 0
TBGL_Rect(x, y, x+%s, y+%s)
Next
' -- Store new image
drawing.update()
TBGL_DrawFrame
If TBGL_GetWindowKeyState(hWin, %VK_ESCAPE) Then
Exit While
End If
Wend
TBGL_DestroyWindow
' -- Auxiliary methods
Function AdditiveDrawing.Init( hWnd As DWord, textureSlot As Long )
TBGL_GetWindowClient(hWin, Me._width, Me._height)
Me._textureSlot = textureSlot
TBGL_MakeTexture Repeat$(Me._width * Me._height, MKBYT$(255, 255, 255, 255)), %TBGL_DATA_BGRA, Me._width, Me._height, Me._textureSlot, %TBGL_TEX_NEAREST
End Function
Function AdditiveDrawing.DrawLast()
TBGL_PushStateProtect %TBGL_DEPTH
TBGL_PushColor 255, 255, 255
TBGL_PushState %TBGL_TEXTURING
TBGL_PushTexture 1
TBGL_BeginPoly %GL_QUADS
TBGL_TexCoord2D 0, 0
TBGL_Vertex 0, 0
TBGL_TexCoord2D 1, 0
TBGL_Vertex Me._width, 0
TBGL_TexCoord2D 1, 1
TBGL_Vertex Me._width, Me._height
TBGL_TexCoord2D 0, 1
TBGL_Vertex 0, Me._height
TBGL_EndPoly
TBGL_PopTexture
TBGL_PopState
TBGL_PopColor
TBGL_PopStateProtect
End Function
Function AdditiveDrawing.Update()
TBGL_RenderToTexture( Me._textureSlot, 0, 0, Me._width, Me._height )
End Function
Bookmarks