Keine Tiefeninformation beim Picking in QGlWidget

Alles rund um die Programmierung mit Qt
Antworten
leseratte_68
Beiträge: 10
Registriert: 16. September 2011 14:58

Keine Tiefeninformation beim Picking in QGlWidget

Beitrag von leseratte_68 »

Hallo zusammen,

ich habe ein Problem mit dem Picken von Objekten in einem QGlWidget.
Grundsätzlich funktioniert alles, jedoch ist bei allen gefundenen Objekte die Tiefeninformation, also z-min und z-max immer genau gleich 2147483648.
Ich habe das mal im Sourcecode markiert.

Ich arbeite unter MinGW, Elipse und Window XP

Hier der relevante Teil des PRogrammcodes:
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
...
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
...
glSelectBuffer(PICKING_BUFSIZE, m_arPickingBuffer);
glRenderMode(GL_SELECT);
...
glMatrixMode(GL_PROJECTION);
gluPickMatrix(dPickX, dPickY, iPickRadius, iPickRadius, arTibasVp);
gluPerspective(45, dRatio, 1, 1000);
glMatrixMode(GL_MODELVIEW);
gluLookAt(vEye.x, vEye.y, vEye.z, // eye position
vView.x, vView.y, vView.z, // look at position
0.0f, 1.0f, 0.0f); // up-vector
...
DrawTheScene()....
...
iHits = glRenderMode (GL_RENDER);
ProcessHits(iHits);
void TibasVpOgl::ProcessHits(const GLint _iHits)
{
// pActHit[0] := hit count for hit 0
// pActHit[1] := Minimum depth for hit
// pActHit[2] := Maximum depth for hit
// pActHit[3] := name for 1. hit in this group
// pActHit[4] := name for 2. hit in this group... until hit count

// pActHit[5] := hit count for hit 1
// ...
// ... until _iHits

s32 s32ActHit;
s32 s32ActName;
GLuint *pActValue = m_arPickingBuffer;
GLuint uiNamesCount;
GLuint uiZ1, uiZ2, uiName;
RefPtr<TreeItem> pTI;

qDebug() << "//////////////// hits:" << _iHits; // ------------------> this result is correct !!!

// iter over all hits
for (s32ActHit=0; s32ActHit<_iHits; s32ActHit++)
{
// number of names for this hit
uiNamesCount = *pActValue++; // -------------------------------------> this result is correct !!!
qDebug() << "number of names for this hit: " << uiNamesCount;

// z1
uiZ1 = *pActValue++; // ------------------------------------------------> this result is wrong, always 2147483648 !!!
qDebug() << "z1: " << uiZ1;

// z2
uiZ2 = *pActValue++; // -------------------------------------------------> this result is wrong, always 2147483648 !!!
qDebug() << "z2: " << uiZ2; !!! always 2147483648 !!!

// iter over all names
qDebug() << "names for hit " << s32ActHit << ": ";
for (s32ActName = 0; s32ActName < (s32) uiNamesCount; s32ActName++)
{
// get the next name
uiName = *pActValue++;
qDebug() << "uiName: " << uiName; // ------------------------------> this result is correct !!!
}
}
} // TibasVpOgl::ProcessHits
Hat jemand eine Idee, woran das liegen könnte?

Danke für eure Hilfe
Andreas
Antworten