⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 glut_gamemode.c

📁 mesa-6.5-minigui源码
💻 C
📖 第 1 页 / 共 2 页
字号:
      return -1;    }    bpp = (int) strtol(&word[1], &response, 0);    if (response == &word[1]) {      /* Not a valid number. */      return -1;    }    criterion[0].capability = DM_PIXEL_DEPTH;    criterion[0].comparison = EQ;    criterion[0].value = bpp;    got = specialCaseParse(response,      &criterion[1], 1 << DM_WIDTH | 1 << DM_PIXEL_DEPTH);    if (got >= 0) {      return got + 1;    } else {      return -1;    }  case '@':    /* The @HZ case. */    if (mask & (1 << DM_HERTZ)) {      return -1;    }    hertz = (int) strtol(&word[1], &response, 0);    if (response == &word[1]) {      /* Not a valid number. */      return -1;    }    criterion[0].capability = DM_HERTZ;    criterion[0].comparison = EQ;    criterion[0].value = hertz;    got = specialCaseParse(response,      &criterion[1], ~DM_HERTZ);    if (got >= 0) {      return got + 1;    } else {      return -1;    }  case '\0':    return 0;  }  return -1;}/* This routine is based on similiar code in glut_dstr.c */static intparseCriteria(char *word, Criterion * criterion){  char *cstr, *vstr, *response;  int comparator, value = 0;  cstr = strpbrk(word, "=><!~");  if (cstr) {    switch (cstr[0]) {    case '=':      comparator = EQ;      vstr = &cstr[1];      break;    case '~':      comparator = MIN;      vstr = &cstr[1];      break;    case '>':      if (cstr[1] == '=') {        comparator = GTE;        vstr = &cstr[2];      } else {        comparator = GT;        vstr = &cstr[1];      }      break;    case '<':      if (cstr[1] == '=') {        comparator = LTE;        vstr = &cstr[2];      } else {        comparator = LT;        vstr = &cstr[1];      }      break;    case '!':      if (cstr[1] == '=') {        comparator = NEQ;        vstr = &cstr[2];      } else {        return -1;      }      break;    default:      return -1;    }    value = (int) strtol(vstr, &response, 0);    if (response == vstr) {      /* Not a valid number. */      return -1;    }    *cstr = '\0';  } else {    comparator = NONE;  }  switch (word[0]) {  case 'b':    if (!strcmp(word, "bpp")) {      criterion[0].capability = DM_PIXEL_DEPTH;      if (comparator == NONE) {        return -1;      } else {        criterion[0].comparison = comparator;        criterion[0].value = value;        return 1;      }    }    return -1;  case 'h':    if (!strcmp(word, "height")) {      criterion[0].capability = DM_HEIGHT;      if (comparator == NONE) {        return -1;      } else {        criterion[0].comparison = comparator;        criterion[0].value = value;        return 1;      }    }    if (!strcmp(word, "hertz")) {      criterion[0].capability = DM_HERTZ;      if (comparator == NONE) {        return -1;      } else {        criterion[0].comparison = comparator;        criterion[0].value = value;        return 1;      }    }    return -1;  case 'n':    if (!strcmp(word, "num")) {      criterion[0].capability = DM_NUM;      if (comparator == NONE) {        return -1;      } else {        criterion[0].comparison = comparator;        criterion[0].value = value;        return 1;      }    }    return -1;  case 'w':    if (!strcmp(word, "width")) {      criterion[0].capability = DM_WIDTH;      if (comparator == NONE) {        return -1;      } else {        criterion[0].comparison = comparator;        criterion[0].value = value;        return 1;      }    }    return -1;  }  if (comparator == NONE) {    return specialCaseParse(word, criterion, 0);  }  return -1;}/* This routine is based on similiar code in glut_dstr.c */static Criterion *parseDisplayString(const char *display, int *ncriteria){  Criterion *criteria = NULL;  int n, parsed;  char *copy, *word;  copy = __glutStrdup(display);  /* Attempt to estimate how many criteria entries should be     needed. */  n = 0;  word = strtok(copy, " \t");  while (word) {    n++;    word = strtok(NULL, " \t");  }  /* Allocate number of words of criteria.  A word     could contain as many as four criteria in the     worst case.  Example: 800x600:16@60 */  criteria = (Criterion *) malloc(4 * n * sizeof(Criterion));  if (!criteria) {    __glutFatalError("out of memory.");  }  /* Re-copy the copy of the display string. */  strcpy(copy, display);  n = 0;  word = strtok(copy, " \t");  while (word) {    parsed = parseCriteria(word, &criteria[n]);    if (parsed >= 0) {      n += parsed;    } else {      __glutWarning("Unrecognized game mode string word: %s (ignoring)\n", word);    }    word = strtok(NULL, " \t");  }  free(copy);  *ncriteria = n;  return criteria;}void GLUTAPIENTRYglutGameModeString(const char *string){  Criterion *criteria;  int ncriteria;  initGameModeSupport();  criteria = parseDisplayString(string, &ncriteria);  currentDm = findMatch(dmodes, ndmodes, criteria, ncriteria);  free(criteria);}int GLUTAPIENTRYglutEnterGameMode(void){  GLUTwindow *window;  int width, height;  Window win;  if (__glutMappedMenu) {    __glutFatalUsage("entering game mode not allowed while menus in use");  }  if (__glutGameModeWindow) {    /* Already in game mode, so blow away game mode       window so apps can change resolutions. */    window = __glutGameModeWindow;    /* Setting the game mode window to NULL tricks       the window destroy code into not undoing the       screen display change since we plan on immediately       doing another mode change. */    __glutGameModeWindow = NULL;    __glutDestroyWindow(window, window);  }  /* Assume default screen size until we find out if we     can actually change the display settings. */  width = __glutScreenWidth;  height = __glutScreenHeight;  if (currentDm) {#ifdef _WIN32    LONG status;    static int registered = 0;    status = ChangeDisplaySettings(&currentDm->devmode,      CDS_FULLSCREEN);    if (status == DISP_CHANGE_SUCCESSFUL) {      __glutDisplaySettingsChanged = 1;      width = currentDm->cap[DM_WIDTH];      height = currentDm->cap[DM_HEIGHT];      if (!registered) {        atexit(__glutCloseDownGameMode);        registered = 1;      }    } else {      /* Switch back to default resolution. */      ChangeDisplaySettings(NULL, 0);    }#endif  }  window = __glutCreateWindow(NULL, 0, 0,    width, height, /* game mode */ 1);  win = window->win;#if !defined(_WIN32)  if (__glutMotifHints == None) {    __glutMotifHints = XSGIFastInternAtom(__glutDisplay, "_MOTIF_WM_HINTS",      SGI_XA__MOTIF_WM_HINTS, 0);    if (__glutMotifHints == None) {      __glutWarning("Could not intern X atom for _MOTIF_WM_HINTS.");    }  }  /* Game mode window is a toplevel window. */  XSetWMProtocols(__glutDisplay, win, &__glutWMDeleteWindow, 1);#endif  /* Schedule the fullscreen property to be added and to     make sure the window is configured right.  Win32     doesn't need this. */  window->desiredX = 0;  window->desiredY = 0;  window->desiredWidth = width;  window->desiredHeight = height;  window->desiredConfMask |= CWX | CWY | CWWidth | CWHeight;#ifdef _WIN32  /* Win32 does not want to use GLUT_FULL_SCREEN_WORK     for game mode because we need to be maximizing     the window in game mode, not just sizing it to     take up the full screen.  The Win32-ness of game     mode happens when you pass 1 in the gameMode parameter     to __glutCreateWindow above.  A gameMode of creates     a WS_POPUP window, not a standard WS_OVERLAPPEDWINDOW     window.  WS_POPUP ensures the taskbar is hidden. */  __glutPutOnWorkList(window,    GLUT_CONFIGURE_WORK);#else  __glutPutOnWorkList(window,    GLUT_CONFIGURE_WORK | GLUT_FULL_SCREEN_WORK);#endif  __glutGameModeWindow = window;  return window->num + 1;}int GLUTAPIENTRYglutGameModeGet(GLenum mode){  switch (mode) {  case GLUT_GAME_MODE_ACTIVE:    return __glutGameModeWindow != NULL;  case GLUT_GAME_MODE_POSSIBLE:    return currentDm != NULL;  case GLUT_GAME_MODE_WIDTH:    return currentDm ? currentDm->cap[DM_WIDTH] : -1;  case GLUT_GAME_MODE_HEIGHT:    return currentDm ? currentDm->cap[DM_HEIGHT] : -1;  case GLUT_GAME_MODE_PIXEL_DEPTH:    return currentDm ? currentDm->cap[DM_PIXEL_DEPTH] : -1;  case GLUT_GAME_MODE_REFRESH_RATE:    return currentDm ? currentDm->cap[DM_HERTZ] : -1;  case GLUT_GAME_MODE_DISPLAY_CHANGED:    return __glutDisplaySettingsChanged;  default:    return -1;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -