Skip to content
This repository has been archived by the owner on Jun 11, 2022. It is now read-only.

Rendering On A High DPI Screen Is Broken #46

Closed
JackStouffer opened this issue May 29, 2015 · 47 comments
Closed

Rendering On A High DPI Screen Is Broken #46

JackStouffer opened this issue May 29, 2015 · 47 comments

Comments

@JackStouffer
Copy link

I am on a retina Mac Book Pro, and when the window is rendered, the actual contents of the window are rendered in the bottom left hand side of the window and do not take up the actual space.

screen shot 2015-05-29 at 5 05 11 pm

The text object for the FPS counter is positioned at 0,0. The content is being rendered at its actual size rather than the scaled resolution.

@Dgame
Copy link
Owner

Dgame commented May 29, 2015

Did you tried to remove Style.HighDPI and pass only Style.OpenGL | Style.Shown to the Window?
Would be nice if you could show me your code. Do you change the window size somehow?

@Dgame
Copy link
Owner

Dgame commented May 29, 2015

@JackStouffer
Copy link
Author

Thanks, I am completely new to Dgame and was following the tutorials so I didn't know about that. Style.OpenGL works fine, but Style.Shown and Style.HighDPI crash the process. Is that a bug?

$ dub
Target derelict-util 2.0.0 is up to date. Use --force to rebuild.
Target derelict-sdl2 1.9.5 is up to date. Use --force to rebuild.
Target derelict-gl3 1.0.12 is up to date. Use --force to rebuild.
Target dgame 0.5.3 is up to date. Use --force to rebuild.
Building dungeon ~master configuration "application", build type debug.
Compiling using dmd...
Linking...
Running ./dungeon
SDL version: 2.0.3
Error executing command run:
Program exited with code -11

Here is the code
https://gist.github.com/JackStouffer/77f0843449a211e76614

@JackStouffer
Copy link
Author

Also, changing the window call in that code to

Window wnd = Window(640, 480, "Dgame Test", Window.Style.OpenGL, GLSettings(0, 0, 2));

crashes the process as well

@Dgame
Copy link
Owner

Dgame commented May 30, 2015

It shouldn't crash at all, but in your last example it crashes because OpenGL 0.0.2 does not exists. OpenGL 2.1 is needed at least, but I schould cover this, thanks. ;)
Did you tried Style.OpenGL | Style.Shown?

@JackStouffer
Copy link
Author

The last argument to GLSettings is also part of the version? In the tutorial it says that it's for anti-aliasing http://dgame-dev.de/?page=tutorial&tut=gl_settings If that is not for anti-aliasing how do you add it in?

Also, yes Style.OpenGL works fine, I was using Style.Default when I had the rendering error. Putting in Style.OpenGL | Style.Shown in works as well, but passing in Style.HighDPI or Style.Shown by themselves crashes the process.

@Dgame
Copy link
Owner

Dgame commented May 30, 2015

I'm sorry you're right. I was in a hurry and I've overlooked it, I thought for a momemt you put the patch level to OpenGL, not the Anti-Alias Level. :)

Also, yes Style.OpenGL works fine, I was using Style.Default when I had the rendering error. Putting in Style.OpenGL | Style.Shown in works as well, but passing in Style.HighDPI or Style.Shown by themselves crashes the process.

Yes because Style.OpenGL is always needed. Only in special cases if you exactly know what you are doing you can ignore it. Otherwise you must combine them with a bit or (Style.Shown | Style.OpenGL). I'll add a note for that in the coming version 0.6. :)

Besides that it I've got the feeling, that you discoverd the SDL bug which I mentioned before. I'll try to find a solution, but because I have no Mac I would like to notify you then, so that you can test that. Would that be ok?

@JackStouffer
Copy link
Author

Sure, you can notify me.

Is the anti-aliasing bug a part of the same issue?

@Dgame
Copy link
Owner

Dgame commented May 30, 2015

No I'm sure it has something to do with the absence of Style.Shown. I will investigate that.

@JackStouffer
Copy link
Author

I am passing in Style.Shown like so:

Window wnd = Window(640, 480, "Dgame Test", Window.Style.OpenGL | Window.Style.Shown, GLSettings(0, 0, 2));

