PureBasic Forum
http://forums.purebasic.com/english/

PB5.70 - DisplayTransparentSprite bug
http://forums.purebasic.com/english/viewtopic.php?f=15&t=72041
Page 1 of 1

Author:  Andre [ Sat Jan 05, 2019 4:25 pm ]
Post subject:  PB5.70 - DisplayTransparentSprite bug

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:
; 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

Author:  ts-soft [ Sat Jan 05, 2019 4:50 pm ]
Post subject:  Re: PB5.70 - DisplayTransparentSprite bug

I can't see any error on Linux Mint 19.1 Cinnamon x64:
Image

Greetings - Thomas

Author:  Andre [ Sat Jan 05, 2019 5:03 pm ]
Post subject:  Re: PB5.70 - DisplayTransparentSprite bug

Thank you, Thomas!

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

Author:  Shardik [ Sat Jan 05, 2019 6:32 pm ]
Post subject:  Re: PB5.70 - DisplayTransparentSprite bug

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.

Author:  mk-soft [ Sat Jan 05, 2019 8:38 pm ]
Post subject:  Re: PB5.70 - DisplayTransparentSprite bug

Works on Ubuntu 18.10 (VM under Parallels)

Author:  ccode [ Sat Jan 05, 2019 9:28 pm ]
Post subject:  Re: PB5.70 - DisplayTransparentSprite bug

Works on real hardware with Linux Mint LMDE 3 without problems.

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

Author:  mk-soft [ Sat Jan 05, 2019 10:12 pm ]
Post subject:  Re: PB5.70 - DisplayTransparentSprite bug

VM Ubuntu 18.10
Quote:
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

Author:  Andre [ Sat Jan 05, 2019 10:39 pm ]
Post subject:  Re: PB5.70 - DisplayTransparentSprite bug

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.

Author:  Andre [ Sun Jan 06, 2019 9:03 pm ]
Post subject:  Re: PB5.70 - DisplayTransparentSprite bug

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

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/