🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Picking with multi-monitors

Started by
-1 comments, last by Woltan 17 years, 7 months ago
Hey folks, i ran into a problem for which i need your help. I am using a picking method much like in NeHes tutorial #32. Everything works out fine, except when I use multiple monitors. Here the source how the pickin is done:

int ResourceHolder::RetrieveObject(int x, int y, OpenGLWindow *pWindow)
	{
	int objectsFound = 0;
	int	viewportCoords[4] = {0};
	unsigned int selectBuffer[32] = {0};				
														
	glSelectBuffer(32, selectBuffer);

	glGetIntegerv(GL_VIEWPORT, viewportCoords);

	glMatrixMode(GL_PROJECTION);
	
	glPushMatrix();

	glRenderMode(GL_SELECT);

	glLoadIdentity();

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

	pWindow->PushPerspective();

	glMatrixMode(GL_MODELVIEW);
	
	pWindow->Paint();//<--- criical call
	pWindow->SwapBuffers();

	objectsFound = glRenderMode(GL_RENDER);

	glMatrixMode(GL_PROJECTION);
	glPopMatrix();

	glMatrixMode(GL_MODELVIEW);

	if(objectsFound > 0)
		{
		unsigned int lowestDepth = selectBuffer[1];

		int selectedObject = selectBuffer[3];

		for(int i = 1; i < objectsFound; i++)
			{
			if(selectBuffer[(i * 3) + 1] < lowestDepth)
				{
				lowestDepth = selectBuffer[(i * 3) + 1];

				selectedObject = selectBuffer[(i * 3) + 3];
				}
			}	
		return selectedObject;
		}
	return 0;											
	}
I think the source should be pretty self explainatory, however if there is something unclear, i am happy to go into it in more detail. What is going wrong: The critical call is when I render into the selection buffer. This takes about 15 times longer than it usualy does (no multi monitoring). Does anyone have an idea of what is going wrong? Maybe a link to an article where this problem is discribed? Any hint, help or link is appreciated! cherio Woltan

This topic is closed to new replies.

Advertisement