@Dgame
Copy link
Owner

Dgame commented May 30, 2015

And that makes the application crash?

@JackStouffer
Copy link
Author

Yeah. Also, the terminal output is the same as the error output above.

@Dgame
Copy link
Owner

Dgame commented May 30, 2015

And without GLSettings(0, 0, 2) it works?

@JackStouffer
Copy link
Author

Yup.

@Dgame
Copy link
Owner

Dgame commented May 30, 2015

Seems to be an OSX issue. What is your Mac version?

@JackStouffer
Copy link
Author

10.10.3

@Dgame
Copy link
Owner

Dgame commented May 30, 2015

Thanks a lot, I'll examine it tonight. Sorry for your trouble.

@JackStouffer
Copy link
Author

It's cool man, you're working for free :)

@Dgame
Copy link
Owner

Dgame commented May 30, 2015

BTW: Do you have some other OS where you can test if it works? Then we could narrow it down to OSX.

@JackStouffer
Copy link
Author

I can boot up a linux VM. I will get back to you when I have D and SDL installed in it.

@JackStouffer
Copy link
Author

Ok, after trying to install OpenGL 3 on linux unsuccessfully for three hours, I am giving up. I am going to try to test this on windows instead.

@Dgame
Copy link
Owner

Dgame commented May 31, 2015

Don't rush yourself. I am on Windows 8.1 Pro, 64 bit and it works like a charm.

@JackStouffer
Copy link
Author

I figured that I should create a separate issue for this, but I might as well mention it now. For some reason, the sprite in a player class does not render while sprites defined and drawn in the main loop render fine. Here is the code which demonstrates this: https://gist.github.com/JackStouffer/77f0843449a211e76614

I have tried many different images to make sure that there wasn't something wrong with the png, but each image just renders a blank white square.

@Dgame
Copy link
Owner

Dgame commented May 31, 2015

That's not a bug, it's your fault, but maybe I should mention it somehow in the docs. ;)
You must hold the Texture because the Sprite does not own it, it stores only a pointer to it.
Dgame tries to avoid classes and Heap Allocations as much as possible, therefore many parts of Dgame (as Textures) are structs.

@JackStouffer
Copy link
Author

Ah, ok. I was able to fix it from your comment, thanks.

@Dgame
Copy link
Owner

Dgame commented Jun 7, 2015

@JackStouffer Did you tried Windows or Linux and can say me that it works?

@JackStouffer
Copy link
Author

Oh sorry, I thought your comment implied that me testing it on Windows would be redundant because you have already tested it. I will test it on my windows machine by the end of the day.

@Dgame
Copy link
Owner

Dgame commented Jun 7, 2015

Each machine is different. :) Would be nice to know if it works on linux,, but since no other issues were reported I'm sure it works.

@JackStouffer
Copy link
Author

Ok, I tried linux agian, this time on a different machine, but now I am getting this error:

$ dub
Target derelict-util 2.0.0 is up to date. Use --force to rebuild.
Target derelict-sdl2 1.9.5 is up to date. Use --force to rebuild.
Target derelict-gl3 1.0.13 is up to date. Use --force to rebuild.
Target dgame 0.5.3 is up to date. Use --force to rebuild.
Target dungeon ~master is up to date. Use --force to rebuild.
Running ./dungeon 
SDL version: 2.0.2
core.exception.AssertError@../.dub/packages/dgame-0.5.3/source/Dgame/Internal/Error.d(12): Error: Failed to init the required jpg and png support: PNG images are not supported

