I'm Creating a Faster way to draw with the use of the DrawingBuffer() command (along with the other ones too)
and i need a bit of help to understand the how to "poke" the color data into the buffer at a x and y
i kinda have an idea for some modes but for others i don't have a clue like 8 bit and 15bit
also converting colors that rgb() puts out to work with this
using drawingbuffer
using drawingbuffer
~Dreglor
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 :
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
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
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
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
I guess something like this would work fine without to slow your program too much.
If I do not mistake it is exhaustive and does not use anything else PureBasic.
Tell me if this meets your needs, testing it in # configurations.
Rgrds
If I do not mistake it is exhaustive and does not use anything else PureBasic.
Tell me if this meets your needs, testing it in # configurations.
Rgrds
Code: Select all
;
;Make DrawingBuffer parameters global to save some lines and performances.
Global Drawingbuffer.l, DrawingbufferPitch.l, DrawingBufferPixelFormat.l
;
; A sample code procedure to convert the color if necessary
;
Procedure ConvertPixelColorToRawPixelColor(Color.l)
Select DrawingBufferPixelFormat
Case #PB_PixelFormat_24Bits_BGR
ProcedureReturn (Color & $FF0000) >> 16 + (Color & $00FF00) + (Color & $0000FF) << 16
Case #PB_PixelFormat_32Bits_BGR
ProcedureReturn (Color & $FF0000) >> 16 + (Color & $00FF00) + (Color & $0000FF) << 16
Default
ProcedureReturn Color
EndIf
EndProcedure
; ... in your main or procedure opening the drawings :
StartDrawing(ScreenOutput()) ; or SpriteOutput()
DrawingBuffer = DrawingBuffer()
DrawingbufferPitch = DraxingBufferPitch()
DrawingBufferPixelFormat = DrawingBufferPixelFormat()
; ... draw whatever you want
StopDrawing()
; etc
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
