PPP - chapter 16 - flkt wrong screen resolution

I'm currently working my way through Bjarne Stroustrup's Programming, Principles and Practice and I'm currently in chapter 16. My problem is that full tick or whatever reads the screen resolution is somehow off. The resolution of my screen is 1920x1080, but when I run the x_max()/y_max() functions it apparently comes out as 1280x680. In reality I've been aware of the problem for a while, but since I had no idea how to fix it and was able to to make the programs function despite of it, I chose to ignore it, but at this point it is getting really annoying.
Is there any easy way to fix this or will I just have to humor it and pretend that is my resolution?

I'm currently using the following headers:
fltk, Graph, GUI, Point, Simple_window, std_lib_facilities, Window
Source files: Graph, GUI, Window and C16E03_main

Here is a link to the headers and source files I'm using: https://github.com/tattermunge/Lines_window

Any help would be appreciated.

its this a gui program or a full-screen program?
full screen programs often reset the resolution to whatever suits them.

also, is there any chance you are looking at the dimensions of a window or drawing surface, and not the screen itself? Make sure you care calling the right versions of the right functions as the stuff to get dimenions of the screen vs a 'surface' etc are similar looking.

Sorry if you are past these beginner questions, but we have to start somewhere. I can't open 3rd party files at work.

a last thought: any chance you have a dated library that can't understand higher res?


Last edited on
Where did you get your copy of the FLTK library? What version is it?

If you downloaded it from Stroustrup's website the version is very outdated. 1.1.9.

The current stable release is 1.3.5, available at https://www.fltk.org/
Last edited on
its this a gui program or a full-screen program?

It is definitely a gui program.
also, is there any chance you are looking at the dimensions of a window or drawing surface, and not the screen itself? Make sure you care calling the right versions of the right functions as the stuff to get dimenions of the screen vs a 'surface' etc are similar looking.

The way I tested it was by following the instructions from a previous chapter in which Stroustrup draws a bit of text on the screen.
1
2
3
4
5
6
7
8
Point tl(150, 150);
	Simple_window win(tl, 800, 600, "test");
	ostringstream oss;
	oss << "screen size: " << x_max() << '*' << y_max() << ' '
		<< "window size: " << win.x_max() << '*' << win.y_max();
	Text sizes{ Point{150,150},oss.str() };
	sizes.set_color(Color::black);
	win.attach(sizes);

For the window, the size is correct (800x600), or at least, it returns the parameters that I gave it, but as I mentioned, it tells me that my screen resolution is 1280x680.
According to the book, x_max() is supposed to be screen width, but if it doesn't actually return screen width, I guess I wouldn't know.
I now suspect that it returns Fl::w() which is supposed to return the "... width in pixels of the main screen work area.", which I understand as being the width of the screen.
The program I was trying to build have you create a randomly moving button.
I've set the parameters to keep it inside the 800x600 area and it does return points in that range, but the button is still frequently being placed outside the window.
Also, whenever I've tried to create a fullscreen window(1920x1080), it appears to be much larger than the screen.
Where did you get your copy of the FLTK library? What version is it?

If you downloaded it from Stroustrup's website the version is very outdated. 1.1.9.

The current stable release is 1.3.5, available at https://www.fltk.org/
a last thought: any chance you have a dated library that can't understand higher res?

I recently updated to the 2019 version (from 2017) of Visual Studio at which point I also updated from fltk-1.3.4-2 to fltk-1.3.5.
I did so using the method described in this(https://bumpyroadtocode.com/2017/08/29/how-to-install-and-use-fltk-1-3-4-in-visual-studio-2017-complete-guide-2-0-no-cross-contamination/) guide which I also used the first time I installed fltk.

I should mention, that I had the same problem with both versions. Solving it was my primary incentive for the update.
https://www.fltk.org/doc-1.3/group__fl__screen.html
https://stackoverflow.com/questions/19920078/using-fltk-api-how-to-find-the-fullscreen-height

According to this SO post, it may be Fl::screen_xywh that you have to use.

Maybe, but the way I was using it was to get two integers.
How would I use Fl::screen_xywh to test/print my screen resolution?
By the way, I tried to use Fl::w() and Fl::h() which returns the same resolution, so I guess that x_max() simple returns Fl::w().

Sorry if you are past these beginner questions, but we have to start somewhere. I can't open 3rd party files at work.

No need to apologize, I would definitely still consider myself to be a beginner and a lot of the troubles I've run into during the learning process have, in hindsight, been glaringly obvious.
Last edited on
I should mention that when I create a 1280x680 window, it indeed does seem to fit the screen. By the way, I'm generally using a second monitor to extend my screen, but disabling it has had no effect on the problem.
Topic archived. No new replies allowed.