----------------
./dungeon(nothrow @nogc void Dgame.Internal.Error.assert_fmt!(const(char)*).assert_fmt(bool, immutable(char)[], const(char)*)+0x7b) [0x4e619b]
./dungeon(void Dgame.Window.Internal.Init._initSDL()+0x15b) [0x4edaf7]
./dungeon(ref Dgame.Window.Window.Window Dgame.Window.Window.Window.__ctor!().__ctor(const(Dgame.Math.Rect.Rect), immutable(char)[], uint, Dgame.Window.GLSettings.GLSettings)+0x3a) [0x4e9c36]
./dungeon(ref Dgame.Window.Window.Window Dgame.Window.Window.Window.__ctor(uint, uint, immutable(char)[], uint, Dgame.Window.GLSettings.GLSettings)+0x7c) [0x4e89f8]
./dungeon(_Dmain+0x7b) [0x4e10a3]
./dungeon(_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv+0x1f) [0x5109bf]
./dungeon(void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate())+0x2a) [0x510912]
./dungeon(void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll()+0x30) [0x510978]
./dungeon(void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate())+0x2a) [0x510912]
./dungeon(_d_run_main+0x1dc) [0x51088c]
./dungeon(main+0x25) [0x4e1935]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7fa105536ec5]
Error executing command run:
Program exited with code 1

I have all of the latest sdl libraries installed as well as libpng.

@Dgame
Copy link
Owner

Dgame commented Jun 8, 2015

AFAIK the default SDL version on linux has no PNG support (which is required for Dgame) and you have to build the SDL by yourself. But you can test it in C++ if you want: https://www.libsdl.org/projects/SDL_image/docs/SDL_image_frame.html

@JackStouffer
Copy link
Author

I can now confirm that anti-aliasing works on linux. Specifically, this was tested with mesa OpenGL 3.0 on Ubuntu 14.04 LTS.

@Dgame
Copy link
Owner

Dgame commented Jun 9, 2015

With Dgame 0.5 or 0.6 or both?

@JackStouffer
Copy link
Author

0.5

@Dgame
Copy link
Owner

Dgame commented Jun 9, 2015

Thank you very much. If you find the time, it would be very helpful if you would test also Dgame 0.6 beta.

@JackStouffer
Copy link
Author

Is it possible to download the 0.6 beta with dub?

@Dgame
Copy link
Owner

Dgame commented Jun 9, 2015

Yes:
"dgame": "~>0.6.0-beta.1"

@JackStouffer
Copy link
Author

Unfortunately that causes dub to throw an error:

$ dub upgrade
Upgrading project in /Users/Jack/Dropbox/code/dlang/dungeon_game
Error executing command upgrade:
Root package dungeon contains reference to invalid package dgame

Here is the dub.json

{
    "name": "dungeon",
    "sourcePaths":["."],
    "dependencies": {
        "dgame": "~>0.6.0-beta.1"
    },
    "targetType":"executable"
}

@Dgame
Copy link
Owner

Dgame commented Jun 9, 2015

That's odd, maybe you schould clear all Dgame specific dub stuff first.

@JackStouffer
Copy link
Author

I deleted the stored Dgame library in ~/.dub/ and deleted dub.selections.json file, but I am still getting the same error.

@Dgame
Copy link
Owner

Dgame commented Jun 9, 2015

Seems to be a dub issue since it works for me. Maybe you use an outdated version? I use 0.9.23

@JackStouffer
Copy link
Author

I have the latest version as well

$ dub --version
DUB version 0.9.23, built on Apr  6 2015

If I place "dgame": ">=0.5.0" back in everything works fine.

I am going to test this on linux and see what happens.

@JackStouffer
Copy link
Author

dub upgrade on linux works. I am going to create an issue on the dub project for this.

@Dgame
Copy link
Owner

Dgame commented Jun 9, 2015

Thanks a lot. And the anti-alias/High-DPI works with the 0.6? You have to enable HighDPI now by yourself.

@JackStouffer
Copy link
Author

Well, I couldn't get the linux VM I have on my Mac with the high DPI screen to work, so the linux machine I have been testing on is on a normal 1080p screen. And I can't get dub to download the newest beta on my Mac, so I can't test it.

@Dgame
Copy link
Owner

Dgame commented Jun 9, 2015

Alright, then thank you very much for your effort. I will close this as this is a known bug for Mac OS.

@Dgame Dgame closed this as completed Jun 9, 2015
@JackStouffer
Copy link
Author

I wouldn't close this as we don't know for sure if the anti-aliasing is working for Mac yet.

@Dgame
Copy link
Owner

Dgame commented Jun 9, 2015

But Anti-Alias is not the main concern here, that was High-DPI. If Anti-Alias is not working we will see a new issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants