From 87f8c49cffe8a994c62c08cdb207e03ed4e0b6b8 Mon Sep 17 00:00:00 2001 From: ccolin Date: Mon, 28 Dec 2020 18:58:34 +0100 Subject: remove deadcode --- src/opengl_widget.cc | 69 +++++++++------------------------------------------- 1 file changed, 12 insertions(+), 57 deletions(-) (limited to 'src/opengl_widget.cc') diff --git a/src/opengl_widget.cc b/src/opengl_widget.cc index 8d7cab5..5a82d23 100644 --- a/src/opengl_widget.cc +++ b/src/opengl_widget.cc @@ -34,6 +34,7 @@ OpenGLWidget::~OpenGLWidget() { void OpenGLWidget::loadSkybox() { + // Shader program if (!skybox_program.addShaderFromSourceFile(QOpenGLShader::Vertex, ":/shaders/skybox.vert")) { qFatal("Error compiling skybox.vert: %s", skybox_program.log().toLocal8Bit().constData()); } @@ -46,17 +47,17 @@ void OpenGLWidget::loadSkybox() { skybox_program.bind(); skybox_program.setUniformValue("skybox", 0); - // GLfloat skybox_verts[] = { - // -1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, -1.0, 1.0, -1.0, - // -1.0, -1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, -1.0, 1.0, - // 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, -1.0, -1.0, - // -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, -1.0, -1.0, 1.0, - // -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -1.0, - // -1.0, -1.0, -1.0, -1.0, -1.0, 1.0, 1.0, -1.0, -1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0 - // }; - QVector skybox_verts = load_obj(":/mdl/cube.obj", 0); - - // OpenGL native VAO version + QVector skybox_verts { + -1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, -1.0, 1.0, -1.0, + -1.0, -1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, -1.0, 1.0, + 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, -1.0, -1.0, + -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, -1.0, -1.0, 1.0, + -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -1.0, + -1.0, -1.0, -1.0, -1.0, -1.0, 1.0, 1.0, -1.0, -1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0 + }; + // QVector skybox_verts = load_obj(":/mdl/cube.obj", 0); + + // VAO glGenVertexArrays(1, &skybox_vao); glBindVertexArray(skybox_vao); glGenBuffers(1, &skybox_vbo); @@ -66,15 +67,6 @@ void OpenGLWidget::loadSkybox() { glEnableVertexAttribArray(0); glBindVertexArray(0); - // // QOpenGLVertexArrayObject version - // skybox_vao.create(); - // skybox_vao.bind(); - // QOpenGLBuffer skybox_vbo(QOpenGLBuffer::VertexBuffer); - // skybox_vbo.setUsagePattern(QOpenGLBuffer::StaticDraw); - // skybox_vbo.allocate((void *) skybox_verts.data(), skybox_verts.size() * sizeof (GLfloat)); - // skybox_program.setAttributeBuffer(0, GL_FLOAT, 0, 3, 0); - // skybox_program.enableAttributeArray(0); - // Skybox texture images QVector skybox_img { QImage(":/img/clouds1_west.jpg").convertToFormat(QImage::Format_RGB888), @@ -86,8 +78,6 @@ void OpenGLWidget::loadSkybox() { }; size_t width = skybox_img[0].width(); size_t height = skybox_img[0].height(); - - // OpenGL native texture version glGenTextures(1, &skybox_tex); glBindTexture(GL_TEXTURE_CUBE_MAP, skybox_tex); for (int i = 0; i < 6; i++) { @@ -101,21 +91,6 @@ void OpenGLWidget::loadSkybox() { glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); glBindTexture(GL_TEXTURE_CUBE_MAP, 0); - // // QOpenGLTexture skybox texture version - // skybox_tex = new QOpenGLTexture(QOpenGLTexture::TargetCubeMap); - // skybox_tex->create(); - // skybox_tex->setSize(width, skybox_img[0].height(), height); - // skybox_tex->setFormat(QOpenGLTexture::RGBA8_UNorm); - // skybox_tex->allocateStorage(); - // for (int i = 0; i < 6; i++) { - // skybox_tex->setData(0, 0, (QOpenGLTexture::CubeMapFace) (QOpenGLTexture::CubeMapPositiveX + i), - // QOpenGLTexture::RGBA, QOpenGLTexture::UInt8, - // (const void*) skybox_img[i].constBits(), 0); - // } - // skybox_tex->setWrapMode(QOpenGLTexture::ClampToEdge); - // skybox_tex->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear); - // skybox_tex->setMagnificationFilter(QOpenGLTexture::LinearMipMapLinear); - skybox_program.release(); } @@ -165,28 +140,16 @@ void OpenGLWidget::paintGL() { trans.translate(0, 0, -cam_dist); QMatrix4x4 view = trans * rot; - // skybox_vao.bind(); - // glActiveTexture(GL_TEXTURE0); - // glBindTexture(GL_TEXTURE_CUBE_MAP, skybox_tex); - // // skybox_tex->bind(); - // glDrawArrays(GL_TRIANGLES, 0, 36); - // // skybox_tex->release(); - // skybox_vao.release(); - glDepthMask(GL_FALSE); glDepthFunc(GL_LEQUAL); skybox_program.bind(); skybox_program.setUniformValue("proj", proj); skybox_program.setUniformValue("view", view); - // skybox_program.setUniformValue("model", QMatrix4x4()); glBindVertexArray(skybox_vao); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_CUBE_MAP, skybox_tex); - // skybox_tex->bind(); - // skybox_vao.bind(); glDrawArrays(GL_TRIANGLES, 0, 36); glBindTexture(GL_TEXTURE_CUBE_MAP, 0); - // skybox_tex->release(); skybox_program.release(); glDepthMask(GL_TRUE); glDepthFunc(GL_LESS); @@ -196,14 +159,6 @@ void OpenGLWidget::paintGL() { main_program.setUniformValue("view", view); glActiveTexture(GL_TEXTURE0); - // main_program.setUniformValue("model", QMatrix4x4()); - // skybox_vao.bind(); - // glDrawArrays(GL_TRIANGLES, 0, 36); - - // skybox_program.bind(); - // skybox_program.setUniformValue("proj", proj); - // skybox_program.setUniformValue("view", view); - for (const OpenGLMesh &mesh : meshes) { main_program.setUniformValue("model", mesh.mat); glBindVertexArray(mesh.vao); -- cgit v1.2.3-70-g09d2