Note that there are some explanatory texts on larger screens.

plurals
  1. POgluPickMatrix - something's wrong and an object is always on the scene
    primarykey
    data
    text
    <p>I have the following code to draw an openGL scene</p> <pre><code>void QGLDiagramWidget::paintGL() { glClearColor(0.2f, 0.0f, 0.5f, 0.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glEnable(GL_MULTISAMPLE); ... load shaders... ... load buffers... ... load textures... glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Set viewport area glViewport(0, 0, this-&gt;size().width(), this-&gt;size().height()); GLint view[4]; glGetIntegerv(GL_VIEWPORT, view); glLoadIdentity(); gluPickMatrix(1, 1, 1, 1, view); // THIS IS THE RELEVANT CODE // I don't use a fixed pipeline, so let's store this pickmatrix in a variable Matrix pickingPerspMatrix; glGetFloatv(GL_PROJECTION_MATRIX, pickingPerspMatrix); // This is successful in my code // Create the projection matrix gl_projection.setToIdentity(); gl_projection *= pickingPerspMatrix; // APPLY THE PICKING MATRIX gl_projection.perspective(45.,((GLfloat)this-&gt;size().width())/((GLfloat)this-&gt;size().height()),0.1f,100.0f); ... now draw the entire scene with shaders, there's a camera matrix (view) and a model matrix (model) ... } </code></pre> <p>As long as I know, this should take a pick matrix from the rect from bottom-left pixel 1,1 (the first of the scene) with width 1 and height 1 and multiply it by the identity matrix and then apply the perspective matrix over it.</p> <p>The goal is: centering just my pixel area on the viewport and render whatever is really visible there.</p> <p>Turns out that whatever value I put into the gluPickMatrix, the object in my viewport is ALWAYS visible, just shrinked or distorted or deformed, but always int he viewport area. And this is wrong since asking for the pick matrix from point (0;0) plus width 1 and height 1 should return an empty area.</p> <p>This is the image that I obtain to help you understand the problem</p> <p><img src="https://i.stack.imgur.com/LxEdG.jpg" alt="enter image description here"></p> <p>Why is this happening? What is a pick matrix supposed to do? Translate the objects out of the scene? Since I use programmable pipelines in my shaders (they're basically simple shaders to load a texture on the object and use phong lighting), what could cause that object deformation and its constant presence on the scene?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload