int main(int argc, char **argv) { char **newargs; LST_InitList (FileList); newargs = argparse (argc, argv, Template); if (!newargs) { EL_printf ("%s\n", GlobalErrMsg); printarghelp (Usage, Template); return EXIT_FAILURE; } else { Verbose = SWITCH_VALUE(ARG_VERBOSE); Pack = !SWITCH_VALUE(ARG_PACK); LittleEndian = !SWITCH_VALUE(ARG_BIGENDIAN); HeaderNdxs = SWITCH_VALUE(ARG_CONST); if (ARG_HDFORMAT) hdformat = ARG_HDFORMAT; if (ARG_BYTES) PadSize = EL_atol (ARG_BYTES); if (ARG_HEADER && !HeaderNdxs) { BinOffsets = FALSE; } // // load all requested files // { LST_LIST *nameList; LST_NODE *nd; nameList = MULTI_ARGLINKEDLIST(ARG_INFILES); nd = LST_Head (nameList); while (!LST_EndOfList (nd)) { int fh; long size; char *filename; filename = LST_NodeName (nd); fh = CHK_ReadOpen (filename); { size = CHK_FileLength (fh); if (size == 0) { WarnMess ("File '%s' is zero bytes long\n", filename); } if (Pack) { if (Verbose) { EL_printf ("Reading %14s : size %6ld", filename, size); } if (size) { buf = CHK_AllocateMemory (size, filename); CHK_Read (fh, buf, size); } } // // see if it's the same as a previous file // { FileContents *fc; FileContents *newfc; newfc = (FileContents*)CHK_CreateNode (sizeof (FileContents), filename, "FileContents"); if (Pack) { fc = (FileContents*)LST_Head (FileList); while (!LST_EndOfList (fc)) { if (fc->Size) { if (!memcmp (fc->Data, buf, size)) { break; } } fc = (FileContents*)LST_Next (fc); } } if (Pack && !LST_EndOfList (fc)) { // // it was the same // newfc->Offset = fc->Offset; if (Verbose) { EL_printf (" : Same as %s", LST_NodeName(fc)); } CHK_DeallocateMemory (buf, "FileContents"); } else { // // it was different // newfc->Size = size; newfc->Offset = CurrentAddress; size = (size + PadSize - 1) / PadSize; size *= PadSize; newfc->PadSize = size; CurrentAddress += size; if (Pack) { newfc->Data = buf; } } CHK_Close (fh); if (Pack && Verbose) { EL_printf ("\n"); } LST_AddTail (FileList, newfc); TotalFiles++; } } nd = LST_Next (nd); } } /******************************* Write Files ******************************/ if (!ErrorCount) { FILE *fp; int fh; FileContents *fc; UINT32 offsetTableSize; UINT32 ndxCount = 0; fh = CHK_WriteOpen (ARG_OUTFILE); if (ARG_HEADER) { fp = CHK_fopen (ARG_HEADER, "w"); } if (!BinOffsets) { offsetTableSize = 0; } else { offsetTableSize = (TotalFiles + 1) * sizeof (UINT32); } if (Verbose) { EL_printf ("Writing %ld bytes to file %s\n", CurrentAddress + offsetTableSize, ARG_OUTFILE); } fc = (FileContents*)LST_Head (FileList); while (!LST_EndOfList (fc)) { UINT32 offset; offset = fc->Offset + offsetTableSize; if (ARG_HEADER) { char work[EIO_MAXPATH]; UINT32 hoffset; hoffset = (HeaderNdxs) ? ndxCount : offset; strcpy (work, EIO_Filename(LST_NodeName(fc))); strupr (work); { char *s; s = work; while (*s) { if (*s == '.' || *s == '-') { *s = '_'; } s++; } } CHK_fprintf (fp, hdformat, work, hoffset ); CHK_fprintf (fp, "\n"); } if (BinOffsets) { if (LittleEndian) { MakeLilLong (offset); } else { MakeBigLong (offset); } CHK_Write (fh, &offset, sizeof (UINT32)); } ndxCount++; fc = (FileContents*)LST_Next (fc); } if (BinOffsets) { UINT32 zero = 0; CHK_Write (fh, &zero, sizeof (UINT32)); } fc = (FileContents*)LST_Head (FileList); while (!LST_EndOfList (fc)) { if (fc->Size) { if (Verbose) { EL_printf ("Writing %7ld bytes from %s\n", fc->Size, LST_NodeName (fc)); } if (Pack) { if (fc->Size) { CHK_Write (fh, fc->Data, fc->Size); } } else { int infh; long bytes; #define BUF_SIZE (1024*1024) buf = CHK_AllocateMemory (BUF_SIZE, "copy buffer"); infh = CHK_ReadOpen (LST_NodeName(fc)); bytes = fc->Size; while (bytes) { long len; len = min (bytes, BUF_SIZE); CHK_Read (infh, buf, len); CHK_Write (fh, buf, len); bytes -= len; } CHK_Close (infh); CHK_DeallocateMemory (buf, "copy buffer"); } } { UINT32 pad; pad = fc->PadSize - fc->Size; while (pad) { UINT32 part; part = min (pad, 256); CHK_Write (fh, ZeroData, part); pad -= part; } } fc = (FileContents*)LST_Next (fc); } CHK_Close (fh); } /************************************ ************************************/ } if (GlobalErr) { EL_printf ("%s\n", GlobalErrMsg); return EXIT_FAILURE; } if (ErrorCount) { return EXIT_FAILURE; } return EXIT_SUCCESS; }
bool frameRenderingQueued(const FrameEvent& evt) { if( ExampleFrameListener::frameRenderingQueued(evt) == false ) { // check if we are exiting, if so, clear static HardwareBuffers to avoid segfault WaterCircle::clearStaticBuffers(); return false; } mAnimState->addTime(evt.timeSinceLastFrame); // process keyboard events Real changeSpeed = evt.timeSinceLastFrame ; // adjust keyboard speed with SHIFT (increase) and CONTROL (decrease) if (mKeyboard->isKeyDown(OIS::KC_LSHIFT) || mKeyboard->isKeyDown(OIS::KC_RSHIFT)) { changeSpeed *= 10.0f ; } if (mKeyboard->isKeyDown(OIS::KC_LCONTROL)) { changeSpeed /= 10.0f ; } // rain processCircles(evt.timeSinceLastFrame); if (mKeyboard->isKeyDown(OIS::KC_SPACE)) { particleEmitter->setEmissionRate(20.0f); } else { particleEmitter->setEmissionRate(0.0f); } processParticles(); // adjust values (some macros for faster change #define ADJUST_RANGE(_value,_plus,_minus,_minVal,_maxVal,_change,_macro) {\ if (mKeyboard->isKeyDown(_plus)) \ { _value+=_change ; if (_value>=_maxVal) _value = _maxVal ; _macro ; } ; \ if (mKeyboard->isKeyDown(_minus)) \ { _value-=_change; if (_value<=_minVal) _value = _minVal ; _macro ; } ; \ } ADJUST_RANGE(headDepth, OIS::KC_U, OIS::KC_J, 0, 10, 0.5*changeSpeed, updateInfoHeadDepth()) ; ADJUST_RANGE(waterMesh->PARAM_C, OIS::KC_2, OIS::KC_1, 0, 10, 0.1f*changeSpeed, updateInfoParamC()) ; ADJUST_RANGE(waterMesh->PARAM_D, OIS::KC_4, OIS::KC_3, 0.1, 10, 0.1f*changeSpeed, updateInfoParamD()) ; ADJUST_RANGE(waterMesh->PARAM_U, OIS::KC_6, OIS::KC_5, -2, 10, 0.1f*changeSpeed, updateInfoParamU()) ; ADJUST_RANGE(waterMesh->PARAM_T, OIS::KC_8, OIS::KC_7, 0, 10, 0.1f*changeSpeed, updateInfoParamT()) ; timeoutDelay-=evt.timeSinceLastFrame ; if (timeoutDelay<=0) timeoutDelay = 0; #define SWITCH_VALUE(_key,_timeDelay, _macro) { \ if (mKeyboard->isKeyDown(_key) && timeoutDelay==0) { \ timeoutDelay = _timeDelay ; _macro ;} } SWITCH_VALUE(OIS::KC_N, 0.5f, switchNormals()); SWITCH_VALUE(OIS::KC_M, 0.5f, switchMaterial()); SWITCH_VALUE(OIS::KC_B, 0.5f, switchSkyBox()); animateHead(evt.timeSinceLastFrame); waterMesh->updateMesh(evt.timeSinceLastFrame); return true; }
int main(int argc, char **argv) { char **newargs; char destDirSep = DIRSEP; #if _EL_PLAT_WIN32__ char *destEOL = "\x0d\x0a"; #elif _EL_PLAT_MACOS__ char *destEOL = "\x0d"; #elif _EL_PLAT_SGI__ char *destEOL = "\x0a"; #endif newargs = argparse (argc, argv, Template); if (!newargs) { EL_printf ("%s\n", GlobalErrMsg); printarghelp (Usage, Template); return EXIT_FAILURE; } else { FILE *infp; FILE *outfp; short lineno = 0; Verbose = SWITCH_VALUE(ARG_VERBOSE); if (ARG_MODE) { long mode; mode = EL_atol (ARG_MODE); switch (mode) { case 0: // native break; case 1: // ms-dos destDirSep = '\\'; destEOL = "\x0d\x0a"; break; case 2: // mac destDirSep = ':'; destEOL = "\x0d"; break; case 3: // unix destDirSep = '/'; destEOL = "\x0a"; break; case 4: // 3do destDirSep = '/'; destEOL = "\x0d"; break; default: EL_printf ("Error: Unknown mode #%ld\n", mode); return EXIT_FAILURE; } } infp = fopen (ARG_INFILE, "rb"); if (!infp) { EL_printf ("Couldn't open '%s'\n", ARG_INFILE); exit (EXIT_FAILURE); } outfp = fopen (ARG_OUTFILE, "wb"); if (!outfp) { EL_printf ("Couldn't open '%s'\n", ARG_OUTFILE); exit (EXIT_FAILURE); } while (getline (InLine, MAXLINE, infp)) { char *s; char quote; lineno++; s = SkipWhiteSpace (InLine); while (isspace (*s)) { s++; } if (!strncmp (s, "#include", 8)) { // // found include line, translate it // s += 8; s = SkipWhiteSpace (s); if (Verbose) { EL_printf ("Old:#%4d:%-60s\n", lineno, InLine); } switch (*s) { case '<': quote = '>'; break; case '"': quote = '"'; break; default: EL_printf ("Error1: Malformed Include at line %d in file %s\n", lineno, ARG_INFILE); exit (EXIT_FAILURE); } s++; while (*s && *s != quote) { if ( (*s == '\\') || (*s == '/') || (*s == ':') ) { *s = destDirSep; } s++; } if (*s != quote) { EL_printf ("Error2: Malformed Include at line %d in file %s\n", lineno, ARG_INFILE); exit (EXIT_FAILURE); } if (Verbose) { EL_printf ("New:#%4d:%-60s\n", lineno, InLine); } } fputs (InLine, outfp); fputs (destEOL, outfp); } fclose (infp); fclose (outfp); { FileDateType fdt; if (!EIO_GetFileDate (ARG_INFILE, &fdt)) { goto cleanup; } if (!EIO_SetFileDate (ARG_OUTFILE, &fdt)) { goto cleanup; } } { FileAttribType fat; if (!EIO_GetFileAttrib (ARG_INFILE, &fat)) { goto cleanup; } if (!EIO_SetFileAttrib (ARG_OUTFILE, &fat)) { goto cleanup; } } { FileCommentType fct; if (!EIO_GetFileComment (ARG_INFILE, &fct)) { goto cleanup; } if (!EIO_SetFileComment (ARG_OUTFILE, &fct)) { goto cleanup; } } } cleanup: if (GlobalErr) { EL_printf ("%s\n", GlobalErrMsg); return EXIT_FAILURE; } return EXIT_SUCCESS; }