Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

GLContext Class Reference

#include <glcontext.h>

Collaboration diagram for GLContext:

Collaboration graph
List of all members.

Public Types

enum  GLRenderPath {
  GLPath_Basic = 0, GLPath_Multitexture = 1, GLPath_NvCombiner = 2, GLPath_DOT3_ARBVP = 3,
  GLPath_NvCombiner_NvVP = 4, GLPath_NvCombiner_ARBVP = 5, GLPath_ARBFP_ARBVP = 6, GLPath_NV30 = 7,
  GLPath_GLSL = 8
}
enum  VertexPath { VPath_Basic = 0, VPath_NV = 1, VPath_ARB = 2 }

Public Member Functions

bool bumpMappingSupported () const
bool extensionSupported (const std::string &) const
FragmentProcessorgetFragmentProcessor () const
int getMaxTextures () const
GLRenderPath getRenderPath () const
VertexPath getVertexPath () const
VertexProcessorgetVertexProcessor () const
 GLContext ()
bool hasMultitexture () const
void init (const std::vector< std::string > &ignoreExt)
GLRenderPath nextRenderPath ()
bool renderPathSupported (GLRenderPath) const
bool setRenderPath (GLRenderPath)
virtual ~GLContext ()

Private Attributes

std::vector< std::stringextensions
FragmentProcessorfragmentProc
int maxSimultaneousTextures
GLRenderPath renderPath
VertexPath vertexPath
VertexProcessorvertexProc

Member Enumeration Documentation

enum GLContext::GLRenderPath
 

Enumeration values:
GLPath_Basic 
GLPath_Multitexture 
GLPath_NvCombiner 
GLPath_DOT3_ARBVP 
GLPath_NvCombiner_NvVP 
GLPath_NvCombiner_ARBVP 
GLPath_ARBFP_ARBVP 
GLPath_NV30 
GLPath_GLSL 

Definition at line 24 of file glcontext.h.

00025     {
00026         GLPath_Basic             = 0,
00027         GLPath_Multitexture      = 1,
00028         GLPath_NvCombiner        = 2,
00029         GLPath_DOT3_ARBVP        = 3,
00030         GLPath_NvCombiner_NvVP   = 4,
00031         GLPath_NvCombiner_ARBVP  = 5,
00032         GLPath_ARBFP_ARBVP       = 6,
00033         GLPath_NV30              = 7,
00034         GLPath_GLSL              = 8,
00035     };

enum GLContext::VertexPath
 

Enumeration values:
VPath_Basic 
VPath_NV 
VPath_ARB 

Definition at line 37 of file glcontext.h.

00038     {
00039         VPath_Basic              = 0,
00040         VPath_NV                 = 1,
00041         VPath_ARB                = 2,
00042     };


Constructor & Destructor Documentation

GLContext::GLContext  ) 
 

Definition at line 24 of file glcontext.cpp.

00024                      :
00025     renderPath(GLPath_Basic),
00026     vertexPath(VPath_Basic),
00027     vertexProc(NULL),
00028     maxSimultaneousTextures(1)
00029 {
00030 }

GLContext::~GLContext  )  [virtual]
 

Definition at line 32 of file glcontext.cpp.

00033 {
00034 }


Member Function Documentation

bool GLContext::bumpMappingSupported  )  const
 

Definition at line 236 of file glcontext.cpp.

References GLPath_Multitexture, and renderPath.

Referenced by Renderer::fragmentShaderSupported(), Renderer::loadTextures(), and Renderer::renderObject().

00237 {
00238     return renderPath > GLPath_Multitexture;
00239 }

bool GLContext::extensionSupported const std::string  )  const
 

Definition at line 230 of file glcontext.cpp.

References extensions.

Referenced by Renderer::init(), init(), and renderPathSupported().

00231 {
00232     return (find(extensions.begin(), extensions.end(), ext) != extensions.end());
00233 }

FragmentProcessor * GLContext::getFragmentProcessor  )  const
 

Definition at line 254 of file glcontext.cpp.

References fragmentProc, GLPath_NV30, and renderPath.

Referenced by Renderer::renderObject().

00255 {
00256     if (renderPath == GLPath_NV30 /* || renderPath == GLPath_ARGFP_ARBVP */ )
00257         return fragmentProc;
00258     else
00259         return NULL;
00260 }

int GLContext::getMaxTextures  )  const [inline]
 

Definition at line 53 of file glcontext.h.

References maxSimultaneousTextures.

Referenced by Renderer::renderObject().

00053 { return maxSimultaneousTextures; };

GLRenderPath GLContext::getRenderPath  )  const [inline]
 

Definition at line 46 of file glcontext.h.

References renderPath.

Referenced by CelestiaCore::charEntered(), GetCurrentPreferences(), KdeGlWidget::initializeGL(), CelestiaCore::initRenderer(), KdePreferencesDialog::KdePreferencesDialog(), KdeApp::queryExit(), Renderer::renderObject(), KdeApp::resyncMenus(), KdePreferencesDialog::setRenderPathLabel(), KdePreferencesDialog::slotApply(), KdeApp::slotSetRenderPathARBFPARBVP(), KdeApp::slotSetRenderPathBasic(), KdeApp::slotSetRenderPathDOT3ARBVP(), KdeApp::slotSetRenderPathGLSL(), KdeApp::slotSetRenderPathMultitexture(), KdeApp::slotSetRenderPathNV30(), KdeApp::slotSetRenderPathNvCombiner(), KdeApp::slotSetRenderPathNvCombinerARBVP(), and KdeApp::slotSetRenderPathNvCombinerNvVP().

00046 { return renderPath; };

GLContext::VertexPath GLContext::getVertexPath  )  const
 

Definition at line 242 of file glcontext.cpp.

References vertexPath.

Referenced by Renderer::renderObject().

00243 {
00244     return vertexPath;
00245 }

VertexProcessor * GLContext::getVertexProcessor  )  const
 

Definition at line 248 of file glcontext.cpp.

References vertexPath, vertexProc, and VPath_Basic.

Referenced by Renderer::PointStarVertexBuffer::finish(), and Renderer::renderObject().

00249 {
00250     return vertexPath == VPath_Basic ? NULL : vertexProc;
00251 }

bool GLContext::hasMultitexture  )  const [inline]
 

Definition at line 54 of file glcontext.h.

References GLPath_Multitexture, and renderPath.

Referenced by Renderer::renderObject().

00054 { return renderPath >= GLPath_Multitexture; };

void GLContext::init const std::vector< std::string > &  ignoreExt  ) 
 

Definition at line 37 of file glcontext.cpp.

References DPRINTF, extensions, extensionSupported(), fpNV, fragmentProc, GL_MAX_TEXTURE_UNITS_ARB, vp::initARB(), InitExtension(), fp::initNV(), vp::initNV(), maxSimultaneousTextures, vertexProc, vpARB, and vpNV.

Referenced by CelestiaCore::initRenderer().

00038 {
00039     char* extensionsString = (char*) glGetString(GL_EXTENSIONS);
00040     if (extensionsString != NULL)
00041     {
00042         char* next = extensionsString;
00043         
00044         while (*next != '\0')
00045         {
00046             while (*next != '\0' && *next != ' ')
00047                 next++;
00048 
00049             string ext(extensionsString, next - extensionsString);
00050 
00051             // scan the ignore list
00052             bool shouldIgnore = false;
00053             for (vector<string>::const_iterator iter = ignoreExt.begin();
00054                  iter != ignoreExt.end(); iter++)
00055             {
00056                 if (*iter == ext)
00057                 {
00058                     shouldIgnore = true;
00059                     break;
00060                 }
00061             }
00062 
00063             if (!shouldIgnore)
00064                 extensions.insert(extensions.end(), ext);
00065 
00066             if (*next == '\0')
00067                 break;
00068             next++;
00069             extensionsString = next;
00070         }
00071     }
00072 
00073     // Initialize all extensions used
00074     for (vector<string>::const_iterator iter = extensions.begin();
00075          iter != extensions.end(); iter++)
00076     {
00077         InitExtension(iter->c_str());
00078     }
00079 
00080     if (extensionSupported("GL_ARB_multitexture") &&
00081         glx::glActiveTextureARB != NULL)
00082     {
00083         glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB,
00084                       (GLint*) &maxSimultaneousTextures);
00085     }
00086 
00087     if (extensionSupported("GL_ARB_vertex_program") &&
00088         glx::glGenProgramsARB)
00089     {
00090         DPRINTF(1, "Renderer: ARB vertex programs supported.\n");
00091         if (vpARB == NULL)
00092             vpARB = vp::initARB();
00093         vertexProc = vpARB;
00094     }
00095     else if (extensionSupported("GL_NV_vertex_program") &&
00096              glx::glGenProgramsNV)
00097     {
00098         DPRINTF(1, "Renderer: nVidia vertex programs supported.\n");
00099         if (vpNV == NULL)
00100             vpNV = vp::initNV();
00101         vertexProc = vpNV;
00102     }
00103 
00104     if (extensionSupported("GL_NV_fragment_program") &&
00105         glx::glGenProgramsNV)
00106     {
00107         DPRINTF(1, "Renderer: nVidia fragment programs supported.\n");
00108         if (fpNV == NULL)
00109             fpNV = fp::initNV();
00110         fragmentProc = fpNV;
00111     }
00112 }

