 +  return 0;
 +}
 +
-+static int NACL_GL_MakeCurrent(_THIS)
-+{
-+  if (!_this->hidden->context3d)
-+  {
++static int NACL_GL_MakeCurrent(_THIS) {
++  if (!_this->hidden->context3d) {
 +    assert(_this->hidden->context3d);
 +    SDL_SetError("GL_MakeCurrent called without an OpenGL video mode set");
 +    return -1;
 +  }
 +  fprintf(stderr, "SDL: making GL context current\n");
-+  int32_t pp_resource = _this->hidden->context3d->pp_resource();
-+  glSetCurrentContextPPAPI(pp_resource);
-+  pp::Module* module = pp::Module::Get();
-+  const void* interface = module->GetBrowserInterface(PPB_OPENGLES2_INTERFACE);
-+
-+  RegalMakeCurrent(pp_resource, (struct PPB_OpenGLES2*)interface);
++  glSetCurrentContextPPAPI(_this->hidden->context3d);
++
++  RegalMakeCurrent(_this->hidden->context3d,
++                   (PPB_OpenGLES2 *)g_nacl_opengles2_interface);
 +  glLogMessageCallbackREGAL(regalLogCallback);
 +  return 0;
 +}
 +
-+static void NACL_GL_SwapBuffers(_THIS)
-+{
-+  if (!_this->hidden->context3d)
-+  {
++static void NACL_GL_SwapBuffers(_THIS) {
++  if (!_this->hidden->context3d) {
 +    assert(_this->hidden->context3d);
-+    fprintf(stderr, "SDL: GL_SwapBuffers called without an OpenGL video mode set\n");
++    fprintf(stderr,
++            "SDL: GL_SwapBuffers called without an OpenGL video mode set\n");
 +    return;
 +  }
-+  _this->hidden->context3d->SwapBuffers(pp::BlockUntilComplete());
++  g_nacl_graphics3d_interface->SwapBuffers(_this->hidden->context3d,
++                                           PP_BlockUntilComplete());
 +}
 +#endif
 +
-+} // extern "C"
++}  // extern "C"
 diff --git a/src/video/nacl/SDL_naclvideo.h b/src/video/nacl/SDL_naclvideo.h
 new file mode 100644
-index 0000000..a9fb7b5
+index 0000000..7dde7dd
 --- /dev/null
 +++ b/src/video/nacl/SDL_naclvideo.h
 @@ -0,0 +1,36 @@

 #define C_LINKAGE	"C"
diff --git a/include/SDL_nacl.h b/include/SDL_nacl.h
new file mode 100644
index 0000000..11670fb
--- /dev/null
+++ b/include/SDL_nacl.h
@@ -0,0 +1,24 @@
+#ifndef _SDL_nacl_h
+#define _SDL_nacl_h
+
+#include "begin_code.h"
+#include <ppapi/cpp/input_event.h>
+
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ppapi/c/ppp_instance.h>
+void SDL_NACL_SetInstance(PP_Instance instance, int width, int height);
+void SDL_NACL_PushEvent(const pp::InputEvent& ppevent);
+void SDL_NACL_SetHasFocus(bool has_focus);
+void SDL_NACL_SetPageVisible(bool is_visible);
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus

+  }
+}
+
+static void flush(void *data, int32_t unused);
+
+/* Initialization/Query functions */
+static int NACL_VideoInit(_THIS, SDL_PixelFormat *vformat);
+static SDL_Rect **NACL_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
+static SDL_Surface *NACL_SetVideoMode(_THIS, SDL_Surface *current, int width,
+                                      int height, int bpp, Uint32 flags);
+static void NACL_VideoQuit(_THIS);
+static void NACL_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
+
+#ifdef SDL_VIDEO_OPENGL_REGAL
+static int NACL_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value);
+static int NACL_GL_MakeCurrent(_THIS);
+static void NACL_GL_SwapBuffers(_THIS);
+#endif
+
+/* The implementation dependent data for the window manager cursor */
+struct WMcursor {
+  // Fake cursor data to fool SDL into not using its broken (as it seems)
+  // software cursor emulation.
+};
+
+static void NACL_FreeWMCursor(_THIS, WMcursor *cursor);
+static WMcursor *NACL_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w,
+                                     int h, int hot_x, int hot_y);
+static int NACL_ShowWMCursor(_THIS, WMcursor *cursor);
+static void NACL_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
+
+static int NACL_Available(void) {
+  return g_nacl_pp_instance != 0;
+}
+
+static void NACL_DeleteDevice(SDL_VideoDevice *device) {
