I am wondering if it is possible to simulate the keyhole search effect in OpenGL.
I have my three-dimensional scene, but I want to do everything black everything except the central circle.
I tried this solution, but its completely opposite to what I want:
// here i draw my 3D scene // Begin 2D orthographic mode glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); GLint viewport [4]; glGetIntegerv(GL_VIEWPORT, viewport); gluOrtho2D(0, viewport[2], viewport[3], 0); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); // Here I draw a circle in the center of the screen float radius=50; glBegin(GL_TRIANGLE_FAN); glVertex2f(x, y); for( int n = 0; n <= 100; ++n ) { float const t = 2*M_PI*(float)n/(float)100; glVertex2f(x + sin(t)*r, y + cos(t)*r); } glEnd(); // end orthographic 2D mode glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix();
What I get is a circle drawn in the center, but I would like to get it extra ...
source share