TAPs 0.7.7.3
TAPsGLARBVertexBufferObject.cpp File Reference
#include "TAPsGLSLFns.hpp"
Include dependency graph for TAPsGLARBVertexBufferObject.cpp:

Go to the source code of this file.

Defines

#define CHECK_GL_ERROR()   GFnCheckGLError( __FILE__, __LINE__ )

Functions

int GFnCheckGLError (char *file, int line)
unsigned long GFnGetFileLength (std::ifstream &file)
unsigned long GFnGetFileLength (char *fileName)
bool GFnInitGLSL ()
bool GFnCheckGLSL ()
bool GFnCheckGL2 ()

Variables

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

Define Documentation

#define CHECK_GL_ERROR ( )    GFnCheckGLError( __FILE__, __LINE__ )

Definition at line 53 of file TAPsGLARBVertexBufferObject.cpp.

Referenced by GLSLProgramObject::BeginGLSL(), ModelDeformableGLSL_Visualization_3DTexture< T >::CalAndRecordFreqsOfHistogramRange_0_255_ToArray(), ModelDeformableGLSL< T >::CalAndRecordFreqsOfHistogramRange_0_255_ToArray(), ModelDeformableGLSL< T >::CollisionDetection(), ModelDeformableGLSL< T >::CollisionDetectionForGrabbingMove(), ModelDeformableGLSL< T >::CollisionDetectionForGrabbingStartOrEnd(), ModelDeformableGLSL< T >::CollisionDetectionTooltipSphereCylinder(), GLSLShader::Compile(), OpenGLCtrlTransferFn::CopyFrom1DTexture(), OpenGLCtrlTransferFn::CopyTo1DTexture(), TexturePool::Create1DTextureFromFile(), TexturePool::Create2DTextureFromFile(), TexturePool::Create3DTextureFromFile(), ModelDeformableGLSL_Visualization_RTGenMesh< T >::DrawByGL(), ModelDeformableGLSL_Visualization_3DTexture< T >::DrawByGL(), ModelDeformableGLSL< T >::DrawByGL_AllElementsWithConnectivities_GPU(), ModelDeformableGLSL< T >::DrawByGL_AllElementsWithConnectivities_GPU_AsQuads(), ModelDeformableGLSL_Visualization_RTGenMesh< T >::DrawByGL_StandardMC(), ModelDeformableGLSL_Visualization_3DTexture< T >::DrawByGLSL(), GLSLProgramObject::EndGLSL(), ModelDeformableGLSL_Visualization_RTGenMesh< T >::GenerateBufferObjects(), ModelDeformableGLSL< T >::GenerateBufferObjects(), GLSLShader::GetCompilerLog(), GLSLProgramObject::GetLinkerLog(), GLSLProgramObject::GetUniLoc(), GLSLFragmentShader::GLSLFragmentShader(), GLSLGeometryShader::GLSLGeometryShader(), GLSLVertexShader::GLSLVertexShader(), RegularPolyhedra< T >::InitGLSL(), GLSLProgramObject::Link(), ModelDeformableGLSL< T >::LoadFromFile(), ModelDeformableGLSL< T >::RelaxationConstraint(), ModelDeformableGLSL< T >::RemoveElementsByCollision(), ModelDeformableGLSL< T >::SaveToFile(), GridGenerator< T, DATA >::SetAllGridPointsToInsideOutsideModel_HW(), OpenGL3DModel< T >::SetData(), ModelDeformableGLSL_Visualization_3DTexture< T >::Setup1DTextureForTransferFnLUT(), ModelDeformableGLSL< T >::Setup3DTextureForConnectivities(), ModelDeformableGLSL_Visualization_3DTexture< T >::Setup3DTextureForVisualization(), ModelDeformableGLSL< T >::SetupA3DTexture(), ModelDeformableGLSL_Visualization_RTGenMesh< T >::SetupEdgeAndTriTablesOnGPU(), ModelDeformableGLSL_Visualization_3DTexture< T >::SetupFBOAndTextureForAlignedSliceDrawDirection(), ModelDeformableGLSL< T >::SimStep(), ModelDeformableGLSL< T >::UpdateConnectivity(), ModelDeformableGLSL_Visualization_RTGenMesh< T >::UpdateCubeTrackingTexture(), OpenGLCtrlTransferFn::UpdateRGBA(), GLSLProgramObject::~GLSLProgramObject(), and GLSLShader::~GLSLShader().


Function Documentation

bool GFnCheckGL2 ( )

Definition at line 199 of file TAPsGLARBVertexBufferObject.cpp.

{
    if ( !gbIsInitialized ) GFnInitGLSL();
    return GLEW_VERSION_2_0 == GL_TRUE;
}
int GFnCheckGLError ( char *  file,
int  line 
)

Definition at line 36 of file TAPsGLARBVertexBufferObject.cpp.

{
    GLenum glErr = glGetError();
    int errCode = 0;
    while ( glErr != GL_NO_ERROR ) {
#ifdef TAPs_USE_WXWIDGETS
        wxLogError( wxT( "GL Error #%d (%s) in file %s at line#%d" ), 
                    glErr, gluErrorString(glErr), file, line );
#else
        std::cerr << "GL Error #" << glErr << " (" << gluErrorString(glErr) << ") "
                  << "in file " << file << " at line#" << line << std::endl;
#endif
        errCode = 1;
        glErr = glGetError();
    }
    return errCode;
}
bool GFnCheckGLSL ( )

Definition at line 138 of file TAPsGLARBVertexBufferObject.cpp.

Referenced by GFnInitGLSL().

