TAPs 0.7.7.3
TAPsGLSLFns.cpp File Reference
#include "TAPsGLSLFns.hpp"
Include dependency graph for TAPsGLSLFns.cpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

unsigned long GFnGetFileLength (std::ifstream &file)
unsigned long GFnGetFileLength (const char *fileName)
bool GFnInitGLSL ()
bool GFnCheckGLSL ()
bool GFnCheckGL2 ()

Variables

BEGIN_NAMESPACE_TAPs__OpenGL char * gbGLSLErrStr []
bool gbIsGLSLSupported = false
bool gbIsInitialized = false

Function Documentation

bool GFnCheckGL2 ( )

Definition at line 218 of file TAPsGLSLFns.cpp.

References gbIsInitialized, and GFnInitGLSL().

{
    if ( !gbIsInitialized ) GFnInitGLSL();
    return GLEW_VERSION_2_0 == GL_TRUE;
}

Here is the call graph for this function:

bool GFnCheckGLSL ( )

Definition at line 118 of file TAPsGLSLFns.cpp.

References gbIsGLSLSupported, gbIsInitialized, and GFnInitGLSL().

{
    if ( gbIsGLSLSupported ) return true;   // GLSL is available and initailized
    //---------------------------------------------------------------
    if ( !gbIsInitialized ) GFnInitGLSL();
    //---------------------------------------------------------------
#ifdef TAPs_DEBUG_MODE
    #ifdef TAPs_USE_WXWIDGETS
        if      ( GLEW_VERSION_3_2 )
            wxLogWarning( wxT( "OpenGL 3.2 is available!" ) );
        else if ( GLEW_VERSION_3_1 )
            wxLogWarning( wxT( "OpenGL 3.1 is available!" ) );
        else if ( GLEW_VERSION_3_0 )
            wxLogWarning( wxT( "OpenGL 3.0 is available!" ) );
        else if ( GLEW_VERSION_2_1 )
            wxLogWarning( wxT( "OpenGL 2.1 is available!" ) );
        else if ( GLEW_VERSION_2_0 )
            wxLogWarning( wxT( "OpenGL 2.0 is available!" ) );
        else if ( GLEW_VERSION_1_5 )
            wxLogWarning( wxT( "OpenGL 1.5 is available!" ) );
        else if ( GLEW_VERSION_1_4 )
            wxLogWarning( wxT( "OpenGL 1.4 is available!" ) );
        else if ( GLEW_VERSION_1_3 )
            wxLogWarning( wxT( "OpenGL 1.3 is available!" ) );
        else if ( GLEW_VERSION_1_2 )
            wxLogWarning( wxT( "OpenGL 1.2 is available!" ) );
    #else
        if      ( GLEW_VERSION_3_2 )
            std::cout << "OpenGL 3.2 is available!\n";
        else if ( GLEW_VERSION_3_1 )
            std::cout << "OpenGL 3.1 is available!\n";
        else if ( GLEW_VERSION_3_0 )
            std::cout << "OpenGL 3.0 is available!\n";
        else if ( GLEW_VERSION_2_1 )
            std::cout << "OpenGL 2.1 is available!\n";
        else if ( GLEW_VERSION_2_0 )
            std::cout << "OpenGL 2.0 is available!\n";
        else if ( GLEW_VERSION_1_5 )
            std::cout << "OpenGL 1.5 is available!\n";
        else if ( GLEW_VERSION_1_4 )
            std::cout << "OpenGL 1.4 is available!\n";
        else if ( GLEW_VERSION_1_3 )
            std::cout << "OpenGL 1.3 is available!\n";
        else if ( GLEW_VERSION_1_2 )
            std::cout << "OpenGL 1.2 is available!\n";
    #endif
#endif
    //---------------------------------------------------------------
    // Ensure we have the necessary OpenGL Shading Language extensions.
    if (glewGetExtension("GL_ARB_fragment_shader")      != GL_TRUE ||
        glewGetExtension("GL_ARB_vertex_shader")        != GL_TRUE ||
        glewGetExtension("GL_ARB_shader_objects")       != GL_TRUE ) //||
        //glewGetExtension("GL_ARB_shading_language_100") != GL_TRUE)
    {
#ifdef TAPs_DEBUG_MODE
    #ifdef TAPs_USE_WXWIDGETS
        wxLogError( wxT( "[FAILIED] OpenGL Shading Language is NOT available!" ) );
    #else
        std::cerr << "[FAILIED] OpenGL Shading Language is NOT available!\n";
    #endif
#endif
        gbIsGLSLSupported = false;
    }
    else {
#ifdef TAPs_DEBUG_MODE
    #ifdef TAPs_USE_WXWIDGETS
        wxLogWarning( wxT( "[OK] OpenGL Shading Language is available!" ) );
    #else
        std::cout << "[OK] OpenGL Shading Language is available!\n";
    #endif
#endif
        gbIsGLSLSupported = true;
    }
    //---------------------------------------------------------------
    // Ensure we have the geometry OpenGL Shading Language extensions.
    if ( glewGetExtension("GL_EXT_geometry_shader4") != GL_TRUE )
    {
#ifdef TAPs_DEBUG_MODE
    #ifdef TAPs_USE_WXWIDGETS
        wxLogError( wxT( "[FAILIED] GL_EXT_geometry_shader4, OpenGL Shading Language, is NOT available!" ) );
    #else
        std::cerr << "[FAILIED] GL_EXT_geometry_shader4, OpenGL Shading Language, is NOT available!\n";
    #endif
#endif
        //gbIsGLSLSupported = false;
    }
    else {
#ifdef TAPs_DEBUG_MODE
    #ifdef TAPs_USE_WXWIDGETS
        wxLogWarning( wxT( "[OK] GL_EXT_geometry_shader4, OpenGL Shading Language, is available!" ) );
    #else
        std::cout << "[OK] GL_EXT_geometry_shader4, OpenGL Shading Language, is available!\n";
    #endif
#endif
        //gbIsGLSLSupported = true;
    }
    //---------------------------------------------------------------
    return gbIsGLSLSupported;
}

