Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenGL full screen not centered #29

Closed
cwscws opened this issue Aug 12, 2023 · 19 comments
Closed

OpenGL full screen not centered #29

cwscws opened this issue Aug 12, 2023 · 19 comments
Labels
bug Something isn't working

Comments

@cwscws
Copy link

cwscws commented Aug 12, 2023

When pressing F11 to switch to full screen, the screen is not centered in OpenGL in MacOS (displayed on the left side instead of centered). It is centered in SDL and GTK+.

@revvv
Copy link
Owner

revvv commented Aug 15, 2023

This happens also on Windows. It started occurring with my first fork release.
Last official GDash correctly centered OpenGL, but there were a lot of code changes by Zoltan and many 3rd party library updates.
I'd love to fix this, even more it would improve the "full cave view" I'm still working on.

I guess it has something to do with glViewport() and glOrtho().

@revvv revvv added the help wanted Extra attention is needed label Aug 15, 2023
@revvv
Copy link
Owner

revvv commented Aug 16, 2023

If I remove glViewport() completely the game is centered in fullscreen, but also looks like it was stretched.

@cwscws
Copy link
Author

cwscws commented Aug 16, 2023

Stretched is not good, aspect ratio should be correct.

@revvv
Copy link
Owner

revvv commented Aug 17, 2023

Can you tell me why full screen size on Linux stretches the graphics to fit the screen, while on Mac/Windows it is not stretched, but just adds black areas around the graphics?

So my approach would be:

  1. Add new setting "Center OpenGL full screen"
  2. Ignore user scaling factor, use calculated one. Don't call glViewport() to get centered.
  3. The game gets scaled preserving the aspect ratio.
  4. Find out why intermissions are scaled differently and not preserving the aspect ratio. Have you noticed the missing pixel line at the top and the bottom?

UPDATE: Using a calculated scaling factor is not possible without major refactoring. Not planned.

@cwscws
Copy link
Author

cwscws commented Aug 17, 2023

That’s one of the mysteries that would really be interesting to know😎

Black bars should be only left and right, or did I misunderstand something?

@cwscws
Copy link
Author

cwscws commented Aug 17, 2023

I just read the manual of glViewport. As far as I understand this, the initial values are 0,0 for the lower left corner - which would explain why it’s not centered.

@revvv
Copy link
Owner

revvv commented Aug 21, 2023

I just read the manual of glViewport. As far as I understand this, the initial values are 0,0 for the lower left corner - which would explain why it’s not centered.

It's just the start coordinate. The full screen flag should just do what it says... But why the hell does it work on Linux and not Windows/Mac?

@revvv
Copy link
Owner

revvv commented Aug 21, 2023

New release is out. Let me know what you think. Note that the user defined scaling factor is relevant.

@cwscws
Copy link
Author

cwscws commented Aug 21, 2023

Generally a good workaround! But I’m not fully happy with the slightly stretched screen as there are more visual distortions when using shaders like crt-geom so a correct aspect ratio would be nicer (with black bars left and right on a 16:9 display). But at least this option can be switched on/off…😎

@renyxadarox
Copy link

renyxadarox commented Aug 21, 2023

There is a small repeatable bug:

  1. Go to Options and set
  • Scaling factor: 5
  • Full cave view: yes
  • OpenGL: Center full screen: no
  1. Play a full screen game. Visual area aligns left as expected
  2. Go to Options and set:
  • Full cave view: no
  1. Play a game. Everything looks as usual
  2. Go to Options and set:
  • Full cave view: yes
  1. A new game starts on centered screen
  2. Switching "OpenGL: Center full screen: no/yes" doesn't affect the result: every new full screen game starts on centered screen and only cold start of GDash helps.

Not a big deal, just a minor issue.

@renyxadarox
Copy link

To be honest, I would rather always have a cantered full screen and an option to stretch a visual area to bounds (which may causes visual distortions) or do not stratch and have a precise visual area aspect ratio (with black bars left and right).
But if this is difficult to implement for some reason, the current version's solution is also a pretty good workaround.

@revvv
Copy link
Owner

revvv commented Aug 22, 2023

I don't have a better solution. This is the reason why this issue is marked with help wanted.
To preserve the aspect ratio you could try to use the calculated scaling factor for the full cave view. You can see it's value if you add -v to the command line. (Note: Using it automatically is not possible without a huge refactoring.)

@revvv
Copy link
Owner

revvv commented Aug 22, 2023

@renyxadarox wrote

There are a small repeatable bug
[...]
every new full screen game starts on centered screen and only cold start of GDash helps.

I could reproduce it on Windows. IMHO this is an OpenGL bug or feature. I guess that it's not centered at the beginning is the bug. My setting just adds a workaround...

@renyxadarox
Copy link

renyxadarox commented Aug 22, 2023

I guess that it's not centered at the beginning is the bug. My setting just adds a workaround...
Does it make sense to have the option "OpenGL: Center full screen" at all?
In my opinion, few people need to have full screen left alignment.
Most people would be happy with always centered full screen.

Actually, no matter what is a value of "OpenGL: Center full screen" option, the full screen view is always centered now and it affects only visual area aspect ratio:

OpenGL: Center full screen: no
Screen size: 1680x1050
Visual area size: 1680x921
Aspect ratio: ~44:20
image

OpenGL: Center full screen: yes
Screen size: 1680x1050
Visual area size: 1680x1001
Aspect ratio: ~42:25
image

(the black bars left and right are missing in the screenshots, but they are present in the screen for both cases)

So, maybe you should rename it as "Full screen: Stretch to bounds"? Because that's exactly what it's doing right now.
In Windows at least. Maybe this option works differently in McOS, I don't know.

@cwscws
Copy link
Author

cwscws commented Aug 22, 2023

Maybe Czirkos Zoltan can help?

Or maybe there are websites where these things could be asked? I’m no programmer unfortunately…

@revvv
Copy link
Owner

revvv commented Aug 22, 2023

I have updated SDL: mingw-w64-x86_64-SDL2 2.26.5-1 -> 2.28.2-1
No change. That's all I can do for now.

@revvv revvv closed this as completed Aug 22, 2023
@revvv
Copy link
Owner

revvv commented Aug 30, 2023

To preserve the aspect ratio you need to set a higher scaling factor. Forgot to mention that.

@revvv
Copy link
Owner

revvv commented Sep 9, 2023

Now I know that this happens on all platforms and if it happens depends on the screen size.
I'm going to calculate the perfect scaling factor. SDL will add only one small black bar somewhere, but this preserves the aspect ratio.
Enabling the setting opengl_center will stretch the image almost unnoticeable. So maybe we can remove the setting completely and preserve the aspect ratio.

@revvv revvv reopened this Sep 9, 2023
@revvv revvv changed the title OpenGL full screen not centered in MacOS OpenGL full screen not centered Sep 9, 2023
@revvv revvv removed the help wanted Extra attention is needed label Sep 9, 2023
@revvv
Copy link
Owner

revvv commented Sep 11, 2023

I thought I have fixed it, now my Linux laptop it does cut off the score for 40x22 view. (Release 1.9.5)
I have checked when this happens with gdash -v: (Tried different view sizes)
Values for h_padding that work correctly: 70, 132
Values for h_padding that don't work correctly: 245, 210, 160

So the conclusion is: Whenever h_padding is at least 160 it is a problem??

UPDATE: The weird results came from using glViewport() and glOrtho() at the same time. Using glOrtho() alone works on all platforms. I guess it depends on the OpenGL implementation, so it could have happened anywhere.

@revvv revvv added bug Something isn't working help wanted Extra attention is needed and removed help wanted Extra attention is needed labels Sep 11, 2023
revvv added a commit that referenced this issue Sep 12, 2023
@revvv revvv closed this as completed Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants