int ReUpdate(void) { double t; tRmMovieCapture *capture; START_PROFILE("ReUpdate"); ReInfo->_refreshDisplay = 0; switch (ReInfo->_displayMode) { case RM_DISP_MODE_NORMAL: t = GfTimeClock(); START_PROFILE("ReOneStep*"); while (ReInfo->_reRunning && ((t - ReInfo->_reCurTime) > RCM_MAX_DT_SIMU)) { ReOneStep(RCM_MAX_DT_SIMU); } STOP_PROFILE("ReOneStep*"); GfuiDisplay(); ReInfo->_reGraphicItf.refresh(ReInfo->s); glutPostRedisplay(); /* Callback -> reDisplay */ break; case RM_DISP_MODE_NONE: ReOneStep(RCM_MAX_DT_SIMU); if (ReInfo->_refreshDisplay) { GfuiDisplay(); } glutPostRedisplay(); /* Callback -> reDisplay */ break; case RM_DISP_MODE_CAPTURE: capture = &(ReInfo->movieCapture); while ((ReInfo->_reCurTime - capture->lastFrame) < capture->deltaFrame) { ReOneStep(capture->deltaSimu); } capture->lastFrame = ReInfo->_reCurTime; GfuiDisplay(); ReInfo->_reGraphicItf.refresh(ReInfo->s); reCapture(); glutPostRedisplay(); /* Callback -> reDisplay */ break; } STOP_PROFILE("ReUpdate"); return RM_ASYNC; }
/** Activate a screen and make it current. @ingroup gui @param screen Screen to activate @warning The current screen at the call time is deactivated. */ void GfuiScreenActivate(void *screen) { if ((GfuiScreen) && (GfuiScreen->onDeactivate)) GfuiScreen->onDeactivate(GfuiScreen->userDeactData); GfuiScreen = (tGfuiScreen*)screen; glutKeyboardFunc(gfuiKeyboard); glutSpecialFunc(gfuiSpecial); glutKeyboardUpFunc(gfuiKeyboardUp); glutSpecialUpFunc(gfuiSpecialUp); glutMouseFunc(gfuiMouse); glutMotionFunc(gfuiMotion); glutPassiveMotionFunc(gfuiPassiveMotion); glutIdleFunc((void(*)(void))NULL); if (GfuiScreen->onlyCallback == 0) { if (GfuiScreen->hasFocus == NULL) { gfuiSelectNext(NULL); } glutDisplayFunc(GfuiDisplay); } else { glutDisplayFunc(GfuiDisplayNothing); } if (GfuiScreen->onActivate) GfuiScreen->onActivate(GfuiScreen->userActData); if (GfuiScreen->onlyCallback == 0) { GfuiDisplay(); glutPostRedisplay(); } }
/** @ingroup racemantools @param text Text to display. @return None. */ void RmLoadingScreenSetText(char *text) { int i, j; GfOut("%s\n", text); if (menuHandle) { if (rmTextLines[rmCurText]) { free(rmTextLines[rmCurText]); } if (text) { rmTextLines[rmCurText] = strdup(text); rmCurText = (rmCurText + 1) % TEXTLINES; } i = rmCurText; j = 0; do { if (rmTextLines[i]) { GfuiLabelSetText(menuHandle, rmTextId[j], rmTextLines[i]); } j++; i = (i + 1) % TEXTLINES; } while (i != rmCurText); GfuiDisplay(); } }
static void reResScreenActivate(void * /* dummy */) { glutDisplayFunc(reDisplay); GfuiDisplay(); glutPostRedisplay(); }
/** @ingroup racemantools @param text Text to display. @return None. */ void RmLoadingScreenSetText(const char *text) { GfLogTrace("%s\n", text); if (!HScreen) { //GfLogWarning("Can't display loading message : loading screen not created.\n"); return; } if (TextLines[CurTextLineIdx]) freez(TextLines[CurTextLineIdx]); if (text) { TextLines[CurTextLineIdx] = strdup(text); CurTextLineIdx = (CurTextLineIdx + 1) % NTextLines; } int i = CurTextLineIdx; int j = 0; do { if (TextLines[i]) GfuiLabelSetText(HScreen, TextLineIds[j], TextLines[i]); j++; i = (i + 1) % NTextLines; } while (i != CurTextLineIdx); GfuiDisplay(); }
/** @ingroup racemantools @param title Screen title. @param bgimg Optionnal backgrounf image (0 for no img). @return None. */ void RmLoadingScreenStart(char *title, char *bgimg) { int i; int y; if (GfuiScreenIsActive(menuHandle)) { /* Already active */ return; } if (menuHandle) { GfuiScreenRelease(menuHandle); } menuHandle = GfuiScreenCreateEx(black, NULL, NULL, NULL, rmDeativate, 0); GfuiTitleCreate(menuHandle, title, strlen(title)); /* create 20 lines of text */ for (i = 0, y = 400; i < TEXTLINES; i++, y -= 16) { white[i][0] = white[i][1] = white[i][2] = 1.0; white[i][3] = (float)i * 0.0421 + 0.2; rmTextId[i] = GfuiLabelCreateEx(menuHandle, "", white[i], GFUI_FONT_MEDIUM_C, 60, y, GFUI_ALIGN_HL_VB, 100); if (rmTextLines[i]) { /* free old text */ free(rmTextLines[i]); rmTextLines[i] = NULL; } } rmCurText = 0; if (bgimg) { GfuiScreenAddBgImg(menuHandle, bgimg); } GfuiScreenActivate(menuHandle); GfuiDisplay(); }
static void reContDisplay(void) { GfuiDisplay(); glutPostRedisplay(); }
/** @ingroup racemantools @param title Screen title. @param bgimg Optional background image (0 for no img). @return None. */ void RmLoadingScreenStart(const char *title, const char *bgimg) { if (HScreen && GfuiScreenIsActive(HScreen)) return; if (HScreen) RmLoadingScreenShutdown(); // Create screen, load menu XML descriptor and create static controls. HScreen = GfuiScreenCreate(BGColor, NULL, NULL, NULL, NULL, 0); void *hmenu = GfuiMenuLoad("loadingscreen.xml"); GfuiMenuCreateStaticControls(HScreen, hmenu); // Create variable title label. int titleId = GfuiMenuCreateLabelControl(HScreen, hmenu, "titlelabel"); GfuiLabelSetText(HScreen, titleId, title); // Get layout / coloring properties. NTextLines = (int)GfuiMenuGetNumProperty(hmenu, "nLines", 20); const int yTopLine = (int)GfuiMenuGetNumProperty(hmenu, "yTopLine", 400); const int yLineShift = (int)GfuiMenuGetNumProperty(hmenu, "yLineShift", 16); const float alpha0 = GfuiMenuGetNumProperty(hmenu, "alpha0", 0.2); const float alphaSlope = GfuiMenuGetNumProperty(hmenu, "alphaSlope", 0.0421); // Allocate line info arrays. FGColors = (float**)calloc(NTextLines, sizeof(float*)); TextLines = (char**)calloc(NTextLines, sizeof(char*)); TextLineIds = (int*)calloc(NTextLines, sizeof(int)); // Create one label for each text line int y = yTopLine; for (int i = 0; i < NTextLines; i++) { // Create and set the color for this line. FGColors[i] = (float*)calloc(4, sizeof(float)); FGColors[i][0] = FGColors[i][1] = FGColors[i][2] = 1.0; FGColors[i][3] = (float)i * alphaSlope + alpha0; // Create the control from the template. TextLineIds[i] = GfuiMenuCreateLabelControl(HScreen, hmenu, "line", true, // from template "", GFUI_TPL_X, y, GFUI_TPL_FONTID, GFUI_TPL_WIDTH, GFUI_TPL_ALIGN, GFUI_TPL_MAXLEN, FGColors[i]); // Next line if not last. y -= yLineShift; } CurTextLineIdx = 0; // Add background image. if (bgimg) GfuiScreenAddBgImg(HScreen, bgimg); // Close menu XML descriptor. GfParmReleaseHandle(hmenu); // Display screen. GfuiScreenActivate(HScreen); GfuiDisplay(); }