knightcrawler25 / GLSL-PathTracer

A toy physically based GPU path tracer (C++/OpenGL/GLSL)
MIT License
1.87k stars 176 forks source link

Fix quarter rendering window issue in MacOS #73

Closed LeeTeng2001 closed 1 year ago

LeeTeng2001 commented 1 year ago

The actual resolution of window is different if you have retina display (like MacOS), thus we need to query from SDL once more after we have created the window to get the actual drawable size. Thus will fix the black range in the rendering window

    auto window_flags = (SDL_WindowFlags) (SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE |
                                                      SDL_WINDOW_ALLOW_HIGHDPI);
    loopdata.mWindow = SDL_CreateWindow("GLSL Raytracing", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
                                        renderOptions.windowResolution.x, renderOptions.windowResolution.y,
                                        window_flags);

    // Query actual drawable window size
    int w, h;
    SDL_GL_GetDrawableSize(loopdata.mWindow, &w, &h);
    renderOptions.windowResolution.x = w;
    renderOptions.windowResolution.y = h;

Before: Screenshot 2022-12-14 at 10 38 20 AM

After: Screenshot 2022-12-14 at 10 38 43 AM

LeeTeng2001 commented 1 year ago

Should be an easy fix

knightcrawler25 commented 1 year ago

Thanks. I've added the code you've suggested.

Also, out of curiosity, did you have to make other changes to get the code to run on a Mac?

LeeTeng2001 commented 1 year ago

Yes I did, do you want me to make a pr branch for adding support for MacOS build?

knightcrawler25 commented 1 year ago

That'll be helpful as I don't have a way to test the repo on macOS :)

LeeTeng2001 commented 1 year ago

ok! I'll work on it after my exam (which will be around early jan)

LeeTeng2001 commented 1 year ago

I'll open another issue