[SDL] Getting the system resolution
Jeff
j_post at pacbell.net
Sat Dec 2 15:25:51 PST 2006
On Sat December 2 2006 13:27, Nuno Santos wrote:
>
> I'm looking to that structure and i don't see those fields:
>
Maybe this is what you're looking for?
#include <stdio.h>
#include <stdlib.h>
#include <SDL.h>
#include <SDL_syswm.h>
int main(void)
{
int w, h, x11screen;
const SDL_VideoInfo *info;
SDL_PixelFormat *vfmt;
SDL_SysWMinfo winfo;
if (SDL_Init(SDL_INIT_VIDEO))
{
printf("\nCan't initialize SDL\n\n");
return 1;
}
info = SDL_GetVideoInfo();
printf("\n\nhw avail: %d", info->hw_available);
printf("\nwm avail: %d", info->wm_available);
printf("\nblit hw: %d", info->blit_hw);
printf("\nvideo memory %d", info->video_mem);
if (info->vfmt)
{
vfmt = info->vfmt;
printf("\nBits per pixel %d", vfmt->BitsPerPixel);
printf("\nBytes per pixel %d", vfmt->BytesPerPixel);
}
SDL_VERSION(&winfo.version);
if (SDL_GetWMInfo(&winfo) > 0)
{
if (winfo.subsystem == SDL_SYSWM_X11)
{
x11screen = DefaultScreen(winfo.info.x11.display);
w = DisplayWidth(winfo.info.x11.display, x11screen);
h = DisplayHeight(winfo.info.x11.display, x11screen);
printf("\nScreen width %d, height %d", w, h);
}
else
printf("\n\nNOT X11!");
}
else
printf("\n\nCan't get window manager info!");
printf("\n\n");
SDL_Quit();
return 0;
}
More information about the SDL
mailing list