RE: VSYNC and Extensions

I am trying swapbuffers without waiting for the vertical blank of the monitor. Word on the street is that the following code will work:

wglSwapControl = (PFNWGLEXTSWAPCONTROLPROC) wglGetProcAddress(“wglSwapIntervalEXT”);

At first the problem was that I did’t have “wgl.h” on my machine. So, I went and found it. But, the version I found has a #include for “gdi.h”, which I don’t have either. I found “gdi.h”, but it has a #include for “super.h.” I can’t find this file, and I bet that when I do, it will have some other dependancy. Can anybody help me. I would really appreciate it. Google and MSDN have nothing left for me!


  • Lee

[This message has been edited by leepatton (edited 08-28-2002).]

I believe the WGL routines are defined via the “windows.h” include file. I’m assuming you’re coding in Win32 since you’re using a ‘wgl*’ prefixed procedure.

Thanks, but I have included ‘windows.h,’ and I still get the following errors:

--------------------Configuration: vbOpenGL - Win32 Debug--------------------
E:\TestDLL\vbOpenGL\Src\vbOpenGL.cpp(61) : error C2065: ‘wglSwapControl’ : undeclared identifier
E:\TestDLL\vbOpenGL\Src\vbOpenGL.cpp(61) : error C2065: ‘PFNWGLEXTSWAPCONTROLPROC’ : undeclared identifier
E:\TestDLL\vbOpenGL\Src\vbOpenGL.cpp(61) : error C2146: syntax error : missing ‘;’ before identifier ‘wglGetProcAddress’
Error executing cl.exe.

vbOpenGL.dll - 3 error(s), 0 warning(s)

To avoid problems, you can do the declarations yourself:

// Typedef (I use my own naming convention here)
typedef int (APIENTRY * WGLSWAPINTERVALEXT_T) (int interval);

// Function pointer

// Code
wglSwapIntervalEXT = (WGLSWAPINTERVALEXT_T) wglGetProcAddress( "wglSwapIntervalEXT" );
if( wglSwapIntervalEXT )
    wglSwapIntervalEXT( 0 );

…should work.

Thanks. The code compiled beautifully, but it seems that the address of wglSwapIntervalEXT is not being returned by wglGetProcAddress. Hmm… I’ll admit very quickly that I am no C++ expert. Perhaps there is something else I’m doing incorrectly. I’m writing a dll in C++ to be called from VB. Here’s what I have:

in the header:

typedef int (APIENTRY *WGLSWAPINTERVALEXT_T) (int interval);

and here’s the function:

int __stdcall vsync( int enable)
// outline: this function enables (1) disables (0) the syncronizaiton of the swapbuffers
// command to the vertical blank of the monitor

wglSwapIntervalEXT = (WGLSWAPINTERVALEXT_T) wglGetProcAddress( “wglSwapIntervalEXT” );

if( wglSwapIntervalEXT )

  // enable/disable vsync according to input
  if(enable == 1)
  	wglSwapIntervalEXT( 0);
  	wglSwapIntervalEXT( 1);

  // return success
  return 1;

// return failure
return 0;


[This message has been edited by leepatton (edited 09-05-2002).]

Correction… I am developing this app to run on a number of different platforms, and it was the platform I was testing this routine on that didn’t support wglSwapIntervalEXT. I got it to work on an NVIDIA platform. Thanks for all the help.