Steff
12-23-2011, 04:15 AM
I work in the moment on a c++ SDL/OpenGL 3D application and run into a problem with picking using glReadPixels and gluUnProject.
Everything works fin till I resize the window.
The problem is that glReadPixels donīt give me a right value for the new screen reagions. I get always the value 8.96831e-044. in this reagions. Else I get back 0.0f till 1.0f.
Here my resize function :
void Video::resize( int xres_, int yres_ )
{
_xres = xres_;
_yres = yres_;
_ratio = static_cast<float>( xres() ) / static_cast<float>( yres() );
SDL_Rect rect = { 0, 0, xres(), yres() };
SDL_SetClipRect( _primary, &rect );
glViewport( 0.0f, 0.0f, xres(), yres() );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective( fov(), ratio(), nearclip(), farclip() );
glMatrixMode( GL_MODELVIEW );
}
The rendering works fine after resize only the picking fails. The reagion from the left lower screen corner work fine. The new reagions above and right beside donīt work.
Everything works fin till I resize the window.
The problem is that glReadPixels donīt give me a right value for the new screen reagions. I get always the value 8.96831e-044. in this reagions. Else I get back 0.0f till 1.0f.
Here my resize function :
void Video::resize( int xres_, int yres_ )
{
_xres = xres_;
_yres = yres_;
_ratio = static_cast<float>( xres() ) / static_cast<float>( yres() );
SDL_Rect rect = { 0, 0, xres(), yres() };
SDL_SetClipRect( _primary, &rect );
glViewport( 0.0f, 0.0f, xres(), yres() );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective( fov(), ratio(), nearclip(), farclip() );
glMatrixMode( GL_MODELVIEW );
}
The rendering works fine after resize only the picking fails. The reagion from the left lower screen corner work fine. The new reagions above and right beside donīt work.