Jump to content

Compiling a program from source, anybody see what's wrong with this code?

SilicateWielder

Hey guys,

 

I'm going to be compiling an opensource RPG engine called Sphere from it's source in order to fix a graphical bug I'm experiencing on Windows, now I'm not familiar with C so I have no idea what i'm looking at. Does anyone know what's wrong with this code? It compiles to a DLL for using OpenGL.

 

I'm assuming this is where the bug lies, when entering fullscreen while using this DLL as the video driver for sphere in fullscreen the image is squished so-to-speak leaving black black bars on the bottom and top of my screen.

 

if (!fullscreen)
    {

        CenterWindow(SphereWindow, ScreenWidth * SCALE(), ScreenHeight * SCALE());
    }
    else
    {
        // set fullscreen mode
        DEVMODE dm;
        memset(&dm, 0, sizeof(dm));

        dm.dmSize       = sizeof(dm);
        dm.dmFields     = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
        dm.dmBitsPerPel = DriverConfig.bitdepth;
        dm.dmPelsWidth  = ScreenWidth  * SCALE();
        dm.dmPelsHeight = ScreenHeight * SCALE();

        WindowStyle   = GetWindowLong(SphereWindow, GWL_STYLE);
        WindowStyleEx = GetWindowLong(SphereWindow, GWL_EXSTYLE);

        SetWindowLong(SphereWindow, GWL_STYLE, WS_POPUP | WS_CLIPSIBLINGS);
        SetWindowLong(SphereWindow, GWL_EXSTYLE, 0);

        if (ChangeDisplaySettings(&dm, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
        {
            error_msg = "Unable to set fullscreen mode";
            goto error;
        }

        if (1)
        {

            DEVMODE dm;
            memset(&dm, 0, sizeof(dm));
            EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm);
            if (dm.dmBitsPerPel != DriverConfig.bitdepth)
            {

                error_msg = "Unable to set bits per pixel, try a different setting";
                goto error;
            }
        }

        // Set up window
        SetWindowPos(SphereWindow, HWND_TOPMOST, 0, 0, ScreenWidth * SCALE(), ScreenHeight * SCALE(), SWP_SHOWWINDOW);
    }

 

My procrastination is the bane of my existence.

I make games and stuff in my spare time.

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Assuming it's correctly getting the "ScreenWidth" and "ScreenHeight", the problem would be whatever "SCALE()" is. Try removing all the  * SCALE()s.

1474412270.2748842

Link to comment
Share on other sites

Link to post
Share on other sites

6 minutes ago, fizzlesticks said:

Assuming it's correctly getting the "ScreenWidth" and "ScreenHeight", the problem would be whatever "SCALE()" is. Try removing all the  * SCALE()s.

That's probably not causing the letterboxing OP claims is happening, assuming SCALE() does the same operation to both values.

 

There's nothing I can see that's obviously causing the letterboxing. My only other guess is something is up with the renderer.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×