[Touch Pro2, Tilt 2 Windows Mobile General] .oisyn:
Hi there,

I'm writing an OpenGL ES 1.0 application using C#, .Net 2.0 and this .Net OpenGL ES wrapper: www .koushikdutta.com/2008/08/net-compact-framework-wrapper-for.html. My phone is a Touch Pro2 (duh), with WM 6.5.5 (build 23549, EnergyRom).

My app is working fine, with the exception of the slideout keyboard. After I slide it out, it renders a couple of frames (20 or so) and then it freezes on the first OpenGL call in the next frame (which is glViewport in my case).

Is there anything I'm doing wrong, or is this a driver issue with my phone?

Here's my setup code:

display = egl.GetDisplay(EGLNativeDisplayType.Default);

int major, minor;
egl.Initialize(display, out major, out minor);

EGLConfig[] configs = new EGLConfig[10];
int[] attribList = new int[]
{
egl.EGL_RED_SIZE, egl.EGL_DONT_CARE,
egl.EGL_GREEN_SIZE, egl.EGL_DONT_CARE,
egl.EGL_BLUE_SIZE, egl.EGL_DONT_CARE,
egl.EGL_DEPTH_SIZE, 16,
egl.EGL_SURFACE_TYPE, egl.EGL_WINDOW_BIT,
egl.EGL_STENCIL_SIZE, egl.EGL_DONT_CARE,
egl.EGL_NONE, egl.EGL_NONE
};

int numConfig;
if (!egl.ChooseConfig(display, attribList, configs, configs.Length, out numConfig) || numConfig < 1)
throw new InvalidOperationException("Unable to choose config.");

config = configs[0];
context = egl.CreateContext(display, config, EGLContext.None, null);
surface = egl.CreateWindowSurface(display, config, windowHandle, null);
if (surface.Pointer == EGLSurface.None.Pointer)
throw new InvalidOperationException("Can't create window surface.");

int width, height;
egl.QuerySurface(display, surface, egl.EGL_WIDTH, out width);
egl.QuerySurface(display, surface, egl.EGL_HEIGHT, out height);
System.Diagnostics.Debug.WriteLine("Surface size: " + width + " x " + height);

egl.MakeCurrent(display, surface, surface, context);

And this is what I do when the control is resized:

egl.MakeCurrent(display, EGLSurface.None, EGLSurface.None, context);
egl.DestroySurface(display, surface);

surface = egl.CreateWindowSurface(display, config, hWnd, null);
if (surface.Pointer == EGLSurface.None.Pointer)
throw new InvalidOperationException("Can't create window surface.");

int width, height;
egl.QuerySurface(display, surface, egl.EGL_WIDTH, out width);
egl.QuerySurface(display, surface, egl.EGL_HEIGHT, out height);
System.Diagnostics.Debug.WriteLine("Surface size: " + width + " x " + height);

egl.MakeCurrent(display, surface, surface, context);

What I'm seeing is as follows. I run the app and it renders normally. Then I slide out the keyboard, and the window is resized. The surface is recreated with the appropriate settings, and I see a 20 or so frames being rendered. Then, all of a sudden, I see what looks like an old framebuffer from before the resize taking up the left half the screen (since it was merely 480 pixels wide), right half black, and the application freezes. Breaking in the debugger reveals it hangs on the first OpenGL call in that frame (glViewport). Shift-f5 doesn't close the app, I can still pop up the start menu and the call window using the physical buttons, but the home screen does not render anything (any contents that happened to be on the screen, the start menu for example, just stay there), nor do applications like arkswitch and advanced task manager. I have to softreset my phone before I can use it again.

What, if any, am I doing wrong?