#define GLX_GLXEXT_PROTOTYPES
#include <GL/glx.h>
+
#ifndef GLX_CONTEXT_OPENGL_NO_ERROR_ARB
#define GLX_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3
#endif
+#ifndef PFNGLXSWAPINTERVALMESAPROC
+#define PFNGLXSWAPINTERVALMESAPROC PFNGLXSWAPINTERVALSGIPROC
+#endif
+
namespace tcu
{
namespace lnx
virtual void postIterate (void);
virtual void makeCurrent (void);
void clearCurrent (void);
+ void swapInterval (int interval);
virtual const glw::Functions& getFunctions (void) const;
virtual const tcu::RenderTarget& getRenderTarget (void) const;
virtual glw::GenericFuncType getProcAddress (const char* name) const;
{
const int screen = XDefaultScreen(m_display);
// nVidia doesn't seem to report client-side extensions correctly,
- // so only use server side
- const char* const extensions =
+ // so use also server side
+ const char* const server_extensions =
TCU_CHECK_GLX(glXQueryServerString(m_display, screen, GLX_EXTENSIONS));
- istringstream extStream(extensions);
- m_extensions = set<string>(istream_iterator<string>(extStream),
+ const char* const client_extensions =
+ TCU_CHECK_GLX(glXQueryExtensionsString(m_display, screen));
+ istringstream srvExtStream(server_extensions);
+ istringstream cliExtStream(client_extensions);
+ m_extensions = set<string>(istream_iterator<string>(srvExtStream),
istream_iterator<string>());
+ m_extensions.insert(istream_iterator<string>(cliExtStream),
+ istream_iterator<string>());
}
}
const GlxFunctionLoader loader;
makeCurrent();
glu::initFunctions(&m_functions, &loader, config.type.getAPI());
+ swapInterval(0);
}
GlxRenderContext::~GlxRenderContext (void)
return glXGetProcAddress(reinterpret_cast<const GLubyte*>(name));
}
+void GlxRenderContext::swapInterval (int interval)
+{
+ if (m_glxVisual.getGlxDisplay().isGlxExtensionSupported("GLX_EXT_swap_control"))
+ {
+ PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT =
+ reinterpret_cast<PFNGLXSWAPINTERVALEXTPROC>(
+ TCU_CHECK_GLX(
+ glXGetProcAddress(
+ reinterpret_cast<const GLubyte*>("glXSwapIntervalEXT"))));
+
+ glXSwapIntervalEXT(m_glxVisual.getXDisplay(), m_glxDrawable->getGLXDrawable(), interval);
+ }
+ else if (m_glxVisual.getGlxDisplay().isGlxExtensionSupported("GLX_MESA_swap_control"))
+ {
+ PFNGLXSWAPINTERVALMESAPROC glXSwapIntervalMESA =
+ reinterpret_cast<PFNGLXSWAPINTERVALMESAPROC>(
+ TCU_CHECK_GLX(
+ glXGetProcAddress(
+ reinterpret_cast<const GLubyte*>("glXSwapIntervalMESA"))));
+
+ glXSwapIntervalMESA(interval);
+ }
+}
+
ContextType GlxRenderContext::getType (void) const
{
return m_type;
typedef HGLRC (WINAPI* wglCreateContextAttribsARBFunc) (HDC hdc, HGLRC hshareContext, const int* attribList);
typedef const char* (WINAPI* wglGetExtensionsStringARBFunc) (HDC hdc);
+// WGL_EXT_swap_control
+typedef BOOL (WINAPI* wglSwapIntervalEXTFunc) (int interval);
+
DE_END_EXTERN_C
namespace tcu
wglCreateContextAttribsARBFunc createContextAttribsARB;
wglGetExtensionsStringARBFunc getExtensionsStringARB;
+ // WGL_EXT_swap_control
+ wglSwapIntervalEXTFunc swapIntervalEXT;
+
+
Functions (void)
: createContext (DE_NULL)
, deleteContext (DE_NULL)
m_functions.createContextAttribsARB = (wglCreateContextAttribsARBFunc)m_functions.getProcAddress("wglCreateContextAttribsARB");
m_functions.getExtensionsStringARB = (wglGetExtensionsStringARBFunc)m_functions.getProcAddress("wglGetExtensionsStringARB");
+ // WGL_EXT_swap_control
+ m_functions.swapIntervalEXT = (wglSwapIntervalEXTFunc)m_functions.getProcAddress("wglSwapIntervalEXT");
+
m_functions.makeCurrent(tmpWindow.getDeviceContext(), NULL);
m_functions.deleteContext(tmpCtx);
wgl.deleteContext(m_context);
TCU_THROW(ResourceError, "wglMakeCurrent() failed");
}
+
+ if (core->getLibrary()->isWglExtensionSupported("WGL_EXT_swap_control"))
+ core->getLibrary()->getFunctions().swapIntervalEXT(0);
}
Context::~Context (void)