From af7595217b4c6413b97b5b6e09f200d7d52da350 Mon Sep 17 00:00:00 2001 From: ouv Date: Fri, 2 Sep 2005 09:06:50 +0000 Subject: [PATCH] Functions from ARB extension defined as pointers --- src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx | 82 ++++++------------- 1 file changed, 26 insertions(+), 56 deletions(-) diff --git a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx index f560a081..3b04118c 100755 --- a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx +++ b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx @@ -47,13 +47,12 @@ #include "vtkOpenGLTexture.h" #include "vtkBMPReader.h" #include "vtkXMLImageDataReader.h" - #include "vtkImageData.h" -#include "GL/glext.h" +#include +#include #include -#include #include #include @@ -82,23 +81,20 @@ extern "C" { #define GL_COORD_REPLACE_ARB 0x8862 #define GL_ARB_point_parameters 1 -GLAPI void APIENTRY glPointParameterfARB (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *); - -GLAPI void APIENTRY glBindProgramARB (GLenum, GLuint); -GLAPI void APIENTRY glGenProgramsARB (GLsizei, GLuint *); -GLAPI void APIENTRY glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glBindProgramNV (GLenum, GLuint); -GLAPI void APIENTRY glGenProgramsNV (GLsizei, GLuint *); -GLAPI void APIENTRY glLoadProgramNV (GLenum, GLuint, GLsizei, const GLubyte *); -GLAPI void APIENTRY glProgramParameter4fNV (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +//GLAPI void APIENTRY glPointParameterfARB (GLenum, GLfloat); +//GLAPI void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *); #ifdef __cplusplus } #endif +PFNGLGENPROGRAMSARBPROC glGenProgramsARB = NULL; +PFNGLDELETEPROGRAMSARBPROC glDeleteProgramsARB = NULL; +PFNGLBINDPROGRAMARBPROC glBindProgramARB = NULL; +PFNGLPROGRAMSTRINGARBPROC glProgramStringARB = NULL; +PFNGLPROGRAMENVPARAMETER4FARBPROC glProgramEnvParameter4fARB = NULL; + unsigned int shaderId; //----------------------------------------------------------------------------- @@ -122,7 +118,7 @@ VISU_OpenGLPointSpriteMapper::VISU_OpenGLPointSpriteMapper() { this->bmpReader = vtkBMPReader::New(); } - this->DefaultPointSize = 10.0; //-1.0; + this->DefaultPointSize = 50.0; //-1.0; this->MaximumSupportedSize = 0.0; this->QuadraticPointDistanceAttenuation[0] = 1.0; this->QuadraticPointDistanceAttenuation[1] = 0.0; @@ -213,39 +209,24 @@ unsigned char *readShaderFile( std::string fileName ) //----------------------------------------------------------------------------- void initShader() { - std::string aResDir = std::string( getenv( "VISU_ROOT_DIR") ) +"/share/salome/resources/"; + std::string fileName = std::string( getenv( "VISU_ROOT_DIR") ) + + "/share/salome/resources/Vertex_Program_ARB.txt"; -#ifdef ARB_PROGRAM - unsigned char* shader = readShaderFile( aResDir + "Vertex_Program_ARB.txt" ); + unsigned char* shader = readShaderFile( fileName ); int size = strlen( (char*)shader ); - /* - cout << "Shader :" << endl; - for( int i = 0; i < size; i++ ) - cout << shader[i]; - cout << endl; - */ + glGenProgramsARB( 1, &shaderId ); glBindProgramARB( GL_VERTEX_PROGRAM_ARB, shaderId ); glProgramStringARB( GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, size, shader ); -#else - unsigned char* shader = readShaderFile( aResDir + "Vertex_Program_NV.txt" ); - int size = strlen( (char*)shader ); + /* cout << "Shader :" << endl; for( int i = 0; i < size; i++ ) cout << shader[i]; cout << endl; - */ - glGenProgramsNV( 1, &shaderId ); - glLoadProgramNV( GL_VERTEX_PROGRAM_NV, shaderId, - size, ( const GLubyte* )shader ); - - glBindProgramNV( GL_VERTEX_PROGRAM_NV, shaderId ); -#endif - /* if( glGetError() == GL_NO_ERROR ) cout << "Loading vertex program... ok" << endl << endl; else @@ -265,13 +246,9 @@ void setShaderConstants() glRotatef( 0.0f, 1.0f, 0.0f, 0.0f ); glRotatef( 0.0f, 0.0f, 1.0f, 0.0f ); -#ifdef ARB_PROGRAM - glProgramEnvParameter4fARB( GL_VERTEX_PROGRAM_ARB, 0, 1.0f, 1.0f, 1.0f, 1.0f ); - glProgramEnvParameter4fARB( GL_VERTEX_PROGRAM_ARB, 1, 1.0f, 10.0f, 100.0f, 1000.0f ); -#else - glProgramParameter4fNV( GL_VERTEX_PROGRAM_NV, 0, 1.0f, 1.0f, 1.0f, 1.0f ); - glProgramParameter4fNV( GL_VERTEX_PROGRAM_NV, 1, 100.0f, 1.0f, 1.0f, 1.0f ); -#endif + glProgramEnvParameter4fARB( GL_VERTEX_PROGRAM_ARB, 0, 50.0f, 1.0f, 1.0f, 1.0f ); + glProgramEnvParameter4fARB( GL_VERTEX_PROGRAM_ARB, 1, 1.0f, 1.0f, 1.0f, 1.0f ); + glProgramEnvParameter4fARB( GL_VERTEX_PROGRAM_ARB, 2, 1.0f, 10.0f, 100.0f, 1000.0f ); } //----------------------------------------------------------------------------- // Release the graphics resources used by this mapper. In this case, release @@ -308,6 +285,12 @@ void VISU_OpenGLPointSpriteMapper::InitializeExtensions() return; } + glGenProgramsARB = (PFNGLGENPROGRAMSARBPROC)glXGetProcAddressARB((const GLubyte*)"glGenProgramsARB"); + glDeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC)glXGetProcAddressARB((const GLubyte*)"glDeleteProgramsARB"); + glBindProgramARB = (PFNGLBINDPROGRAMARBPROC)glXGetProcAddressARB((const GLubyte*)"glBindProgramARB"); + glProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC)glXGetProcAddressARB((const GLubyte*)"glProgramStringARB"); + glProgramEnvParameter4fARB = (PFNGLPROGRAMENVPARAMETER4FARBPROC)glXGetProcAddressARB((const GLubyte*)"glProgramEnvParameter4fARB"); + initShader(); setShaderConstants(); @@ -878,20 +861,11 @@ void VISU_OpenGLPointSpriteMapper::DrawPoints(int idx, initSprites(); - -#ifdef ARB_PROGRAM glEnable( GL_VERTEX_PROGRAM_ARB ); glColor4f( 1.0, 1.0, 1.0, 1.0 ); glBindProgramARB( GL_VERTEX_PROGRAM_ARB, shaderId ); -#else - glEnable( GL_VERTEX_PROGRAM_NV ); - - glColor4f( 1.0, 1.0, 1.0, 1.0 ); - - glBindProgramARB( GL_VERTEX_PROGRAM_NV, shaderId ); -#endif vtkIdType *pts = 0; vtkIdType npts = 0; @@ -945,7 +919,7 @@ void VISU_OpenGLPointSpriteMapper::DrawPoints(int idx, p->GetPoint(pts[0])[0], p->GetPoint(pts[0])[1], p->GetPoint(pts[0])[2] ); - + /* this->DrawTexture( TextureAlphaChannel, p->GetPoint(pts[0])[0], p->GetPoint(pts[0])[1], @@ -968,11 +942,7 @@ void VISU_OpenGLPointSpriteMapper::DrawPoints(int idx, } glEnd(); -#ifdef ARB_PROGRAM glDisable( GL_VERTEX_PROGRAM_ARB ); -#else - glDisable( GL_VERTEX_PROGRAM_NV ); -#endif } } // -- 2.39.2