{
    if ( gbIsGLSLSupported ) return true;   // GLSL is available and initailized
    //---------------------------------------------------------------
    if ( !gbIsInitialized ) GFnInitGLSL();
    //---------------------------------------------------------------
#ifdef TAPs_DEBUG_MODE
    #ifdef TAPs_USE_WXWIDGETS
        if      ( GLEW_VERSION_2_0 )
            wxLogError( wxT( "OpenGL 2.0 is available!" ) );
        else if ( GLEW_VERSION_1_5 )
            wxLogError( wxT( "OpenGL 1.5 is available!" ) );
        else if ( GLEW_VERSION_1_4 )
            wxLogError( wxT( "OpenGL 1.4 is available!" ) );
        else if ( GLEW_VERSION_1_3 )
            wxLogError( wxT( "OpenGL 1.3 is available!" ) );
        else if ( GLEW_VERSION_1_2 )
            wxLogError( wxT( "OpenGL 1.2 is available!" ) );
    #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::cout << "[FAILIED] OpenGL Shading Language is NOT available!\n";
    #endif
#endif
        gbIsGLSLSupported = false;
    }
    else {
#ifdef TAPs_DEBUG_MODE
    #ifdef TAPs_USE_WXWIDGETS
        wxLogError( wxT( "[OK] OpenGL Shading Language is available!" ) );
    #else
        std::cout << "[OK] OpenGL Shading Language is available!\n";
    #endif
#endif
        gbIsGLSLSupported = true;
    }
    //---------------------------------------------------------------
    return gbIsGLSLSupported;
}

Here is the caller graph for this function:

unsigned long GFnGetFileLength ( std::ifstream &  file)

Definition at line 56 of file TAPsGLARBVertexBufferObject.cpp.

Referenced by GLSLShader::Load().

{
    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
        wxLogError( wxT( "Length of File: %d" ), len );
    #else
        std::cout << "Length of File: " << len << std::endl;
    #endif
#endif
    return len;
}

Here is the caller graph for this function:

unsigned long GFnGetFileLength ( char *  fileName)

Definition at line 74 of file TAPsGLARBVertexBufferObject.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;
}
bool GFnInitGLSL ( )

Definition at line 102 of file TAPsGLARBVertexBufferObject.cpp.

Referenced by GFnCheckGL2(), GFnCheckGLSL(), GLSLProgramObject::GLSLProgramObject(), GLSLShader::GLSLShader(), ModelDeformableGLSL< T >::ModelDeformableGLSL(), ModelDeformableGLSL_Visualization_3DTexture< T >::ModelDeformableGLSL_Visualization_3DTexture(), and ModelDeformableGLSL_Visualization_RTGenMesh< T >::ModelDeformableGLSL_Visualization_RTGenMesh().

{
    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
        wxLogError( wxT( "OpenGL Vendor:   %s" ), glGetString( GL_VENDOR ) );
        wxLogError( wxT( "OpenGL Renderer: %s" ), glGetString( GL_RENDERER ) );
        wxLogError( 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 caller 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 TAPsGLARBVertexBufferObject.cpp.

Referenced by GLSLShader::GetCompilerLog(), and GLSLProgramObject::GetLinkerLog().

bool gbIsGLSLSupported = false

Definition at line 29 of file TAPsGLARBVertexBufferObject.cpp.

Referenced by GLSLProgramObject::AddShader(), GLSLProgramObject::BeginGLSL(), GLSLShader::Compile(), GLSLProgramObject::EndGLSL(), GLSLShader::GetCompilerLog(), GLSLProgramObject::GetLinkerLog(), GLSLProgramObject::GetUniformfv(), GLSLProgramObject::GetUniformiv(), GLSLProgramObject::GetUniformuiv(), GFnCheckGLSL(), GFnInitGLSL(), GLSLFragmentShader::GLSLFragmentShader(), GLSLGeometryShader::GLSLGeometryShader(), GLSLVertexShader::GLSLVertexShader(), GLSLProgramObject::IsGLSLEnabled(), GLSLProgramObject::Link(), GLSLProgramObject::SetUniform1f(), GLSLProgramObject::SetUniform1fv(), GLSLProgramObject::SetUniform1i(), GLSLProgramObject::SetUniform1iv(), GLSLProgramObject::SetUniform1ui(), GLSLProgramObject::SetUniform2f(), GLSLProgramObject::SetUniform2fv(), GLSLProgramObject::SetUniform2i(), GLSLProgramObject::SetUniform2iv(), GLSLProgramObject::SetUniform2ui(), GLSLProgramObject::SetUniform3f(), GLSLProgramObject::SetUniform3fv(), GLSLProgramObject::SetUniform3i(), GLSLProgramObject::SetUniform3iv(), GLSLProgramObject::SetUniform3ui(), GLSLProgramObject::SetUniform4f(), GLSLProgramObject::SetUniform4fv(), GLSLProgramObject::SetUniform4i(), GLSLProgramObject::SetUniform4iv(), GLSLProgramObject::SetUniform4ui(), GLSLProgramObject::SetUniformMatrix2fv(), GLSLProgramObject::SetUniformMatrix3fv(), GLSLProgramObject::SetUniformMatrix4fv(), GLSLProgramObject::SetVertexAttrib1f(), GLSLProgramObject::SetVertexAttrib2f(), GLSLProgramObject::SetVertexAttrib3f(), GLSLProgramObject::SetVertexAttrib4f(), and GLSLProgramObject::~GLSLProgramObject().

bool gbIsInitialized = false

Definition at line 30 of file TAPsGLARBVertexBufferObject.cpp.

Referenced by GFnCheckGL2(), GFnCheckGLSL(), and GFnInitGLSL().

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines