Graphics question.

General FreeBASIC programming questions.
Achaean
Posts: 51
Joined: Aug 02, 2017 12:54

Graphics question.

Post by Achaean »

Hi! :-)

I'm trying to do some graphics, with the command "ScreenRes". I know how to do with "SCREEN", but since "ScreenRes" provides better possibilities, I was trying to familiarize myself with it.

At this program, I'm printing the "hello world" at graphics screen:

Code: Select all

ScreenRes 320, 200
Print "Hello world!!"
Sleep
So far , so good. Then I tried to do the same thing, going full-screen:

Code: Select all

#include "fbgfx.bi"
#if __FB_LANG__ = "fb"
Using FB '' Screen mode flags are in the FB namespace in lang FB
#endif

ScreenRes 320, 200, (GFX_FULLSCREEN)
Print "Hello world!!"
Sleep
Apparently, didn't work!
Ehm...Why???
What I'm doing wrong? :-)
TIA!
A.

EDIT:
I tried also with bigger resolutions (that SCREENLIST says that are supported. eg.1024X768). Nothing changes.

Sidequestion:
I'm suspecting that it's related, although I'm not sure.
The manual says that GfxLib defaults to OpenGL, but can alternatively used X11 or XBDev (on Linux).
Supposedly with ScreenControl, but I don't quite understand the procedure! :-)
Anyone knows this item?
paul doe
Moderator
Posts: 1730
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Graphics question.

Post by paul doe »

Achaean wrote:...Apparently, didn't work!
Ehm...Why???
What I'm doing wrong? :-)
...
Sidequestion:
I'm suspecting that it's related, although I'm not sure.
The manual says that GfxLib defaults to OpenGL, but can alternatively used X11 or XBDev (on Linux).
Supposedly with ScreenControl, but I don't quite understand the procedure! :-)
Anyone knows this item?
Hi, Achaean

You're missing the 'depth' parameter, that sets the bit depth for the graphics mode you're requesting. The correct call in this case would be:

Code: Select all

screenRes( 320, 200, 32, , fb.gfx_fullScreen )
This will set the video mode to 320x200x32 bit color. The fourth parameter is the number of pages the mode will have (defaults to 1, you can request more if you want).
Achaean
Posts: 51
Joined: Aug 02, 2017 12:54

Re: Graphics question.

Post by Achaean »

THANKS Paul! :-)

I tried all possible combinations of color (8, 16 and 32bit) and pages.
I think skipping a parameter, equals to entering the default (and the compiler don't complains).
Anyway, I entered the full range of parameters, but nothing changed.

Meanwhile, I tested my graphic programs at Windows (10 x64 Pro) too.
To my astonishment, they run flawlessly!!!
Seems NOT to be an FB bug. Seems to be related to OpenGL (the default back-end for GfxLib, according to the manual).

Under the light of this finding, I further tested my graphic programs, with the good old SCREEN command (choosing a proper for today's standards mode (the VGA ones 11 & 12)).
They're also functional at Windows, but at Linux (I'm using Debian Jessie x64 KDE), although they compile and run, they're definitely buggy.
They're:
1) messing the desktop resolution, that you have to restore manually (eg. with KRandRTray) and
2) if you gona Alt-Enter for changing between full-screen and windowed mode, they probably crashing (and you have to switch to another VT (eg. with ctrl-alt-f1), login, kill them manually (eg. with "killall MYPROGRAM") and return (ctrl-alt-f7).

(If i'm not wrong), I have to repeat the question:
How can someone changes OpenGL backend -> X11 or XBDev?
Was someone able, to accomplish it?
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Graphics question.

Post by MrSwiss »

Manual wrote:DirectX The default selection of FB GfxLib. May not be available on old Windows installations.
This (on WIN, at least) does NOT appear to be true any longer ...
OpenGL isn't used as default, it seems to default to GDI (as below code, clearly demonstrates):

Code: Select all

Const As Short  sw = 640, sh = 480, cd = 8, pg = 1, at = 0 ' sceen def.

' ===== MAIN =====
ScreenRes(sw, sh, cd, pg, at)
Width 80, 30

Dim As Integer  w, h, c, bpp, ptch, rte     ' required by ScreenInfo()
Dim As String   drv, ttl = "General Screen information (currently set)"

ScreenInfo(w, h, c, bpp, ptch, rte, drv)    ' retrieve curr. set param's.
' below: show user, the results obtained ...
Print " "; ttl
Print " "; String(Len(ttl), "-")
Print
Print " width/height: "; Str(w); " x "; Str(h)
Print " color depth:  "; Str(c)
Print " bytes p/pix.: "; Str(bpp)
Print " refresh rate: "; Str(rte)
Print " curr. driver: "; drv
Locate CsrLin + 2
Print " press a key, to EXIT prog. ";
' wait for: user interaction ...  
Sleep
' ===== END-MAIN =====
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Graphics question.

Post by fxm »

By default with Windows:
- fbc 32-bit => DirectX (for both gas and gcc), otherwise GDI can be imposed.
- fbc 64-bit => GDI (only GDI is available)
Last edited by fxm on Dec 08, 2017 18:59, edited 3 times in total.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Graphics question.

Post by MrSwiss »

@fxm,

I've tested FBC 64, only. This then means to me:
Doc should be updated, to reflect the current state of things.

Maybe stressing the difference: FBC 32 - FBC 64 clearly.
(Btw: is that only -gen gas, or also -gen gcc on 32-bit?)
Achaean
Posts: 51
Joined: Aug 02, 2017 12:54

Re: Graphics question.

Post by Achaean »

Oh...I see!
Running the above posted program, indicates that FB x64 on my system (Linux) is running X11.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Graphics question.

Post by MrSwiss »

@Achaean,

jep, exactly as the Manual (about: FBGFX) states, for 'ix-Systems (incl. Linux).
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Graphics question.

Post by fxm »

I updated my previous post.
Achaean
Posts: 51
Joined: Aug 02, 2017 12:54

Re: Graphics question.

Post by Achaean »

MrSwiss wrote:@Achaean,

jep, exactly as the Manual (about: FBGFX) states, for 'ix-Systems (incl. Linux).
Ooops!
My bad! :-)

Ehm...How can I switch, to something else? :-)
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Graphics question.

