Adding SGI Video Sync support.

ver1_5_1
Pat Suwalski 2006-12-12 01:29:27 +00:00
parent f99d2f5b73
commit 178d489a00
5 changed files with 56 additions and 1 deletions

View File

@ -109,6 +109,9 @@ void GLContext::init(const vector<string>& ignoreExt)
fpNV = fp::initNV();
fragmentProc = fpNV;
}
// Initialize GLX_SGI_video_sync blindly. At most, it will be null.
InitExtension("GLX_SGI_video_sync");
}

View File

@ -130,6 +130,11 @@ glx::PFNGLBLENDEQUATIONEXTPROC glx::glBlendEquationEXT;
glx::PFNWGLSWAPINTERVALEXTPROC glx::wglSwapIntervalEXT;
glx::PFNWGLGETSWAPINTERVALEXTPROC glx::wglGetSwapIntervalEXT;
// GLX_SGI_video_sync command function pointers
glx::PFNGLXGETVIDEOSYNCSGIPROC glx::glXGetVideoSyncSGI;
glx::PFNGLXWAITVIDEOSYNCSGIPROC glx::glXWaitVideoSyncSGI;
glx::PFNGLXGETREFRESHRATESGIPROC glx::glXGetRefreshRateSGI;
// ARB_vertex_program function pointers
glx::PFNGLBINDPROGRAMARBPROC glx::glBindProgramARB;
glx::PFNGLDELETEPROGRAMSARBPROC glx::glDeleteProgramsARB;
@ -650,6 +655,14 @@ static void InitExt_EXT_swap_control()
}
static void InitExt_GLX_SGI_video_sync()
{
glx::glXGetVideoSyncSGI = (glx::PFNGLXGETVIDEOSYNCSGIPROC) GET_GL_PROC_ADDRESS("glXGetVideoSyncSGI");
glx::glXWaitVideoSyncSGI = (glx::PFNGLXWAITVIDEOSYNCSGIPROC) GET_GL_PROC_ADDRESS("glXWaitVideoSyncSGI");
glx::glXGetRefreshRateSGI = (glx::PFNGLXGETREFRESHRATESGIPROC) GET_GL_PROC_ADDRESS("glXGetRefreshRateSGI");
}
static void InitExt_NV_fragment_program()
{
#if defined(GET_GL_PROC_ADDRESS)
@ -840,6 +853,9 @@ void InitExtension(const char* ext)
InitExt_ARB_vertex_shader();
else if (!strcmp(ext, "WGL_EXT_swap_control"))
InitExt_EXT_swap_control();
else if (!strcmp(ext, "GLX_SGI_video_sync"))
InitExt_GLX_SGI_video_sync();
}

View File

@ -1275,6 +1275,19 @@ namespace glx
#endif
/* SGI Video Sync from glxext.h, for refresh-rate syncing. */
namespace glx
{
typedef int ( * PFNGLXGETVIDEOSYNCSGIPROC) (unsigned int *count);
typedef int ( * PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int *count);
typedef int ( * PFNGLXGETREFRESHRATESGIPROC) (unsigned int *);
extern PFNGLXGETVIDEOSYNCSGIPROC glXGetVideoSyncSGI;
extern PFNGLXWAITVIDEOSYNCSGIPROC glXWaitVideoSyncSGI;
extern PFNGLXGETREFRESHRATESGIPROC glXGetRefreshRateSGI;
};
extern void InitExtension(const char* ext);
extern bool ExtensionSupported(const char *ext);

View File

@ -203,7 +203,8 @@ Renderer::Renderer() :
distanceLimit(1.0e6f),
minFeatureSize(MinFeatureSizeForLabel),
locationFilter(~0u),
colorTemp(NULL)
colorTemp(NULL),
videoSync(false)
{
starVertexBuffer = new StarVertexBuffer(2048);
pointStarVertexBuffer = new PointStarVertexBuffer(2048);
@ -821,6 +822,17 @@ Renderer::setStarColorTable(const ColorTemperatureTable* ct)
}
bool Renderer::getVideoSync() const
{
return videoSync;
}
void Renderer::setVideoSync(bool sync)
{
videoSync = sync;
}
float Renderer::getAmbientLightLevel() const
{
return ambientLightLevel;
@ -1980,6 +1992,13 @@ void Renderer::render(const Observer& observer,
cout << "glError: " << (char*) gluErrorString(errCode) << '\n';
}
#endif
if (videoSync && glx::glXWaitVideoSyncSGI != NULL)
{
unsigned int count;
glx::glXGetVideoSyncSGI(&count);
glx::glXWaitVideoSyncSGI(2, (count+1) & 1, &count);
}
}

View File

@ -140,6 +140,8 @@ class Renderer
void setScreenDpi(int);
const ColorTemperatureTable* getStarColorTable() const;
void setStarColorTable(const ColorTemperatureTable*);
bool getVideoSync() const;
void setVideoSync(bool);
bool getFragmentShaderEnabled() const;
void setFragmentShaderEnabled(bool);
@ -543,6 +545,8 @@ class Renderer
const ColorTemperatureTable* colorTemp;
Selection highlightObject;
bool videoSync;
};
#endif // _RENDER_H_