//==================================================================================================================================== bool GPUProgram::createFromFiles( const std::string& _rstrVertexShaderPath, const std::string& _rstrGeometryShaderPath , const std::string& _rstrFragmentShaderPath ) { // required to have the OpenGL functions working - this is because of our use of OpenGL with Qt initializeOpenGLFunctions(); const bool bUseGeometryShader = "" != _rstrGeometryShaderPath; // Creates the requested Shaders - or assert on error ! m_iGPUVertexShaderID = createShader( _rstrVertexShaderPath, GL_VERTEX_SHADER ); m_iGPUFragmentShaderID = createShader( _rstrFragmentShaderPath, GL_FRAGMENT_SHADER ); if( bUseGeometryShader ) { m_iGPUGeometryShaderID = createShader( _rstrGeometryShaderPath, GL_GEOMETRY_SHADER ); } // Creates the GPU Program m_iGPUProgramID = glCreateProgram(); // Attaches a Vertex and a Fragmen Shader glAttachShader( m_iGPUProgramID, m_iGPUVertexShaderID ); glAttachShader( m_iGPUProgramID, m_iGPUFragmentShaderID ); if( bUseGeometryShader ) { glAttachShader( m_iGPUProgramID, m_iGPUGeometryShaderID ); } // Links the GPU Program to finally make it effective // NB : this will "copy" the attached Shaders into the Program, kinda like static C library linking glLinkProgram( m_iGPUProgramID ); // Now you can detach the Shaders ! // NB : You can even delete the Shaders // if you don't want to use them for other GPU Programs // => they are not needed, since linking "copied" them into the Program ! // NB2: on some mobile device, the driver may not behave properly, // and won't like to have the Shaders to be detached !... But this is out of scope. glDetachShader( m_iGPUProgramID, m_iGPUVertexShaderID ); glDetachShader( m_iGPUProgramID, m_iGPUFragmentShaderID ); if( bUseGeometryShader ) { glDetachShader( m_iGPUProgramID, m_iGPUGeometryShaderID ); } destroyShader( m_iGPUVertexShaderID ); destroyShader( m_iGPUFragmentShaderID ); if( bUseGeometryShader ) { destroyShader( m_iGPUGeometryShaderID ); } }
// the object deletion method void destroyObject( Object *object ) { // This is basic cheching if the object exists then delete the // memory that was allocated for each place if( object != NULL ) { // free each of my arrays that I might have allocated if( object->verticies != NULL ) { free( object->verticies ); } if( object->normals != NULL ) { free( object->normals ); } if( object->connectivity != NULL ) { free( object->connectivity ); } destroyShader( object->shader ); free( object ); } return; }
void Gradient::addColorStop(const Gradient::ColorStop& stop) { m_stops.append(stop); m_stopsSorted = false; destroyShader(); invalidateHash(); }
static void deleteShaders(Shaders *shaders) { destroyShader(shaders->vert_hard); destroyShader(shaders->vert_smooth); destroyShader(shaders->frag_fill); destroyShader(shaders->frag_tex); destroyShader(shaders->frag_quad); destroyShader(shaders->frag_circle); destroyShader(shaders->frag_ring); }
void Gradient::addColorStop(float value, const Color& color) { float r; float g; float b; float a; color.getRGBA(r, g, b, a); m_stops.append(ColorStop(value, r, g, b, a)); m_stopsSorted = false; destroyShader(); invalidateHash(); }
void destroyGlApplication() { destroyShader(); destroyVertexBuffer(); }
Gradient::~Gradient() { destroyShader(); }