{{fbdoc item="title" value="SCREENCONTROL"}}----
Sets or gets internal graphics library settings

{{fbdoc item="syntax"}}##
	for fbc version < 1.08:
		[[KeyPgDeclare|declare]] [[KeyPgSub|sub]] **""ScreenControl""** ( [[KeyPgByval|byval]] what [[KeyPgAs|as]] [[KeyPgLong|long]], [[KeyPgByref|byref]] param1 [[KeyPgAs|as]] [[KeyPgInteger|integer]] = 0, [[KeyPgByref|byref]] param2 [[KeyPgAs|as]] [[KeyPgInteger|integer]] = 0, [[KeyPgByref|byref]] param3 [[KeyPgAs|as]] [[KeyPgInteger|integer]] = 0, [[KeyPgByref|byref]] param4 [[KeyPgAs|as]] [[KeyPgInteger|integer]] = 0 )
		[[KeyPgDeclare|declare]] [[KeyPgSub|sub]] **""ScreenControl""** ( [[KeyPgByval|byval]] what [[KeyPgAs|as]] [[KeyPgLong|long]], [[KeyPgByref|byref]] param [[KeyPgAs|as]] [[KeyPgString|string]] = ##"####"## )
	for fbc version >= 1.08:
		[[KeyPgDeclare|declare]] [[KeyPgSub|sub]] **""ScreenControl""** ( [[KeyPgByval|byval]] what [[KeyPgAs|as]] [[KeyPgConstQualifier|const]] [[KeyPgLong|long]], [[KeyPgByref|byref]] param1 [[KeyPgAs|as]] [[KeyPgLong|long]] = &h80000000, [[KeyPgByref|byref]] param2 [[KeyPgAs|as]] [[KeyPgLong|long]] = &h80000000, [[KeyPgByref|byref]] param3 [[KeyPgAs|as]] [[KeyPgLong|long]] = &h80000000, [[KeyPgByref|byref]] param4 [[KeyPgAs|as]] [[KeyPgLong|long]] = &h80000000 )
		[[KeyPgDeclare|declare]] [[KeyPgSub|sub]] **""ScreenControl""** ( [[KeyPgByval|byval]] what [[KeyPgAs|as]] [[KeyPgConstQualifier|const]] [[KeyPgLong|long]], [[KeyPgByref|byref]] param1 [[KeyPgAs|as]] [[KeyPgLongint|longint]], [[KeyPgByref|byref]] param2 [[KeyPgAs|as]] [[KeyPgLongint|longint]] = &h80000000, [[KeyPgByref|byref]] param3 [[KeyPgAs|as]] [[KeyPgLongint|longint]] = &h80000000, [[KeyPgByref|byref]] param4 [[KeyPgAs|as]] [[KeyPgLongint|longint]] = &h80000000 )
		[[KeyPgDeclare|declare]] [[KeyPgSub|sub]] **""ScreenControl""** ( [[KeyPgByval|byval]] what [[KeyPgAs|as]] [[KeyPgConstQualifier|const]] [[KeyPgLong|long]], [[KeyPgByref|byref]] param [[KeyPgAs|as]] [[KeyPgString|string]])
##
{{fbdoc item="usage"}}##
	for fbc version < 1.08:
		**""ScreenControl""**( //what// [, [ //param1// ] [, [ //param2// ] [, [ //param3// ] [, [ //param4// ]]]]] )
			or,
		**""ScreenControl""**( //what// [, //param// ] )
	for fbc version >= 1.08:
		in the LONG (or INTEGER<32>) version of the sub:
			**""ScreenControl""**( //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// )
##
{{fbdoc item="param"}}
	##//what//##
		specifies the function to perform
	##//param1//##
		first integer parameter, contains value to be set on entry or value got on exit
	##//param2//##
		second integer parameter, contains value to be set on entry or value got on exit
	##//param3//##
		third integer parameter, contains value to be set on entry or value got on exit
	##//param4//##
		fourth integer parameter, contains value to be set on entry or value got on exit
	##//param//##
		string parameter, contains text to be set on entry or text got on exit

{{fbdoc item="desc"}}
	This function can be used to set or get internal ""GfxLib"" states. The ##//what//## 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, ##//param*//## will hold the values returned by ""GfxLib"" when the function returns.
	The meaning of the ##//param*//## parameters depend on the ##//what//## parameter, whose possible values are defined as constants in ##fbgfx.bi##.  In //[[CompilerDialects|lang fb]]//, they are set to be stored in the ##FB## ##[[KeyPgNamespace|Namespace]]##.
	Below is a list of the supported ##//what//## constants - and their values as defined at time of writing - 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 [[KeyPgScreengraphics|Screen (Graphics)]] or [[KeyPgScreenres|ScreenRes]],
			(""**"") denotes the operations that must be performed before the graphics mode is set via [[KeyPgScreengraphics|Screen (Graphics)]] or [[KeyPgScreenres|ScreenRes]],
			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_WINDOW_POS## Returns the current window position, in desktop coordinates.
		[OUT] ##//param1//## x
		[OUT] ##//param2//## y
	- (*) ##GET_WINDOW_TITLE## Returns the title of the program window.
		[OUT] ##//param//## title
	- ##GET_WINDOW_HANDLE## Returns a handle to the program window.
		[OUT] ##//param1//## handle; this is a ##HWND## in Windows, a "Window" XID in X11
		[OUT] ##//param2//## display ptr in 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.
		[OUT] ##//param1//## bytes per pixel
	- ##GET_SCREEN_PITCH## Returns the current graphics mode framebuffer pitch, in bytes.
		[OUT] ##//param1//## pitch
	- ##GET_SCREEN_REFRESH## Returns the current graphics mode refresh rate, in hertz.
		[OUT] ##//param1//## rate
	- ##GET_DRIVER_NAME## Returns the current graphics mode driver name.
		[OUT] ##//param//## name
	- ##GET_TRANSPARENT_COLOR## Returns the transparent color value for the current graphics mode depth.
		[OUT] ##//param1//## value
	- ##GET_VIEWPORT## Returns the current viewport as set by the [[KeyPgViewgraphics|View (Graphics)]] statement, in screen coordinates.
		[OUT] ##//param1//## x1
		[OUT] ##//param2//## y1
		[OUT] ##//param3//## x2
		[OUT] ##//param4//## y2
	- ##GET_PEN_POS## Returns the last graphical pen position, in screen coordinates. This position is used in graphics functions supporting relative coordinates using the ##[[KeyPgStep|Step]]## keyword.
		[OUT] ##//param1//## x
		[OUT] ##//param2//## y
	- ##GET_COLOR## Returns the current graphics mode color.
		[OUT] ##//param1//## foreground
		[OUT] ##//param2//## background
	- ##GET_ALPHA_PRIMITIVES## Returns if primitives drawing support for alpha channel is enabled.
		[OUT] ##//param1//## ##TRUE## (##-1##) if alpha primitives is enabled, ##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 ##[[KeyPgScreengraphics|Screen]]## or ##[[KeyPgScreenres|Screenres]]##.
		[OUT] ##//param1//## higher priority graphics processing enabled
		
		**Set operations**
	- ##SET_WINDOW_POS## Sets the current program window position, in desktop coordinates.
		[IN] ##//param1//## x
		[IN] ##//param2//## y
	- (*) ##SET_WINDOW_TITLE## Sets the current program window title. This is equivalent to calling ##[[KeyPgWindowtitle|WindowTitle]]( //param// )##.
		[IN] ##//param//## title
	- ##SET_PEN_POS## Sets the current graphical pen position, in screen coordinates. This position is used in graphics functions supporting relative coordinates using the ##[[KeyPgStep|Step]]## keyword.
		[IN] ##//param1//## x
		[IN] ##//param2//## y
	- (*) ##SET_DRIVER_NAME## Sets the name of the internal graphics driver to be used in subsequent calls to ##[[KeyPgScreengraphics|Screen]]## or ##[[KeyPgScreenres|ScreenRes]]##.
		[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
		[IN] ##//param1//## bits
	- (*) ##SET_GL_COLOR_RED_BITS## Sets the number of bits dedicated to the red component of the ""OpenGL"" color buffer
		[IN] ##//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"" color buffer
		[IN] ##//param1//## 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 number of bits dedicated to the ""OpenGL"" depth buffer
		[IN] ##//param1//## bits
	- (*) ##SET_GL_STENCIL_BITS## Sets the number of bits dedicated to the ""OpenGL"" stencil buffer
		[IN] ##//param1//## bits
	- (*) ##SET_GL_ACCUM_BITS## Sets the number of bits dedicated to the ""OpenGL"" accumulation buffer
		[IN] ##//param1//## bits
	- (*) ##SET_GL_ACCUM_RED_BITS## Sets the number of bits dedicated 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] ##//param1//## bits
	- (*) ##SET_GL_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"" multisampling
		[IN] ##//param1//## samples
	- (""**"") ##SET_GL_2D_MODE## Sets OpenGL 2D render
		[IN] ##//param1//##:
			##OGL_2D_NONE## No rendering
			##OGL_2D_MANUAL_SYNC## Manual rendering (when ##[[KeyPgFlip|Flip]]## is called)
			##OGL_2D_AUTO_SYNC## Automatic rendering
	- (""**"") ##SET_GL_SCALE## 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//## zoom factor (0: no rendering)
		
		**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 ##[[KeyPgFlip|Flip]]## is not used, as normally ##[[KeyPgFlip|Flip]]## will cause these events to be polled.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/gfx/screencontrol.bas"}}%%(freebasic)
'' include fbgfx.bi for some useful definitions
#include "fbgfx.bi"

'' use FB namespace for easy access to types/constants
using FB

dim e as EVENT
dim as integer 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))
			screencontrol SET_WINDOW_POS, x, y

		else

			'' move window back to its original coordinates
			screencontrol 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 (shakes = 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 closed the window or pressed a key
		case EVENT_WINDOW_CLOSE, EVENT_KEY_PRESS
			'' exit to end of program
			exit do

		end select
	end if

	'' free up CPU for other programs
	sleep 5

loop
%%

{{fbdoc item="filename" value="examples/manual/gfx/screencontrol2.bas"}}%%(freebasic)
'' include fbgfx.bi for some useful definitions
#include "fbgfx.bi"

dim as string driver

#ifdef __FB_WIN32__
'' set graphics driver to GDI (Win32 only), before calling ScreenRes
screencontrol 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 "Graphics driver name: " & driver

'' wait for a keypress before closing the window
sleep
%%

{{fbdoc item="lang"}}
	- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Screencontrol""**##.

{{fbdoc item="diff"}}
	- New to ""FreeBASIC""

{{fbdoc item="see"}}
	- ##[[KeyPgScreengraphics|Screen (Graphics)]]##
	- ##[[KeyPgScreenevent|ScreenEvent]]##
	- ##[[KeyPgScreeninfo|ScreenInfo]]##
	- ##[[KeyPgWindowtitle|WindowTitle]]##
	- ##[[KeyPgViewgraphics|View (Graphics)]]##

{{fbdoc item="back" value="CatPgGfxScreen|Screen Functions"}}