コード例 #1
1
bool AnimeGLWidget::initShaders(QOpenGLShaderProgram &program, QString prefix)
{
    if (!program.addShaderFromSourceFile(QOpenGLShader::Vertex, ":/root/Resources/shaders/" + prefix + "_v.glsl"))
    {
        qDebug() << "failed add shader vertex";
        return false;
    }

    if (!program.addShaderFromSourceFile(QOpenGLShader::Fragment, ":/root/Resources/shaders/" + prefix + "_f.glsl"))
    {
        qDebug() << "failed add shader fragment";
        return false;
    }

    if (!program.link())
    {
        qDebug() << "failed link";
        return false;
    }

    if (!program.bind())
    {
        qDebug() << "failed bind";
        return false;
    }
    return true;
}
コード例 #2
0
ファイル: dvwindow.cpp プロジェクト: chipgw/depthview2
void DVWindow::loadShader(QOpenGLShaderProgram& shader, const char* vshader, const char* fshader) {
    /* Load the shaders from the qrc. */
    shader.addShaderFromSourceFile(QOpenGLShader::Vertex, vshader);

    QFile res(fshader);
    res.open(QIODevice::ReadOnly | QIODevice::Text);
    QString fshaderSrc = res.readAll();

    if (!context()->isOpenGLES())
        fshaderSrc.prepend("#version 130\n");

    shader.addShaderFromSourceCode(QOpenGLShader::Fragment, fshaderSrc);

    /* Bind the attribute handles. */
    shader.bindAttributeLocation("vertex", vertex);
    shader.bindAttributeLocation("uv", uv);

    shader.link();

    /* Bind so we set the texture sampler uniform values. */
    shader.bind();

    /* Left image is TEXTURE0. */
    shader.setUniformValue("textureL", 0);
    /* Right image is TEXTURE1. */
    shader.setUniformValue("textureR", 1);
}
コード例 #3
0
ファイル: drawextensions.hpp プロジェクト: jdisset/seacells
	void load() {
		shader.addShaderFromSourceCode(QOpenGLShader::Vertex,
		                               shaderWithHeader(":/shaders/mvp.vert"));
		shader.addShaderFromSourceCode(QOpenGLShader::Fragment,
		                               shaderWithHeader(":/shaders/flat.frag"));
		shader.link();
		cube.load(shader);
	}
コード例 #4
0
ファイル: main.cpp プロジェクト: RSATom/Qt
//! [4]
void TriangleWindow::initialize()
{
    m_program = new QOpenGLShaderProgram(this);
    m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource);
    m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource);
    m_program->link();
    m_posAttr = m_program->attributeLocation("posAttr");
    m_colAttr = m_program->attributeLocation("colAttr");
    m_matrixUniform = m_program->uniformLocation("matrix");
}
コード例 #5
0
void OpenGLWidgetPrivate::initialize()
{
    initializeOpenGLFunctions();
    m_program = new QOpenGLShaderProgram;
    m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource);
    m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource);
    m_program->link();
    m_posAttr = m_program->attributeLocation("posAttr");
    m_colAttr = m_program->attributeLocation("colAttr");
    m_matrixUniform = m_program->uniformLocation("matrix");
}
コード例 #6
0
ファイル: drawextensions.hpp プロジェクト: jdisset/seacells
	void load() {
		shader.addShaderFromSourceCode(QOpenGLShader::Vertex,
		                               shaderWithHeader(":/shaders/mvp.vert"));
		shader.addShaderFromSourceCode(QOpenGLShader::Fragment,
		                               shaderWithHeader(":/shaders/flat.frag"));
		texture = unique_ptr<QOpenGLTexture>(
		    new QOpenGLTexture(QImage("../resources/sand.jpg").mirrored()));
		texture->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear);
		texture->setMagnificationFilter(QOpenGLTexture::Linear);
		shader.link();
		sphere.load(shader);
	}
