// - Update client subsystem for rendering, audio and input
void Client::Tick( void )
{
// - Viewport rendering goes here
// - Update each viewport opened
for( int i = 0; i < nViewports; i++ )
{
assert( viewport ); // - Won't crash
// - Clear viewport and set view
render->preCompute( viewport );
assert( viewport ); // - Will crash
viewport->tick( ); // - Crashes also
// - Do something like a screen flash
render->postCompute( viewport );
}
}
* i'll get a segmentation violation here and don't know why. The render::preCompute will do nothing else than using some values of viewport to set the view. but afterwards the pointer will point to nirvana. Even an assert-statement will cause a crash here. Any suggestions? [Edited by - S0n0 on October 21, 2005 6:25:14 AM]
🔒 Locked
🎯 Unreal
pointers
Advertisement
Original Post
Hi there, i've got a little problem using pointers and i don't know how to handle that.
// - RenderDevice OpenGL implementationvoid RenderDevice::preCompute( Viewport *viewport ){ // - This is for function-call-backtrace guard( RenderDevice::preCompute ); assert( viewport ); glViewport( viewport->x, viewport->y, viewport->w, viewport->h ); glClear( ClearFlags ); glMatrixMode( GL_PROJECTION ) glLoadIdentity( ); // - This could be wrong glFrustum( -1.f, 1.f, -1.f, 1.f, viewport->nearZ, viewport->farZ ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity( ); glRotatef( viewport->yaw, 1.f, 0.f, 0.f ); glRotatef( viewport->roll, 0.f, 1.f, 0.f ); glRotatef( viewport->pitch, 0.f, 0.f, 1.f ); // - Viewport object will exist until here return; unguard( );}[Edited by - S0n0 on October 21, 2005 6:10:03 AM]
I am not familiar with the guard() and unguard() functions, but one thing I noticed is that the call to unguard() is after the return; line, so it never gets executed. Could that be the problem?
the assert is valid, means viewport is non-null. everything i know is that i never modified the data where viewport points to.
the guard- and unguard-statements are macros implementing try and catch.
an assert will throw an exception catched by the catch-directive after return.
the guard function will push the current function's name onto the stack. Is the function's name out of scope (means function has been left) the name will be popped. If an assertion fails it will throw an exception right to the unguard-statement which rewinds the stack and shows me a backtrace (which functions have been called and what happend in which file and line)
the guard- and unguard-statements are macros implementing try and catch.
an assert will throw an exception catched by the catch-directive after return.
the guard function will push the current function's name onto the stack. Is the function's name out of scope (means function has been left) the name will be popped. If an assertion fails it will throw an exception right to the unguard-statement which rewinds the stack and shows me a backtrace (which functions have been called and what happend in which file and line)
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement