bmx-ng / sdl.mod

SDL backend for BlitzMax
7 stars 6 forks source link

[SDLRenderMax2D] broken with multiple setcolor/setalpha #47

Closed GWRon closed 1 year ago

GWRon commented 1 year ago
SuperStrict
Framework Brl.StandardIO
Import Brl.Random
'Import Brl.GLMax2D
'Import Brl.D3D9Max2D
'Import SDL.D3D9SDLMax2D
'Import Sdl.GLSDLMax2D
'Import SDL.GL2SDLMax2D
Import Sdl.SDLRenderMax2D

Function DrawGradient(x:int, y:int)
    For local i:int = 0 until 300
'variant 1: nothing is drawn
'       SetColor 255, 255, 255
'       SetAlpha 0
'       SetColor 255, 255, 255
'       SetAlpha (i * 0.003)

'variant 2: first pixel line is white!
        SetColor 255, 255, 255
        SetAlpha (i * 0.003)

'variant 3: correct (alpha and color setter switched)
'       SetAlpha i * 0.003
'       SetColor 255, 255, 255

        For local j:int = 0 until 50
'           SetColor j*5,j*5,j*5
            Plot(x + j, y + i)
        Next
    Next
    SetColor 255, 255, 255
    SetAlpha 1.0
End Function

Graphics(800, 600)
SetBlend AlphaBlend
SetColor 255,255,255
SetClsColor 40, 80, 160
While Not KeyDown(KEY_ESCAPE)    
    Cls
    SetColor 255,255,255
    DrawText("Renderer:" + GetGraphicsDriver().ToString(), 0, 0)

    DrawGradient(65,65)

    Flip
Wend

End

variant1: image

variant2: image

variant3: image

GWRon commented 1 year ago

Seems SetAlpha() was just missing to tell the (sdl)render to update the draw color - PR created.