Esempio n. 1
0
void SkyboxRenderer::render(Camera *camera)
{
    _shader->start();
    _shader->loadViewMatrix(camera);
    glm::mat4 mMatrix = Maths::createTransformationMatrix(_cube->getPosition(),
                                                          _cube->getRotX(),
                                                          _cube->getRotY(),
                                                          _cube->getRotZ(),
                                                          _cube->getScale());
    
    _shader->loadModelMatrix(mMatrix);
    bindTextures();
    
    glDepthMask(GL_FALSE);
    glDepthFunc(GL_LEQUAL);
    for(Mesh* m : _cube->getModel()->getMeshes()){
        glBindVertexArray(m->getVaoID());
        glDisable(GL_CULL_FACE);
        glDrawElements(GL_TRIANGLES,m->getVertexCount(), GL_UNSIGNED_INT, 0);
        glEnable(GL_CULL_FACE);
    }
    glDepthMask(GL_TRUE);
    
    glBindVertexArray(0);
    _shader->stop();
    
}
Esempio n. 2
0
/*!
    \reimp
*/
void QGLMaterial::bind(QGLPainter *painter)
{
    painter->setFaceMaterial(QGL::AllFaces, this);
    const_cast<QGLLightModel *>(painter->lightModel())
        ->setModel(QGLLightModel::OneSided); // FIXME
    bindTextures(painter);
}
Esempio n. 3
0
void bindAndSetUniforms(Shader& shader, TextureUnitContainer& cont, const Image& image,
                        const std::string& id, ImageType type) {
    switch (type) {
        case COLOR_ONLY: {
            TextureUnit unit;
            bindColorTexture(image, unit);
            utilgl::setShaderUniforms(shader, image, id + "Parameters");
            shader.setUniform(id + "Color", unit.getUnitNumber());
            cont.push_back(std::move(unit));
            break;
        }
        case COLOR_DEPTH: {
            TextureUnit unit1, unit2;
            bindTextures(image, unit1, unit2);
            utilgl::setShaderUniforms(shader, image, id + "Parameters");
            shader.setUniform(id + "Color", unit1.getUnitNumber());
            shader.setUniform(id + "Depth", unit2.getUnitNumber());
            cont.push_back(std::move(unit1));
            cont.push_back(std::move(unit2));
            break;
        }
        case COLOR_PICKING: {
            TextureUnit unit1, unit2;
            bindColorTexture(image, unit1);
            bindPickingTexture(image, unit2);
            utilgl::setShaderUniforms(shader, image, id + "Parameters");
            shader.setUniform(id + "Color", unit1.getUnitNumber());
            shader.setUniform(id + "Picking", unit2.getUnitNumber());
            cont.push_back(std::move(unit1));
            cont.push_back(std::move(unit2));
            break;
        }
        case COLOR_DEPTH_PICKING: {
            TextureUnit unit1, unit2, unit3;
            bindTextures(image, unit1, unit2, unit3);
            utilgl::setShaderUniforms(shader, image, id + "Parameters");
            shader.setUniform(id + "Color", unit1.getUnitNumber());
            shader.setUniform(id + "Depth", unit2.getUnitNumber());
            shader.setUniform(id + "Picking", unit3.getUnitNumber());
            cont.push_back(std::move(unit1));
            cont.push_back(std::move(unit2));
            cont.push_back(std::move(unit3));
            break;
        }
    }
}
Esempio n. 4
0
void SimplePostProcPass::apply()
{
    bindTextures();

    m_fbo->bind();
    m_quad->draw();
    m_fbo->unbind();
}
Esempio n. 5
0
void Entity::render(Shader* shader)
{
	shader->useShader();
	// Set shader data
	shader->setEntity(this);

	// Update shader
	bindTextures();
	shader->update();

	// Render
	mesh->render();
	shader->stopShader();
}
Esempio n. 6
0
void Shader::bind() const
{
    if (m_shaderProgram)
    {
        ensureGlContext();

        // Enable the program
        glCheck(glUseProgramObjectARB(m_shaderProgram));

        // Bind the textures
        bindTextures();

        // Bind the current texture
        if (m_currentTexture != -1)
            glCheck(glUniform1iARB(m_currentTexture, 0));
    }
}
/**
 *  GLRender, updates and checks handles if necessary.
 *  If node id has changed (ie, if anything in the node has changed)
 *  an update is performed, otherwise it binds the stored handles to units.
 */
void SoXipBindTextures::GLRender(SoGLRenderAction* action)
{
    if (attachmentHandles.getNum() > 16) {
        SoDebugError::post("SoXipBindTextures", "cant process more than 16 handles");
        return;
    }

    bool dbgPrint = false;
    if (mNodeId != getNodeId())
    {
        mNodeId = getNodeId();

        // Check if any handles have changed
        bool handlesChanged = false;
        for (int i = 0; i < attachmentHandles.getNum(); i++) {
            if (mTexHandles[i] != attachmentHandles[i]) {
                handlesChanged = true;
            }
        }

        // If something has changed we process
        if (mNumTextures != attachmentHandles.getNum() || handlesChanged)
        {
            mNumTextures = attachmentHandles.getNum();
	        assignTextures(action);
            dbgPrint = true;
        }
    }

    bindTextures(action);
    syncOutput();

#ifdef a_DEBUG
    if (dbgPrint)
    {
        dbgPrint = false;
        // Debug printout
        FboSetup * fbo = SoXipFboElement::getActive(action->getState(), this);
        int col = fbo->numColorAttachments;
        int dep = fbo->numDepthAttachments;
        SoDebugError::postInfo("SoXipBindTextures", "(fbo %d %d %d) binding %d %d %d on %d %d %d",
            fbo->fboHandle, col, dep, mTexHandles[0], mTexHandles[1], mTexHandles[2],
                                      mTexUnits[0],   mTexUnits[1],   mTexUnits[2]);
    }
#endif
}
Esempio n. 8
0
inline void Mesh::coreDraw() {
	mVAO->bind();

	bindTextures();

	//xxx blinking scene
	//xxx (OpenGL 3.3+)consider using conditional rendering this way:
	//#ifdef FILLWAVE_GLES_3_0
	//#else
	//   mConditionalRendering.begin(mOcclusionQuery.getID());
	onDraw();
	//   mConditionalRendering.end();
	//
	//#endif

	core::VertexArray::unbindVAO();

	core::Texture2D::unbind2DTextures();
}
Esempio n. 9
0
void Model::draw(Camera * camera)
{
    shaderProgram()->setUniformMatrix4fv("projection", camera->projectionMatrix());
    shaderProgram()->setUniformMatrix4fv("view", camera->transformationMatrix());
    shaderProgram()->setUniformMatrix4fv("model", transformationMatrix());

    bindTextures();

    shaderProgram()->use();

    if (isWireframeMode())
    {
//          wireframe mode
        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
    }

    glBindVertexArray ( m_vaoId );

    if (geometry()->isExist("index"))
    {
        GeometryBuffer *indices = geometry()->get("index");
        indices->bind();
        glDrawElements(GL_TRIANGLES, indices->size(), GL_UNSIGNED_INT, 0);

    } else {
        glDrawArrays      ( GL_TRIANGLES, 0, geometry()->get("vertex")->size() );
    }

    glBindVertexArray ( 0 );

    if (isWireframeMode())
    {
//          wireframe mode
        glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
    }

    shaderProgram()->disable();

    unbindTextures();

}
Esempio n. 10
0
/**
 * @brief Enables the shader. This will effectively replace the render pipeline functions by
 * the program shader
 * In case the geometry shader fails
 * - Check whether the input geometry primitive type sent by the draw call is
 *   the same as the shader's
 */
