Red frame

Advanced game related topics
User avatar
SPH
Enthusiast
Enthusiast
Posts: 268
Joined: Tue Jan 04, 2011 6:21 pm

Red frame

Post by SPH »

Hi, 8)

Do you see the red frame surrounding the screen? ( http://xmas.free.fr/cadre_echelle.bmp )
Thank you for answering me.

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  SPH(2021) ;; Polygons_Run_3 ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;EnableExplicit

;-CONSTANTS
Enumeration
  #MainWindow
  #OpenGLGadget
EndEnumeration

;These two GL constants are used for texture creation. Don't change their values.
#GL_BGR = $80E0
#GL_BGRA = $80E1

If ExamineDesktops()
  ddw=DesktopWidth(0)
  ddh=DesktopHeight(0)
Else
  ddw=1024
  ddh=768
EndIf

; 
;


xf.f=1920/ddw
yf.f=1080/ddh

; a la ligne 29 et 30, creation d'une echelle de grandeur
; a la ligne 175, utilisation de cette echelle


;-STRUCTURES
Structure Integer2
  X.i
  Y.i
EndStructure
Global.Integer2 WindowDim
WindowDim\X = ddw
WindowDim\Y = ddh


;-DEFINES
Define.i Event
Define.i WindowFlags = #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget


;-DECLARES
Declare Render()
Declare Render2DQuad(OGLTexture.i, StartX.d, StartY.d, Width.i, Height.i, Z.d)
Declare SetupOpenGL()
Declare SetupGLTexture(ImageHandle.i)


;-MAIN WINDOW
win=OpenWindow(#MainWindow, 0, 0,ddw,ddh, "Polygons_Run",#PB_Window_Maximize|#PB_Window_BorderLess)
If win=0
  Beep_(500,250) : Delay(150) : Beep_(500,250)
  MessageRequester("Erreur","OpenWindow() impossible")
  End
EndIf

screenGL=OpenGLGadget(#OpenGLGadget,0,0,ddw,ddh)
If screenGL=0
  Beep_(500,250) : Delay(150) : Beep_(500,250)
  MessageRequester("Erreur","OpenGLGadget() impossible")
  End
EndIf


SetupOpenGL()

AddKeyboardShortcut(0,  #PB_Shortcut_Escape, 666) ; quitter


glOrtho_(0,ddw,ddh,0,-1,1)
glMatrixMode_(#GL_MODELVIEW)
glLoadIdentity_()
glClear_(0)

;*********************************************************************************************************************************
;*********************************************************************************************************************************
;*********************************************************************************************************************************
;*********************************************************************************************************************************

    long=21
    Dim poly_mx2(long)
    Dim poly_my2(long)
    For i=1 To long
      Read.w poly_mx2(i-1)
      Read.w poly_my2(i-1)
    Next  


;*********************************************************************************************************************************
;*********************************************************************************************************************************
;*********************************************************************************************************************************
;*********************************************************************************************************************************
timer=ElapsedMilliseconds()

;-MAIN REPEAT
Repeat ;- ..... Repeat
  
 ; glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
;##############################################
;##############################################
;##############################################

  Event = WaitWindowEvent()
  
  Select Event
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 1
          Resx = GetGadgetAttribute(1, #PB_OpenGL_MouseX)
          Resy = GetGadgetAttribute(1, #PB_OpenGL_MouseY)
          ;;;;;;;          
          Select EventType()
              ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;              
            Case #PB_EventType_LeftClick
              End
              ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
            Case #PB_EventType_RightDoubleClick 
              End
              ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;              
            Case #PB_EventType_RightClick
              End
              ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;              
            Case #PB_EventType_MiddleButtonDown
              End
              ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;              
          EndSelect
      EndSelect
    Case #PB_Event_Menu
      Select EventMenu()
        Case 666
          End
      EndSelect
  EndSelect
  
;##############################################
;##############################################
;##############################################

  nb2=0
  ii=0
  While poly_my2(nb2)>0
    ii=poly_my2(nb2)
    alpha2.f=poly_mx2(nb2+4)/32767
    glBegin_(#GL_POLYGON)
    If alpha2=1
      glBlendFunc_(#GL_SRC_ALPHA,0)
      glColor4f_(poly_mx2(nb2+1)/32767,poly_mx2(nb2+2)/32767,poly_mx2(nb2+3)/32767,1)
    Else
      glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
      glColor4f_(poly_mx2(nb2+1)/32767,poly_mx2(nb2+2)/32767,poly_mx2(nb2+3)/32767,alpha2)
    EndIf
    
    For i=1 To poly_my2(nb2)-5
      glVertex2f_(poly_mx2(nb2+4+i)/xf.f,poly_my2(nb2+4+i)/yf.f)
    Next
    glEnd_()
    nb2+ii
  Wend
  
  ;========================================================
  ;=======================================================
  
  SetGadgetAttribute(#OpenGLGadget, #PB_OpenGL_FlipBuffers, #True)
  
ForEver

;*********************************************************************************************************************************
;*********************************************************************************************************************************
;*********************************************************************************************************************************
;*************************************************************** ******************************************************************
;*********************************************************************************************************************************
;************************************************************************* *******************************************************
;*********************************************************************************************************************************

Procedure Render()
  
  ;Clearing buffers and resetting clear color to remove old graphics from the last frame.
  glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
  ;  glClearColor_(0.2, 0.2, 0.2, 1.0)
  glClearColor_(0,0,0,1)
  
  ;## DRAWING TEXTURES/IMAGES
  ;First enable the Texture system.
  glEnable_(#GL_TEXTURE_2D)
  
  ;This procedure will create a quad and apply a texture to it.
  ;The Texture variable contains the texture created earlier using SetupGLTexture().
  Render2DQuad(Texture1, 0, 0, ImageWidth(Image1), ImageHeight(Image1), -2)
  ; Render2DQuad(Texture2, 0, 0, ImageWidth(Image2), ImageHeight(Image2), -1)
  
  ;After all the textures have been displayed disable the texture system.
  ;Otherwise it will conflict with the non texture graphics.
  glDisable_(#GL_TEXTURE_2D)
  
EndProcedure

Procedure Render2DQuad(OGLTexture.i, StartX.d, StartY.d, Width.i, Height.i, Z.d)
  
  ;The texture is first bound which tells OpenGL to use this texture for any future rendering.
  glBindTexture_(#GL_TEXTURE_2D, OGLTexture)
  glBegin_(#GL_QUADS)
  glColor4f_   (1,1,1,1)
  glNormal3f_  (0,0,1.0)
  glTexCoord2f_(1.0,1.0)
  glVertex3f_  (StartX+Width,StartY,Z)
  glTexCoord2f_(0.0,1.0)
  glVertex3f_  (StartX,StartY,Z)
  glTexCoord2f_(0.0,0.0)
  glVertex3f_  (StartX,StartY+Height,Z)
  glTexCoord2f_(1.0,0.0)
  glVertex3f_  (StartX+Width,StartY+Height,Z)
  glEnd_()
  
EndProcedure

Procedure SetupOpenGL()
  
  glMatrixMode_(#GL_PROJECTION)
  
  glOrtho_(0.0, WindowDim\X, WindowDim\Y, 0.0, -1000.0, 1000.0)
  
  glMatrixMode_(#GL_MODELVIEW)
  
  ; glEnable_(#GL_DEPTH_TEST)
  
  glEnable_(#GL_BLEND)
  glBlendFunc_(#GL_SRC_ALPHA, #GL_ONE_MINUS_SRC_ALPHA)
  
EndProcedure


DataSection
  Data.w 2,9,32767,0,0,0,0,0,32767,0,0,0,1919,0,1919,1079,0,1079,0,9,16384,0,16384,0,16384,0,32767,0,45,44,1863,52,1863,1040,43,1035,0,0,0,0,0,0,0,0
EndDataSection
http://HexaScrabble.com/
!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 5.73LTS - 32 bits
User avatar
falsam
Enthusiast
Enthusiast
Posts: 630
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: Red frame

Post by falsam »

yes

➽ Windows 11 64-bit - PB 6.0 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect.
User avatar
SPH
Enthusiast
Enthusiast
Posts: 268
Joined: Tue Jan 04, 2011 6:21 pm

Re: Red frame

Post by SPH »

falsam wrote:yes
What is your desktop resolution ?
http://HexaScrabble.com/
!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 5.73LTS - 32 bits
User avatar
Mijikai
Addict
Addict
Posts: 1360
Joined: Sun Sep 11, 2016 2:17 pm

Re: Red frame

Post by Mijikai »

Yes, 2K
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1251
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: Red frame

Post by Paul »

Nope, cut off...

Image

4K monitor (3840x2160), 175% DPI Scaling.
Image Image
User avatar
SPH
Enthusiast
Enthusiast
Posts: 268
Joined: Tue Jan 04, 2011 6:21 pm

Re: Red frame

Post by SPH »

Paul wrote:Nope, cut off...

Image

4K monitor (3840x2160), 175% DPI Scaling.
I guess 100% DPI Scaling fixes the problem?

You who are in 4K, what PB instruction should I use to correct this?

Thank you for your reply :wink:
http://HexaScrabble.com/
!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 5.73LTS - 32 bits
BarryG
Addict
Addict
Posts: 3318
Joined: Thu Apr 18, 2019 8:17 am

Re: Red frame

Post by BarryG »

Yes, I see the entire red frame on my 1920 x 1080 monitor at 100% DPI.

But I don't see it at 125% DPI - I only see the top and left red sides.
User avatar
SPH
Enthusiast
Enthusiast
Posts: 268
Joined: Tue Jan 04, 2011 6:21 pm

Re: Red frame

Post by SPH »

I added instructions for rendering the DPI.
It was necessary to compile with an option checked (DPI)

Can you tell me if this is ok : http://xmas.free.fr/red_frame_with_dpi.exe

The code is :

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  SPH(2021) ;; Polygons_Run_3 ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;EnableExplicit

;-CONSTANTS
Enumeration
  #MainWindow
  #OpenGLGadget
EndEnumeration

;These two GL constants are used for texture creation. Don't change their values.
#GL_BGR = $80E0
#GL_BGRA = $80E1

If ExamineDesktops()
  ddw=DesktopWidth(0)
  ddh=DesktopHeight(0)
Else
  ddw=1024
  ddh=768
EndIf

;********************* DPI *********************
dpix.f=DesktopResolutionX()
dpiy.f=DesktopResolutionY()

xf.f=(1920/ddw)/dpix
yf.f=(1080/ddh)/dpiy
;**********************************************

;-STRUCTURES
Structure Integer2
  X.i
  Y.i
EndStructure
Global.Integer2 WindowDim
WindowDim\X = ddw
WindowDim\Y = ddh


;-DEFINES
Define.i Event
Define.i WindowFlags = #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget


;-DECLARES
Declare Render()
Declare Render2DQuad(OGLTexture.i, StartX.d, StartY.d, Width.i, Height.i, Z.d)
Declare SetupOpenGL()
Declare SetupGLTexture(ImageHandle.i)


;-MAIN WINDOW
win=OpenWindow(#MainWindow, 0, 0,ddw,ddh, "Polygons_Run",#PB_Window_Maximize|#PB_Window_BorderLess)
If win=0
  Beep_(500,250) : Delay(150) : Beep_(500,250)
  MessageRequester("Erreur","OpenWindow() impossible")
  End
EndIf

screenGL=OpenGLGadget(#OpenGLGadget,0,0,ddw,ddh)
If screenGL=0
  Beep_(500,250) : Delay(150) : Beep_(500,250)
  MessageRequester("Erreur","OpenGLGadget() impossible")
  End
EndIf


SetupOpenGL()

AddKeyboardShortcut(0,  #PB_Shortcut_Escape, 666) ; quitter


glOrtho_(0,ddw,ddh,0,-1,1)
glMatrixMode_(#GL_MODELVIEW)
glLoadIdentity_()
glClear_(0)

;*********************************************************************************************************************************
;*********************************************************************************************************************************
;*********************************************************************************************************************************
;*********************************************************************************************************************************

    long=21
    Dim poly_mx2(long)
    Dim poly_my2(long)
    For i=1 To long
      Read.w poly_mx2(i-1)
      Read.w poly_my2(i-1)
    Next 


;*********************************************************************************************************************************
;*********************************************************************************************************************************
;*********************************************************************************************************************************
;*********************************************************************************************************************************
timer=ElapsedMilliseconds()

;-MAIN REPEAT
Repeat ;- ..... Repeat
 
 ; glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
;##############################################
;##############################################
;##############################################

  Event = WaitWindowEvent()
 
  Select Event
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 1
          Resx = GetGadgetAttribute(1, #PB_OpenGL_MouseX)
          Resy = GetGadgetAttribute(1, #PB_OpenGL_MouseY)
          ;;;;;;;         
          Select EventType()
              ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;             
            Case #PB_EventType_LeftClick
              End
              ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
            Case #PB_EventType_RightDoubleClick
              End
              ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;             
            Case #PB_EventType_RightClick
              End
              ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;             
            Case #PB_EventType_MiddleButtonDown
              End
              ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;             
          EndSelect
      EndSelect
    Case #PB_Event_Menu
      Select EventMenu()
        Case 666
          End
      EndSelect
  EndSelect
 
;##############################################
;##############################################
;##############################################

  nb2=0
  ii=0
  While poly_my2(nb2)>0
    ii=poly_my2(nb2)
    alpha2.f=poly_mx2(nb2+4)/32767
    glBegin_(#GL_POLYGON)
    If alpha2=1
      glBlendFunc_(#GL_SRC_ALPHA,0)
      glColor4f_(poly_mx2(nb2+1)/32767,poly_mx2(nb2+2)/32767,poly_mx2(nb2+3)/32767,1)
    Else
      glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
      glColor4f_(poly_mx2(nb2+1)/32767,poly_mx2(nb2+2)/32767,poly_mx2(nb2+3)/32767,alpha2)
    EndIf
   
    For i=1 To poly_my2(nb2)-5
      glVertex2f_(poly_mx2(nb2+4+i)/xf.f,poly_my2(nb2+4+i)/yf.f)
    Next
    glEnd_()
    nb2+ii
  Wend
 
  ;========================================================
  ;=======================================================
 
  SetGadgetAttribute(#OpenGLGadget, #PB_OpenGL_FlipBuffers, #True)
 
ForEver

;*********************************************************************************************************************************
;*********************************************************************************************************************************
;*********************************************************************************************************************************
;*************************************************************** ******************************************************************
;*********************************************************************************************************************************
;************************************************************************* *******************************************************
;*********************************************************************************************************************************

Procedure Render()
 
  ;Clearing buffers and resetting clear color to remove old graphics from the last frame.
  glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
  ;  glClearColor_(0.2, 0.2, 0.2, 1.0)
  glClearColor_(0,0,0,1)
 
  ;## DRAWING TEXTURES/IMAGES
  ;First enable the Texture system.
  glEnable_(#GL_TEXTURE_2D)
 
  ;This procedure will create a quad and apply a texture to it.
  ;The Texture variable contains the texture created earlier using SetupGLTexture().
  Render2DQuad(Texture1, 0, 0, ImageWidth(Image1), ImageHeight(Image1), -2)
  ; Render2DQuad(Texture2, 0, 0, ImageWidth(Image2), ImageHeight(Image2), -1)
 
  ;After all the textures have been displayed disable the texture system.
  ;Otherwise it will conflict with the non texture graphics.
  glDisable_(#GL_TEXTURE_2D)
 
EndProcedure

Procedure Render2DQuad(OGLTexture.i, StartX.d, StartY.d, Width.i, Height.i, Z.d)
 
  ;The texture is first bound which tells OpenGL to use this texture for any future rendering.
  glBindTexture_(#GL_TEXTURE_2D, OGLTexture)
  glBegin_(#GL_QUADS)
  glColor4f_   (1,1,1,1)
  glNormal3f_  (0,0,1.0)
  glTexCoord2f_(1.0,1.0)
  glVertex3f_  (StartX+Width,StartY,Z)
  glTexCoord2f_(0.0,1.0)
  glVertex3f_  (StartX,StartY,Z)
  glTexCoord2f_(0.0,0.0)
  glVertex3f_  (StartX,StartY+Height,Z)
  glTexCoord2f_(1.0,0.0)
  glVertex3f_  (StartX+Width,StartY+Height,Z)
  glEnd_()
 
EndProcedure

Procedure SetupOpenGL()
 
  glMatrixMode_(#GL_PROJECTION)
 
  glOrtho_(0.0, WindowDim\X, WindowDim\Y, 0.0, -1000.0, 1000.0)
 
  glMatrixMode_(#GL_MODELVIEW)
 
  ; glEnable_(#GL_DEPTH_TEST)
 
  glEnable_(#GL_BLEND)
  glBlendFunc_(#GL_SRC_ALPHA, #GL_ONE_MINUS_SRC_ALPHA)
 
EndProcedure


DataSection
  Data.w 2,9,32767,0,0,0,0,0,32767,0,0,0,1919,0,1919,1079,0,1079,0,9,16384,0,16384,0,16384,0,32767,0,45,44,1863,52,1863,1040,43,1035,0,0,0,0,0,0,0,0
EndDataSection
http://HexaScrabble.com/
!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 5.73LTS - 32 bits
BarryG
Addict
Addict
Posts: 3318
Joined: Thu Apr 18, 2019 8:17 am

Re: Red frame

Post by BarryG »

SPH wrote:I added instructions for rendering the DPI.
It was necessary to compile with an option checked (DPI)
Can you tell me if this is ok : http://xmas.free.fr/red_frame_with_dpi.exe
Nope, it's still missing the right and bottom red sides for me with 125% DPI. I tried your code (with DPI-aware turned on in Compiler Options) and also ran your exe to test. Sorry!
User avatar
SPH
Enthusiast
Enthusiast
Posts: 268
Joined: Tue Jan 04, 2011 6:21 pm

Re: Red frame

Post by SPH »

http://HexaScrabble.com/
!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 5.73LTS - 32 bits
BarryG
Addict
Addict
Posts: 3318
Joined: Thu Apr 18, 2019 8:17 am

Re: Red frame

Post by BarryG »

Yep, you fixed it! All red sides showing on my 125% DPI monitor. Good job.
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1251
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: Red frame

Post by Paul »

Yes, that displays correct here on 4K, 175% DPI
Image Image
User avatar
SPH
Enthusiast
Enthusiast
Posts: 268
Joined: Tue Jan 04, 2011 6:21 pm

Re: Red frame

Post by SPH »

YOUPIIIII, HOURAAAAA !!! :P

I'm the best of the best of the best of the... OOPS : thx for your tests :wink:
http://HexaScrabble.com/
!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 5.73LTS - 32 bits
Nituvious
Addict
Addict
Posts: 1000
Joined: Sat Jul 11, 2009 4:57 am
Location: United States

Re: Red frame

Post by Nituvious »

oddly enough the red border did not appear until after it had finished loading. the grey was there though. :?:
▓▓▓▓▓▒▒▒▒▒░░░░░
User avatar
SPH
Enthusiast
Enthusiast
Posts: 268
Joined: Tue Jan 04, 2011 6:21 pm

Re: Red frame

Post by SPH »

http://HexaScrabble.com/
!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 5.73LTS - 32 bits
Post Reply