Page 1 of 1

[PB5.2 Mac/Linux] 3D Test - confirm 2D Drawing bugs

Posted: Wed Sep 25, 2013 10:07 pm
by eddy
Expected result [win]
Image

Hi,
Could you test this code below to confirm following bugs ?
  • reversed colors
  • DrawText glitches
On Mac, sometimes you will get weird stuff displayed. Not at every start, maybe every 3rd or 4th run. (original post)
Image

Code: Select all

DisableExplicit
CompilerIf #PB_Compiler_Version<520
   MessageRequester("PB Version", "PB 5.20 required for this test")
CompilerEndIf
   
If InitEngine3D()=0 Or InitSprite()=0
   MessageRequester("Engine3D / Sprite", "Failed")
EndIf

win=OpenWindow(#PB_Any, 0, 0, 800, 600, "TextureOutput - Test running on PB5.2", #PB_Window_BorderLess |#PB_Window_ScreenCentered |#PB_Window_SystemMenu)
If IsWindow(win)=0 Or OpenWindowedScreen(WindowID(win), 0, 0, WindowWidth(win), WindowHeight(win))=0
   MessageRequester("Window / Screen", "Failed")
EndIf

tex=CreateTexture(#PB_Any, 128, 128)
fontID=LoadFont(0, "Arial", 22, #PB_Font_Bold|#PB_Font_HighQuality|#PB_Font_Italic)
If StartDrawing(TextureOutput(tex))=0
   MessageRequester("TextureOutput", "Failed")
Else
   DrawingMode(#PB_2DDrawing_Transparent|#PB_2DDrawing_AlphaBlend)
   DrawingFont(fontID)
   DrawText(25, 10, "ATLAS", RGBA(255, 255, 255, 255))
   txtW=TextWidth("ATLAS")
   txtH=TextHeight("ATLAS")
   
   DrawingMode(#PB_2DDrawing_Gradient|#PB_2DDrawing_AlphaBlend)
   BackColor(RGBA(255, 255, 0, 255))
   GradientColor(0.8, RGBA(255, 0, 0, 50))
   FrontColor(RGBA(200, 70, 10, 255))
   LinearGradient(0, 0, 0, 64)
   Box(5, 5, 16, 64)
   
   BackColor(RGBA(0, 255, 0, 255))
   GradientColor(0.8, RGBA(0, 0, 255, 50))
   FrontColor(RGBA(60, 100, 255, 255))
   LinearGradient(0, 0, 64, 0)
   Box(21, 69, 64, 16)
   
   DrawingMode(#PB_2DDrawing_Outlined|#PB_2DDrawing_AlphaBlend)
   FrontColor(RGBA(255, 255, 255, 255))
   Box(5, 5, 16, 64)
   Box(21, 69, 64, 16)
   Box(0, 0, 128, 128)
   StopDrawing()
EndIf

cam=CreateCamera(#PB_Any, 0, 0, 100,100)
CameraBackColor(cam, RGB(29, 117, 188))
MoveCamera(cam, 0, 0, 10)
CameraLookAt(cam, 0, 0, 0)

mat=CreateMaterial(#PB_Any, TextureID(tex))
MaterialCullingMode(mat, #PB_Material_NoCulling)
MaterialFilteringMode(mat, #PB_Material_None)
MaterialBlendingMode(mat, #PB_Material_AlphaBlend)
DisableMaterialLighting(mat, #True)
box=CreateCube(#PB_Any,  2)
ent=CreateEntity(#PB_Any, MeshID(box), MaterialID(mat))


Repeat
   RotateEntity(ent, 0.1, 0.2, 0.3, #PB_Relative)
   RenderWorld()
   FlipBuffers()
Until WaitWindowEvent(1)=#PB_Event_CloseWindow

Re: [PB5.2 Mac] 3D Test - confirm 2D Drawing bugs

Posted: Wed Sep 25, 2013 10:46 pm
by idle
It does weird stuff on Linux too!
garbage is displayed on the cube and at right and bottom
sometimes the cube displays as intended

Image

Re: [PB5.2 Mac] 3D Test - confirm 2D Drawing bugs

Posted: Wed Sep 25, 2013 10:47 pm
by eddy
Does your colors are reversed too ?
Could you post a screenshot ?

Re: [PB5.2 Mac/Linux] 3D Test - confirm 2D Drawing bugs

Posted: Thu Sep 26, 2013 12:26 am
by idle
it sometimes displays the cube as it should, sometimes reverses the colours or draws garbage on it
posted screen shot in previous post

Re: [PB5.2 Mac/Linux] 3D Test - confirm 2D Drawing bugs

Posted: Thu Sep 26, 2013 6:08 am
by Danilo
Mac OS X 10.8.5:
Image

Image

Always: no text
Always: flickering, random video memory on right side and bottom, in the area where no camera is defined.
Most of the time: weird display, notice the many points and "dirt" in the cube texture. Looks like texture memory corruption or something like that.
Colors seem to be different from original image (always). No yellow here.

Re: [PB5.2 Mac/Linux] 3D Test - confirm 2D Drawing bugs

Posted: Thu Sep 26, 2013 7:49 am
by Wladek
This is memory leak

Re: [PB5.2 Mac/Linux] 3D Test - confirm 2D Drawing bugs

Posted: Thu Sep 26, 2013 7:29 pm
by Danilo
Wladek wrote:This is memory leak
The pixel "dirt" seems to be because the texture memory is uninitialized after texture creation.
Doesn't happen if you initialize the texture with a full box() first.

New test code:

Code: Select all

#MODE = 0 ; mode 0 or 1


CompilerIf #MODE = 0
#CAM_WIDTH  = 100
#CAM_HEIGHT = 100
CompilerElseIf #MODE = 1
#CAM_WIDTH  = 50
#CAM_HEIGHT = 50
CompilerEndIf

Procedure Draw()
      DrawingMode(#PB_2DDrawing_Gradient|#PB_2DDrawing_AlphaBlend)
      BackColor(RGBA(255,0,0,255))
      GradientColor(0.4, RGBA(255,255,0,255))
      GradientColor(0.6, RGBA(0,255,255,255))
      FrontColor(RGBA(0,0,255,255))
      
      LinearGradient(1, 0, 0, OutputHeight())
      Box(0,0,OutputWidth(),OutputHeight())
      
      DrawingMode(#PB_2DDrawing_Transparent|#PB_2DDrawing_AlphaBlend)
      DrawText(25, 10, "ATLAS", RGBA(255, 255, 255, 255))      
      
      DrawingMode(#PB_2DDrawing_Gradient|#PB_2DDrawing_AlphaBlend)
      BackColor(RGBA(255, 255, 0, 255))
      GradientColor(0.5, RGBA(255, 0, 0, 50))
      FrontColor(RGBA(200, 70, 10, 255))
      LinearGradient(0, 0, 0, 64)
      Box(5, 5, 16, 64)

      BackColor(RGBA(0, 255, 0, 255))
      GradientColor(0.8, RGBA(0, 0, 255, 50))
      FrontColor(RGBA(60, 100, 255, 255))
      LinearGradient(0, 0, 64, 0)
      Box(21, 69, 64, 16)
   
      DrawingMode(#PB_2DDrawing_Outlined|#PB_2DDrawing_AlphaBlend)
      FrontColor(RGBA(255, 255, 255, 255))
      Box(5, 5, 16, 64)
      Box(21, 69, 64, 16)
      Box(0, 0, 128, 128)      
EndProcedure

If InitEngine3D()=0 Or InitSprite()=0
    End
EndIf

If OpenWindow(0,0,0,800,400,"Colors",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
    CanvasGadget(0,0,0,400,400)
    
    If StartDrawing(CanvasOutput(0))
        Draw()
        StopDrawing()
    EndIf
    
    OpenWindowedScreen(WindowID(0),400,0,400,400)
    
    CreateCamera(0,0,0,#CAM_WIDTH,#CAM_HEIGHT)
    CameraBackColor(0, RGB(29, 117, 188))
    MoveCamera(0, 0, 0, 10)
    CameraLookAt(0, 0, 0, 0)
    
    CreateSprite(0,128,128,#PB_Sprite_AlphaBlending)
    If StartDrawing(SpriteOutput(0))
        Draw()
        StopDrawing()
    EndIf
    
    tex = CreateTexture(#PB_Any, 128, 128)
    If StartDrawing(TextureOutput(tex))
        Draw()
        StopDrawing()
    EndIf
    
    mat=CreateMaterial(#PB_Any, TextureID(tex))
    MaterialCullingMode(mat, #PB_Material_ClockWiseCull)
    MaterialFilteringMode(mat, #PB_Material_None)
    MaterialBlendingMode(mat, #PB_Material_AlphaBlend)
    DisableMaterialLighting(mat, #True)
    obj=CreateCube(#PB_Any,  4)
    ;obj = CreatePlane(#PB_Any,4,4,20,20,1,1)
    ent=CreateEntity(#PB_Any, MeshID(obj), MaterialID(mat))
    
    RotateEntity(ent, 45, 45, 45, #PB_Absolute)

    Repeat
        Repeat
            event = WindowEvent()
            If event = #PB_Event_CloseWindow
                quit = 1
            EndIf
        Until event = 0
        Delay(20)
        
        ;RotateEntity(ent, 0.2, 0.4, 0.6, #PB_Relative)
        RenderWorld()
        DisplayTransparentSprite(0,0,0)
        FlipBuffers()
        
    Until quit
EndIf

#MODE = 0 on Windows:
Image

#MODE = 0 on Mac OS X:
Image


#MODE = 1 on Windows:
Image

#MODE = 1 on Mac OS X:
Image

On Mac OS X:
- No text on TextureOutput()
- Camera mode 1 (50,50) resizes camera output, but viewport is like (100,100)
- Different colors on TextureOutput() with RGBA() (notice cube background gradient colors are reversed)

Re: [PB5.2 Mac/Linux] 3D Test - confirm 2D Drawing bugs

Posted: Thu Sep 26, 2013 9:57 pm
by idle
the results on linux for the two modes distorted texture in both modes

mode0
Image

mode1
Image

Re: [PB5.2 Mac/Linux] 3D Test - confirm 2D Drawing bugs

Posted: Fri Sep 27, 2013 7:10 am
by Danilo