FGAPI void FGAPIENTRY glutSetVertexAttribCoord3(GLint attrib);
FGAPI void FGAPIENTRY glutSetVertexAttribNormal(GLint attrib);
+/* Mobile platforms lifecycle */
+FGAPI void FGAPIENTRY glutFixMyNameInitContextFunc(void (* callback)());
+FGAPI void FGAPIENTRY glutFixMyNamePauseFunc(void (* callback)());
+FGAPI void FGAPIENTRY glutFixMyNameResumeFunc(void (* callback)());
/*
* GLUT API macro definitions -- the display mode definitions
*/
#include <GL/freeglut.h>
+#include <GL/freeglut_ext.h>
#include <stdarg.h>
#include <stdio.h>
/* Program entry point */
-void init_resources() {
+void init_context() {
+ printf("init_context\n"); fflush(stdout);
glClearColor(1,1,1,1);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glutSpecialFunc(special);
glutIdleFunc(idle);
glutMouseFunc(onMouseClick);
+ glutFixMyNameInitContextFunc(init_context);
glutSetOption ( GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION ) ;
- init_resources();
glutMainLoop();
#ifdef _MSC_VER
/* The application is being hidden, but may be restored */
LOGI("handle_cmd: APP_CMD_TERM_WINDOW");
fghPlatformCloseWindowEGL(window);
+ window->State.NeedToFixMyNameInitContext = GL_TRUE;
fgDisplay.pDisplay.single_native_window = NULL;
break;
case APP_CMD_STOP:
surface; in which case fgPlatformOpenWindow will no-op. */
fgPlatformOpenWindow(window, "", GL_FALSE, 0, 0, GL_FALSE, 0, 0, GL_FALSE, GL_FALSE);
/* TODO: INVOKE_WCB(*window, Pause?); */
- /* TODO: INVOKE_WCB(*window, LoadResources/ContextLost/...?); */
/* TODO: INVOKE_WCB(*window, Resume?); */
}
}
SET_CALLBACK( MultiPassive );
}
+/*
+ * Sets the context reload callback for the current window
+ */
+void FGAPIENTRY glutFixMyNameInitContextFunc( void (* callback)() )
+{
+ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutFixMyNameInitContextFunc" );
+ SET_CALLBACK( FixMyNameInitContext );
+}
+
+/*
+ * Sets the pause callback for the current window
+ */
+void FGAPIENTRY glutFixMyNamePauseFunc( void (* callback)() )
+{
+ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutFixMyNamePauseFunc" );
+ SET_CALLBACK( FixMyNamePause );
+}
+
+/*
+ * Sets the resume callback for the current window
+ */
+void FGAPIENTRY glutFixMyNameResumeFunc( void (* callback)() )
+{
+ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutFixMyNameResumeFunc" );
+ SET_CALLBACK( FixMyNameResume );
+}
+
/*** END OF FILE ***/
CHECK_NAME(glutInitContextProfile);
CHECK_NAME(glutInitErrorFunc);
CHECK_NAME(glutInitWarningFunc);
+ CHECK_NAME(glutFixMyNameInitContextFunc)
+ CHECK_NAME(glutFixMyNamePauseFunc)
+ CHECK_NAME(glutFixMyNameResumeFunc)
#undef CHECK_NAME
return NULL;
typedef void (* FGCBMultiMotion )( int, int, int );
typedef void (* FGCBMultiPassive )( int, int, int );
+typedef void (* FGCBFixMyNameInitContext)();
+typedef void (* FGCBFixMyNamePause)();
+typedef void (* FGCBFixMyNameResume)();
+
/* The global callbacks type definitions */
typedef void (* FGCBIdle )( void );
typedef void (* FGCBTimer )( int );
GLboolean NeedToResize; /* Do we need to resize the window? */
GLboolean IsFullscreen; /* is the window fullscreen? */
+
+ GLboolean NeedToFixMyNameInitContext; /* are OpenGL context/resources loaded? */
};
CB_MultiMotion,
CB_MultiPassive,
+ /* Mobile platforms LifeCycle */
+ CB_FixMyNameInitContext,
+ CB_FixMyNamePause,
+ CB_FixMyNameResume,
+
/* Presently ignored */
CB_Select,
CB_OverlayDisplay,
SFG_Window *current_window = fgStructure.CurrentWindow;
freeglut_return_if_fail( window );
+
+ if( window->State.NeedToFixMyNameInitContext ) {
+ INVOKE_WCB( *window, FixMyNameInitContext, ());
+ window->State.NeedToFixMyNameInitContext = GL_FALSE;
+ }
+
freeglut_return_if_fail( FETCH_WCB ( *window, Display ) );
window->State.Redisplay = GL_FALSE;
window->Window.attribute_v_normal = -1;
fgInitGL2();
+
+ window->State.NeedToFixMyNameInitContext = GL_TRUE;
}
/*