A couple of things you need to realize when using fragments with a glsurfaceview. It gets a little tricky but stay with me. When you navigate to a new fragment, ondestroyview gets called on your fragment with the glsurfaceview automatically, which destroys your view (the glsurfaceview that you created and returned in oncreateview).
So when you navigate to a new fragment then onpause, onstop, ondestroyview gets called automatically, without any work on your part. when you come back to that fragment with the glsurfaceview then oncreateview, onactivitycreated, onstart and onresume gets called automatically, without any work on your part.
The key to your question is understanding the fragment lifecycle which can be found at the android developer website, and understanding how glsurfaceview functions as well.
Now, using the glsurfaceview you have to implement the renderer, using onsurfacecreated, onsurfacechanged, and ondrawframe. Navigating to another fragment and then coming back to your fragment with the glsurfaceview will result in onsurfacecreated being called again, since your glsurfaceview was destroyed in ondestroyview, your context has been lost and you need to reload all of your resources on the gl thread.
Lastly, it looks from your question that ondrawframe is not being called, which is probably due to you not recreating your view, set the renderer, and returning your view from oncreateview.
so in oncreateview you need something like this
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
savedInstanceState)
{
View mView = inflater.inflate(R.layout.fragment_layout, null);
surface = (GLSurfaceView) mView.findViewById (R.id.glsurfaceview);
surface.setEGLContextClientVersion(2);
//return your view here
return mView;
}
@Override
public void onActivityCreated(Bundle mState)
{
super.onActivityCreated(mState);
//setting your renderer here causes onSurfaceCreated to be called
//if you set your renderer here then you have a context to load resources
surface.setRenderer( shader );
}
You don't want to create your rendering class (shader) in oncreateview unless you want your rendering class to 'start over' every time you come back to your fragment with the glsurfaceview. Instead create your rendering class in your Fragments onCreate, that way if you have things set up then you will start right where you left since simply setting the renderer will provide you with the surface which will cause the onsurfacecreated, onsurfacechanged, and ondrawframe to be invoked automatically. Make sure you reload whatever resources you were last using in onsurfacecreated, on in the ondrawframe prior to drawing them.
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
shader = new Shader(this);
Log.d("Fragment", "OnCreate");
}
when it comes to pausing and resuming your fragment, then in most cases this is automatically handled when you dynamically replace a fragment and add it to the backstack, so just simply put surface.onpause() and surface.onResume() in the right spots and you are good to go.
To make things crystal clear try putting log statements in the methods revolving around the fragment lifecycle and glsurfaceview renderer and you will be able to see what is and isn't happening.