From f510b19bbe2aa254df1a11f7f492771a9651fd7e Mon Sep 17 00:00:00 2001 From: divverent Date: Tue, 5 Apr 2011 17:28:32 +0000 Subject: [PATCH] sanity check the visual obtained git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11026 d7cf8633-e32d-0410-b094-e92efae38249 --- vid_glx.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/vid_glx.c b/vid_glx.c index b469e8e4..c0a7efc8 100644 --- a/vid_glx.c +++ b/vid_glx.c @@ -455,6 +455,31 @@ static keynum_t buttonremap[18] = static qboolean BuildXImages(int w, int h) { int i; + if(DefaultDepth(vidx11_display, vidx11_screen) != 32 && DefaultDepth(vidx11_display, vidx11_screen) != 24) + { + Con_Printf("Sorry, we only support 24bpp and 32bpp modes\n"); + VID_Shutdown(); + return false; + } + // match to dpsoftrast's specs + if(vidx11_visual->red_mask != 0x00FF0000) + { + Con_Printf("Sorry, we only support BGR visuals\n"); + VID_Shutdown(); + return false; + } + if(vidx11_visual->green_mask != 0x0000FF00) + { + Con_Printf("Sorry, we only support BGR visuals\n"); + VID_Shutdown(); + return false; + } + if(vidx11_visual->blue_mask != 0x000000FF) + { + Con_Printf("Sorry, we only support BGR visuals\n"); + VID_Shutdown(); + return false; + } if(vidx11_shmevent >= 0) { for(i = 0; i < 2; ++i) @@ -467,6 +492,12 @@ static qboolean BuildXImages(int w, int h) VID_Shutdown(); return false; } + if(vidx11_ximage[i]->bytes_per_line != w * 4) + { + Con_Printf("Sorry, we only support linear pixel layout\n"); + VID_Shutdown(); + return false; + } vidx11_shminfo[i].shmid = shmget(IPC_PRIVATE, vidx11_ximage[i]->bytes_per_line * vidx11_ximage[i]->height, IPC_CREAT|0777); if(vidx11_shminfo[i].shmid < 0) { @@ -498,6 +529,12 @@ static qboolean BuildXImages(int w, int h) VID_Shutdown(); return false; } + if(vidx11_ximage[i]->bytes_per_line != w * 4) + { + Con_Printf("Sorry, we only support linear pixel layout\n"); + VID_Shutdown(); + return false; + } } } return true; -- 2.39.2