Page 1 of 1

Direct sprite access problem

Posted: Mon Dec 29, 2008 11:55 pm
by Godai
I seem to have issues grabbing 32-bit pixel data from a sprite for use with my software texture mapper (next raycast example).
How do I grab an RGB color directly from the sprite for use with my texture mapper?

Thanks in advance

Posted: Tue Dec 30, 2008 11:15 am
by netmaestro

Code: Select all

InitSprite()
OpenScreen(800,600,32,"")
CreateSprite(0,2,2,#PB_Sprite_Texture|#PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(0))
  Plot(0,0,#Red)
  Plot(1,0,#Green)
  Plot(0,1,#Blue)
  Plot(1,1,#White)
StopDrawing()

StartDrawing(SpriteOutput(0))
  *buf = DrawingBuffer()
  If DrawingBufferPixelFormat() = #PB_PixelFormat_32Bits_BGR
    For i = 0 To 1
      For j = *buf To *buf + DrawingBufferPitch()-4 Step SizeOf(RGBQUAD)
        *color.RGBQUAD = j
        With *color
          Debug \rgbBlue & $FF
          Debug \rgbGreen & $FF
          Debug \rgbRed & $FF
        EndWith
        Debug ""
      Next
      *buf+DrawingBufferPitch()
    Next
  EndIf
StopDrawing()

Posted: Tue Dec 30, 2008 11:23 am
by Godai
Ahh thanks. Got the texturing going with Dim and Plot (http://www.purebasic.fr/english/viewtopic.php?t=35848) but I'll definitely revisit this later :)