PDA

View Full Version : can't select objects at all!...



mehmedean
12-17-2009, 10:51 PM
hi all,

i'm newbie in openGL. I try to make a 3D office planner. I use Visual C++ 2008 Express Edition and latest version of openGL. I still don't understand exactly how things work although I can draw/rotate/etc.. objects. the thing that I want is to be able to select an object however I can't successfully embed the codes I found on the net... Could you please help me about this situation? my main() and gfxinit() are above:

....
void main(int argc, char **argv)
{
glutInit(&argc,argv);
gfxInit();
glutDisplayFunc(drawScene);
glutKeyboardFunc(processKeyboard);
glutMotionFunc(processMouseMotion);
glutMouseFunc(processMouse);
glutMainLoop();
}
....
void gfxInit()
{
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowPosition(0,0);
glutInitWindowSize(winWidth,winHeight);
glutCreateWindow("MyViewer");

glShadeModel(GL_FLAT);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background

glMatrixMode(GL_PROJECTION); // Set the current openGL matrix to GL_PROJECTION ie projection matrix.
glLoadIdentity(); // Load identity values in the above.
gluPerspective(70.0, (GLfloat)winWidth/(GLfloat)winHeight, 1.0, 500.0);

glMatrixMode(GL_MODELVIEW); // Change the current matrix mode to Model-View matrix.
glLoadIdentity();

glClearColor (0.0, 0.0, 0.0, 0.0); // Set the background color to black.

glEnable(GL_DEPTH_TEST);
glEnableClientState(GL_VERTEX_ARRAY);
}
....

DarkShadow44
12-18-2009, 12:26 PM
How do you mean "select an object" ? By clicking on it ?

mehmedean
12-19-2009, 04:27 AM
yes... the code is my current code and has nothing for seection. my problem is how to and where to add stuff? A simple 3D selection c++ code also works for me.

ZbuffeR
12-19-2009, 06:10 AM
Old style GL selection is quite easy for a start :
http://www.opengl.org/resources/faq/technical/selection.htm#sele0020