コード例 #7
0
ファイル: Shader.cpp プロジェクト: cr8tr/omnidome
    void initShader(QOpenGLShaderProgram& _s, const char *_filename) {
      QString _vertSrc =
        ShaderCompiler::compile(":/shaders/" + QString(_filename) + ".vert");
      QString _fragmentSrc =
        ShaderCompiler::compile(":/shaders/" + QString(_filename) + ".frag");

      _s.addShaderFromSourceCode(QOpenGLShader::Vertex,
                                 _vertSrc);
      _s.addShaderFromSourceCode(QOpenGLShader::Fragment,
                                 _fragmentSrc);
      _s.link();
    }
コード例 #8
0
ファイル: painter.cpp プロジェクト: Boffmann/3D_Grafik
QOpenGLShaderProgram* Painter::createBasicShaderProgram(const QString &vertexShaderFileName, const QString &fragmentShaderFileName)
{
    QOpenGLShaderProgram * program = new QOpenGLShaderProgram();

    m_shaders << FileAssociatedShader::getOrCreate(
        QOpenGLShader::Vertex, vertexShaderFileName, *program);
    m_shaders << FileAssociatedShader::getOrCreate(
        QOpenGLShader::Fragment, fragmentShaderFileName, *program);
    program->bindAttributeLocation("position", 0);
    program->link();

    return program;
}
コード例 #9
0
ファイル: abstractpainter.cpp プロジェクト: Tymolc/CG-I-2015
QOpenGLShaderProgram* AbstractPainter::createBasicShaderProgram(const QString &vertexShaderFileName, const QString &fragmentShaderFileName)
{
    QOpenGLShaderProgram * program = new QOpenGLShaderProgram();
    program->create();

    m_shaders << FileAssociatedShader::getOrCreate(
        QOpenGLShader::Vertex, vertexShaderFileName, *program);
    m_shaders << FileAssociatedShader::getOrCreate(
        QOpenGLShader::Fragment, fragmentShaderFileName, *program);
    program->link();

    return program;
}
コード例 #10
0
ファイル: Viewer.cpp プロジェクト: myluoxz/cgal
QOpenGLShaderProgram* Viewer::declare_program(int name,
                                      const char* v_shader,
                                      const char* f_shader) const
{
  // workaround constness issues in Qt
  Viewer* viewer = const_cast<Viewer*>(this);

  if(d->shader_programs[name])
  {
    return d->shader_programs[name];
  }

  else
  {

    QOpenGLShaderProgram *program = new QOpenGLShaderProgram(viewer);
    if(!program->addShaderFromSourceFile(QOpenGLShader::Vertex,v_shader))
    {
      std::cerr<<"adding vertex shader FAILED"<<std::endl;
    }
    if(!program->addShaderFromSourceFile(QOpenGLShader::Fragment,f_shader))
    {
      std::cerr<<"adding fragment shader FAILED"<<std::endl;
    }
    if(isOpenGL_4_3())
    {
      if(strcmp(f_shader,":/cgal/Polyhedron_3/resources/shader_flat.f" ) == 0)
      {
        if(!program->addShaderFromSourceFile(QOpenGLShader::Geometry,":/cgal/Polyhedron_3/resources/shader_flat.g" ))
        {
          std::cerr<<"adding geometry shader FAILED"<<std::endl;
        }
      }
      if(strcmp(f_shader,":/cgal/Polyhedron_3/resources/solid_wireframe_shader.f" ) == 0)
      {
        if(!program->addShaderFromSourceFile(QOpenGLShader::Geometry,":/cgal/Polyhedron_3/resources/solid_wireframe_shader.g" ))
        {
          std::cerr<<"adding geometry shader FAILED"<<std::endl;
        }
      }
    }
    program->bindAttributeLocation("colors", 1);
    program->link();
    d->shader_programs[name] = program;
    return program;
  }
}
コード例 #11
0
ファイル: lightsources.cpp プロジェクト: ragemcmad/CGBillard
void LightSources::loadShader()
{
    // Standardshader
    QOpenGLShaderProgram* standardShaderProg = new QOpenGLShaderProgram();
    QOpenGLShader vertShader(QOpenGLShader::Vertex);
    vertShader.compileSourceFile(":/shader/lightsource.vert");
    standardShaderProg->addShader(&vertShader);
    QOpenGLShader fragShader(QOpenGLShader::Fragment);
    fragShader.compileSourceFile(":/shader/lightsource.frag");
    standardShaderProg->addShader(&fragShader);
    standardShaderProg->link();

    // Sonnenshader
    this->shaderProgram = standardShaderProg;

    glEnable(GL_TEXTURE_2D);
}
QOpenGLShaderProgram *
GLView::erstelleShaderProgramAusDateien( QString const & p_filenameVertexShader, QString const & p_filenameFragmentShader ) {

	QOpenGLShaderProgram
	* shaderProgram = new QOpenGLShaderProgram( this );

	if( !shaderProgram ) {

		qWarning( ) << "Shader Programm konnte nicht erzeugt werden.\n";

		return 0;
	}

	if(	!shaderProgram->addShaderFromSourceFile( QOpenGLShader::Vertex, shadersPath + "/" + p_filenameVertexShader ) ){

		shaderProgram->removeAllShaders( );
		delete shaderProgram;
		shaderProgram = 0;
		qWarning( ) << "Vertex Shader konnte nicht geladen oder kompiliert werden.\n";

		return 0;
	}

	if(	!shaderProgram->addShaderFromSourceFile( QOpenGLShader::Fragment, shadersPath + "/" + p_filenameFragmentShader ) ){

		shaderProgram->removeAllShaders( );
		delete shaderProgram;
		shaderProgram = 0;
		qWarning( ) << "Fragment Shader konnte nicht geladen oder kompiliert werden.\n";

		return 0;
	}

	if(	!shaderProgram->link( ) ){

		qWarning( ) << "Shader Programm konnte nicht gelinkt werden.\n";

		return  0;
	}

	 return shaderProgram;
}
コード例 #13
0
ファイル: common.cpp プロジェクト: paulolav/mazecompositor
QOpenGLShaderProgram *generateShaderProgram(QObject *parent, QByteArray vsrc, QByteArray fsrc)
{
    QOpenGLShaderProgram *program = new QOpenGLShaderProgram(parent);

    QOpenGLShader *vshader = new QOpenGLShader(QOpenGLShader::Vertex, program);
    vshader->compileSourceCode(vsrc);
    if (!vshader->compileSourceCode(vsrc))
        qFatal("Error in vertex src:\n%s\n", vsrc.constData());

    QOpenGLShader *fshader = new QOpenGLShader(QOpenGLShader::Fragment, program);
    if (!fshader->compileSourceCode(fsrc))
        qFatal("Error in fragment src:\n%s\n", fsrc.constData());

    program->addShader(vshader);
    program->addShader(fshader);
    if (!program->link())
        qFatal("Error linking:\n%s\n%s\n", vsrc.constData(), fsrc.constData());

    return program;
}
コード例 #14
0
// Build a passthrough glsl program
QOpenGLShaderProgram* GLImageProcessor::buildPassthorughProgram() const
{
	QOpenGLShaderProgram* prog = new QOpenGLShaderProgram();

	QOpenGLShader *vshader = new QOpenGLShader(QOpenGLShader::Vertex, prog);
	const char *vsrc =
		"attribute highp vec4 in_Vertex;\n"
		"attribute mediump vec4 in_TexCoord;\n"
		"varying mediump vec4 texCoord;\n"
		"void main(void)\n"
		"{\n"
		"    gl_Position = in_Vertex;\n"
		"    texCoord = in_TexCoord;\n"
		"}\n";
	vshader->compileSourceCode(vsrc);


	QOpenGLShader *fshader = new QOpenGLShader(QOpenGLShader::Fragment, prog);
	const char *fsrc =
		"uniform sampler2D in_Texture;\n"
		"varying mediump vec4 texCoord;\n"
		"void main(void)\n"
		"{\n"
		"    gl_FragColor = texture2D(in_Texture, texCoord.st);\n"
		"}\n";
	fshader->compileSourceCode(fsrc);

	prog->addShader(vshader);
	prog->addShader(fshader);
	prog->bindAttributeLocation("in_Vertex", 0);
	prog->bindAttributeLocation("in_TexCoord", 1);
	prog->link();
	prog->bind();
	prog->setUniformValue("in_Texture", 0);
	prog->release();

	return prog;
}
コード例 #15
0
ファイル: Scene_item.cpp プロジェクト: Huanglihan/cgal
QOpenGLShaderProgram* Scene_item::getShaderProgram(int name, Viewer_interface * viewer) const
{
    switch(name)
    {
    case PROGRAM_WITH_LIGHT:
        if(shader_programs[PROGRAM_WITH_LIGHT])
        {
            return shader_programs[PROGRAM_WITH_LIGHT];
        }

        else
        {

            QOpenGLShaderProgram *program = new QOpenGLShaderProgram(viewer);
            if(!program->addShaderFromSourceFile(QOpenGLShader::Vertex,":/cgal/Polyhedron_3/resources/shader_with_light.v"))
            {
                std::cerr<<"adding vertex shader FAILED"<<std::endl;
            }
            if(!program->addShaderFromSourceFile(QOpenGLShader::Fragment,":/cgal/Polyhedron_3/resources/shader_with_light.f"))
            {
                std::cerr<<"adding fragment shader FAILED"<<std::endl;
            }
            program->link();
            shader_programs[PROGRAM_WITH_LIGHT] = program;
            return program;
        }
        break;
    case PROGRAM_WITHOUT_LIGHT:
        if( shader_programs[PROGRAM_WITHOUT_LIGHT])
        {
            return shader_programs[PROGRAM_WITHOUT_LIGHT];
        }
        else
        {
            QOpenGLShaderProgram *program = new QOpenGLShaderProgram(viewer);
            if(!program->addShaderFromSourceFile(QOpenGLShader::Vertex,":/cgal/Polyhedron_3/resources/shader_without_light.v"))
            {
                std::cerr<<"adding vertex shader FAILED"<<std::endl;
            }
            if(!program->addShaderFromSourceFile(QOpenGLShader::Fragment,":/cgal/Polyhedron_3/resources/shader_without_light.f"))
            {
                std::cerr<<"adding fragment shader FAILED"<<std::endl;
            }
            program->link();
            shader_programs[PROGRAM_WITHOUT_LIGHT] = program;
            return program;
        }
        break;
    case PROGRAM_WITH_TEXTURE:
        if( shader_programs[PROGRAM_WITH_TEXTURE])
        {
            return shader_programs[PROGRAM_WITH_TEXTURE];
        }
        else
        {
            QOpenGLShaderProgram *program = new QOpenGLShaderProgram(viewer);
            if(!program->addShaderFromSourceFile(QOpenGLShader::Vertex,":/cgal/Polyhedron_3/resources/shader_with_texture.v"))
            {
                std::cerr<<"adding vertex shader FAILED"<<std::endl;
            }
            if(!program->addShaderFromSourceFile(QOpenGLShader::Fragment,":/cgal/Polyhedron_3/resources/shader_with_texture.f"))
            {
                std::cerr<<"adding fragment shader FAILED"<<std::endl;
            }
            program->link();
            shader_programs[PROGRAM_WITH_TEXTURE] = program;
            return program;
        }
        break;
    case PROGRAM_WITH_TEXTURED_EDGES:
        if( shader_programs[PROGRAM_WITH_TEXTURED_EDGES])
        {
            return shader_programs[PROGRAM_WITH_TEXTURED_EDGES];
        }
        else
        {
            QOpenGLShaderProgram *program = new QOpenGLShaderProgram(viewer);
            if(!program->addShaderFromSourceFile(QOpenGLShader::Vertex,":/cgal/Polyhedron_3/resources/shader_with_textured_edges.v" ))
            {
                std::cerr<<"adding vertex shader FAILED"<<std::endl;
            }
            if(!program->addShaderFromSourceFile(QOpenGLShader::Fragment,":/cgal/Polyhedron_3/resources/shader_with_textured_edges.f" ))
            {
                std::cerr<<"adding fragment shader FAILED"<<std::endl;
            }
            program->link();
            shader_programs[PROGRAM_WITH_TEXTURED_EDGES] = program;
            return program;

        }
        break;
    case PROGRAM_INSTANCED:
        if( shader_programs[PROGRAM_INSTANCED])
        {
            return shader_programs[PROGRAM_INSTANCED];
        }
        else
        {
            QOpenGLShaderProgram *program = new QOpenGLShaderProgram(viewer);
            if(!program->addShaderFromSourceFile(QOpenGLShader::Vertex,":/cgal/Polyhedron_3/resources/shader_instanced.v" ))
            {
                std::cerr<<"adding vertex shader FAILED"<<std::endl;
            }
            if(!program->addShaderFromSourceFile(QOpenGLShader::Fragment,":/cgal/Polyhedron_3/resources/shader_with_light.f" ))
            {
                std::cerr<<"adding fragment shader FAILED"<<std::endl;
            }
            program->link();
            shader_programs[PROGRAM_INSTANCED] = program;
            return program;

        }
        break;
    case PROGRAM_INSTANCED_WIRE:
        if( shader_programs[PROGRAM_INSTANCED_WIRE])
        {
            return shader_programs[PROGRAM_INSTANCED_WIRE];
        }
        else
        {
            QOpenGLShaderProgram *program = new QOpenGLShaderProgram(viewer);
            if(!program->addShaderFromSourceFile(QOpenGLShader::Vertex,":/cgal/Polyhedron_3/resources/shader_instanced.v" ))
            {
                std::cerr<<"adding vertex shader FAILED"<<std::endl;
            }
            if(!program->addShaderFromSourceFile(QOpenGLShader::Fragment,":/cgal/Polyhedron_3/resources/shader_without_light.f" ))
            {
                std::cerr<<"adding fragment shader FAILED"<<std::endl;
            }
            program->link();
            shader_programs[PROGRAM_INSTANCED_WIRE] = program;
            return program;

        }
        break;
    default:
        std::cerr<<"ERROR : Program not found."<<std::endl;
        return 0;
    }
}
コード例 #16
0
ファイル: Painter.cpp プロジェクト: stiXits/demo_shadow
bool Painter::initialize()
{
    initializeOpenGLFunctions();

    // Note: As always, feel free to change/modify parameters .. as long as its possible to
    // see the terrain and navigation basically works, everything is ok.

    glClearColor(1.f, 1.f, 1.f, 0.f);

    m_quad = new ScreenAlignedQuad(*this);

    m_light = QVector3D(2.f, 3.f, 2.f);

    QOpenGLShaderProgram * program;

    // setup default assimp scene shader (rendering the meshes...)

    // ToDo: If you render your own scene (e.g., a terrain, keep in mind
    // to extend your shaders for supporting shadowmaps as well as in assimp shaders...

    program = createBasicShaderProgram("data/assimp.vert", "data/assimp.frag");
    m_programs[PaintMode1] = program;
    program->bindAttributeLocation("a_vertex", 0);
    program->bindAttributeLocation("a_normal", 1);
    program->bindAttributeLocation("a_texc", 2);
    program->link();

    // load labeling shaders and resources

    m_programs[LabelAlphaMappingProgram]  = createBasicShaderProgram("data/label.vert", "data/labelAM.frag");
    m_programs[LabelDistanceMapProgram] = createBasicShaderProgram("data/label.vert", "data/labelDM.frag");

    m_hpicgsLabelAM = FileAssociatedTexture::getOrCreate2D("data/hpicgs_label.png", *this);
    m_portccLabelAM = FileAssociatedTexture::getOrCreate2D("data/companion_cube_label.png", *this);

    // load and position 3d models in the scene
    // Note: feel free to modify / add / remove here... there should be at least
    // a few scene objects visible ;)

    m_hpicgs = new AssimpScene(*this, "data/hpicgs.obj", true);
    m_hpicgs->transform().scale(0.7f, 0.7f, 0.7f);
    m_hpicgs->transform().translate(-0.9f, 0.8f, -0.3f);
    m_hpicgs->transform().rotate( 56.0f, 0.f, 1.0f, 0.f);
    m_hpicgs->transform().rotate(0.0f, 1.f, 0.0f, 0.f);
    m_plane = new AssimpScene(*this, "data/plane.obj", false);
    m_plane->transform().translate(0.f, -0.1f, 0.f);
    m_portcc = new AssimpScene(*this, "data/companion_cube.obj", true);
    m_portcc->transform().scale(0.5f, 0.5f, 0.5f);
    m_portcc->transform().translate(1.1f, 0.73f, 1.2f);
    m_portcc->transform().rotate(8.0f, 0.f, 1.0f, 0.f);

    // initialize label positions


    // Task_3_1 - ToDo Begin

    // Modify the transformation matrix T to position, scale, and orient
    // the labels to appropriate places, based on the initial view! No
    // interaction should be required to be able to see both labels.

    m_hpicgsLabel = new ScreenAlignedQuad(*this, 0);
    QMatrix4x4 T;
    T.translate(0.5, 0.5, -1.0);
    T.scale(1.0, 0.3);
    // ToDo: use T.translate/scale/rotate ...

    m_transforms << T;

    m_portccLabel = new ScreenAlignedQuad(*this, 0);
    T.translate(-1.5, 0.0, 2.0);
    // ToDo: use T.translate/scale/rotate ...

    m_transforms << T;

    // Task_3_1 - ToDo End


    // initialize shader program attribute input

    program = m_programs[LabelAlphaMappingProgram];
    program->bind();
    program->bindAttributeLocation("a_vertex", 0);
    program->release();

    program = m_programs[LabelDistanceMapProgram];
    program->bind();
    program->bindAttributeLocation("a_vertex", 0);
    program->release();

    // create distance transforms of label images

    glGenTextures(1, &m_hpicgsLabelDM);
    glBindTexture(GL_TEXTURE_2D, m_hpicgsLabelDM);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    {
        QImage image("data/hpicgs_label_bitmask.png");

        // ToDo: pre resize?

        DistanceTransform DT(image, 512, 128, 0.0625f);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F, 512, 128, 0, GL_RED, GL_FLOAT, DT.data());
    }
    glGenerateMipmap(GL_TEXTURE_2D);


    glGenTextures(1, &m_portccLabelDM);
    glBindTexture(GL_TEXTURE_2D, m_portccLabelDM);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    {
        QImage image("data/companion_cube_label_bitmask.png");

        // ToDo: pre resize?
        // image = image.scaled(? , ? , Qt::FastTransformation);

        DistanceTransform DT(image, 512, 128, 0.125f);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F, 512, 128, 0, GL_RED, GL_FLOAT, DT.data());
    }
    glGenerateMipmap(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, 0);

    // create fbo

    m_programs[ShadowMapProgram] = createBasicShaderProgram("data/shadowmap.vert", "data/shadowmap.frag");
    m_programs[ShadowMapDumpProgram] = createBasicShaderProgram("data/dump.vert", "data/dump.frag");

    glGenTextures(1, &m_depthTex);
    glBindTexture(GL_TEXTURE_2D, m_depthTex);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, ShadowMapSize, ShadowMapSize, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0);

    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    float color[] = { 1.0f, 1.0f, 1.0f, 1.0f };
    glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, color);
    glBindTexture(GL_TEXTURE_2D, 0);

    glGenFramebuffers(1, &m_depthFbo);
    glBindFramebuffer(GL_FRAMEBUFFER, m_depthFbo);

    glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_depthTex, 0);
    glDrawBuffer(GL_NONE);
    glReadBuffer(GL_NONE);

    if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
        qDebug() << "depth fbo invalid";

    glBindFramebuffer(GL_FRAMEBUFFER, 0);

    return true;
}