Page 3 of 5

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Sun Apr 22, 2012 6:16 pm
by eesau
I have a question regarding this library. Is there a way to use a memory-loaded truetype font for drawing? A font loaded with AddFontMemResourceEx_ does not seem to work (gSetFont() fails). I tried looking at GdipPrivateAddMemoryFont but it wasn't defined in the include file and after adding it I don't get it to work. Any ideas? :oops:

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Mon Apr 23, 2012 4:13 am
by Danilo
eesau wrote:I have a question regarding this library. Is there a way to use a memory-loaded truetype font for drawing?
I added gLoadAppFont(filename.s) and gCatchAppFont(*memory,length) now for loading/catching TrueTypeFonts (.ttf).

Those loaded .ttf are private to your application. To use them, you have to specify the flag
#PB_Font_App for the functions gSetFont() and gGetFontList(). Please try examples 27 and 28.

Version 0.85b:

Code: Select all

gDrawing v0.85b, 14. April 2012

- added commands

    gImage = gLoadMetafile( filename.s )
    
        load .EMF and .WMF

    gMetafileOutput( @metafile, Width, Height [, filename.s [, description.s ]] )
        
        
- added examples

    example 25  -  create and display .EMF metafile
    example 26  -  load   and display .WMF or .EMF metafiles
gMetafileOutput( @metafile, Width, Height ) without the optional filename
creates the Metafile in memory only. Display it with gDrawImage.


Version 0.85b2:

Code: Select all

gDrawing v0.85b2, 23. April 2012

- added commands

    success = gLoadAppFont( filename.s )
    
        load .ttf font
        and add it to the internal application font list
        
        returns 0 if failed

    gCatchAppFont( *memory, length )

        catch/load .ttf font from memory
        and add it to the internal application font list
        
        returns 0 if failed

    gFreeAppFonts()

        release/free the internal application font list
    
        Note: The internal application font list is automatically freed
              at program end in the function gEnd().
              You can use gFreeAppFonts() to free the list manually
              if you don't need the internal application fonts anymore.
              Maybe useful in applications that run for a long time period.

              
- changed commands

    gGetFontList() has now optional flag parameter
    
        the only valid flag is #PB_Font_App
        for getting the internal application font list

    gSetFont() has a new flag for FontStyle: #PB_Font_App
    
        #PB_Font_App has to be used to set fonts
        from the internal application font list

        
- fixed commands

    gDrawText() did not work correctly after setting some flags (like alignment)
                with gSetDrawTextFlags() and using gDrawFormattedText() thereafter.

                Thanks to STARGÅTE for finding and reporting the issue!

        
- added Flags

    #PB_Font_App
    
        for gSetFont()     -> FontStyle #PB_Font_App uses the internal application font list,
                              not the system font list.
                              You add fonts to the internal application font list by using
                              gLoadAppFont and gCatchAppFont.
        
        for gGetFontList() -> If you specify the optional flag #PB_Font_App,
                              the internal application font list is added to
                              your linked list (1st argument).
                              


- added examples

    example 27  -  gLoadAppFont  - load true type font (.ttf)
    example 28  -  gCatchAppFont - load true type font (.ttf) from memory
DOWNLOAD: gDrawing_v0.85b2.zip (89,1k)

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Mon Apr 23, 2012 4:21 am
by eesau
Danilo wrote:
eesau wrote:I have a question regarding this library. Is there a way to use a memory-loaded truetype font for drawing?
I added gLoadAppFont(filename.s) and gCatchAppFont(*memory,length) now for loading/catching TrueTypeFonts (.ttf).

Those loaded .ttf are private to your application. To use them, you have to specify the flag
#PB_Font_App for the functions gSetFont() and gGetFontList(). Please try examples 27 and 28.
Excellent, thank you! :)

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Fri Aug 31, 2012 4:31 pm
by Mesa
Hello,

I've got a problem with image's rotation.
With a rotation of -90 degrees the image is truncated but not with an angle of -30°, -60° etc.

An idea ?

Code: Select all

;{- Enumerations / DataSections
XIncludeFile "gDrawing.pbi"
;{ Windows
Enumeration
  #Window_0
EndEnumeration
;}

Mesa.
;{ Gadgets
Enumeration
  #Button_0
  #ScrollArea_1
  #ImageGadget_1
  #Image_1
  #Image_2
  
EndEnumeration
;}

Define.l Event, EventWindow, EventGadget, EventType, EventMenu
;Define image$,outFichier$
;}

Global Dim Tableau(8000, 8000) 

Procedure.s openimage()
  Protected FichierParDefaut$,Filtre$,Filtre,image$
  FichierParDefaut$ = ""   
  Filtre$ = "Images (*.bmp)|*.bmp|All (*.*)|*.*"
  Filtre  = 0    
  image$ = OpenFileRequester("Image", FichierParDefaut$, Filtre$, Filtre)
  ProcedureReturn image$
EndProcedure
Procedure OpenWindow_Window_0()
  If OpenWindow(#Window_0, 3, 2, 1020, 760, "Window_0", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
    ButtonGadget(#Button_0, 20, 15, 135, 30, "Open image")
    ScrollAreaGadget(#ScrollArea_1, 5, 60, 1000, 650, 4000, 3000, 100, #PB_ScrollArea_Single)
    ImageGadget(#ImageGadget_1, 10, 10, 565, 450, 0, #PB_Image_Border)
    CloseGadgetList()
  EndIf
EndProcedure
Procedure rotation(image.l, pivotX.l, PivotY.l, Angle.f, WrapMode.l)
  ;beware pivotX in % and pivotY in %
  wi=ImageWidth(image)
  hi=ImageHeight(image)
  Anglerad.f=angle*#PI/180 ; in radian
  wf = wi * Abs(Cos(Anglerad)) + hi * Abs(Sin(Anglerad))+5 ; width final
  hf = hi * Abs(Cos(Anglerad)) + wi * Abs(Sin(Anglerad))+5 ; height final
  NewImageID = CreateImage(#PB_Any, wf, hf)
  ;    Debug wf
  ;    Debug hf
  pivotX=pivotX*wi/100 ; transformation % to pix
  pivotY=pivotY*hi/100 ; transformation % to pix
  xi=pivotX+(0-pivotX)*Cos(Anglerad)+(0-PivotY)*Sin(Anglerad)
  yi=PivotY-(0-pivotX)*Sin(Anglerad)+(0-PivotY)*Cos(Anglerad)
  
  yi=-yi
  ;   Debug xi
  ;   Debug yi
  If angle<-90
    xi=pivotX+(wi-pivotX)*Cos(Anglerad)+(0-PivotY)*Sin(Anglerad)
    yi=PivotY-(0-pivotX)*Sin(Anglerad)+(hi-PivotY)*Cos(Anglerad)
    Debug xi
    Debug yi
    yi=-yi
  EndIf
  
  If gStartDrawing(ImageOutput(NewImageID))
    ;Box(0,0,wf,hf,#White)
    logo = gBufferImage(ImageID(image))
    gSetPenImage(logo,WrapMode)
    gSetOrigin(-xi,yi)
    ;gSetPenTransform(pivotX,PivotY,Angle) ; Texture :pivot par rapport à ???
    gRotateAt(pivotX,PivotY,Angle)
    ;gRotate(Angle)
    
    ; draw a cross at the pivot
    gBox(0,0, wf, hf)
    gResetTransform()
    gLineXY(0,0+yi,wf,yi,$FFFFFF00)
    gResetTransform()
    gLineXY(wi/2-xi,0,wi/2-xi,hf,$FFFFFF00)
    gStopdrawing()
  EndIf
  
  ProcedureReturn NewImageID
EndProcedure

OpenWindow_Window_0()

If gInit() 
  OpenWindow_Window_0()
  
  ; rotation 0 to -150°
  rotationInDegrees = -90 ; I've got a problem with -90°, the image is truncated
  pivotX=50 ; 50% of the with
  pivotY=0
  
  
  
  ;{- Event loop
  Repeat
    Event = WaitWindowEvent()
    Select Event
        ; ///////////////////
      Case #PB_Event_Gadget
        EventGadget = EventGadget()
        EventType = EventType()
        If EventGadget = #Button_0
          image$=openimage()
          If image$
            LoadImage(#Image_1,image$)
            SetGadgetState(#ImageGadget_1,ImageID(#Image_1))
            image2=rotation(#Image_1, pivotX, 0, rotationInDegrees, #WrapModeClamp)
            ;   Enumeration ; WrapMode
            ;     #WrapModeTile         ; 0 ; fonctionne avec une grande image
            ;     #WrapModeTileFlipX    ; 1
            ;     #WrapModeTileFlipY    ; 2
            ;     #WrapModeTileFlipXY   ; 3
            ;     #WrapModeClamp        ; 4
            ; EndEnumeration
            SetGadgetState(#ImageGadget_1,ImageID(Image2))
          EndIf
        EndIf
        ; ////////////////////////
      Case #PB_Event_CloseWindow
        EventWindow = EventWindow()
        If EventWindow = #Window_0
          CloseWindow(#Window_0)
          Break
        EndIf
    EndSelect
  ForEver
  ;
  gEnd()
EndIf
;}

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Sat Sep 01, 2012 9:01 am
by Danilo
Mesa wrote:Hello,

I've got a problem with image's rotation.
With a rotation of -90 degrees the image is truncated but not with an angle of -30°, -60° etc.

An idea ?
The problem seems to be your line:

Code: Select all

gSetOrigin(-xi,yi)
It changes the origin and the box you paint later is too small.

If you change:

Code: Select all

gBox(0,0, wf, hf)
to:

Code: Select all

gBox(0,0, wf+xi, hf+yi)
it works correctly again.

I added a TrackbarGadget at the top for the rotation.
Look at the line with comment "FIX" and try it.

Code: Select all

;{- Enumerations / DataSections
XIncludeFile "gDrawing.pbi"
;{ Windows
Enumeration
  #Window_0
EndEnumeration
;}

;{ Gadgets
Enumeration
  #Button_0
  #ScrollArea_1
  #ImageGadget_1
  #Image_1
  #Image_2
 
EndEnumeration
;}

Define.l Event, EventWindow, EventGadget, EventType, EventMenu
;Define image$,outFichier$
;}

Global Dim Tableau(8000, 8000)

Procedure.s openimage()
  Protected FichierParDefaut$,Filtre$,Filtre,image$
  FichierParDefaut$ = ""   
  Filtre$ = "Images (*.bmp)|*.bmp|All (*.*)|*.*"
  Filtre  = 0   
  image$ = OpenFileRequester("Image", FichierParDefaut$, Filtre$, Filtre)
  ProcedureReturn image$
EndProcedure
Procedure OpenWindow_Window_0()
  If OpenWindow(#Window_0, 3, 2, 1020, 760, "Window_0", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
    ButtonGadget(#Button_0, 20, 15, 135, 30, "Open image")
    ScrollAreaGadget(#ScrollArea_1, 5, 60, 1000, 650, 4000, 3000, 100, #PB_ScrollArea_Single)
    ImageGadget(#ImageGadget_1, 10, 10, 565, 450, 0, #PB_Image_Border)
    CloseGadgetList()
  EndIf
EndProcedure
Procedure rotation(image.l, pivotX.l, PivotY.l, Angle.f, WrapMode.l)
  ;beware pivotX in % and pivotY in %
  wi=ImageWidth(image)
  hi=ImageHeight(image)
  Anglerad.f=angle*#PI/180 ; in radian
  wf = wi * Abs(Cos(Anglerad)) + hi * Abs(Sin(Anglerad))+5 ; width final
  hf = hi * Abs(Cos(Anglerad)) + wi * Abs(Sin(Anglerad))+5 ; height final
  NewImageID = CreateImage(#PB_Any, wf, hf)
  ;    Debug wf
  ;    Debug hf
  pivotX=pivotX*wi/100 ; transformation % to pix
  pivotY=pivotY*hi/100 ; transformation % to pix
  xi=pivotX+(0-pivotX)*Cos(Anglerad)+(0-PivotY)*Sin(Anglerad)
  yi=PivotY-(0-pivotX)*Sin(Anglerad)+(0-PivotY)*Cos(Anglerad)
 
  yi=-yi
  ;   Debug xi
  ;   Debug yi
  If angle<-90
    xi=pivotX+(wi-pivotX)*Cos(Anglerad)+(0-PivotY)*Sin(Anglerad)
    yi=PivotY-(0-pivotX)*Sin(Anglerad)+(hi-PivotY)*Cos(Anglerad)
    Debug xi
    Debug yi
    yi=-yi
  EndIf
 
  If gStartDrawing(ImageOutput(NewImageID))
    Box(0,0,wf,hf,#White)
    logo = gBufferImage(ImageID(image))
    ;logo=image
    gSetPenImage(logo,WrapMode)
    ;gStartTransform()
    gSetOrigin(-xi,yi)
    ;gSetPenTransform(pivotX,PivotY,Angle) ; Texture :pivot par rapport à ???
    gRotateAt(pivotX,PivotY,Angle)
    ;gRotate(Angle)
   
    ; draw a cross at the pivot
    gBox(0,0, wf   , hf)     ; <-- WITHOUT FIX
    ;gBox(0,0, wf+xi, hf+yi)  ; <-- FIX


    gResetTransform()
    gLineXY(0,0+yi,wf,yi,$FFFFFF00)
    ;gResetTransform()
    gLineXY(wi/2-xi,0,wi/2-xi,hf,$FFFFFF00)
    gStopdrawing()
  EndIf
 
  ProcedureReturn NewImageID
EndProcedure

OpenWindow_Window_0()

If gInit()
  OpenWindow_Window_0()
 
  ; rotation 0 to -150°
  rotationInDegrees = -85;-90 ; I've got a problem with -90°, the image is truncated
  pivotX=50 ; 50% of the with
  pivotY=0
 
  trackbar=TrackBarGadget(#PB_Any,200,20,400,20,0,180)
  SetGadgetState(trackbar,rotationInDegrees+180)
 
  ;{- Event loop
  Repeat
    Event = WaitWindowEvent()
    Select Event
        ; ///////////////////
      Case #PB_Event_Gadget
        EventGadget = EventGadget()
        EventType = EventType()
        If EventGadget = #Button_0
          image$=openimage()
          If image$
            LoadImage(#Image_1,image$)
            SetGadgetState(#ImageGadget_1,ImageID(#Image_1))
            image2=rotation(#Image_1, pivotX, 0, rotationInDegrees, #WrapModeClamp)
            ;   Enumeration ; WrapMode
            ;     #WrapModeTile         ; 0 ; fonctionne avec une grande image
            ;     #WrapModeTileFlipX    ; 1
            ;     #WrapModeTileFlipY    ; 2
            ;     #WrapModeTileFlipXY   ; 3
            ;     #WrapModeClamp        ; 4
            ; EndEnumeration
            SetGadgetState(#ImageGadget_1,ImageID(Image2))
          EndIf
        ElseIf EventGadget=trackbar
            rotationInDegrees = GetGadgetState(trackbar)-180
            FreeImage(image2)
            image2=rotation(#Image_1, pivotX, 0, rotationInDegrees, #WrapModeClamp)
            SetGadgetState(#ImageGadget_1,ImageID(Image2))
        EndIf
        ; ////////////////////////
      Case #PB_Event_CloseWindow
        EventWindow = EventWindow()
        If EventWindow = #Window_0
          CloseWindow(#Window_0)
          Break
        EndIf
    EndSelect
  ForEver
  ;
  gEnd()
EndIf
;}

If you don't need image tiling, you could use gDrawImage directly:

Code: Select all

Procedure rotation(image.l, pivotX.l, PivotY.l, Angle.f, WrapMode.l)
  ;beware pivotX in % and pivotY in %
  wi=ImageWidth(image)
  hi=ImageHeight(image)
  Anglerad.f=angle*#PI/180 ; in radian
  wf = wi * Abs(Cos(Anglerad)) + hi * Abs(Sin(Anglerad))+5 ; width final
  hf = hi * Abs(Cos(Anglerad)) + wi * Abs(Sin(Anglerad))+5 ; height final
  NewImageID = CreateImage(#PB_Any, wf, hf)
  ;    Debug wf
  ;    Debug hf
  pivotX=pivotX*wi/100 ; transformation % to pix
  pivotY=pivotY*hi/100 ; transformation % to pix
  xi=pivotX+(0-pivotX)*Cos(Anglerad)+(0-PivotY)*Sin(Anglerad)
  yi=PivotY-(0-pivotX)*Sin(Anglerad)+(0-PivotY)*Cos(Anglerad)
 
  yi=-yi
  ;   Debug xi
  ;   Debug yi
  If angle<-90
    xi=pivotX+(wi-pivotX)*Cos(Anglerad)+(0-PivotY)*Sin(Anglerad)
    yi=PivotY-(0-pivotX)*Sin(Anglerad)+(hi-PivotY)*Cos(Anglerad)
    Debug xi
    Debug yi
    yi=-yi
  EndIf
 
  If gStartDrawing(ImageOutput(NewImageID))
    Box(0,0,wf,hf,#White)

    gSetOrigin(-xi,yi)
    gRotateAt(pivotX,PivotY,Angle)
    gDrawImage(image,0,0)

    gResetTransform()
    gLineXY(0,0+yi,wf,yi,$FFFFFF00)
    gLineXY(wi/2-xi,0,wi/2-xi,hf,$FFFFFF00)
    gStopdrawing()
  EndIf
 
  ProcedureReturn NewImageID
EndProcedure

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Wed Dec 05, 2012 11:58 am
by IdeasVacuum
I have got a problem matching the height of text in an EditorGadget and the same text drawn using GDI+.

According to the PB Help, the input for font height is measured in Points. I'm not sure that it is, because if I measure the height of some text in an Editor Gadget, PB seems to be using Pixel Height.

GDI+: gSetFont("Arial", 20, #PB_Font_Bold)
PB: LoadFont(#Font, "Arial", 20, #PB_Font_Bold):

Image

On the left, the g text height is approx 15pixels, which sounds right if 1pixel = approx 0.75 points.
On the right is the PB Text in an Editor Gadget, the text height is approx 20pixels.

Confused!

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Wed Dec 05, 2012 12:41 pm
by Danilo
gDrawing uses pixels for font size by default.

After "gSetUnit(#UnitMillimeter)", the command "gSetFont("Arial",40)" loads the font with size 40mm.
This makes sense to output to different devices with different DPI (screen, printers) at the same size.
40mm are 40mm on screen and on printers (example "Printing 01.pb").

You can change to other "#Unit..." enumerations:

Code: Select all

    #UnitPixel       ; 2 -- Each unit is one device pixel.
    #UnitPoint       ; 3 -- Each unit is a printer's point, or 1/72 inch.
    #UnitInch        ; 4 -- Each unit is 1 inch.
Also, you have gGetDpiX() and gGetDpiY() to get the DPI of the output device (for example 600x600 DPI for a printer),
so you can convert DPI to any other sizes.

Don't forget that some characters go under the base line, for example (lowercase) 'g' and 'j'.
In your example text you can't see it.


See also: DPI and Device-Independent Pixels (Windows)

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Wed Dec 05, 2012 4:32 pm
by IdeasVacuum
Hi Danilo

Thanks for getting back to me.

There is something 'wrong' somewhere, because no matter what unit is set via gSetUnit(), the resulting text is always smaller than what PB displays in an EditorGadget for the same height value.........

Edit: ...and that something 'wrong' is a typo in my code!

Thanks for your help Danilo. Time for a coffee.

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Wed Dec 26, 2012 7:24 pm
by deseven
Thanks for your Include.

But how can i draw alpha-blended sprites?

I tried to use it like that:

Code: Select all

CreateSprite(0,100,100,#PB_Sprite_AlphaBlending|#PB_Sprite_Texture)
gStartDrawing(SpriteOutput(0))
gCircle(50,50,50,50)
gStopDrawing()
CreateSprite3D(0,0)

...

Start3D()
DisplaySprite3D(0,0,0)
Stop3D()
I also tried to set the gDrawingMode and tried to use gClear with $00000000 - no luck, i got fully transparent sprites.

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Thu Dec 27, 2012 5:36 am
by netmaestro
I don't use that library but the characteristics of the following sample code will apply to the gdiplus library too. There is a problem with #PB_Sprite_AlphaBlending when used with CreateSprite(). The alphas come out wrong. With LoadSprite(), all is well. For now, if you want to draw your own sprites with alphablending, they have to come in via LoadSprite(). Here is the sample:

Code: Select all

InitSprite():InitSprite3D():InitKeyboard()
OpenWindow(0,0,0,320,240,"Press any key to end...",#pb_window_screencentered)
OpenWindowedScreen(WindowID(0),0,0,128,64)
CreateSprite(0, 64,64, #PB_sprite_texture|#pb_sprite_alphablending)
CreateImage(0, 64,64, 32|#pb_image_transparent)
StartDrawing(ImageOutput(0))
  DrawingMode(#pb_2ddrawing_alphablend)
  Circle(26,26,16,RGBA(255,0,0,64))
  Circle(36,36,16,RGBA(0,0,255,64))
StopDrawing()
StartDrawing(SpriteOutput(0))
  DrawAlphaImage(ImageID(0),0,0)
StopDrawing()
CreateSprite3D(0,0)
UsePNGImageEncoder()
SaveImage(0, "c:\test.png", #pb_imageplugin_png)
UsePNGImageDecoder()
LoadSprite(1, "c:\test.png", #PB_sprite_texture|#pb_sprite_alphablending)
CreateSprite3D(1,1)

Repeat
  While WindowEvent():Wend
  ClearScreen(GetSysColor_(#COLOR_BTNFACE))
  Start3D()
    DisplaySprite3D(0,0,0)
    DisplaySprite3D(1,64,0)
  Stop3D()
  FlipBuffers()
  ExamineKeyboard()
Until KeyboardPushed(#pb_key_all)
Only the Sprite3D which came in via LoadSprite() displays correctly. It is unfortunately no better with the OpenGL subsystem as opposed to the native DX9.

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Thu Dec 27, 2012 8:26 am
by deseven
netmaestro wrote:if you want to draw your own sprites with alphablending, they have to come in via LoadSprite()
Thanks!
So... Is this a bug? Do devs know about it?

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Thu Dec 27, 2012 1:10 pm
by STARGÅTE
No Bug, alpha-channel is not support with StartDrawing() and SpriteOutput()

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Fri Oct 18, 2013 9:26 pm
by VisualJump3D
Hi,

how can I use "gDrawing" with InitEngine3D () ?

thank

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Sat Oct 19, 2013 8:42 am
by Danilo
VisualJump3D wrote:how can I use "gDrawing" with InitEngine3D () ?
Did you mean how to use gDrawing with TextureOutput()?

If so, I guess you have to draw to images, and draw the image onto the texture. Maybe like this:

Code: Select all

Procedure.i ImageToTexture(img)
    Protected result, texture
    
    If IsImage(img)
        texture = CreateTexture(#PB_Any, ImageWidth(img), ImageHeight(img))
        If texture
            If StartDrawing(TextureOutput(texture))
                DrawImage(ImageID(img),0,0)
                StopDrawing()
                ProcedureReturn texture
            Else
                FreeTexture(texture)
            EndIf
        EndIf
    EndIf
EndProcedure

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Sat Oct 19, 2013 3:48 pm
by VisualJump3D
no ...

the problem is , when i work with InitEngine3D () + openwindowedscreen

Es 19

EnableExplicit

XIncludeFile "gDrawing.pbi"

Define mainWin, quit


InitEngine3D () ( NOT IN Example 19 but in my code yes ) ( I get an error )
InitSprite()
InitKeyboard()

Procedure Screen()
ClearScreen(0)
If gStartDrawing(ScreenOutput())
gSetFont("Arial",200,#PB_Font_Bold)
gDrawText(100,100,"Text",RGBA($00,$00,$FF,$FF))
gDrawingMode(#PB_2DDrawing_Outlined)
gDrawText(100,100,"Text",RGBA($FF,$FF,$FF,$FF))
gBox(100,100,gTextWidth("Text"),gTextHeight(),RGBA($FF,$FF,$FF,$FF))
gStopdrawing()
EndIf

FlipBuffers()
EndProcedure

If gInit()

mainWin = OpenWindow(#PB_Any,0,0,800,600,"gDrawing on screen",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(mainWin),0,0,800,600,0,0,0)

Repeat
Select WindowEvent()
Case #PB_Event_CloseWindow
quit = #True
EndSelect
Screen()
Until quit=#True

gEnd()
EndIf