Direct sprite access problem

Advanced game related topics
Godai
Enthusiast
Enthusiast
Posts: 171
Joined: Thu Oct 05, 2006 8:13 pm

Direct sprite access problem

Post 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
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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()
BERESHEIT
Godai
Enthusiast
Enthusiast
Posts: 171
Joined: Thu Oct 05, 2006 8:13 pm

Post 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 :)
Post Reply