Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8272159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:02:44+00:00 2026-06-08T07:02:44+00:00

I have the following code to draw an openGL scene void QGLDiagramWidget::paintGL() { glClearColor(0.2f,

  • 0

I have the following code to draw an openGL scene

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->size().width(), this->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->size().width())/((GLfloat)this->size().height()),0.1f,100.0f);



    ... now draw the entire scene with shaders, there's a camera matrix (view) and a model matrix (model) ...
}

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.

The goal is: centering just my pixel area on the viewport and render whatever is really visible there.

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.

This is the image that I obtain to help you understand the problem

enter image description here

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T07:02:47+00:00Added an answer on June 8, 2026 at 7:02 am

    The pickmatrix is used to restrict rendering to a small part of the viewport. Read about gluPickMatrix here: http://www.opengl.org/sdk/docs/man/xhtml/gluPickMatrix.xml

    Picking won’t work with your programmable pipeline. Picking works by associating each drawcall with a “name” (a number that represents the pickable object) and when rendering the scene with picking, it return any pixels/fragments.

    The details are explained here:
    http://content.gpwiki.org/index.php/OpenGL:Tutorials:Picking
    and here
    web.engr.oregonstate.edu/…/Picking/picking.pdf

    You might be better off avoiding deprecated functionality and use color picking, render each object with a unique solid color, then use glReadPixels to find out whats under the mouse.

    Colorpicking is well explained here: http://content.gpwiki.org/index.php/OpenGL_Selection_Using_Unique_Color_IDs

    Another possibility is using ray-primitive tests for selection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got the following code to draw a filled circle in opengl. The
I have the following code to draw text centered vertically (and horizontally) in a
I have the following code for writing draw calls to a back buffer canvas,
I have the following code in my Rails application's routes file: MyApp::Application.routes.draw do constraints
I have following code for updating user's column public void UpdateLastModifiedDate(string username) { using
I have the following code to draw an array of points but it only
I have the following code to draw a square outline with the following code.
I have the following code to draw candlestick visualization. But the visualization is not
I have a simple OpenGL ES 2.0 code to draw points. Here is the
I have the following code: public void DrawLetter(int Cell, string Letter, int X, int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.