GLContext::GLRenderPath GLContext::nextRenderPath  ) 
 

Definition at line 214 of file glcontext.cpp.

References GLPath_Basic, GLPath_GLSL, renderPath, and renderPathSupported().

Referenced by CelestiaCore::charEntered().

00215 {
00216     GLContext::GLRenderPath newPath = renderPath;
00217 
00218     do {
00219         newPath = (GLRenderPath) ((int) newPath + 1);;
00220         if (newPath > GLPath_GLSL)
00221             newPath = GLPath_Basic;
00222     } while (newPath != renderPath && !renderPathSupported(newPath));
00223 
00224     renderPath = newPath;
00225 
00226     return renderPath;
00227 }

bool GLContext::renderPathSupported GLRenderPath   )  const
 

Definition at line 147 of file glcontext.cpp.

References extensionSupported(), GLPath_ARBFP_ARBVP, GLPath_Basic, GLPath_DOT3_ARBVP, GLPath_GLSL, GLPath_Multitexture, GLPath_NV30, GLPath_NvCombiner, GLPath_NvCombiner_ARBVP, GLPath_NvCombiner_NvVP, maxSimultaneousTextures, and vertexProc.

Referenced by KdeGlWidget::initializeGL(), KdePreferencesDialog::KdePreferencesDialog(), nextRenderPath(), setRenderPath(), KdePreferencesDialog::slotRenderPath(), and WinMain().

00148 {
00149     switch (path)
00150     {
00151     case GLPath_Basic:
00152         return true;
00153 
00154     case GLPath_Multitexture:
00155         return (maxSimultaneousTextures > 1 &&
00156                ( extensionSupported("GL_EXT_texture_env_combine") ||
00157                  extensionSupported("GL_ARB_texture_env_combine")) );
00158 
00159     case GLPath_NvCombiner:
00160         return false;
00161         /*
00162         // No longer supported; all recent NVIDIA drivers also support
00163         // the vertex_program extension, so the combiners-only path
00164         // isn't necessary.
00165         return extensionSupported("GL_NV_register_combiners");
00166         */
00167 
00168     case GLPath_DOT3_ARBVP:
00169         return (extensionSupported("GL_ARB_texture_env_dot3") &&
00170                 extensionSupported("GL_ARB_vertex_program") &&
00171                 vertexProc != NULL);
00172 
00173     case GLPath_NvCombiner_NvVP:
00174         // If ARB_vertex_program is supported, don't report support for
00175         // this render path.
00176         return (extensionSupported("GL_NV_register_combiners") &&
00177                 extensionSupported("GL_NV_vertex_program") &&
00178                 !extensionSupported("GL_ARB_vertex_program") &&
00179                 vertexProc != NULL);
00180 
00181     case GLPath_NvCombiner_ARBVP:
00182         return (extensionSupported("GL_NV_register_combiners") &&
00183                 extensionSupported("GL_ARB_vertex_program") &&
00184                 vertexProc != NULL);
00185 
00186     case GLPath_ARBFP_ARBVP:
00187         return false;
00188         /*
00189         return (extensionSupported("GL_ARB_vertex_program") &&
00190                 extensionSupported("GL_ARB_fragment_program") &&
00191                 vertexProc != NULL);
00192         */
00193 
00194     case GLPath_NV30:
00195                 /* This render path is deprecated; GLSL is now preferred */
00196                 return false;
00197                 /*
00198         return (extensionSupported("GL_ARB_vertex_program") &&
00199                 extensionSupported("GL_NV_fragment_program"));
00200                 */
00201 
00202     case GLPath_GLSL:
00203         return (extensionSupported("GL_ARB_shader_objects") &&
00204                 extensionSupported("GL_ARB_shading_language_100") &&
00205                 extensionSupported("GL_ARB_vertex_shader") &&
00206                 extensionSupported("GL_ARB_fragment_shader"));
00207 
00208     default:
00209         return false;
00210     }
00211 }

