SpriteOutput() does not work on fullscreen/OpenGL/3D

Everything related to 3D programming
MightyMAC
User
User
Posts: 42
Joined: Thu Apr 11, 2013 5:47 pm

SpriteOutput() does not work on fullscreen/OpenGL/3D

Post by MightyMAC »

Hi guys,

is it just me or does SpriteOutput() not work with the combination: Fullscreen / OpenGL subsystem enabled / 3D engine anabled?

Please try this one (remember to enable OpenGL subsystem):

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Sprite example file
;
;    (c) 2013 - Fantaisie Software
;
; ------------------------------------------------------------
;

InitEngine3D()
If InitSprite() = 0 Or InitKeyboard() = 0
  MessageRequester("Error", "Sprite system can't be initialized", 0)
  End
EndIf

;
; Now, open a 800*600 - 32 bits screen
;
If OpenScreen(800, 600, 32, "Sprite")

  CreateSprite(0,60,60)
  StartDrawing(SpriteOutput(0))
    Box(0,0,20,20)
  StopDrawing()

  CopySprite(0,1,0)
  
  Repeat
    
    ; Inverse the buffers (the back become the front (visible)... And we can do the rendering on the back)
    
    FlipBuffers()
    
 ;   ClearScreen(RGB(0,0,0))
    
    ; Draw our sprite

    ClipSprite(0, 0, 0, x, x/8)
     
    DisplaySprite(0, x, 100)
    DisplaySprite(1, x, x)
    DisplaySprite(0, 600-x, x)
    
    x+1
    
    ExamineKeyboard()
  Until KeyboardPushed(#PB_Key_Escape)
  
Else
  MessageRequester("Error", "Can't open a 800*600 - 32 bit screen !", 0)
EndIf

End   
If you change one of the preconditions: fullscreen to windowed screen / opengl subsystem enabled/disabled / InitEngine3D() in use/remarked it works fine. Could anyone confirm this?

Regards
MAC
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 755
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: SpriteOutput() does not work on fullscreen/OpenGL/3D

Post by Samuel »

With OpenGL your code crashes on SpriteOutput() with the error "The specified output is NULL (0 value)". DirectX seems to work fine.

Also if your using sprites in the 3D world. You should create a camera to put the sprites on.

Code: Select all

InitEngine3D()
If InitSprite() = 0 Or InitKeyboard() = 0
  MessageRequester("Error", "Sprite system can't be initialized", 0)
  End
EndIf

If OpenScreen(800, 600, 32, "Sprite")

  CreateSprite(0,60,60)
  StartDrawing(SpriteOutput(0))
    Box(0,0,20,20,RGB(255,0,0))
  StopDrawing()

  CopySprite(0,1,0)
  
  CreateCamera(0,0,0,100,100)
  
  Repeat
   
    RenderWorld()
    ClipSprite(0, 0, 0, x, x/8)
    DisplaySprite(0, x, 100)
    DisplaySprite(1, x, x)
    DisplaySprite(0, 600-x, x)
    x+1
    FlipBuffers()
    
    ExamineKeyboard()
  Until KeyboardPushed(#PB_Key_Escape)
 
Else
  MessageRequester("Error", "Can't open a 800*600 - 32 bit screen !", 0)
EndIf

End  
MightyMAC
User
User
Posts: 42
Joined: Thu Apr 11, 2013 5:47 pm

Re: SpriteOutput() does not work on fullscreen/OpenGL/3D

Post by MightyMAC »

Yes, of course, in my current project I use a camera and also RenderWorld(), but my intention was to point out the error, which is the same in my project and so I altered the sprite example from the manual. I think I should post it in the bugs forum?!?
Post Reply