summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
4b1d80d)
git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1291
7f0cb862-5218-0410-a997-
914c9d46530a
#include <GL/freeglut.h>
#include "fg_internal.h"
#include <GL/freeglut.h>
#include "fg_internal.h"
#include "egl/fg_init_egl.h"
void fgPlatformInitialize()
#include "egl/fg_init_egl.h"
void fgPlatformInitialize()
typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState;
struct tagSFG_PlatformWindowState
{
typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState;
struct tagSFG_PlatformWindowState
{
+ int32_t LastHeight;
+ int32_t LastWidth;
};
#endif /* FREEGLUT_INTERNAL_ANDROID_H */
};
#endif /* FREEGLUT_INTERNAL_ANDROID_H */
/* The window is being hidden or closed, clean it up. */
LOGI("handle_cmd: APP_CMD_TERM_WINDOW");
fgDestroyWindow(fgDisplay.pDisplay.single_window);
/* The window is being hidden or closed, clean it up. */
LOGI("handle_cmd: APP_CMD_TERM_WINDOW");
fgDestroyWindow(fgDisplay.pDisplay.single_window);
+ fgDisplay.pDisplay.single_window = NULL;
break;
case APP_CMD_DESTROY:
LOGI("handle_cmd: APP_CMD_DESTROY");
break;
case APP_CMD_DESTROY:
LOGI("handle_cmd: APP_CMD_DESTROY");
void fgPlatformProcessSingleEvent ( void )
{
void fgPlatformProcessSingleEvent ( void )
{
- static int32_t last_width = -1;
- static int32_t last_height = -1;
-
/* When the screen is resized, the window handle still points to the
old window until the next SwapBuffer, while it's crucial to set
the size (onShape) correctly before the next onDisplay callback.
/* When the screen is resized, the window handle still points to the
old window until the next SwapBuffer, while it's crucial to set
the size (onShape) correctly before the next onDisplay callback.
if (window != NULL && window->Window.Handle != NULL) {
int32_t width = ANativeWindow_getWidth(window->Window.Handle);
int32_t height = ANativeWindow_getHeight(window->Window.Handle);
if (window != NULL && window->Window.Handle != NULL) {
int32_t width = ANativeWindow_getWidth(window->Window.Handle);
int32_t height = ANativeWindow_getHeight(window->Window.Handle);
- if (width != last_width || height != last_height) {
- last_width = width;
- last_height = height;
+ if (width != window->State.pWState.LastWidth || height != window->State.pWState.LastHeight) {
+ window->State.pWState.LastWidth = width;
+ window->State.pWState.LastHeight = height;
LOGI("width=%d, height=%d", width, height);
if( FETCH_WCB( *window, Reshape ) )
INVOKE_WCB( *window, Reshape, ( width, height ) );
LOGI("width=%d, height=%d", width, height);
if( FETCH_WCB( *window, Reshape ) )
INVOKE_WCB( *window, Reshape, ( width, height ) );
char progname[5] = "self";
char* argv[] = {progname, NULL};
main(1, argv);
char progname[5] = "self";
char* argv[] = {progname, NULL};
main(1, argv);
+ /* FreeGLUT will exit() by itself if
+ GLUT_ACTION_ON_WINDOW_CLOSE == GLUT_ACTION_EXIT */
}
LOGI("android_main: end");
}
LOGI("android_main: end");
while (!app->destroyRequested)
fgPlatformProcessSingleEvent();
while (!app->destroyRequested)
fgPlatformProcessSingleEvent();
- /* In theory we should let NativeActivity restart us, however this
- doesn't work well yet, so force exit */
- exit(0);
+ /* Let NativeActivity restart us */
+ /* Users may want to forcibly exit() in their main() anyway because
+ NativeActivity doesn't dlclose() us, so all statically-assigned
+ variables keep their old values on restart.. */
void fgPlatformCreateWindow ( SFG_Window *window )
{
fghPlatformCreateWindowEGL(window);
void fgPlatformCreateWindow ( SFG_Window *window )
{
fghPlatformCreateWindowEGL(window);
+ window->State.pWState.LastWidth = -1;
+ window->State.pWState.LastHeight = -1;
GLboolean gameMode, GLboolean isSubWindow )
{
/* TODO: only one full-screen window possible? */
GLboolean gameMode, GLboolean isSubWindow )
{
/* TODO: only one full-screen window possible? */
- static int nb_windows = 0;
- if (nb_windows == 0) {
- nb_windows++;
+ if (fgDisplay.pDisplay.single_window == NULL) {
fgDisplay.pDisplay.single_window = window;
} else {
fgDisplay.pDisplay.single_window = window;
} else {
+ fgWarning("You can't have more than one window on Android");