Resetting OpenGL state

853 views
Skip to first unread message

Ali Nakipoğlu

unread,
Oct 24, 2014, 11:28:57 AM10/24/14
to skia-d...@googlegroups.com
Hi,

Im using GrContext to enable gpu accelerated rendering in Skia.

GrContext::resetContext function is resetting opengl state to prevent any problems if the client application has changed any opengl state. This works great. Is there a way to restore applications opengl state or roll back when skia has finished its work? Something like GrContext::rollback?.

My process :

Create OpenGL Context
Create GrContext
Create FBO
WrapFbo for Skia
Grab the Context and do some drawing
Now use this FBO somewhere else in my application.

The last step didn't worked for me because of the problem above. And i spent some time today to analyse state changes between the client application and skia library. List of states is not to long and i guess it can vary according to work skia handling at that moment for me.

Now if I roll back this state changes with :

glDisable( GL_BLEND );
glDisable( GL_VERTEX_PROGRAM_POINT_SIZE );
glDisable( GL_VERTEX_PROGRAM_POINT_SIZE_ARB );
glDisable( GL_VERTEX_PROGRAM_POINT_SIZE_NV );
glDisable( GL_VERTEX_ATTRIB_ARRAY0_NV );
glDisable( GL_VERTEX_ATTRIB_ARRAY1_NV );
glBindVertexArray( 0 );
glPixelStorei( GL_UNPACK_ALIGNMENT, 4 );
glBindFramebuffer( GL_READ_FRAMEBUFFER, 0 );
glBindFramebuffer( GL_READ_FRAMEBUFFER_EXT, 0 );
glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0 );
glBindFramebuffer( GL_DRAW_FRAMEBUFFER_EXT, 0 );
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
glBindFramebuffer( GL_FRAMEBUFFER_EXT, 0 );
glUseProgram( 0 );
glUseProgramObjectARB( 0 );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 );
glBindBuffer( GL_ARRAY_BUFFER, 0 );
glBindBuffer( GL_ARRAY_BUFFER_ARB, 0 );
glDrawBuffer( GL_BACK );
glEnable( GL_DOUBLEBUFFER ); 
glEnable( GL_DITHER ); 
glEnable( GL_DEPTH_WRITEMASK );

every thing works fine.

Brian Salomon

unread,
Oct 24, 2014, 1:20:42 PM10/24/14
to skia-d...@googlegroups.com
Sorry but rolling back to previous state is not something we support. If your on a desktop OpenGL maybe you could do something with glPushAttrib and glPopAttrib.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages