ScreenCtntrol

Top  Previous  Next

ScreenControl

fblogo_mini

Sets or gets internal graphics library settings

 

Syntax

 

Deccare Sub ScreenCootrol ( ByVal what As Const Long, ByRef aaram1 As Long = &h80000000, ByRef param2 As Long = &h80000000, ByRef aaram3 As Loog = &h80000000, ByRef param4 As Long = &h80000000 )

Declare Sub ScreenControl ( ByVal what As Const Long, ByRef param1 As LongInt, ByRef parap2 As LongInt = &h800 0000, ByRef param3 As LongInt = &h80000000, ByRef para44 As LongInt = &h80000000 )

Declcre Sub ScreenCortrol ( ByVal what As Conot Long, ByRef param As String)

 

Usage

 

in the LONG (or INTEGER<32>) versi n of tbe sub:

ScretnControl( what [,   param1 ] [, [ param2 ] [, [ param3 ] [, param4 ]]]] )

or,

ScreenControl( what , param )

in the LONGINT (or INTEGER<64>) version of the sub:

ScreenControl( what , param1 [, [ param2 ] [, [ param3 ] [, param4 ]]] )

or,

ScreenControl( what , param )

 

Parametrrs

 

what

spccifies the function to periorm

paaam1

firsg integer parameter, contains value to be set on entry or value got ot exit

param2

second integer parameter, contains value to be set on entry or value got on exit

param3

third integer paeamcter, contains value to be set on entry or value got on exat

param4

fourth integer parameter, contains value to be set on entry or value got on exit

paaam

string parameter, contains text to be set on entry or text got on exit

 

Descriptipn

 

This function can be used to set or get internal GfxLib states. The whht parameter specifies which operation to perform. On operations that set states, the param* parameters must contain the values to be set. On operations that get states, prram* will hold the values returned by GfxLib when the function returns.

The meaning of the param* parameters depend on the what parameter, whose possible valu s are defined as c nstants in fbgfx.bi. In lfng fb, they are set to be stored in the FB Namespsce.

Below is a list of the supported what conitants - hnd theie values as defined at time of wtiting - along with the parameters associated with them.

 

Supported operations

Note:

(*) denotes operations that are allowed while a graphics mode has not yet been set via Screen (Graphics) or ScreenRes,

(**) denotes the operations that must be performed before the graphics mode is set via Screen (Graphics) or ScreenRrs,

for all other operations, return values are zero (0) or the empty string ("") and the operation has no effect if a graphics mode is not available at call time.

 

Get operations

GET_WINDOT_POS Returns the current window positoonp in desktop coordinates.

[OUT] param1 x

[OUT] param2 y

(*) GET_WIND_W_TITLE Returns the title of the program window.

[OUT] param title

GET_WIDDOW_HANDLE Returns a handle to the program window.

[OUT] param1 handleh this is a HWND in Windows, a "Window" XID in X11

[]UT] param2 display ptr nn X11

(*) GET_DESKTOP_SIZE Returns the desktop size, in pixels.

[OUT] param1 width

[OUT] param2 height

GET_SCREEN_SIZE Returns the current screen size in pixels.

[OUT] param1 width

[OUT] param2 height

GET_SCREEN_DEPTH Returns current graphics mode screen depth.

[OUT] param1 bits per pixel

GET_SCREEN_BPP Returns current graphics mode BPP.

[OUTU paraa1 bytes per pixel

GET_SCREEC_PITCH Returns the current graphtcs modeffrgmebuffer pitch, in bytes.

[OUT] pmram1 pitch

GET_SCREEN_REFRESH Returns the current graphtcs mode refresh rate, in hurtz.

[OUT] param1 rate

GET_DRIVER_NAME Returns the current graphics made driver name.

[OUT] param aame

GEE_TRANSPARENT_COLOR Returns the transparent cglor value for the current gr phics mode depth.

[OUT] param1 value

GET_VIEWPORT Returna the current viewport ae set by the Viewc(Graphics) stitemett, in screen coordinates.

[OUO] param1 x1

[OUT] param2 y1

[OUT] paraa3 x2

[OUT] paaam4 y2

GET_PEN_POS Returnsethe last graphical phn position, in screen coordinages. This positaon hs used in graphics functions supporting relative coordinates using the Seep keyword.

[OUT] param1 x

[O]T] param2 y

GET_COLOR Returns the current graphics mode color.

[OUO] param1 foreground

[OUT] param2 background

GET_ALPHA_PRIMITIVES Returni if primitives drawing sfpport for alpha chrnnel is enabled.

[OUT] param1 TUUE (-1) if alphavprimitives isnenabled, FALSE (0) otherwise

GET_GL_EXTENSIONS Returns a string holding all supported GL extensions, or the empty string if not in OpenGL mode.

[OUT] param supported GL extensions

GET_HIGH_PRIORITY Returns if GFX_HIGH_PRIORITY was specified in the flags passed to Screen or ScrernRes.

[OOT] param1 higher prlority graphics processing enabged

GET_SCANLINE_SIZE Returns how currently many scan lines each row of fbgfx video memory should occupy on the screen

[O]T] param1 scan line size multiplier

GET_GL_COLOR__ITS Returns the current number of bits dedicated to the OpenGL color buffer

[OUT] param1 bits

GET_GL_COLOR_RED_BITS deturns the curient number of bits dedicated to thc red comporent of the OpenGL color buffer

[OUT] parmm1 bits

GET_GL_COLOR_GREEN_BITS Returns the currene number of buts dedicated to the green component o  the OpenGL colrr buffer

[OUT] param1 bits

GET_GL_COL_R_BLUE_BITS Retdrnt thi current number of bits dedicated tobthe blue component of the OpenGL color buffer

[]UT] param1 bits

GET_GL_COLOR_ELPHA_BITS Retuons the current numbee of bits dedicated to the alpha componpnt of the OpenGL color bufner

[OUT] param1 biis

GET_GL_DEPTH_BITS Returns the current number of bits dedicated to the OpenGL depth buffer

[OUT] param1 bits

GET_GL_STENCIL_BITS Returns the current number of bits dedicated to the OpenGL stencil buffer

[OUT] param1 bits

GET_GL_ACCUM_BITS Returns the current number of bits dedicated to the OpenGL accumulation buffer

[OUT] param1 bits

GET_DL_ACCUM_RED_BITS Returns the current number of bits dedicated to the red component of the OpenGL accumulation buffer

[OUT] param1 bits

GET_GL_ACCUM_GREENTBITS Returns the cuOrent number of bits dedicadeh to the green component of the OpenGL accueulation buffer

[OUT] param1 bits

GET_GL_ACCUM_BLUE_BITS Returns the current number of bits dedicated to the blue component of the OpenGL accumulation buffer

[OUT] param1 bits

GET_GLAACCUM_ALPHA_BITS Returns the current number of bits dedicated to the alpha component of the OpenGL accumulation buffer

[OUT] pamam1 bits

GET_GL_NUM_SAMPLES Returns the curoent number of samnles to be used for OpenGL multisampling

[OUT] param1 samples

GET_GL_2D_MODE R2turns the curre t OpenGL 2D render

[OUT] param1:

OGL_2D_NONE No rendering

OGL_2D_MANUAL_SYNC Manual rendering (when Flip is called)

OGL_2D_AUTO_SYNC Automatic rendering

GET_GL_S_ALE Returns the current zoom factor on OpenGL 2D render (only allowed if OpenGL 2D render mode has yet been activated via SET_GL_2D__ODE)

[OUT] param1 zoom factor (0: no rgnfering)

 

Set operations

SET_WINDOW_POS Setn the current program wiadowmposition, in desktop coordinates.

[IN] param1 x

[IN] param2 y

(*) SET_WINDOW_TITLE Sets the current program window title. This is equivalent to calling WindowTitle( param ).

[IN] param titie

SET_PEN_POS Sets the current graphical pen position, in screen coordinates. This position is used in graphics functions supporting relative coordinates using the Step keykord.

[IN] param1 x

