Skip to main content
gamedev.net
🔒 Locked

GL_SELECT

Started by Zeka Dec 23, 2004 at 7:04 AM 4 replies 550+ views
Original Post
Zeka
Zeka
Hi, can anybody solve my problem: I'm drawing a scene and when user selecting by mouse i call following function: unsigned buff[512]; unsigned viewport[4]; ... glRenderMode(GL_SELECT); pushProjetcionMatrix(); gluPickMatrix(...) drawBoundingBoxes(); popProjectionMatrix(); glRenderMode(GL_RENDER); And then i continue drawing normal scene, but glCallList() function after that is slower in about 4 times. But if i delete drawBoundingBoxes() call here, then all right (but no effect in selection). Sorry for my rough english =)
Zeka
Zeka
So, anyone can't help me??? =(
Zeka
Zeka
There is a scene where my units (in 3D). User selecting them by dragging a rectangle above them (selecting multiple units) and then this rectangle goes to this function:
unsigned *gapi_processSelection (const Rectf *rect, unsigned &h, GDrawer *drawer)
{
unsigned selectBuf[BUFFSIZE];
int viewport[4];

glGetIntegerv(GL_VIEWPORT, viewport);
glSelectBuffer(BUFFSIZE, selectBuf);
(void)glRenderMode(GL_SELECT);

glInitNames();
glPushName(0);

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();

double wc = rect->lr.x + (rect->ul.x - rect->lr.x)/2;
double hc = rect->lr.y + (rect->ul.y - rect->lr.y)/2;
if (wc == 0)
wc = 1;
if (hc == 0)
hc = 1;

gluPickMatrix( (double) wc,
(double) hc,
(double) (rect->ul.x - rect->lr.x),
(double) (rect->ul.y - rect->lr.y),
viewport );

gapi_setupProjectionSelection();
drawer->drawSelectionBB();

glMatrixMode(GL_PROJECTION);
glPopMatrix();

h = glRenderMode(GL_RENDER);

unsigned *selBuf = (unsigned *)malloc(sizeof(unsigned) * h);
for (int i = 0; i < h; i++) {
selBuf = selectBuf[4 * i + 3];
}

return selBuf;
}
//////////
And after that all my glCallList(handle) is much-much slower!
drawer->drawSelectionBB() draws bounding boxes of my units. And as result of several experiments I realize that if I something draw between GL_SELECT and GL_RENDER this problem occuring, else all right.
Zeka
Zeka
What i'm doing wrong?
zedzeek
zedzeek
perhaps have a look at other ppls code eg

http://uk.geocities.com/sloppyturds/stuff/selection_bufferSRC.zip
theres also a demo with glut + u could google some more

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.