bool GLContext::setRenderPath GLRenderPath   ) 
 

Definition at line 115 of file glcontext.cpp.

References GLPath_ARBFP_ARBVP, GLPath_Basic, GLPath_DOT3_ARBVP, GLPath_GLSL, GLPath_Multitexture, GLPath_NV30, GLPath_NvCombiner, GLPath_NvCombiner_ARBVP, GLPath_NvCombiner_NvVP, renderPath, renderPathSupported(), vertexPath, VPath_ARB, VPath_Basic, and VPath_NV.

Referenced by CelestiaCore::charEntered(), KdeGlWidget::initializeGL(), CelestiaCore::initRenderer(), CommandRenderPath::process(), KdePreferencesDialog::slotCancel(), KdePreferencesDialog::slotRenderPath(), KdeApp::slotSetRenderPathARBFPARBVP(), KdeApp::slotSetRenderPathBasic(), KdeApp::slotSetRenderPathDOT3ARBVP(), KdeApp::slotSetRenderPathGLSL(), KdeApp::slotSetRenderPathMultitexture(), KdeApp::slotSetRenderPathNV30(), KdeApp::slotSetRenderPathNvCombiner(), KdeApp::slotSetRenderPathNvCombinerARBVP(), KdeApp::slotSetRenderPathNvCombinerNvVP(), and WinMain().

00116 {
00117     if (!renderPathSupported(path))
00118         return false;
00119 
00120     switch (path)
00121     {
00122     case GLPath_Basic:
00123     case GLPath_Multitexture:
00124     case GLPath_NvCombiner:
00125         vertexPath = VPath_Basic;
00126         break;
00127     case GLPath_NvCombiner_NvVP:
00128         vertexPath = VPath_NV;
00129         break;
00130     case GLPath_DOT3_ARBVP:
00131     case GLPath_NvCombiner_ARBVP:
00132     case GLPath_ARBFP_ARBVP:
00133     case GLPath_NV30:
00134     case GLPath_GLSL:
00135         vertexPath = VPath_ARB;
00136         break;
00137     default:
00138         return false;
00139     }
00140 
00141     renderPath = path;
00142 
00143     return true;
00144 }


Member Data Documentation

std::vector<std::string> GLContext::extensions [private]
 

Definition at line 69 of file glcontext.h.

Referenced by extensionSupported(), and init().

FragmentProcessor* GLContext::fragmentProc [private]
 

Definition at line 66 of file glcontext.h.

Referenced by getFragmentProcessor(), and init().

int GLContext::maxSimultaneousTextures [private]
 

Definition at line 68 of file glcontext.h.

Referenced by getMaxTextures(), init(), and renderPathSupported().

GLRenderPath GLContext::renderPath [private]
 

Definition at line 63 of file glcontext.h.

Referenced by bumpMappingSupported(), getFragmentProcessor(), getRenderPath(), hasMultitexture(), nextRenderPath(), and setRenderPath().

VertexPath GLContext::vertexPath [private]
 

Definition at line 64 of file glcontext.h.

Referenced by getVertexPath(), getVertexProcessor(), and setRenderPath().

VertexProcessor* GLContext::vertexProc [private]
 

Definition at line 65 of file glcontext.h.

Referenced by getVertexProcessor(), init(), and renderPathSupported().


The documentation for this class was generated from the following files:
Generated on Sat Jan 14 22:33:21 2006 for Celestia by  doxygen 1.4.1