Full Screen w/multiple monitors in Ubuntu

Linux specific questions.
danielnice
Posts: 6
Joined: Apr 23, 2018 20:29

Full Screen w/multiple monitors in Ubuntu

Postby danielnice » May 15, 2018 15:43

I'm new to Linux and FreeBASIC.
My past experience is with DOS and BASIC 7.1 (and assembler).

I am evaluating the feasibility of moving a digital signage application from BASIC 7/MASM on DOS to FreeBASIC on Linux.
I might even keep a DOS version based on FreeBASIC.

This test was to see what happens with "full screen" graphics using FreeBASIC.
I am using Ubuntu 16.04 LTS (64 bit) with two screens.

When I run this program:
#INCLUDE "FBGFX.BI"
SCREENRES 640, 480, 32, 2, FB.GFX_FULLSCREEN
LINE (0,0)-(639,479), &H00FF0000, BF
SLEEP

I got the expected red screen on my first monitor.
However, my second monitor became black.

After terminating the FreeBASIC program, I went into System Settings: Displays and found that monitor 2 was now "OFF"

I have several questions:
(1) How can I prevent FreeBASIC from disabling the second monitor? I would like to use it for debugging.
(2) Is there a way I can designate which monitor the full screen FreeBASIC program uses?
(3) I know there is a way to make multiple screen buffers in FreeBASIC, but is there a way to send them to one monitor or the other?
This would allow me to run several digital signs from one PC.

(4) When I am running a fullscreen FreeBASIC program, am I actually using X-Windows? I ask this because I would like to deploy a production version of the program without as much as possible (similar to deploying on DOS).


Thank you for your help.
badidea
Posts: 814
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Full Screen w/multiple monitors in Ubuntu

Postby badidea » May 15, 2018 20:17

Hi, I have only 1 monitor at the moment, so I cannot test things. Some suggestions:

What might work is, creating a normal window (not full screen) with flags FB.GFX_NO_FRAME and (actually or) FB.GFX_ALWAYS_ON_TOP.
For details on setting these flags, see: https://freebasic.net/wiki/wikka.php?wa ... gScreenres

In addition, there is 'ScreenControl' which allows you to set the window position, see example in:
https://freebasic.net/wiki/wikka.php?wa ... eencontrol

Another thing you could try is the FB.GFX_OPENGL driver, see 'ScreenRes' info again. Maybe different behaviour.

It could also depends on the Linux graphics driver and Linux monitor control.
St_W
Posts: 1317
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: Full Screen w/multiple monitors in Ubuntu

Postby St_W » May 15, 2018 22:01

re (4): FreeBasic supports multiple graphics backends, including the good old framebuffer device (fbdev). So you don't need X11 or any other display server if your Linux Distro provides a framebuffer device. If you are running x11 you're probably using the X11 (or openGL, which builds upon x11) driver. See https://freebasic.net/wiki/wikka.php?wakka=GfxLib for an overview and https://freebasic.net/wiki/wikka.php?wa ... eencontrol SET_DRIVER_NAME to set the driver.

re (1)-(3): as far as I know gfxlib2 doesn't support multiple monitors so you probably have to use lower level APIs like the ones gfxlib2 uses internally, depending on the used driver (x11, fbdev, ...) to achieve that. (but I may be wrong on that)
speedfixer
Posts: 286
Joined: Nov 28, 2012 1:27
Location: California

Re: Full Screen w/multiple monitors in Ubuntu

Postby speedfixer » May 16, 2018 16:09

Hi, danielnice

Welcome to FreeBASIC

Yes, FB does multimonitors.
I assume you found the issue with FB turning off your second monitor (other post).

This is a part of my personal libraries. Feel free to steal code, since I stole most of it from the examples and forums. No restrictions.

Code: Select all

type screen_dat             ' size = 80
' all current data
    as long conr            ' rows
    as long conc            ' columns
    as integer cdepth          ' color depth
    as integer bpp             ' bytes per pixel
    as integer hsz             ' horz size - pixels
    as integer vsz             ' vert size - pixels
    as long bg              ' color fg & bg --- when rk_scr_dat updates, it reads the color
    as long fg              ' if the color is set first anywhere
                            ' ... but use pal_choice.cp(0).ppb as 'normal' color pair
    as long curcol
    as long currow
    as long currchar
    as long factor          ' custom setup for big/small char
    as boolean console      ' true if no screen mode set
    wid as any ptr          ' can be cast to any pointer type - does not require any particular predefinition