void Shader::enable() {
    // Validate the program
    /**
     * XXX: do only during developpement to avoid this overhead in release
     **/
	static int i=0;
	if(i==0)
	{
    	glValidateProgram(mProgramHandle);
		i++;
	}
	else
	{
//		std::cout << "aezfgbfvdnjk"<<std::endl;
	}
    GLenum errCode;

    if ((errCode = glGetError()) != GL_NO_ERROR) {
        std::cerr << "Shader::enable: Error: " << std::endl;
        const GLubyte *errString;
        errString = gluErrorString(errCode);
        std::cerr<< "OpenGL Error (" << errCode << "): "<< errString << std::endl;
        if(errCode = GL_INVALID_OPERATION)  {
            std::cerr << "GL_INVALID_OPERATION is generated if a geometry shader is active and mode is incompatible with the input primitive type of the geometry shader in the currently installed program object."<< std::endl
                << "GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to an enabled array or the element array and the buffer object's data store is currently mapped." << std::endl;
            exit(1);
        }
    }

    // Enable the program
    glUseProgram(mProgramHandle);

    // Bind the textures
    bindTextures();
	if(vao)
	{
		glBindVertexArray(vao);
	}
}
Esempio n. 11
0
void bindDepthTexture(const ImageOutport& outport, GLenum texUnit) {
    bindTextures(*outport.getData(), false, true, false, 0, texUnit, 0);
}
Esempio n. 12
0
void bindPickingTexture(const Image& image, GLenum texUnit) {
    bindTextures(image, false, false, true, 0, 0, texUnit);
}
Esempio n. 13
0
void bindTextures(const ImageOutport& outport, const TextureUnit& colorTexUnit,
                  const TextureUnit& depthTexUnit, const TextureUnit& pickingTexUnit) {
    bindTextures(*outport.getData(), true, true, true, colorTexUnit.getEnum(),
                 depthTexUnit.getEnum(), pickingTexUnit.getEnum());
}
Esempio n. 14
0
void bindTextures(const Image& image, const TextureUnit& colorTexUnit,
                  const TextureUnit& depthTexUnit, const TextureUnit& pickingTexUnit) {
    bindTextures(image, true, true, true, colorTexUnit.getEnum(), depthTexUnit.getEnum(),
                 pickingTexUnit.getEnum());
}
Esempio n. 15
0
void bindTextures(const ImageInport& inport, const TextureUnit& colorTexUnit,
                  const TextureUnit& depthTexUnit) {
    bindTextures(*inport.getData(), true, true, false, colorTexUnit.getEnum(),
                 depthTexUnit.getEnum(), 0);
}
Esempio n. 16
0
void bindTextures(const ImageInport& inport, GLenum colorTexUnit, GLenum depthTexUnit) {
    bindTextures(*inport.getData(), true, true, false, colorTexUnit, depthTexUnit, 0);
}
Esempio n. 17
0
void bindColorTexture(const ImageInport& inport, GLenum texUnit) {
    bindTextures(*inport.getData(), true, false, false, texUnit, 0, 0);
}
Esempio n. 18
0
void bindPickingTexture(const Image& image, const TextureUnit& texUnit) {
    bindTextures(image, false, false, true, 0, 0, texUnit.getEnum());
}
Esempio n. 19
0
void bindDepthTexture(const ImageInport& inport, const TextureUnit& texUnit) {
    bindTextures(*inport.getData(), false, true, false, 0, texUnit.getEnum(), 0);
}
Esempio n. 20
0
void bindPickingTexture(const ImageOutport& outport, GLenum texUnit) {
    bindTextures(*outport.getData(), false, false, true, 0, 0, texUnit);
}
Esempio n. 21
0
void bindColorTexture(const ImageOutport& outport, const TextureUnit& texUnit) {
    bindTextures(*outport.getData(), true, false, false, texUnit.getEnum(), 0, 0);
}
Esempio n. 22
0
void bindTextures(const ImageOutport& outport, GLenum colorTexUnit, GLenum depthTexUnit,
                  GLenum pickingTexUnit) {
    bindTextures(*outport.getData(), true, true, true, colorTexUnit, depthTexUnit,
                 pickingTexUnit);
}
Esempio n. 23
0
void bindTextures(const Image& image, GLenum colorTexUnit, GLenum depthTexUnit,
                  GLenum pickingTexUnit) {
    bindTextures(image, true, true, true, colorTexUnit, depthTexUnit, pickingTexUnit);
}
Esempio n. 24
0
void bindDepthTexture(const Image& image, GLenum texUnit) {
    bindTextures(image, false, true, false, 0, texUnit, 0);
}
Esempio n. 25
0
void bindPickingTexture(const ImageOutport& outport, const TextureUnit& texUnit) {
    bindTextures(*outport.getData(), false, false, true, 0, 0, texUnit.getEnum());
}
Esempio n. 26
0
void bindTextures(const Image& image, const TextureUnit& colorTexUnit,
                  const TextureUnit& depthTexUnit) {
    bindTextures(image, true, true, false, colorTexUnit.getEnum(), depthTexUnit.getEnum(), 0);
}
Esempio n. 27
0
void bindDepthTexture(const Image& image, const TextureUnit& texUnit) {
    bindTextures(image, false, true, false, 0, texUnit.getEnum(), 0);
}
Esempio n. 28
0
void bindTextures(const Image& image, GLenum colorTexUnit, GLenum depthTexUnit) {
    bindTextures(image, true, true, false, colorTexUnit, depthTexUnit, 0);
}