"Fossies" - the Fresh Open Source Software Archive

Member "FreeBASIC-1.08.1-source/doc/manual/cache/KeyPgScreencontrol.wakka" (6 Jul 2021, 13005 Bytes) of package /linux/privat/FreeBASIC-1.08.1-source.tar.xz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "KeyPgScreencontrol.wakka": 1.08.0_vs_1.08.1.

    1 {{fbdoc item="title" value="SCREENCONTROL"}}----
    2 Sets or gets internal graphics library settings
    3 
    4 {{fbdoc item="syntax"}}##
    5 	for fbc version < 1.08:
    6 		[[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 )
    7 		[[KeyPgDeclare|declare]] [[KeyPgSub|sub]] **""ScreenControl""** ( [[KeyPgByval|byval]] what [[KeyPgAs|as]] [[KeyPgLong|long]], [[KeyPgByref|byref]] param [[KeyPgAs|as]] [[KeyPgString|string]] = ##"####"## )
    8 	for fbc version >= 1.08:
    9 		[[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 )
   10 		[[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 )
   11 		[[KeyPgDeclare|declare]] [[KeyPgSub|sub]] **""ScreenControl""** ( [[KeyPgByval|byval]] what [[KeyPgAs|as]] [[KeyPgConstQualifier|const]] [[KeyPgLong|long]], [[KeyPgByref|byref]] param [[KeyPgAs|as]] [[KeyPgString|string]])
   12 ##
   13 {{fbdoc item="usage"}}##
   14 	for fbc version < 1.08:
   15 		**""ScreenControl""**( //what// [, [ //param1// ] [, [ //param2// ] [, [ //param3// ] [, [ //param4// ]]]]] )
   16 			or,
   17 		**""ScreenControl""**( //what// [, //param// ] )
   18 	for fbc version >= 1.08:
   19 		in the LONG (or INTEGER<32>) version of the sub:
   20 			**""ScreenControl""**( //what// [, [ //param1// ] [, [ //param2// ] [, [ //param3// ] [, //param4// ]]]] )
   21 				or,
   22 			**""ScreenControl""**( //what// , //param// )
   23 		in the LONGINT (or INTEGER<64>) version of the sub:
   24 			**""ScreenControl""**( //what// , //param1// [, [ //param2// ] [, [ //param3// ] [, //param4// ]]] )
   25 				or,
   26 			**""ScreenControl""**( //what// , //param// )
   27 ##
   28 {{fbdoc item="param"}}
   29 	##//what//##
   30 		specifies the function to perform
   31 	##//param1//##
   32 		first integer parameter, contains value to be set on entry or value got on exit
   33 	##//param2//##
   34 		second integer parameter, contains value to be set on entry or value got on exit
   35 	##//param3//##
   36 		third integer parameter, contains value to be set on entry or value got on exit
   37 	##//param4//##
   38 		fourth integer parameter, contains value to be set on entry or value got on exit
   39 	##//param//##
   40 		string parameter, contains text to be set on entry or text got on exit
   41 
   42 {{fbdoc item="desc"}}
   43 	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.
   44 	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]]##.
   45 	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.
   46 	
   47 	__Supported operations__
   48 		
   49 		Note:
   50 			(*) denotes operations that are allowed while a graphics mode has not yet been set via [[KeyPgScreengraphics|Screen (Graphics)]] or [[KeyPgScreenres|ScreenRes]],
   51 			(""**"") denotes the operations that must be performed before the graphics mode is set via [[KeyPgScreengraphics|Screen (Graphics)]] or [[KeyPgScreenres|ScreenRes]],
   52 			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.
   53 			
   54 		**Get operations**
   55 	- ##GET_WINDOW_POS## Returns the current window position, in desktop coordinates.
   56 		[OUT] ##//param1//## x
   57 		[OUT] ##//param2//## y
   58 	- (*) ##GET_WINDOW_TITLE## Returns the title of the program window.
   59 		[OUT] ##//param//## title
   60 	- ##GET_WINDOW_HANDLE## Returns a handle to the program window.
   61 		[OUT] ##//param1//## handle; this is a ##HWND## in Windows, a "Window" XID in X11
   62 		[OUT] ##//param2//## display ptr in X11
   63 	- (*) ##GET_DESKTOP_SIZE## Returns the desktop size, in pixels.
   64 		[OUT] ##//param1//## width
   65 		[OUT] ##//param2//## height
   66 	- ##GET_SCREEN_SIZE## Returns the current screen size in pixels.
   67 		[OUT] ##//param1//## width
   68 		[OUT] ##//param2//## height
   69 	- ##GET_SCREEN_DEPTH## Returns current graphics mode screen depth.
   70 		[OUT] ##//param1//## bits per pixel
   71 	- ##GET_SCREEN_BPP## Returns current graphics mode BPP.
   72 		[OUT] ##//param1//## bytes per pixel
   73 	- ##GET_SCREEN_PITCH## Returns the current graphics mode framebuffer pitch, in bytes.
   74 		[OUT] ##//param1//## pitch
   75 	- ##GET_SCREEN_REFRESH## Returns the current graphics mode refresh rate, in hertz.
   76 		[OUT] ##//param1//## rate
   77 	- ##GET_DRIVER_NAME## Returns the current graphics mode driver name.
   78 		[OUT] ##//param//## name
   79 	- ##GET_TRANSPARENT_COLOR## Returns the transparent color value for the current graphics mode depth.
   80 		[OUT] ##//param1//## value
   81 	- ##GET_VIEWPORT## Returns the current viewport as set by the [[KeyPgViewgraphics|View (Graphics)]] statement, in screen coordinates.
   82 		[OUT] ##//param1//## x1
   83 		[OUT] ##//param2//## y1
   84 		[OUT] ##//param3//## x2
   85 		[OUT] ##//param4//## y2
   86 	- ##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.
   87 		[OUT] ##//param1//## x
   88 		[OUT] ##//param2//## y
   89 	- ##GET_COLOR## Returns the current graphics mode color.
   90 		[OUT] ##//param1//## foreground
   91 		[OUT] ##//param2//## background
   92 	- ##GET_ALPHA_PRIMITIVES## Returns if primitives drawing support for alpha channel is enabled.
   93 		[OUT] ##//param1//## ##TRUE## (##-1##) if alpha primitives is enabled, ##FALSE## (##0##) otherwise
   94 	- ##GET_GL_EXTENSIONS## Returns a string holding all supported GL extensions, or the empty string if not in ""OpenGL"" mode.
   95 		[OUT] ##//param//## supported GL extensions
   96 	- ##GET_HIGH_PRIORITY## Returns if ##GFX_HIGH_PRIORITY## was specified in the flags passed to ##[[KeyPgScreengraphics|Screen]]## or ##[[KeyPgScreenres|Screenres]]##.
   97 		[OUT] ##//param1//## higher priority graphics processing enabled
   98 		
   99 		**Set operations**
  100 	- ##SET_WINDOW_POS## Sets the current program window position, in desktop coordinates.
  101 		[IN] ##//param1//## x
  102 		[IN] ##//param2//## y
  103 	- (*) ##SET_WINDOW_TITLE## Sets the current program window title. This is equivalent to calling ##[[KeyPgWindowtitle|WindowTitle]]( //param// )##.
  104 		[IN] ##//param//## title
  105 	- ##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.
  106 		[IN] ##//param1//## x
  107 		[IN] ##//param2//## y
  108 	- (*) ##SET_DRIVER_NAME## Sets the name of the internal graphics driver to be used in subsequent calls to ##[[KeyPgScreengraphics|Screen]]## or ##[[KeyPgScreenres|ScreenRes]]##.
  109 		[IN] ##//param//## driver name
  110 	- ##SET_ALPHA_PRIMITIVES## Sets if primitives drawing should honor alpha channel.
  111 		[IN] ##//param1//## enabled
  112 	- (*) ##SET_GL_COLOR_BITS## Sets the number of bits dedicated to the ""OpenGL"" color buffer
  113 		[IN] ##//param1//## bits
  114 	- (*) ##SET_GL_COLOR_RED_BITS## Sets the number of bits dedicated to the red component of the ""OpenGL"" color buffer
  115 		[IN] ##//param1//## bits
  116 	- (*) ##SET_GL_COLOR_GREEN_BITS## Sets the number of bits dedicated to the green component of the ""OpenGL"" color buffer
  117 		[IN] ##//param1//## bits
  118 	- (*) ##SET_GL_COLOR_BLUE_BITS## Sets the number of bits dedicated to the blue component of the ""OpenGL"" color buffer
  119 		[IN] ##//param1//## bits
  120 	- (*) ##SET_GL_COLOR_ALPHA_BITS## Sets the number of bits dedicated to the alpha component of the ""OpenGL"" color buffer
  121 		[IN] ##//param1//## bits
  122 	- (*) ##SET_GL_DEPTH_BITS## Sets the number of bits dedicated to the ""OpenGL"" depth buffer
  123 		[IN] ##//param1//## bits
  124 	- (*) ##SET_GL_STENCIL_BITS## Sets the number of bits dedicated to the ""OpenGL"" stencil buffer
  125 		[IN] ##//param1//## bits
  126 	- (*) ##SET_GL_ACCUM_BITS## Sets the number of bits dedicated to the ""OpenGL"" accumulation buffer
  127 		[IN] ##//param1//## bits
  128 	- (*) ##SET_GL_ACCUM_RED_BITS## Sets the number of bits dedicated to the red component of the ""OpenGL"" accumulation buffer
  129 		[IN] ##//param1//## bits
  130 	- (*) ##SET_GL_ACCUM_GREEN_BITS## Sets the number of bits dedicated to the green component of the ""OpenGL"" accumulation buffer
  131 		[IN] ##//param1//## bits
  132 	- (*) ##SET_GL_ACCUM_BLUE_BITS## Sets the number of bits dedicated to the blue component of the ""OpenGL"" accumulation buffer
  133 		[IN] ##//param1//## bits
  134 	- (*) ##SET_GL_ACCUM_ALPHA_BITS## Sets the number of bits dedicated to the alpha component of the ""OpenGL"" accumulation buffer
  135 		[IN] ##//param1//## bits
  136 	- (*) ##SET_GL_NUM_SAMPLES## Sets the number of samples to be used for ""OpenGL"" multisampling
  137 		[IN] ##//param1//## samples
  138 	- (""**"") ##SET_GL_2D_MODE## Sets OpenGL 2D render
  139 		[IN] ##//param1//##:
  140 			##OGL_2D_NONE## No rendering
  141 			##OGL_2D_MANUAL_SYNC## Manual rendering (when ##[[KeyPgFlip|Flip]]## is called)
  142 			##OGL_2D_AUTO_SYNC## Automatic rendering
  143 	- (""**"") ##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##)
  144 		[IN] ##//param1//## zoom factor (0: no rendering)
  145 		
  146 		**Other operations**
  147 	- ##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.
  148 
  149 {{fbdoc item="ex"}}
  150 {{fbdoc item="filename" value="examples/manual/gfx/screencontrol.bas"}}%%(freebasic)
  151 '' include fbgfx.bi for some useful definitions
  152 #include "fbgfx.bi"
  153 
  154 '' use FB namespace for easy access to types/constants
  155 using FB
  156 
  157 dim e as EVENT
  158 dim as integer x0, y0, x, y
  159 dim as integer shakes = 0
  160 dim as any ptr img
  161 
  162 screenres 320, 200, 32
  163 print "Click to shake window"
  164 
  165 '' find window coordinates
  166 screencontrol GET_WINDOW_POS, x0, y0
  167 
  168 do
  169 
  170 	if (shakes > 0) then
  171 		
  172 		'' do a shake of the window
  173 
  174 		if (shakes > 1) then
  175 
  176 			'' move window to a random position near its original coordinates
  177 			x = x0 + int(32 * (rnd() - 0.5))
  178 			y = y0 + int(32 * (rnd() - 0.5))
  179 			screencontrol SET_WINDOW_POS, x, y
  180 
  181 		else
  182 
  183 			'' move window back to its original coordinates
  184 			screencontrol SET_WINDOW_POS, x0, y0
  185 
  186 		end if
  187 
  188 		shakes -= 1
  189 
  190 	end if
  191 
  192 	if (screenevent(@e)) then
  193 		select case e.type
  194 		
  195 		'' user pressed the mouse button
  196 		case EVENT_MOUSE_BUTTON_PRESS
  197 
  198 			if (shakes = 0) then
  199 				'' set to do 20 shakes
  200 				shakes = 20
  201 
  202 				'' find current window coordinates to shake around
  203 				screencontrol GET_WINDOW_POS, x0, y0
  204 			end if
  205 
  206 		'' user closed the window or pressed a key
  207 		case EVENT_WINDOW_CLOSE, EVENT_KEY_PRESS
  208 			'' exit to end of program
  209 			exit do
  210 
  211 		end select
  212 	end if
  213 
  214 	'' free up CPU for other programs
  215 	sleep 5
  216 
  217 loop
  218 %%
  219 
  220 {{fbdoc item="filename" value="examples/manual/gfx/screencontrol2.bas"}}%%(freebasic)
  221 '' include fbgfx.bi for some useful definitions
  222 #include "fbgfx.bi"
  223 
  224 dim as string driver
  225 
  226 #ifdef __FB_WIN32__
  227 '' set graphics driver to GDI (Win32 only), before calling ScreenRes
  228 screencontrol FB.SET_DRIVER_NAME, "GDI"
  229 #endif
  230 
  231 screenres 640, 480
  232 
  233 '' fetch graphics driver name and display it to user
  234 screencontrol FB.GET_DRIVER_NAME, driver
  235 print "Graphics driver name: " & driver
  236 
  237 '' wait for a keypress before closing the window
  238 sleep
  239 %%
  240 
  241 {{fbdoc item="lang"}}
  242 	- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Screencontrol""**##.
  243 
  244 {{fbdoc item="diff"}}
  245 	- New to ""FreeBASIC""
  246 
  247 {{fbdoc item="see"}}
  248 	- ##[[KeyPgScreengraphics|Screen (Graphics)]]##
  249 	- ##[[KeyPgScreenevent|ScreenEvent]]##
  250 	- ##[[KeyPgScreeninfo|ScreenInfo]]##
  251 	- ##[[KeyPgWindowtitle|WindowTitle]]##
  252 	- ##[[KeyPgViewgraphics|View (Graphics)]]##
  253 
  254 {{fbdoc item="back" value="CatPgGfxScreen|Screen Functions"}}