X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=vid_glx.c;h=9f142bb9a0caf34be92da7fe97f6611d3a111146;hb=0c520681a142ef15d2a0e28e9b3ee75d5fb1b7eb;hp=b469e8e479317a1b51295292700e5869ae79434b;hpb=2092ef1266974d9713b0788174dbaf366bf9ddca;p=xonotic%2Fdarkplaces.git diff --git a/vid_glx.c b/vid_glx.c index b469e8e4..9f142bb9 100644 --- a/vid_glx.c +++ b/vid_glx.c @@ -89,7 +89,7 @@ static Window win, root; static GLXContext ctx = NULL; static GC vidx11_gc = NULL; static XImage *vidx11_ximage[2] = { NULL, NULL }; -static int vidx11_ximage_pos; +static int vidx11_ximage_pos = 0; static XShmSegmentInfo vidx11_shminfo[2]; static int vidx11_shmevent = -1; static int vidx11_shmwait = 0; // number of frames outstanding @@ -278,7 +278,9 @@ static int XLateKey(XKeyEvent *ev, Uchar *ascii) case XK_KP_Subtract: key = K_KP_MINUS; break; case XK_KP_Divide: key = K_KP_SLASH; break; - case XK_section: key = '~'; break; + case XK_asciicircum: *ascii = key = '^'; break; // for some reason, XLookupString returns "" on this one for Grunt|2 + + case XK_section: *ascii = key = '~'; break; default: if (keysym < 32) @@ -455,6 +457,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 +494,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) { @@ -487,7 +520,7 @@ static qboolean BuildXImages(int w, int h) } else { - for(i = 0; i < 2; ++i) + for(i = 0; i < 1; ++i) // we only need one buffer if we don't use Xshm { char *p = calloc(4, w * h); vidx11_shminfo[i].shmid = -1; @@ -498,6 +531,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; @@ -792,9 +831,10 @@ void *GL_GetProcAddress(const char *name) void VID_Shutdown(void) { - if (!ctx || !vidx11_display) + if (!vidx11_display) return; + VID_EnableJoystick(false); VID_SetMouse(false, false, false); VID_RestoreSystemGamma(); @@ -812,6 +852,7 @@ void VID_Shutdown(void) if (vid.softdepthpixels) free(vid.softdepthpixels); + vid.softdepthpixels = NULL; if (win) XDestroyWindow(vidx11_display, win); @@ -857,11 +898,11 @@ void VID_Finish (void) switch(vid.renderpath) { case RENDERPATH_SOFT: - vidx11_ximage_pos = !vidx11_ximage_pos; - vid.softpixels = (unsigned int *) vidx11_ximage[vidx11_ximage_pos]->data; - DPSOFTRAST_SetRenderTargets(vid.width, vid.height, vid.softdepthpixels, vid.softpixels, NULL, NULL, NULL); - if(vidx11_shmevent >= 0) { + vidx11_ximage_pos = !vidx11_ximage_pos; + vid.softpixels = (unsigned int *) vidx11_ximage[vidx11_ximage_pos]->data; + DPSOFTRAST_SetRenderTargets(vid.width, vid.height, vid.softdepthpixels, vid.softpixels, NULL, NULL, NULL); + // save mouse motion so we can deal with it later in_mouse_x = 0; in_mouse_y = 0; @@ -875,13 +916,16 @@ void VID_Finish (void) ++vidx11_shmwait; XShmPutImage(vidx11_display, win, vidx11_gc, vidx11_ximage[!vidx11_ximage_pos], 0, 0, 0, 0, vid.width, vid.height, True); } else { - XPutImage(vidx11_display, win, vidx11_gc, vidx11_ximage[!vidx11_ximage_pos], 0, 0, 0, 0, vid.width, vid.height); + // no buffer switching here, we just flush the renderer + DPSOFTRAST_Finish(); + XPutImage(vidx11_display, win, vidx11_gc, vidx11_ximage[vidx11_ximage_pos], 0, 0, 0, 0, vid.width, vid.height); } break; case RENDERPATH_GL11: case RENDERPATH_GL13: case RENDERPATH_GL20: + case RENDERPATH_GLES1: case RENDERPATH_GLES2: if (vid_usingvsync != vid_usevsync) { @@ -1629,8 +1673,34 @@ void Sys_SendKeyEvents(void) HandleEvents(); } +void VID_BuildJoyState(vid_joystate_t *joystate) +{ + VID_Shared_BuildJoyState_Begin(joystate); + VID_Shared_BuildJoyState_Finish(joystate); +} + +void VID_EnableJoystick(qboolean enable) +{ + int index = joy_enable.integer > 0 ? joy_index.integer : -1; + qboolean success = false; + int sharedcount = 0; + sharedcount = VID_Shared_SetJoystick(index); + if (index >= 0 && index < sharedcount) + success = true; + + // update cvar containing count of XInput joysticks + if (joy_detected.integer != sharedcount) + Cvar_SetValueQuick(&joy_detected, sharedcount); + + Cvar_SetValueQuick(&joy_active, success ? 1 : 0); +} + void IN_Move (void) { + vid_joystate_t joystate; + VID_EnableJoystick(true); + VID_BuildJoyState(&joystate); + VID_ApplyJoyState(&joystate); } size_t VID_ListModes(vid_mode_t *modes, size_t maxcount)