I guess this will help :
when you code a :
Plot(x, y, Color)
the PokeL equivalent is :
PokeL(DrawingBuffer() + y * DrawingBufferPitch() + x * 4, Color)
Then the best is to store :
DrawingBuffer = DrawingBuffer()
DrawingBufferPitch = DrawingBufferPitch()
somewhere just after StartDrawing(ScreenOutput()),
and to loop Pokes after.
Also when doing part or full screen pokes, will allow you to loop considering rows and lines so that you can do something like this :
Code: Select all
Left = 100
Top = 100
Right = 300
Bottom = 300
If InitSprite() And InitKeyboard() And OpenScreen(1024, 768, 32, "Screen")
Repeat
FlipBuffers(0)
StartDrawing(ScreenOutput())
DrawingBuffer = DrawingBuffer()
DrawingBufferPitch = DrawingBufferPitch()
Address = DrawingBuffer ; a full screen paint
For y = 0 To 767
For x = 0 To 1023
Color = #Blue
PokeL(Address, (Color & $FF0000) >> 16 + (Color & $00FF00) + (Color & $0000FF) << 16)
Address + 4
Next
Next
For y = Top To Bottom ; a part screen paint
Address = DrawingBuffer + y * DrawingBufferPitch + 4 * Left
For x = Left To Right
Color = Random($FFFFFF)
PokeL(Address, (Color & $FF0000) >> 16 + (Color & $00FF00) + (Color & $0000FF) << 16)
Address + 4
Next
Next
StopDrawing()
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
EndIf
End
As you see, you will probably have to switch the color attribute from RGB to BGR (see DrawingBufferPixelFormat() function to know the color format).
The better way would be to code in ASM for a good optimization of your code. But you will probably it is not easy to go as fast or faster than PureBasic does.
Also be really carefull never address outside the screen's pixels. This means you will probably have to place tests to check if pixel's coordinates are inside the screen range.
Rgrds