Here is the call graph for this function:

unsigned long GFnGetFileLength ( const char *  fileName)

Definition at line 54 of file TAPsGLSLFns.cpp.

{
    // Returns the size in bytes of the shader fileName.
    // If an error occurred, it returns -1.
    int fd;
    int count = -1;
    //
    // Open the file, seek to the end to find its length
    //
#ifdef WIN32 /*[*/
    fd = _open(fileName, _O_RDONLY);
    if (fd != -1)
    {
        count = _lseek(fd, 0, SEEK_END) + 1;
        _close(fd);
    }
#else /*][*/
    fd = open(fileName, O_RDONLY);
    if (fd != -1)
    {
        count = lseek(fd, 0, SEEK_END) + 1;
        close(fd);
    }
#endif /*]*/

    return count;
}
unsigned long GFnGetFileLength ( std::ifstream &  file)

Definition at line 36 of file TAPsGLSLFns.cpp.

{
    if ( !file.good() ) return 0;
    //unsigned long pos = file.tellg();
    file.seekg( 0, std::ios::end );
    unsigned long len = file.tellg();
    file.seekg( std::ios::beg );
#ifdef TAPs_DEBUG_MODE
    #ifdef TAPs_USE_WXWIDGETS
        wxLogWarning( wxT( "Length of File: %d" ), len );
    #else
        std::cout << "Length of File: " << len << std::endl;
    #endif
#endif
    return len;
}
bool GFnInitGLSL ( )

Definition at line 82 of file TAPsGLSLFns.cpp.

References gbIsGLSLSupported, gbIsInitialized, and GFnCheckGLSL().

{
    if ( gbIsGLSLSupported ) return true;   // GLSL has already been initialized
    //---------------------------------------------------------------
    // Initialize the "OpenGL Extension Wrangler" library
    if ( gbIsInitialized )   return true;
    gbIsInitialized = true;
    GLenum err = glewInit();
    if ( GLEW_OK != err ) {
#ifdef TAPs_USE_WXWIDGETS
        wxLogError( wxT( "Error: %s" ), glewGetErrorString( err ) );
#else
        std::cerr << "Error: " << glewGetErrorString( err ) << std::endl;
#endif
        gbIsGLSLSupported = false;
        return gbIsGLSLSupported;
    }
    //---------------------------------------------------------------
    // OpenGL Info
#ifdef TAPs_DEBUG_MODE
    #ifdef TAPs_USE_WXWIDGETS
        wxLogWarning( wxT( "OpenGL Vendor:   %s" ), glGetString( GL_VENDOR ) );
        wxLogWarning( wxT( "OpenGL Renderer: %s" ), glGetString( GL_RENDERER ) );
        wxLogWarning( wxT( "OpenGL Version:  %s" ), glGetString( GL_VERSION ) );
    #else
        std::cout << "OpenGL Vendor:   " << glGetString( GL_VENDOR ) << "\n";
        std::cout << "OpenGL Renderer: " << glGetString( GL_RENDERER ) << "\n";
        std::cout << "OpenGL Version:  " << glGetString( GL_VERSION ) << "\n";
    #endif
#endif
    //---------------------------------------------------------------
    GFnCheckGLSL();
    //---------------------------------------------------------------
    return gbIsGLSLSupported;
}

Here is the call graph for this function:


Variable Documentation

BEGIN_NAMESPACE_TAPs__OpenGL char* gbGLSLErrStr[]
Initial value:
 {
    "GLSL is not supported/enabled!",               
    "Not a valid program object!",                  
    "Not a valid object!",                          
    "Out of memory!",                               
    "Compiler log is not available!",               
    "Unknown compiler error!"                       
    "Linker log is not available!",                 
    "Unknown linker error!",                        
    ""                                              
}

Definition at line 18 of file TAPsGLSLFns.cpp.

bool gbIsGLSLSupported = false

Definition at line 29 of file TAPsGLSLFns.cpp.

bool gbIsInitialized = false

Definition at line 30 of file TAPsGLSLFns.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines