From 1a3675956e500796e1652ac0518c30b967ffeae8 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 23 Jan 2021 15:54:02 +0100 Subject: [PATCH] Ported to OpenGL 3.2 for Windows compatibility. --- .../view_25d/lay_plugin/layD25ViewWidget.cc | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc index 9d3c2ac41..4aaed12f1 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc @@ -195,9 +195,6 @@ D25ViewWidget::D25ViewWidget (QWidget *parent) format.setDepthBufferSize (24); format.setSamples (4); // more -> widget extends beyond boundary! format.setStencilBufferSize (8); - format.setProfile (QSurfaceFormat::CoreProfile); - format.setVersion(3, 2); - format.setRenderableType (QSurfaceFormat::OpenGLES); setFormat (format); m_zmin = m_zmax = 0.0; @@ -738,16 +735,16 @@ D25ViewWidget::do_initialize_gl () glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); static const char *shapes_vertex_shader_source = - "#version 320 es\n" + "#version 150\n" "\n" - "layout (location = 0) in vec4 posAttr;\n" + "in vec4 posAttr;\n" "\n" "void main() {\n" " gl_Position = posAttr;\n" "}\n"; static const char *shapes_geometry_shader_source = - "#version 320 es\n" + "#version 150\n" "\n" "uniform vec4 color;\n" "uniform vec4 ambient;\n" @@ -775,7 +772,7 @@ D25ViewWidget::do_initialize_gl () "}\n"; static const char *shapes_fragment_shader_source = - "#version 320 es\n" + "#version 150\n" "\n" "in lowp vec4 vertexColor;\n" "out lowp vec4 fragColor;\n" @@ -817,11 +814,9 @@ D25ViewWidget::do_initialize_gl () // grid plane shader source static const char *gridplan_vertex_shader_source = - "#version 320 es\n" - "#undef lowp\n" - "#undef highp\n" - "#undef mediump\n" - "layout (location = 0) in vec4 posAttr;\n" + "#version 150\n" + "\n" + "in vec4 posAttr;\n" "uniform mat4 matrix;\n" "\n" "void main() {\n" @@ -829,10 +824,8 @@ D25ViewWidget::do_initialize_gl () "}\n"; static const char *gridplan_fragment_shader_source = - "#version 320 es\n" - "#undef lowp\n" - "#undef highp\n" - "#undef mediump\n" + "#version 150\n" + "\n" "uniform lowp vec4 color;\n" "out lowp vec4 fragColor;\n" "void main() {\n" @@ -865,12 +858,12 @@ D25ViewWidget::paintGL () glClearColor (float (c.red ()) / 255.0f, float (c.green ()) / 255.0f, float (c.blue ()) / 255.0f, 1.0); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - const int positions = 0; - if (! m_shapes_program || ! m_gridplane_program) { return; } + int positions = m_shapes_program->attributeLocation ("posAttr"); + QMatrix4x4 scene_trans, scene_trans_wo_y; // provide the displacement and scaling (in this order!) @@ -907,8 +900,11 @@ D25ViewWidget::paintGL () m_shapes_program->release (); + // decoration + positions = m_gridplane_program->attributeLocation ("posAttr"); + // a vertex buffer for the decoration lay::mem_chunks vertexes;