SimplePostProcPass::SimplePostProcPass( const QString & fragmentShaderSource, GLenum outputTextureFormat, GLenum outputTextureFiltering) : m_textureFormat(outputTextureFormat) { initializeFbo(outputTextureFiltering); m_quad = new glowutils::ScreenAlignedQuad( glowutils::createShaderFromFile(GL_FRAGMENT_SHADER, fragmentShaderSource.toStdString())); }
SimplePostProcPass::SimplePostProcPass( const QString & vertexShaderSource, const QString & fragmentShaderSource, GLenum outputTextureFormat, GLenum outputTextureFiltering) : m_textureFormat(outputTextureFormat) { initializeFbo(outputTextureFiltering); glow::ref_ptr<glow::Program> program = new glow::Program(); program->attach(glowutils::createShaderFromFile(GL_VERTEX_SHADER, vertexShaderSource.toStdString()), glowutils::createShaderFromFile(GL_FRAGMENT_SHADER, fragmentShaderSource.toStdString())); m_quad = new glowutils::ScreenAlignedQuad(program); }
void PointLightnigRenderPass::initialize() { if (m_initialized) { dsWarning() << "Render pass has been already initialized"; return; } m_pShaderProgram = ShaderProgram::createFromSource(vertexShaderSrc, fragmentShaderSrc); if (!m_pShaderProgram) { return; } // Initialize target render buffer initializeFbo(); glGenVertexArrays(1, &m_vertexArray); glBindVertexArray(m_vertexArray); // Points define the view port (where the drawing will be performed). GLfloat pointCoords[] = { -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f }; // Coordinatex of two triangles vertices to coved the view port GLfloat texCoords[] = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f }; // Indices in texCoords array for two trianges covering the view port GLuint elements[] = { 0, 1, 2, 0, 2, 3 }; glGenBuffers(1, &m_vertexBuffer); glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer); glBufferData(GL_ARRAY_BUFFER, 2 * 4 * sizeof(GLfloat), pointCoords, GL_STATIC_DRAW); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(0); glGenBuffers(1, &m_texCoordBuffer); glBindBuffer(GL_ARRAY_BUFFER, m_texCoordBuffer); glBufferData(GL_ARRAY_BUFFER, 2 * 4 * sizeof(GLfloat), texCoords, GL_STATIC_DRAW); glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(1); glGenBuffers(1, &m_elementsBuffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_elementsBuffer); glBufferData(GL_ELEMENT_ARRAY_BUFFER, 6 * sizeof(GLuint), elements, GL_STATIC_DRAW); DS_CHECK_GL_ERROR; glBindVertexArray(0); m_initialized = true; }