GlExtensionLoaderWin32.cpp

Go to the documentation of this file.
00001 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
00002  *
00003  * VR Juggler is (C) Copyright 1998-2006 by Iowa State University
00004  *
00005  * Original Authors:
00006  *   Allen Bierbaum, Christopher Just,
00007  *   Patrick Hartling, Kevin Meinert,
00008  *   Carolina Cruz-Neira, Albert Baker
00009  *
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Library General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2 of the License, or (at your option) any later version.
00014  *
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Library General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Library General Public
00021  * License along with this library; if not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00023  * Boston, MA 02111-1307, USA.
00024  *
00025  * -----------------------------------------------------------------
00026  * File:          $RCSfile$
00027  * Date modified: $Date$
00028  * Version:       $Revision$
00029  * -----------------------------------------------------------------
00030  *
00031  *************** <auto-copyright.pl END do not edit this line> ***************/
00032 
00033 #include <vrj/Draw/OGL/GlExtensionLoaderWin32.h>
00034 #include <vpr/Util/Debug.h>
00035 #include <vpr/Util/Assert.h>
00036 
00037 #ifndef GLAPI
00038 #  define GLAPI __stdcall
00039 #  define __DEFINED_GLAPI
00040 #endif
00041 
00042 namespace vrj
00043 {
00044    // NVIDIA swap control
00045    typedef BOOL (GLAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hdc,
00046                                                 GLuint group);
00047    
00048    typedef BOOL (GLAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group,
00049                                                   GLuint barrier);
00050    
00051    typedef BOOL (GLAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hdc,
00052                                                  GLuint *group,
00053                                                  GLuint *barrier);
00054    
00055    typedef BOOL (GLAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hdc,
00056                                                      /*int screen,*/
00057                                                      GLuint *maxGroups,
00058                                                      GLuint *maxBarriers);
00059    
00060    typedef BOOL (GLAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hdc,
00061                                                   /*int screen,*/
00062                                                   GLuint *count);
00063    
00064    typedef BOOL (GLAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hdc/*, int screen*/);
00065 
00066 
00067 struct GlExtensionLoaderWin32::WglFuncs
00068 {
00069    WglFuncs()
00070    {
00071       wglJoinSwapGroupNV = NULL;
00072       wglBindSwapBarrierNV = NULL;
00073       wglQuerySwapGroupNV = NULL;
00074       wglQueryMaxSwapGroupsNV = NULL;
00075       wglQueryFrameCountNV = NULL;
00076       wglResetFrameCountNV = NULL;
00077    }
00078 
00079    PFNWGLJOINSWAPGROUPNVPROC        wglJoinSwapGroupNV;
00080    PFNWGLBINDSWAPBARRIERNVPROC      wglBindSwapBarrierNV;
00081    PFNWGLQUERYSWAPGROUPNVPROC       wglQuerySwapGroupNV;
00082    PFNWGLQUERYMAXSWAPGROUPSNVPROC   wglQueryMaxSwapGroupsNV;
00083    PFNWGLQUERYFRAMECOUNTNVPROC      wglQueryFrameCountNV;
00084    PFNWGLRESETFRAMECOUNTNVPROC      wglResetFrameCountNV;
00085 };
00086 
00087 GlExtensionLoaderWin32::GlExtensionLoaderWin32()
00088 {
00089    mWglFuncs = boost::shared_ptr<WglFuncs>(new WglFuncs);
00090 }
00091 
00092 void GlExtensionLoaderWin32::registerExtensions()
00093 {
00094    GlExtensionLoader::registerExtensions();
00095 
00096    mWglFuncs->wglJoinSwapGroupNV       = (PFNWGLJOINSWAPGROUPNVPROC)       (getFunctionByName("wglJoinSwapGroupNV"));
00097    mWglFuncs->wglBindSwapBarrierNV     = (PFNWGLBINDSWAPBARRIERNVPROC)     (getFunctionByName("wglBindSwapBarrierNV"));
00098    mWglFuncs->wglQuerySwapGroupNV      = (PFNWGLQUERYSWAPGROUPNVPROC)      (getFunctionByName("wglQuerySwapGroupNV"));
00099    mWglFuncs->wglQueryMaxSwapGroupsNV  = (PFNWGLQUERYMAXSWAPGROUPSNVPROC)  (getFunctionByName("wglQueryMaxSwapGroupsNV"));
00100    mWglFuncs->wglQueryFrameCountNV     = (PFNWGLQUERYFRAMECOUNTNVPROC)     (getFunctionByName("wglQueryFrameCountNV"));
00101    mWglFuncs->wglResetFrameCountNV     = (PFNWGLRESETFRAMECOUNTNVPROC)     (getFunctionByName("wglResetFrameCountNV"));
00102 }
00103 
00104 // --- NVIDIA Swap Control methods --- //
00105 bool GlExtensionLoaderWin32::hasSwapGroupNV()
00106 {
00107    return (mWglFuncs->wglJoinSwapGroupNV != NULL);
00108 }
00109 
00110 BOOL GlExtensionLoaderWin32::wglJoinSwapGroupNV(HDC hdc, GLuint group)
00111 {
00112    vprASSERT(mWglFuncs->wglJoinSwapGroupNV != NULL && "Attemped to call unsupported extension.");
00113    return mWglFuncs->wglJoinSwapGroupNV(hdc, group);
00114 }
00115 
00116 BOOL GlExtensionLoaderWin32::wglBindSwapBarrierNV(GLuint group, GLuint barrier)
00117 {
00118    vprASSERT(mWglFuncs->wglBindSwapBarrierNV != NULL && "Attemped to call unsupported extension.");
00119    return mWglFuncs->wglBindSwapBarrierNV(group, barrier);
00120 }
00121 
00122 BOOL GlExtensionLoaderWin32::wglQuerySwapGroupNV(HDC hdc, GLuint *group, GLuint *barrier)
00123 {
00124    vprASSERT(mWglFuncs->wglQuerySwapGroupNV != NULL && "Attemped to call unsupported extension.");
00125    return mWglFuncs->wglQuerySwapGroupNV(hdc, group, barrier);
00126 }
00127 
00128 BOOL GlExtensionLoaderWin32::wglQueryMaxSwapGroupsNV(HDC hdc, GLuint *maxGroups, GLuint *maxBarriers)
00129 {
00130    vprASSERT(mWglFuncs->wglQueryMaxSwapGroupsNV != NULL && "Attemped to call unsupported extension.");
00131    return mWglFuncs->wglQueryMaxSwapGroupsNV(hdc, maxGroups, maxBarriers);
00132 }
00133 
00134 BOOL GlExtensionLoaderWin32::wglQueryFrameCountNV(HDC hdc, /*int screen,*/ GLuint *count)
00135 {
00136    vprASSERT(mWglFuncs->wglQueryFrameCountNV != NULL && "Attemped to call unsupported extension.");
00137    return mWglFuncs->wglQueryFrameCountNV(hdc, /*screen,*/ count);
00138 }
00139 
00140 BOOL GlExtensionLoaderWin32::wglResetFrameCountNV(HDC hdc/*, int screen*/)
00141 {
00142    vprASSERT(mWglFuncs->wglResetFrameCountNV != NULL && "Attemped to call unsupported extension.");
00143    return mWglFuncs->wglResetFrameCountNV(hdc/*, screen*/);
00144 }
00145 
00146 }  // namespace vrj

Generated on Thu Jan 4 10:56:51 2007 for VR Juggler by  doxygen 1.5.1