PDA

View Full Version : ortho prob



04-27-2004, 05:50 PM
can anyone tell me what is wrong with this code?



void selectionChoice(int x, int y)
{
unsigned int selectBuf[1024];
int hits;
int viewport[1024];

glGetIntegerv(GL_VIEWPORT, viewport);

glSelectBuffer(512, selectBuf);

glRenderMode(GL_SELECT);

glInitNames();
glPushName(0);

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


gluPickMatrix ((GLdouble)x, (GLdouble)(viewport[3] - y), 2, 2, viewport);

if (x > windowHeight)//windowHeight == windowWidth*.75
glOrtho(0, windowWidth*.25, windowHeight, 0, -1, 1); //toolbar
else if (drawType != 2)
gluPerspective(80, 1, .1, 200);
else if (drawType == 2)
glOrtho(-viewsWidth, viewsWidth, -viewsWidth, viewsWidth, -1, 1);

glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);

if (x > windowHeight)
drawToolbar(GL_SELECT);
else if (drawType != 2)
drawRendered(GL_SELECT);
else if (drawType == 2)
drawTextField(GL_SELECT);

hits = glRenderMode(GL_RENDER);
unsigned int currentName;
currentName = processHits(hits, selectBuf);

glMatrixMode(GL_PROJECTION);
glPopMatrix();

glMatrixMode(GL_MODELVIEW);

}It does not seem to be able to pick up any polygons in the toolbar which is located at the right fourth of the screen. it notices a click, but does not give any hits. the other ortho, when drawType == 2, works fine. but this does not work correctly when x > windowWidth*.75 .
any help?

plasmonster
04-28-2004, 03:12 AM
<name>,

your code looks ok to me. I suspect the problem is in one of your functions:


// what's going on in these?
if (x > windowHeight)
drawToolbar(GL_SELECT);
else if (drawType != 2)
drawRendered(GL_SELECT);
else if (drawType == 2)
drawTextField(GL_SELECT);

hits = glRenderMode(GL_RENDER);

unsigned int currentName;

// what's going on in here?
currentName = processHits(hits, selectBuf);