Results 1 to 6 of 6

Thread: wgl.h

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    Dayton, Ohio USA
    Posts
    6

    wgl.h

    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");
    wglSwapControl(0);

    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!

    Cheers,
    - Lee


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

  2. #2
    Junior Member Newbie
    Join Date
    Sep 2002
    Posts
    1

    Re: wgl.h

    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.

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    Dayton, Ohio USA
    Posts
    6

    Re: wgl.h

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

    --------------------Configuration: vbOpenGL - Win32 Debug--------------------
    Compiling...
    vbOpenGL.cpp
    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)
    ---------------------------------------------

  4. #4
    Senior Member Frequent Contributor marcus256's Avatar
    Join Date
    Aug 2001
    Location
    Sweden
    Posts
    764

    Re: wgl.h

    To avoid problems, you can do the declarations yourself:

    Code :
    // Typedef (I use my own naming convention here)
    typedef int (APIENTRY * WGLSWAPINTERVALEXT_T) (int interval);
     
    // Function pointer
    WGLSWAPINTERVALEXT_T wglSwapIntervalEXT;
     
    // Code
    wglSwapIntervalEXT = (WGLSWAPINTERVALEXT_T) wglGetProcAddress( "wglSwapIntervalEXT" );
    if( wglSwapIntervalEXT )
    {
        wglSwapIntervalEXT( 0 );
    }
    ...should work.

  5. #5
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    Dayton, Ohio USA
    Posts
    6

    Re: wgl.h

    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:
    Code :
    typedef int (APIENTRY *WGLSWAPINTERVALEXT_T) (int interval);
    WGLSWAPINTERVALEXT_T wglSwapIntervalEXT;
    and here's the function:
    Code :
    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);
    		}
    		else
    		{
    			wglSwapIntervalEXT( 1);
    		}	
     
    		// return success
    		return 1;
     
     
    	}else
    	{
    		// return failure
    		return 0;
    	}
     
     
    }

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

  6. #6
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    Dayton, Ohio USA
    Posts
    6

    Re: wgl.h

    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.

    Cheers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean