FULLSCREEN: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
No edit summary
m (Mirror ON|OFF formatting in other wiki pages)
 
(6 intermediate revisions by 2 users not shown)
Line 4: Line 4:


{{PageSyntax}}
{{PageSyntax}}
:[[_FULLSCREEN]] [''_STRETCH | _SQUAREPIXELS| _OFF''][, ''_SMOOTH'']
:[[_FULLSCREEN]] [''_STRETCH|_SQUAREPIXELS|_OFF''][, ''_SMOOTH'']




{{Parameters}}
{{PageParameters}}
* {{Parameter|_STRETCH}} default first choice attempts to mimic QBasic's full screens if possible. [[_FULLSCREEN (function)]] returns 1.
* {{Parameter|_STRETCH}} default first choice attempts to mimic QBasic's full screens if possible. [[_FULLSCREEN (function)]] returns 1.
* {{Parameter|_SQUAREPIXELS}} alternate choice enlarges the pixels into squares on some monitors. [[_FULLSCREEN (function)|_FULLSCREEN]] returns 2
* {{Parameter|_SQUAREPIXELS}} alternate choice enlarges the pixels into squares on some monitors. [[_FULLSCREEN (function)|_FULLSCREEN]] returns 2
Line 26: Line 26:
''Example 1:'' Setting the screen mode first prevents enlargement of the desktop before the program window is set:
''Example 1:'' Setting the screen mode first prevents enlargement of the desktop before the program window is set:
{{CodeStart}}
{{CodeStart}}
{{Cl|SCREEN}} 12
{{Cl|SCREEN}} {{Text|12|#F580B1}}
{{Cl|_FULLSCREEN}}
{{Cl|_FULLSCREEN}}
{{Cl|IF...THEN|IF}} {{Cl|_FULLSCREEN (function)|_FULLSCREEN}} = 0 {{Cl|THEN}} {{Cl|_FULLSCREEN}} _OFF 'check that a full screen mode initialized
{{Cl|IF}} {{Cl|_FULLSCREEN (function)|_FULLSCREEN}} = {{Text|0|#F580B1}} {{Cl|THEN}} {{Cl|_FULLSCREEN}} {{Cl|_OFF}} {{Text|<nowiki>'check that a full screen mode initialized</nowiki>|#919191}}


{{Cl|LINE}} (100, 100)-(500, 400), 13, BF
{{Cl|LINE}} ({{Text|100|#F580B1}}, {{Text|100|#F580B1}})-({{Text|500|#F580B1}}, {{Text|400|#F580B1}}), {{Text|13|#F580B1}}, BF
{{CodeEnd}}
{{CodeEnd}}


----


''Example 2:'' How fonts and _FULLSCREEN affect the program's window size.
''Example 2:'' How fonts and _FULLSCREEN affect the program's window size.
{{CodeStart}}
{{CodeStart}}
{{Cl|SCREEN (statement)|SCREEN}} 0
{{Cl|SCREEN}} {{Text|0|#F580B1}}
{{Cl|DO}}
{{Cl|DO}}
  {{Cl|PRINT}}
    {{Cl|PRINT}}
  {{Cl|LINE INPUT}} "Enter MODE 1) ENLARGE WINDOW  2) FULL _SQUAREPIXELS  3) FULL _STRETCH: ", WMODE$
    {{Cl|LINE INPUT}} {{Text|<nowiki>"Enter MODE 1) ENLARGE WINDOW  2) FULL _SQUAREPIXELS  3) FULL _STRETCH: "</nowiki>|#FFB100}}, WMODE$
  {{Cl|PRINT}}
    {{Cl|PRINT}}
  {{Cl|IF}} WMODE$ = "1" {{Cl|THEN}} {{Cl|INPUT (file mode)|INPUT}} "SIZE 1 {{Cl|TO}} 9: ", ENLARGE%
    {{Cl|IF}} WMODE$ = {{Text|<nowiki>"1"</nowiki>|#FFB100}} {{Cl|THEN}} {{Cl|INPUT}} {{Text|<nowiki>"SIZE 1 TO 9: "</nowiki>|#FFB100}}, ENLARGE%


  {{Cl|SELECT CASE}} ENLARGE%
    {{Cl|SELECT CASE}} ENLARGE%
    {{Cl|CASE}} 1, 2, 3, 4, 5: STYLE$ = "MONOSPACE, BOLD"
        {{Cl|CASE}} {{Text|1|#F580B1}}, {{Text|2|#F580B1}}, {{Text|3|#F580B1}}, {{Text|4|#F580B1}}, {{Text|5|#F580B1}}: STYLE$ = {{Text|<nowiki>"MONOSPACE, BOLD"</nowiki>|#FFB100}}
    {{Cl|CASE}} 6, 7, 8, 9: STYLE$ = "MONOSPACE"
        {{Cl|CASE}} {{Text|6|#F580B1}}, {{Text|7|#F580B1}}, {{Text|8|#F580B1}}, {{Text|9|#F580B1}}: STYLE$ = {{Text|<nowiki>"MONOSPACE"</nowiki>|#FFB100}}
    {{Cl|CASE ELSE}}: STYLE$ = "MONOSPACE"
        {{Cl|CASE ELSE}}: STYLE$ = {{Text|<nowiki>"MONOSPACE"</nowiki>|#FFB100}}
  {{Cl|END SELECT}}
    {{Cl|END SELECT}}


  {{Cl|SELECT CASE}} WMODE$
    {{Cl|SELECT CASE}} WMODE$
    {{Cl|CASE}} "1"
        {{Cl|CASE}} {{Text|<nowiki>"1"</nowiki>|#FFB100}}
      full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}}
            full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}}
      {{Cl|IF}} full > 0 {{Cl|THEN}} {{Cl|_FULLSCREEN}} _OFF
            {{Cl|IF}} full > {{Text|0|#F580B1}} {{Cl|THEN}} {{Cl|_FULLSCREEN}} {{Cl|_OFF}}
      f& = {{Cl|_LOADFONT}}("c:\windows\fonts\lucon.ttf", 13 + ENLARGE%, STYLE$)
            f& = {{Cl|_LOADFONT}}({{Text|<nowiki>"c:\windows\fonts\lucon.ttf"</nowiki>|#FFB100}}, {{Text|13|#F580B1}} + ENLARGE%, STYLE$)
      {{Cl|_FONT}} f&
            {{Cl|_FONT}} f&
    {{Cl|CASE}} "2"
        {{Cl|CASE}} {{Text|<nowiki>"2"</nowiki>|#FFB100}}
      {{Cl|_FULLSCREEN}} _SQUAREPIXELS
            {{Cl|_FULLSCREEN}} {{Cl|_SQUAREPIXELS}}
      full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}}
            full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}}
      {{Cl|IF}} full = 0 {{Cl|THEN}} {{Cl|GOSUB}} FCHECK
            {{Cl|IF}} full = {{Text|0|#F580B1}} {{Cl|THEN}} {{Cl|GOSUB}} FCHECK
    {{Cl|CASE}} "3"
        {{Cl|CASE}} {{Text|<nowiki>"3"</nowiki>|#FFB100}}
      {{Cl|_FULLSCREEN}} _STRETCH
            {{Cl|_FULLSCREEN}} {{Cl|_STRETCH}}
      full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}}
            full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}}
      {{Cl|IF}} full = 0 {{Cl|THEN}} {{Cl|GOSUB}} FCHECK
            {{Cl|IF}} full = {{Text|0|#F580B1}} {{Cl|THEN}} {{Cl|GOSUB}} FCHECK
  {{Cl|END SELECT}}
    {{Cl|END SELECT}}


  mode = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}}
    mode = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}}
  {{Cl|PRINT}}
    {{Cl|PRINT}}
  {{Cl|PRINT}} "_FULLSCREEN mode ="; mode,
    {{Cl|PRINT}} {{Text|<nowiki>"_FULLSCREEN mode ="</nowiki>|#FFB100}}; mode,
  {{Cl|PRINT}} "PRESS ESC {{Cl|TO}} {{Cl|END}} {{Cl|OR}} ENTER {{Cl|TO}} CONTINUE..."
    {{Cl|PRINT}} {{Text|<nowiki>"PRESS ESC TO END OR ENTER TO CONTINUE..."</nowiki>|#FFB100}}


  {{Cl|DO}}: {{Cl|SLEEP}}: B$ = {{Cl|INKEY$}}: {{Cl|LOOP}} {{Cl|UNTIL}} B$ = {{Cl|CHR$}}(13) {{Cl|OR}} B$ = {{Cl|CHR$}}(27)
    {{Cl|DO}}: {{Cl|SLEEP}}: B$ = {{Cl|INKEY$}}: {{Cl|DO...LOOP|LOOP UNTIL}} B$ = {{Cl|CHR$}}({{Text|13|#F580B1}}) {{Cl|OR (boolean)|OR}} B$ = {{Cl|CHR$}}({{Text|27|#F580B1}})


  {{Cl|GOSUB}} ClearFont
    {{Cl|GOSUB}} ClearFont


{{Cl|LOOP}} {{Cl|UNTIL}} B$ = {{Cl|CHR$}}(27)
{{Cl|DO...LOOP|LOOP UNTIL}} B$ = {{Cl|CHR$}}({{Text|27|#F580B1}})
ClearFont
{{Cl|GOSUB}} ClearFont
{{Cl|END}}
{{Cl|END}}


FCHECK:
FCHECK:
Z3 = timer
Z3 = {{Cl|TIMER (function)|TIMER}}
{{Cl|DO}}
{{Cl|DO}}
{{Cl|IF}} {{Cl|TIMER (statement)|TIMER }}< Z3 {{Cl|THEN}} Z3 = Z3 - {{Cl|TIMER}}
    {{Cl|IF}} {{Cl|TIMER (function)|TIMER}} < Z3 {{Cl|THEN}} Z3 = Z3 - {{Cl|TIMER (function)|TIMER}}
{{Cl|IF}} {{Cl|TIMER (statement)|TIMER }}- Z3 > 4 {{Cl|THEN}} {{Cl|EXIT DO}}
    {{Cl|IF}} {{Cl|TIMER (function)|TIMER}} - Z3 > {{Text|4|#F580B1}} {{Cl|THEN}} {{Cl|EXIT DO}}
{{Cl|LOOP}}
{{Cl|LOOP}}
full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}}
full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}}
{{Cl|IF}} full = 0 {{Cl|THEN}} {{Cl|_FULLSCREEN}} _{{Cl|OFF}}: {{Cl|SOUND}} 100, .75
{{Cl|IF}} full = {{Text|0|#F580B1}} {{Cl|THEN}} {{Cl|_FULLSCREEN}} {{Cl|_OFF}}: {{Cl|SOUND}} {{Text|100|#F580B1}}, {{Text|.75|#F580B1}}
{{Cl|RETURN}}
{{Cl|RETURN}}


ClearFont:
ClearFont:
{{Cl|IF}} f& > 0 {{Cl|THEN}}
{{Cl|IF}} f& > {{Text|0|#F580B1}} {{Cl|THEN}}
     {{Cl|_FONT}} 16 'select inbuilt 8x16 default font
     {{Cl|_FONT}} {{Text|16|#F580B1}} {{Text|<nowiki>'select inbuilt 8x16 default font</nowiki>|#919191}}
     {{Cl|_FREEFONT}} f&
     {{Cl|_FREEFONT}} f&
{{Cl|END IF}}
{{Cl|END IF}}
{{Cl|RETURN}}
{{Cl|RETURN}}
{{CodeEnd}}
{{CodeEnd}}


----


''Example 3:'' Testing all fullscreen methods.
''Example 3:'' Testing all fullscreen methods.
{{CodeStart}}
{{CodeStart}}
{{Cl|PRINT}} "Hello, world!"
{{Cl|PRINT}} {{Text|<nowiki>"Hello, world!"</nowiki>|#FFB100}}
{{Cl|PRINT}} "Hit 1 for windowed mode;
{{Cl|PRINT}} {{Text|<nowiki>"Hit 1 for windowed mode;"</nowiki>|#FFB100}}
{{Cl|PRINT}} "    2 for _STRETCH"
{{Cl|PRINT}} {{Text|<nowiki>"    2 for _STRETCH"</nowiki>|#FFB100}}
{{Cl|PRINT}} "    3 for _SQUAREPIXELS"
{{Cl|PRINT}} {{Text|<nowiki>"    3 for _SQUAREPIXELS"</nowiki>|#FFB100}}
{{Cl|PRINT}} "    4 for _STRETCH, _SMOOTH"
{{Cl|PRINT}} {{Text|<nowiki>"    4 for _STRETCH, _SMOOTH"</nowiki>|#FFB100}}
{{Cl|PRINT}} "    5 for _SQUAREPIXELS, _SMOOTH"
{{Cl|PRINT}} {{Text|<nowiki>"    5 for _SQUAREPIXELS, _SMOOTH"</nowiki>|#FFB100}}
{{Cl|DO}}
{{Cl|DO}}
     k$ = {{Cl|INKEY$}}
     k$ = {{Cl|INKEY$}}
     {{Cl|SELECT CASE}} {{Cl|VAL}}(k$)
     {{Cl|SELECT CASE}} {{Cl|VAL}}(k$)
         {{Cl|CASE}} 1
         {{Cl|CASE}} {{Text|1|#F580B1}}
             {{Cl|_FULLSCREEN}} _OFF
             {{Cl|_FULLSCREEN}} {{Cl|_OFF}}
         {{Cl|CASE}} 2
         {{Cl|CASE}} {{Text|2|#F580B1}}
             {{Cl|_FULLSCREEN}} _STRETCH
             {{Cl|_FULLSCREEN}} {{Cl|_STRETCH}}
         {{Cl|CASE}} 3
         {{Cl|CASE}} {{Text|3|#F580B1}}
             {{Cl|_FULLSCREEN}} _SQUAREPIXELS
             {{Cl|_FULLSCREEN}} {{Cl|_SQUAREPIXELS}}
         {{Cl|CASE}} 4
         {{Cl|CASE}} {{Text|4|#F580B1}}
             {{Cl|_FULLSCREEN}} _STRETCH, _SMOOTH
             {{Cl|_FULLSCREEN}} {{Cl|_STRETCH}} , {{Cl|_SMOOTH (function)|_SMOOTH}}
         {{Cl|CASE}} 5
         {{Cl|CASE}} {{Text|5|#F580B1}}
             {{Cl|_FULLSCREEN}} _SQUAREPIXELS, _SMOOTH
             {{Cl|_FULLSCREEN}} {{Cl|_SQUAREPIXELS}} , {{Cl|_SMOOTH (function)|_SMOOTH}}
     {{Cl|END SELECT}}
     {{Cl|END SELECT}}
     {{Cl|_LIMIT}} 30
     {{Cl|_LIMIT}} {{Text|30|#F580B1}}
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|_EXIT (function)|_EXIT}}
{{Cl|DO...LOOP|LOOP UNTIL}} {{Cl|_EXIT (function)|_EXIT}}
{{Cl|SYSTEM}}{{CodeEnd}}
{{Cl|SYSTEM}}
{{CodeEnd}}





Latest revision as of 02:41, 8 November 2024

The _FULLSCREEN statement attempts to make the program window fullscreen.


Syntax

_FULLSCREEN [_STRETCH|_SQUAREPIXELS|_OFF][, _SMOOTH]


Parameters

  • _STRETCH default first choice attempts to mimic QBasic's full screens if possible. _FULLSCREEN (function) returns 1.
  • _SQUAREPIXELS alternate choice enlarges the pixels into squares on some monitors. _FULLSCREEN returns 2
  • _OFF turns _FULLSCREEN off after full screen has been enabled. _FULLSCREEN (function) returns 0.
  • Second optional parameter _SMOOTH applies antialiasing to the stretched screen.


Description

  • Set the SCREEN mode and text WIDTH when necessary first. Otherwise there may be desktop view issues.
  • _FULLSCREEN with no parameters chooses _STRETCH or _SQUAREPIXELS (prioritizes _STRETCH to mimic QBasic if possible)
  • Check the fullscreen mode with the _FULLSCREEN function in your programs when a method is required.
  • It is advisable to get input from the user to confirm that fullscreen was completed or there were possible monitor incompatibilities.
  • If fullscreen is not confirmed with a _FULLSCREEN (function) return greater than 0, then disable with _FULLSCREEN _OFF.
  • NOTE: _FULLSCREEN can also be affected by custom _FONT size settings and make program screens too large.


Examples

Example 1: Setting the screen mode first prevents enlargement of the desktop before the program window is set:

SCREEN 12
_FULLSCREEN
IF _FULLSCREEN = 0 THEN _FULLSCREEN _OFF 'check that a full screen mode initialized

LINE (100, 100)-(500, 400), 13, BF

Example 2: How fonts and _FULLSCREEN affect the program's window size.

SCREEN 0
DO
    PRINT
    LINE INPUT "Enter MODE 1) ENLARGE WINDOW  2) FULL _SQUAREPIXELS  3) FULL _STRETCH: ", WMODE$
    PRINT
    IF WMODE$ = "1" THEN INPUT "SIZE 1 TO 9: ", ENLARGE%

    SELECT CASE ENLARGE%
        CASE 1, 2, 3, 4, 5: STYLE$ = "MONOSPACE, BOLD"
        CASE 6, 7, 8, 9: STYLE$ = "MONOSPACE"
        CASE ELSE: STYLE$ = "MONOSPACE"
    END SELECT

    SELECT CASE WMODE$
        CASE "1"
            full = _FULLSCREEN
            IF full > 0 THEN _FULLSCREEN _OFF
            f& = _LOADFONT("c:\windows\fonts\lucon.ttf", 13 + ENLARGE%, STYLE$)
            _FONT f&
        CASE "2"
            _FULLSCREEN _SQUAREPIXELS
            full = _FULLSCREEN
            IF full = 0 THEN GOSUB FCHECK
        CASE "3"
            _FULLSCREEN _STRETCH
            full = _FULLSCREEN
            IF full = 0 THEN GOSUB FCHECK
    END SELECT

    mode = _FULLSCREEN
    PRINT
    PRINT "_FULLSCREEN mode ="; mode,
    PRINT "PRESS ESC TO END OR ENTER TO CONTINUE..."

    DO: SLEEP: B$ = INKEY$: LOOP UNTIL B$ = CHR$(13) OR B$ = CHR$(27)

    GOSUB ClearFont

LOOP UNTIL B$ = CHR$(27)
GOSUB ClearFont
END

FCHECK:
Z3 = TIMER
DO
    IF TIMER < Z3 THEN Z3 = Z3 - TIMER
    IF TIMER - Z3 > 4 THEN EXIT DO
LOOP
full = _FULLSCREEN
IF full = 0 THEN _FULLSCREEN _OFF: SOUND 100, .75
RETURN

ClearFont:
IF f& > 0 THEN
    _FONT 16 'select inbuilt 8x16 default font
    _FREEFONT f&
END IF
RETURN

Example 3: Testing all fullscreen methods.

PRINT "Hello, world!"
PRINT "Hit 1 for windowed mode;"
PRINT "    2 for _STRETCH"
PRINT "    3 for _SQUAREPIXELS"
PRINT "    4 for _STRETCH, _SMOOTH"
PRINT "    5 for _SQUAREPIXELS, _SMOOTH"
DO
    k$ = INKEY$
    SELECT CASE VAL(k$)
        CASE 1
            _FULLSCREEN _OFF
        CASE 2
            _FULLSCREEN _STRETCH
        CASE 3
            _FULLSCREEN _SQUAREPIXELS
        CASE 4
            _FULLSCREEN _STRETCH , _SMOOTH
        CASE 5
            _FULLSCREEN _SQUAREPIXELS , _SMOOTH
    END SELECT
    _LIMIT 30
LOOP UNTIL _EXIT
SYSTEM


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link