From 697e3a723c05b975507b42c12090dd3621e441f8 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 2 Nov 2010 10:02:30 +0100 Subject: [PATCH] Changed: #1034 Use XRender check from FindX11.cmake --- code/nel/CMakeLists.txt | 1 - code/nel/src/3d/driver/opengl/CMakeLists.txt | 43 +++++++++++-------- code/nel/src/3d/driver/opengl/driver_opengl.h | 5 ++- .../3d/driver/opengl/driver_opengl_window.cpp | 42 ++++++++++++------ 4 files changed, 56 insertions(+), 35 deletions(-) diff --git a/code/nel/CMakeLists.txt b/code/nel/CMakeLists.txt index 86a9236cd..ead484a2d 100644 --- a/code/nel/CMakeLists.txt +++ b/code/nel/CMakeLists.txt @@ -27,7 +27,6 @@ IF(WITH_3D) ELSE(APPLE) FIND_PACKAGE(X11) FIND_PACKAGE(XF86VidMode) - FIND_PACKAGE(XRandR) ENDIF(APPLE) ENDIF(NOT WIN32) ENDIF(WITH_DRIVER_OPENGL) diff --git a/code/nel/src/3d/driver/opengl/CMakeLists.txt b/code/nel/src/3d/driver/opengl/CMakeLists.txt index d4643f465..64ef6fb24 100644 --- a/code/nel/src/3d/driver/opengl/CMakeLists.txt +++ b/code/nel/src/3d/driver/opengl/CMakeLists.txt @@ -2,7 +2,7 @@ FILE(GLOB SRC *.cpp *.h *.def) IF(APPLE) FILE(GLOB MAC_SRC mac/*.h mac/*.m mac/*.mm mac/*.cpp) SET(SRC ${SRC} ${MAC_SRC}) - SET_SOURCE_FILES_PROPERTIES(${SRC} + SET_SOURCE_FILES_PROPERTIES(${SRC} PROPERTIES COMPILE_FLAGS "-x objective-c++") ENDIF(APPLE) @@ -29,25 +29,32 @@ IF(WIN32) INCLUDE_DIRECTORIES(${DXSDK_INCLUDE_DIR}) TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${DXSDK_DINPUT_LIBRARY} ${DXSDK_GUID_LIBRARY}) ADD_DEFINITIONS(/DDRIVER_OPENGL_EXPORTS) -ELSE(WIN32) - IF(APPLE) - TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${CARBON}) - TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${COCOA}) - ELSE(APPLE) - TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${X11_X11_LIB}) - IF(XF86VidMode_FOUND) - INCLUDE_DIRECTORIES(${XF86VidMode_INCLUDE_DIR}) - ADD_DEFINITIONS(${XF86VidMode_DEFINITIONS}) - TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${XF86VidMode_LIBRARY}) - ENDIF(XF86VidMode_FOUND) - IF(XRandR_FOUND) - INCLUDE_DIRECTORIES(${XRandR_INCLUDE_DIR}) - ADD_DEFINITIONS(${XRandR_DEFINITIONS}) - TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${XRandR_LIBRARY}) - ENDIF(XRandR_FOUND) - ENDIF(APPLE) ENDIF(WIN32) +IF(APPLE) + TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${CARBON}) + TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${COCOA}) +ENDIF(APPLE) + +IF(UNIX AND NOT APPLE) + TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${X11_X11_LIB}) + IF(XF86VidMode_FOUND) + INCLUDE_DIRECTORIES(${XF86VidMode_INCLUDE_DIR}) + ADD_DEFINITIONS(${XF86VidMode_DEFINITIONS}) + TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${XF86VidMode_LIBRARY}) + ENDIF(XF86VidMode_FOUND) + IF(X11_Xrandr_FOUND) + INCLUDE_DIRECTORIES(${X11_Xrandr_INCLUDE_PATH}) + ADD_DEFINITIONS(-DHAVE_XRANDR) + TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${X11_Xrandr_LIB}) + ENDIF(X11_Xrandr_FOUND) + IF(X11_Xrender_FOUND) + INCLUDE_DIRECTORIES(${X11_Xrender_INCLUDE_PATH}) + ADD_DEFINITIONS(-DHAVE_XRENDER) + TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${X11_Xrender_LIB}) + ENDIF(X11_Xrender_FOUND) +ENDIF(UNIX AND NOT APPLE) + IF(NOT APPLE AND WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(${NLDRV_OGL_LIB} ${CMAKE_CURRENT_SOURCE_DIR}/stdopengl.h ${CMAKE_CURRENT_SOURCE_DIR}/stdopengl.cpp) ENDIF(NOT APPLE AND WITH_PCH) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.h b/code/nel/src/3d/driver/opengl/driver_opengl.h index 3143249c9..f7bf07762 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl.h @@ -730,10 +730,11 @@ private: XVisualInfo* _visual_info; uint32 _xrandr_version; uint32 _xvidmode_version; + uint32 _xrender_version; -#ifdef XRANDR +#ifdef HAVE_XRANDR sint _OldSizeID; -#endif // XRANDR +#endif // HAVE_XRANDR #ifdef XF86VIDMODE sint _OldDotClock; // old dotclock diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp index b45813d41..8d0679d4f 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -29,9 +29,12 @@ #elif defined (NL_OS_UNIX) # include # include -# ifdef XRANDR +# ifdef HAVE_XRANDR # include -# endif +# endif // HAVE_XRANDR +# ifdef HAVE_XRENDER +# include +# endif // HAVE_XRENDER # include # define _NET_WM_STATE_REMOVE 0 # define _NET_WM_STATE_ADD 1 @@ -327,7 +330,7 @@ bool CDriverGL::init (uint windowIcon, emptyProc exitFunc) _xrandr_version = 0; -#ifdef XRANDR +#ifdef HAVE_XRANDR _OldSizeID = 0; sint xrandr_major, xrandr_minor; if (XRRQueryVersion(_dpy, &xrandr_major, &xrandr_minor)) @@ -335,8 +338,7 @@ bool CDriverGL::init (uint windowIcon, emptyProc exitFunc) _xrandr_version = xrandr_major * 100 + xrandr_minor; nlinfo("3D: XRandR %d.%d found", xrandr_major, xrandr_minor); } - -#endif +#endif // HAVE_XRANDR _xvidmode_version = 0; @@ -349,7 +351,19 @@ bool CDriverGL::init (uint windowIcon, emptyProc exitFunc) } #endif + _xrender_version = 0; + +#ifdef HAVE_XRENDER + sint render_major, render_event, render_error; + if (XQueryExtension(_dpy, "RENDER", &render_major, &render_event, &render_error)) + { + _xrender_version = render_major * 100; + nlinfo("3D: XRender %d.%d found", render_major, 0); + } +#endif // HAVE_XRENDER + #endif + return true; } @@ -1103,7 +1117,7 @@ bool CDriverGL::saveScreenMode() int screen = DefaultScreen(_dpy); res = false; -#ifdef XRANDR +#ifdef HAVE_XRANDR if (!res && _xrandr_version > 0) { @@ -1124,7 +1138,7 @@ bool CDriverGL::saveScreenMode() } } -#endif // XRANDR +#endif // HAVE_XRANDR #if defined(XF86VIDMODE) @@ -1167,7 +1181,7 @@ bool CDriverGL::restoreScreenMode() int screen = DefaultScreen(_dpy); -#ifdef XRANDR +#ifdef HAVE_XRANDR if (!res && _xrandr_version > 0) { @@ -1193,7 +1207,7 @@ bool CDriverGL::restoreScreenMode() } } -#endif // XRANDR +#endif // HAVE_XRANDR #if defined(XF86VIDMODE) @@ -1302,7 +1316,7 @@ bool CDriverGL::setScreenMode(const GfxMode &mode) bool found = false; -#ifdef XRANDR +#ifdef HAVE_XRANDR if (!found && _xrandr_version > 0) { @@ -1347,7 +1361,7 @@ bool CDriverGL::setScreenMode(const GfxMode &mode) } } -#endif +#endif // HAVE_XRANDR #if defined(XF86VIDMODE) @@ -1895,7 +1909,7 @@ bool CDriverGL::getModes(std::vector &modes) bool found = false; int screen = DefaultScreen(_dpy); -#if defined(XRANDR) +#if defined(HAVE_XRANDR) if (!found && _xrandr_version >= 100) { XRRScreenConfiguration *screen_config = XRRGetScreenInfo(_dpy, RootWindow(_dpy, screen)); @@ -2029,7 +2043,7 @@ bool CDriverGL::getCurrentScreenMode(GfxMode &mode) bool found = false; int screen = DefaultScreen(_dpy); -#ifdef XRANDR +#ifdef HAVE_XRANDR if (!found && _xrandr_version > 0) { @@ -2068,7 +2082,7 @@ bool CDriverGL::getCurrentScreenMode(GfxMode &mode) } } -#endif // XRANDR +#endif // HAVE_XRANDR #ifdef XF86VIDMODE