glc_ext.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  This file is part of the GLC-lib library.
00004  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
00005  http://glc-lib.sourceforge.net
00006 
00007  GLC-lib is free software; you can redistribute it and/or modify
00008  it under the terms of the GNU Lesser General Public License as published by
00009  the Free Software Foundation; either version 3 of the License, or
00010  (at your option) any later version.
00011 
00012  GLC-lib is distributed in the hope that it will be useful,
00013  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  GNU Lesser General Public License for more details.
00016 
00017  You should have received a copy of the GNU Lesser General Public License
00018  along with GLC-lib; if not, write to the Free Software
00019  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021 *****************************************************************************/
00023 
00024 #include "glc_ext.h"
00025 #include <QString>
00026 #include <QGLContext>
00027 #include <QDebug>
00028 #include <QGLShaderProgram>
00029 #include <QGLBuffer>
00030 
00031 #if !defined(Q_OS_MAC)
00032 
00033 // GL_point_parameters Point Sprite
00034 PFNGLPOINTPARAMETERFARBPROC                     glPointParameterf               = NULL;
00035 PFNGLPOINTPARAMETERFVARBPROC            glPointParameterfv              = NULL;
00036 
00037 #endif
00038 
00039 
00040 // Return true if the extension is supported
00041 bool glc::extensionIsSupported(const QString& extension)
00042 {
00043         QString glExtension(reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)));
00044         return glExtension.contains(extension);
00045 }
00046 
00047 // Return true if VBO extension is succesfully loaded
00048 bool glc::loadVboExtension()
00049 {
00050         QGLBuffer buffer;
00051         bool result= buffer.create();
00052         buffer.destroy();
00053     return result;
00054 }
00055 
00056 // Load GLSL extensions
00057 bool glc::loadGlSlExtension()
00058 {
00059     return QGLShaderProgram::hasOpenGLShaderPrograms();
00060 }
00061 
00062 // Load Point Sprite extension
00063 bool glc::loadPointSpriteExtension()
00064 {
00065         bool result= true;
00066 #if !defined(Q_OS_MAC)
00067         const QGLContext* pContext= QGLContext::currentContext();
00068         glPointParameterf                               = (PFNGLPOINTPARAMETERFARBPROC)pContext->getProcAddress(QLatin1String("glPointParameterf"));
00069         if (!glPointParameterf) qDebug() << "not glPointParameterf";
00070         glPointParameterfv                              = (PFNGLPOINTPARAMETERFVARBPROC)pContext->getProcAddress(QLatin1String("glPointParameterfv"));
00071         if (!glPointParameterfv) qDebug() << "not glPointParameterfv";
00072 
00073         result= glPointParameterf && glPointParameterfv;
00074 
00075 #endif
00076     return result;
00077 }
00078 

SourceForge.net Logo

©2005-2011 Laurent Ribon