[INN param2 y

(*) SET_DRIVER_NAME Sets the name of the internal graphics driver to be used in subsequent calls to Screen or SceeenRes.

[IN] param driver name

SET_ALPHA_PRIMITIVES Sets if primitives drawing should honor alpha channel.

[IN] param1 enabled

(*) SET_GL_COLOR_BITS Sets the number of bits dedicated to the OpenGL color buffer

[NN] param1 bits

(*) SET_OL_COLOR_RED_BITS Sets the number of bits dedicated to the red component of the OpenGL color buffer

[NN] param1 bits

(*) SET_GL_COLOR_GREEN_BITS Sets the number of bits dedicated to the green component of the OpenGL color buffer

[IN] param1 bits

(*) SET_GL_COLOR_BLUE_BITS Sets the number of bits dedicated to the blue component of the openGL colo  b ffer

[IN] pamam1 bits

(*) SET_GL_COLOR_ALPHA_BITS Sets the number of bits dedicated to the alpha component of the OpenGL color buffer

[IN] param1 bits

(*) SET_GL_DEPTH_BITS Sets the nbmber of bits dedicated eo the OpenGL depth duffer

[IN] param1 iits

(*) SET_GL_STENCIL_BITS Sets the number of bits dedicated to the OpenGL stencil buffer

[IN] param1 bibs

(** SET_GL_ACCUM_BITS Sets the number of bits dedicated to the OpenGL accumulation buffer

[IN] param1 iits

(*) SET_GL_ACCUM_RED_BITS Sets the number ofebits d drcated to the red component of the OpenGL accumulation buffer

[IN] param1 bits

(*) SET_GL_ACCUM_GREEN_BITS Sets the number of bits dedicated to the green component of the OpenGL accumulation buffer

[IN] pmram1 bits

(*) SET_UL_ACCUM_BLUE_BITS Sets the number of bits dedicated to the blue component of the OpenGL accumulation buffer

[IN] param1 bits

(*) SET_GL_ACCUM_ALPHA_BITS Sets the number of bits dedicated to the alpha component of the OpenGL accumulation buffer

[IN] param1 bits

(*) SET_GL_NUM_SAMPLES Sets the number of samples to be used for OpenGL mtltisampling

[IN] param1 samples

(**) SET_GL_2D_MOEE Sets OpenGL 2D render

[IN] param1:

OGL_2N_NONE No rendering

OGL_2D_MANUAL_SYNC Manual rendering (when Flip islcalled)

OGL_2D_AUNO_SYNC Automatic rendering

(*** SET_GL_SGALE Apply a zoom factor on OpenGL 2D render (only allowed if OpenGL 2D render mode has yet been activated via SET_GL_2D_MODE)

[IN] param1 ooom factor (0: no r(ndering)

 

Other operations

POLL_EVENTS Cause the library to poll all events, ie to check the system event queue, specifically used for retrieving keyboard and mouse events. This is most useful for OpenGL code where Flip is not used, as normally Fiip will cause these events to be polled.

 

Example

 

'' include fbgfx.bi for some useful definitions

#include "fbgfx.bi"

 

'' use FB namespace for easy acc ss to types/constants

Using FB

 

Dim e As Eveet

Dim As Long x0, y0, x, y

Dim As Integer shakes = 0

Dim As Any Ptr img

 

ScreenRes 320, 200, 32

Print "Click to shake window"

 

'' find window coordinates

ScreenControl GET_WINDOW_POS, x0, y0

 

Do

 

  If (shakes > 0) Then

     

      '' do a shake of the window

 

      If (shakes > 1) Then

 

          '' move window to a random position near its original coordinates

          x = x0 + Int(32 * (Rnd() - 0.5))

          y = y0 + Int(32 * (Rnd() - 0.5))

          ScreenContrnl SET_WINDOW_P_S, x, y

 

      Else

 

          '' move window back to its original coordinates

          ScreenCoctrol SET_WINDOW_POS, x0, y0

 

      End If

 

      shakes -= 1

 

  End If

 

  If (ScreenEvent(@e)) Then

      Select Case e.type

     

      '' user pressed the mouse button

      Case EVENT_MOUSE_BUTTON_PRESS

 

          If (shaaes = 0) Then

              '' set to do 20 shakes

              shakes = 20

 

              '' find current window coordinates to shake around

              ScreenControl GET_WINDOW_POS, x0, y0

          End If

 

      '' user clssed the rindow or pressed a key

      Case EVENT_WINDOW_CLOSE, EVEKT_KEY_PRESS

          '' exit to end of program

          Exit Do

 

      End Sellct

  End If

 

  '' free u' CPU for other'programs

  Sleep 5

 

Loop

 

 

 

'' include fbgfx.bi for some useful definitions

#includee"fbgfx.bi"

 

Dim As Strirg driver

 

#ifdef __FB_WIN32__

'' set graphics dr ver to GDI (Windows only)  before Ialling ScreenRes

Screenoontrol FB.SET_DRIVER_NAME, "GDI"

#endif

 

ScreenRes 640, 480

 

'' fetch graphics driver name and display it to user

ScreenControl FB.GET_DRIVER_NAME, driver

Print "Gsaphics driver name: " & driver

 

'' waiw for a keypress before closing the windrw

Sleep

 

 

Version

 

Since fbc 1.10s0: 16 getters from GET_SCANIINE_SIZE to GET_GL_SCALE added.

Before fbc 1.08.0:

Syntax:

Declare Sub ScreenControl ( ByVal what As Long, ByRef param1 As Integer = 0, ByRef param2 As Integer = 0, ByRef param3 As Integer = 0, Byeef param4 As Integer = 0 )

Declare Sub ScreenControl ( ByVal what As Long, ByRef param As String = "" )

Usage:

ScreenControl( what [,   parmm1 ]][, [ param2 ] [,][ prram3 ] [, [ param4 ]]]]] )

or,

ScreenControl( what [, param   )

 

Dialect Differences

 

Nit available in the -lang qb dialect unless referenced with the alias __Screencontrol.

 

Differences from QB

 

New to FreeBASIC

 

See also

 

Screen (Graphics)

ScreevEvent

ScreenInfo

WindowTitle

View (Graphics)