Post by MrSwiss »

Achaean wrote:How can I switch, to something else?
By using the (optional) flags, in ScreenRes() ... see FB-Manual, for details.

The "const at" in the test prog. (below).
Additional, detailed settings are possible with: ScreenControl() ...
Last edited by MrSwiss on Dec 08, 2017 19:32, edited 1 time in total.
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Graphics question.

Post by fxm »

ScreenRes can only set properties of used driver (it is true that the documentation was confusing to a fast read).
Before calling ScreenRes, use ScreenControl to select the driver.

Documentation updated:
KeyPgScreenres → fxm [Corrected confusion on an existing flag to select the graphics driver]
KeyPgScreengraphics → fxm [Corrected confusion on an existing flag to select the graphics driver]
Achaean
Posts: 51
Joined: Aug 02, 2017 12:54

Re: Graphics question.

Post by Achaean »

THANKS guys!!!

Indeed, I could change the graphic backend in Windows to OpenGL. (DirectX seems to be unavailable. Dunno why).

What I couldn't change, is the Linux one. Whatever I tried, X11 seems to be, the only available.
If someone could successfully change it, I'll be happy to know.

THANKS AGAIN for all your help!!!
A.

PS. I think that should be an easier, more straightforward way, to change such a critical option.
The way that is implemented, the settings are scattered around and doesn't give you enough information, when something fails (and-or in the case of fallbacks).
speedfixer
Posts: 606
Joined: Nov 28, 2012 1:27
Location: CA, USA moving to WA, USA
Contact:

Re: Graphics question.

Post by speedfixer »

Graphics (and OpenGL) are more fragile in Linux than any graphics in Windows.

Is the graphics chip embedded, or is it an external card? What brand?
How much memory?

Which Linux?

How quickly does it crash?
Run some print to the console before changing to graphics to be sure the program loaded and crashed on the graphics.


David
Achaean
Posts: 51
Joined: Aug 02, 2017 12:54

Re: Graphics question.

Post by Achaean »

speedfixer wrote:Graphics (and OpenGL) are more fragile in Linux than any graphics in Windows.
Indeed! However I'm still stuck at X11.
I never managed to switch to something else (only at Linux).
speedfixer wrote: Is the graphics chip embedded, or is it an external card? What brand?
How much memory?
Indeed it is. I have an ASUS motherboard, 4-core AMD, integrated (shared memory) ATI (AMD).
4GB memory, 0.5 for the card, the rest 3.5 for the system.
speedfixer wrote: Which Linux?
(As I stated above), I'm on Debian Jessie x64 KDE.
speedfixer wrote: How quickly does it crash?
Run some print to the console before changing to graphics to be sure the program loaded and crashed on the graphics.
If you avoid alt-enter it may not crash at all, yet when unloads from memory, my desktop is at a very low resolution (640X480) and I have to restore the resolution manually (eg. with KRandRTray) and rearrange my desktop icons (who got all mixed up).
I don't mind restoring the resolution. It's an one-click solution with KrandRTray, however restoring the desktop icons positions, it's a major annoyance!
speedfixer wrote: David
PS. (Just in case, who someone has a similar problem):
After a lot of time, I tried QB64 again and although it has a tendency to segfault when exiting, it runs the full-screen graphics flawlessly.
Post Reply