end type

static shared as screen_dat srcon
common shared ppcon as screen_dat ptr
ppcon = @srcon

declare function rk_scr_dat as string

rk_scr_dat

print
print ppcon->conr, ppcon->conc         ' reported is your console/terminal size
print ppcon->hsz, ppcon->vsz             ' my reported screen size is 4240 x 1440
print

screen 18
'screencontrol 100, 20, 20                     ' left, top
'screencontrol 100, 2100, 720                ' split both screen in middle
screencontrol 100, 3100, 720                ' right, mddle

rk_scr_dat

print
print ppcon->conr, ppcon->conc
print ppcon->hsz, ppcon->vsz      ' reported is correct 640 x 480
print

while inkey = "": sleep 10, 1 : wend

function rk_scr_dat as string
' load/reload the screen data - typically only at screen mode change

    dim as string driver_name
    dim as integer ww, hh, ddd, bbb

    screeninfo ww, hh, ddd, bbb,,, driver_name

' replace w: ppcon->

    (*ppcon).hsz = ww
    (*ppcon).vsz = hh
    (*ppcon).cdepth = ddd
    (*ppcon).bpp = bbb

    if driver_name = "" then
        ppcon->console = true        ' no graphics driver == still in console
                                    ' also, hsz and vsz are desktop pixels, not graphic screen
    else
        ppcon->console = false
    end if

    (*ppcon).curcol = pos
    (*ppcon).currow = csrlin

    (*ppcon).currchar = screen((*ppcon).currow, (*ppcon).curcol, 0)

    (*ppcon).fg = LoWord(color)         ' foreground color
    (*ppcon).bg = HiWord(color)         ' background color

    (*ppcon).conr = hiword(width())     ' total rows, current screen
    (*ppcon).conc = loword(width())     ' total columns, current screen

    ppcon->factor = ppcon->vsz\ppcon->conr

    ppcon->wid = 0
    driver_name = trim(driver_name)

    return driver_name
end function                                                       ' rk_scr_dat


The reported pixel size is the virtual desktop size. My monitors are not same size, so I do have to be careful where I place a screen on the smaller monitor. My setup is Nvidia. Verify that, if yours is not Nvidia, GL reports the 'correct' info.

david
danielnice
Posts: 6
Joined: Apr 23, 2018 20:29

Re: Full Screen w/multiple monitors in Ubuntu

Postby danielnice » May 21, 2018 18:45

Hi speedfixer,

Thank you for your example.
I looked over it (and ran it) today, and I see that it allows me to determine the size of my desktop which expands onto two screens.

However, my problem is that I want to develop a fullscreen FreeBASIC program on one screen, and use the debugger (Insight) on the other.
I would be ok with the FreeBASIC program simply defaulting to the first screen, but it insists on turning off my second screen (!!).

My other problem (looking ahead) would be that I may want to drive two full-screen sessions from one FreeBASIC program.

I understand that I can make a window cover the screen. I may resort to this for debugging purposes, but ultimately I would like to end up with a program that does not run under X-Windows at all and so it would be full screen.

Thank you for your help.

-Daniel Nice
speedfixer
Posts: 286
Joined: Nov 28, 2012 1:27
Location: California

Re: Full Screen w/multiple monitors in Ubuntu

Postby speedfixer » May 31, 2018 0:25

Graphics in Linux without X-windows means you have to roll-your-own with another graphics library.
No X-windows in Linux pretty much means no desktop environment. I doubt you want to reinvent all of those wheels.

FB graphics aren't the best, but they are pretty fast.

1 - What do you want to do that you don't want X-windows?
2 - What is your hardware/software setup that creates your dual-monitor problem?

I have two monitors on 4 systems at home, and another with 3 monitors. Lubuntu. No problems of this type.


david

Return to “Linux”

Who is online

Users browsing this forum: No registered users and 1 guest