Page 1 of 1

PB5.70 - DisplayTransparentSprite bug

Posted: Sat Jan 05, 2019 4:25 pm
by Andre
The following code runs fine on Windows, but does not on Linux (tested on Mint Mate 19.1 x64 and Ubuntu 18.10 x64, on VMware Player), here the box in the top-left corner displays a drawing error as you could see on the screenshot below. See the 'Fixme' note in the following test code, with which settings the bug occurs (it doesn't with PB5.62)...

Thanks for any more tests and feedbacks!

[Update: a possible workaround by limiting the 'Intensity' value is added in the commented code section...]

Code: Select all

; DisplayTransparentSprite() Bug PB570 Linux
; Demo code with workaround as temporary bugfix

EnableExplicit

; Workaround - PB570 Linux - DisplayTransparentSprite()
; CompilerIf #PB_Compiler_OS=#PB_OS_Linux
;   Procedure DisplayTransparentSprite_(output_ID, x, y, alpha)
;     If alpha>253 : alpha=253 : EndIf ; Mostly 254 works, but not ever, it look, it's available 253 work all over
;     DisplayTransparentSprite(output_ID, x, y, alpha)
;   EndProcedure
;   Macro DisplayTransparentSprite(output_ID, x, y, alpha=253)
;     DisplayTransparentSprite_(output_ID, x, y, alpha)
;   EndMacro
; CompilerEndIf

InitSprite()

Define i, ii, texture_ID, sprite_ID, sprite_1_ID, output_x, output_y, output_width=800, output_height=600
Define window_ID=OpenWindow(#PB_Any, #PB_Ignore, #PB_Ignore, output_width, output_height, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If Not OpenWindowedScreen(WindowID(window_ID), 0, 0, output_width, output_height) : End : EndIf

Macro create_sprite
  If IsImage(texture_ID) : FreeImage(texture_ID) : EndIf
  If IsSprite(sprite_ID) : FreeSprite(sprite_ID) : EndIf
  texture_ID=CreateImage(#PB_Any, 200, 200)
  sprite_ID=CreateSprite(#PB_Any, ImageWidth(texture_ID), ImageHeight(texture_ID))
  StartDrawing(ImageOutput(texture_ID))
    DrawingMode(#PB_2DDrawing_Outlined)
    LineXY(0, 0, ImageWidth(texture_ID), ImageHeight(texture_ID), $FFFFFF) ; don't use black, as this is the pre-defined transparent color
    LineXY(ImageWidth(texture_ID), 0, 0, ImageHeight(texture_ID), $FFFF)
    Box(0, 0, ImageWidth(texture_ID), ImageHeight(texture_ID), $FF)
  StopDrawing()
EndMacro
create_sprite

sprite_1_ID=CreateSprite(#PB_Any, output_width, output_height)

Repeat
  
  Repeat ; Get all window events before FlipBuffers()
    Define win_event=WaitWindowEvent(1)
    If win_event=#PB_Event_CloseWindow
      End
    EndIf
  Until Not win_event
  
  FlipBuffers()
  ClearScreen(0)
  DisplaySprite(sprite_1_ID, 0, 0) ; Set a background before the output of the result - here in this snippet we use simply black
  StartDrawing(SpriteOutput(sprite_ID)) ; Draw the texture
  DrawImage(ImageID(texture_ID), 0, 0)
  StopDrawing()
  
  For i=0 To output_width
    For ii=0 To output_height
      ; DisplayTransparentSprite(sprite_ID, i, ii, 254) : ii+ImageHeight(texture_ID)-1 ; = OK
      ; FIXME - 255 on the following line will break the function (254 and all other values work)
      DisplayTransparentSprite(sprite_ID, i, ii) : ii+ImageHeight(texture_ID)-1
    Next
    i+ImageWidth(texture_ID)-1
  Next
  
ForEver
Image

Re: PB5.70 - DisplayTransparentSprite bug

Posted: Sat Jan 05, 2019 4:50 pm
by ts-soft
I can't see any error on Linux Mint 19.1 Cinnamon x64:
Image

Greetings - Thomas

Re: PB5.70 - DisplayTransparentSprite bug

Posted: Sat Jan 05, 2019 5:03 pm
by Andre
Thank you, Thomas!

As this has probably something to do with the used Linux Distros then, any more test results are very welcome :-D

Re: PB5.70 - DisplayTransparentSprite bug

Posted: Sat Jan 05, 2019 6:32 pm
by Shardik
No graphics error on Linux Mint x64 18.3 Cinnamon with PB 5.70 x64 on real hardware. Maybe your described problem is caused by testing on virtual machines. I would always advise to test on real hardware because especially graphics problems often arise because of bugs in the emulated graphics driver.

Re: PB5.70 - DisplayTransparentSprite bug

Posted: Sat Jan 05, 2019 8:38 pm
by mk-soft
Works on Ubuntu 18.10 (VM under Parallels)

Re: PB5.70 - DisplayTransparentSprite bug

Posted: Sat Jan 05, 2019 9:28 pm
by ccode
Works on real hardware with Linux Mint LMDE 3 without problems.

How much graphics memory do you use with the virtual machine?

Re: PB5.70 - DisplayTransparentSprite bug

Posted: Sat Jan 05, 2019 10:12 pm
by mk-soft
VM Ubuntu 18.10
Memory: 1,9 GiB
Processor: Intel® Core™ i7-3615QM CPU @ 2.30GHz × 2
Graphics: Parallels using Intel HD Graphics 4000 OpenGL Engine
Graphics-Mem: 64 MB
Gnome: 3.30.1
OS: 64-bit
Virtual-Type: KVM

Re: PB5.70 - DisplayTransparentSprite bug

Posted: Sat Jan 05, 2019 10:39 pm
by Andre
Thank you for your tests, friends! :D

So it seems so far, that there are probably no problems on a real Linux machine.... and like Shardik says, there are raised some issues with emulated hardware / GFX drivers.

If there are no further confirmations, I will move this topic to the regular Linux section later...
ccode wrote:How much graphics memory do you use with the virtual machine?
768 MB GFX memory, and 2 GB memory in total for the VM.

Re: PB5.70 - DisplayTransparentSprite bug

Posted: Sun Jan 06, 2019 9:03 pm
by Andre
Further tests confirmed, that the above code runs well on native Linux (Mint Mate 19.1).

So there seems to be an error in the latest VMware Player version (v15.02), which worked well before with Linux and MacOS (and PB5.62). So this is now more post to "warn" about possible PB graphics problems, caused by VMware.

Topic moved to regular "Linux" section.

Thanks for all your tests & comments! :D