Find Current Resolution

I found the article about how to find current resulution.
So, I followed that code like this.

#include <SDL_syswm.h>

int main()
{
SDL_SysWMinfo info;
int width;
int height;

    SDL_GetWMInfo(&info);
    width = DisplayWidth(info.info.x11.display, 0);
    height = DisplayHeight(info.info.x11.display, 0);
                                                                           
                                                  
    printf("Width = %d, Height = %d\n", width, height);
                                                                           
                                                  
    return 0;

}

My monitor resolution is 1280*1024. but I cannot understand output of this code.

Width = 1397948467, Height = 1195466568

how can I find my current resolution?

please advice me.
Thanx.

There’s a crucial bit of information missing. (added below)

#include <SDL_syswm.h>

int main()
{
SDL_SysWMinfo info;
int width;
int height;

SDL_VERSION(&info.version);>         SDL_GetWMInfo(&info);
    width = DisplayWidth(info.info.x11.display, 0);
    height = DisplayHeight(info.info.x11.display, 0);
                                                                           
                                                  
    printf("Width = %d, Height = %d\n", width, height);
                                                                           
                                                  
    return 0;

}

John wrote:

I found the article about how to find current resulution.
So, I followed that code like this.

Hi,

your code seems to work only under X,

if you’re interested to get info under Win, you can try that :

int w, h, bpp, freq;

BOOL a;
DEVMODE b;
a=EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &b );

w=b.dmPelsWidth;		// 1024
h=b.dmPelsHeight;		//  768
bpp=b.dmBitsPerPel;		// 16
freq=b.dmDisplayFrequency;	// 75 Hz

Cheers,
Murlock

Thank you for your advice, Sam.
I added code SDL_VERSION(&info.version) like below, but the result is same.
Give me some advice.

Thanks.

Width = 1397948467, Height = 1195466568

#include <SDL_syswm.h>

int main()
{
SDL_SysWMinfo info;
int width=0;
int height=0;

    SDL_VERSION(&info.version);
    SDL_GetWMInfo(&info);
    width = DisplayWidth(info.info.x11.display, 0);
    height = DisplayHeight(info.info.x11.display, 0);
                                                                           
               
    printf("Width = %d, Height = %d\n", width, height);
                                                                           
               
    return 0;

}

John wrote:

Thank you for your advice, Sam.
I added code SDL_VERSION(&info.version) like below, but the result is same.
Give me some advice.

You forgot to call SDL_Init()

Stephane

Hi everyone,

I found the article about how to find current resulution.

your code seems to work only under X,

if you’re interested to get info under Win, you can try that :

[code snipped]

This kind of defeats the purpose of a cross-platform framework :frowning: Isn’t
this something one could put in an SDL function? What is the set of
basic information one can get from every system’s window manager? Or how
about a return structure whose fields are -1 when the info is not
available (framerate, number of screens)?

Bye,
Benjamin