PDA

View Full Version : selectbuffer bug



SteeleR
11-20-2006, 03:43 AM
Hi.. i've got a problem reading(or writing in) the select buffer... the result it returns is something like:
//---
1
2168957372
2168957372
7

2
2168957372
2168957372
7

6
3
2168957372
2168957372

7
6
5
4

2168957372
2168957372
7
6

5
4
5
2168957372

2168957372
7
6
5

4
3
6
2168957372
//---

when I got 8 hits.. the first hit is right.. so does the second.. but in the third the values have changed places...
the code i use is as follows:
//---
GLuint selectBuf[1024];
glSelectBuffer(256, selectBuf);
...
hits = glRenderMode (GL_RENDER);
Memo2->Lines->Clear();
for(GLuint i=0;i<hits*4;i+=4)
{
Memo2->Lines->Add(selectBuf[i]);
Memo2->Lines->Add(selectBuf[i+1]);
Memo2->Lines->Add(selectBuf[i+2]);
Memo2->Lines->Add(selectBuf[i+3]);
Memo2->Lines->Add("");
}
...
//---

any ideas why does it come in changed order?
10x...

k_szczech
11-20-2006, 08:08 AM
These hits are actually:

1
2168957372
2168957372
7

2
2168957372
2168957372
7
6

3
2168957372
2168957372
7
6
5

4
2168957372
2168957372
7
6
5
4

5
2168957372
2168957372
7
6
5
4
3

6
2168957372
....more...Description:

5 - number of objects on the name stack
2168957372 - min depth
2168957372 - max depth
7 - name stack begins here
6
5
4
3 - name stack ends here

SteeleR
11-20-2006, 09:01 AM
so.. after the depth value it gives the names of the items hit, and not the name, depths and ID for every item hit so for every hit there are 4 values stored int the buffer...

just to be clear.. the actual hits are given at the end of the buffer by the form:
1
2168957372
2168957372
7
6
5
4
3
2
1
.... and the objects named 1,2,..,7 are the hit ones, right ?

k_szczech
11-21-2006, 02:55 AM
so for every hit there are 4 values stored int the bufferNot really. Read my description again.

The example you posted above is not correct - it should be:
7 - there are 7 objects on the name stack, not 1
2168957372
2168957372
7
6
5
4
3
2
1