Example #1
0
void
show_video_size(void)
{
  printf("GLUT_VIDEO_RESIZE_X = %d\n",
    glutVideoResizeGet(GLUT_VIDEO_RESIZE_X));
  printf("GLUT_VIDEO_RESIZE_Y = %d\n",
    glutVideoResizeGet(GLUT_VIDEO_RESIZE_Y));
  printf("GLUT_VIDEO_RESIZE_WIDTH = %d\n",
    glutVideoResizeGet(GLUT_VIDEO_RESIZE_WIDTH));
  printf("GLUT_VIDEO_RESIZE_HEIGHT = %d\n",
    glutVideoResizeGet(GLUT_VIDEO_RESIZE_HEIGHT));
}
void APIENTRY 
glutSetupVideoResizing(void)
{
#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
  if (glutVideoResizeGet(GLUT_VIDEO_RESIZE_POSSIBLE)) {
    glXBindChannelToWindowSGIX(__glutDisplay, __glutScreen,
      videoResizeChannel, __glutCurrentWindow->win);
    videoResizeInUse = 1;
  } else
#endif
    __glutFatalError("glutEstablishVideoResizing: video resizing not possible.\n");
}
void APIENTRY 
glutStopVideoResizing(void)
{
#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
  if (glutVideoResizeGet(GLUT_VIDEO_RESIZE_POSSIBLE)) {
    if (videoResizeInUse) {
      glXBindChannelToWindowSGIX(__glutDisplay, __glutScreen,
        videoResizeChannel, None);
      videoResizeInUse = 0;
    }
  }
#endif
}
Example #4
0
int
main(int argc, char **argv)
{
  int i, interact = 0;

  glutInit(&argc, argv);

  for (i = 1; i < argc; i++) {
    if (!strcmp("-i", argv[i])) {
      interact = 1;
    }
  }

  glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
  glutCreateWindow("test21");

  if (!glutVideoResizeGet(GLUT_VIDEO_RESIZE_POSSIBLE)) {
    printf("video resizing not supported\n");
    printf("PASS: test21\n");
    exit(0);
  }
  glutSetupVideoResizing();
  printf("GLUT_VIDEO_RESIZE_X_DELTA = %d\n",
    dx = glutVideoResizeGet(GLUT_VIDEO_RESIZE_X_DELTA));
  printf("GLUT_VIDEO_RESIZE_Y_DELTA = %d\n",
    dy = glutVideoResizeGet(GLUT_VIDEO_RESIZE_Y_DELTA));
  printf("GLUT_VIDEO_RESIZE_WIDTH_DELTA = %d\n",
    dw = glutVideoResizeGet(GLUT_VIDEO_RESIZE_WIDTH_DELTA));
  printf("GLUT_VIDEO_RESIZE_HEIGHT_DELTA = %d\n",
    dh = glutVideoResizeGet(GLUT_VIDEO_RESIZE_HEIGHT_DELTA));
  printf("GLUT_VIDEO_RESIZE_X = %d\n",
    x = glutVideoResizeGet(GLUT_VIDEO_RESIZE_X));
  printf("GLUT_VIDEO_RESIZE_Y = %d\n",
    y = glutVideoResizeGet(GLUT_VIDEO_RESIZE_Y));
  printf("GLUT_VIDEO_RESIZE_WIDTH = %d\n",
    w = glutVideoResizeGet(GLUT_VIDEO_RESIZE_WIDTH));
  printf("GLUT_VIDEO_RESIZE_HEIGHT = %d\n",
    h = glutVideoResizeGet(GLUT_VIDEO_RESIZE_HEIGHT));
  glutStopVideoResizing();
  glutSetupVideoResizing();

  glutDisplayFunc(display);
  glutFullScreen();

  glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
  glLightfv(GL_LIGHT0, GL_POSITION, light_position);
  glEnable(GL_LIGHTING);
  glEnable(GL_LIGHT0);
  glEnable(GL_DEPTH_TEST);
  glMatrixMode(GL_PROJECTION);
  gluPerspective( /* field of view in degree */ 22.0,
  /* aspect ratio */ 1.0,
    /* Z near */ 1.0, /* Z far */ 10.0);
  glMatrixMode(GL_MODELVIEW);
  gluLookAt(0.0, 0.0, 5.0,  /* eye is at (0,0,5) */
    0.0, 0.0, 0.0,      /* center is at (0,0,0) */
    0.0, 1.0, 0.);      /* up is in postivie Y direction */
  glTranslatef(0.0, 0.0, -1.0);

  glutKeyboardFunc(key);
  if (!interact) {
    glutTimerFunc(100, time1, 0);
  }
  glutMainLoop();
  return 0;             /* ANSI C requires main to return int. */
}
/*
 * Class:     gruenewa_opengl_GLUT__
 * Method:    glutVideoResizeGet
 * Signature: (I)I
 */
JNIEXPORT jint JNICALL Java_gruenewa_opengl_GLUT_00024_glutVideoResizeGet
  (JNIEnv * jenv, jobject jobj, jint arg1) {
  return glutVideoResizeGet(arg1); 
}
Example #6
0
int
main(int argc, char **argv)
{
  int i;

  glutInit(&argc, argv);
  for (i = 1; i < argc; i++) {
    if (!strcmp(argv[i], "-orbs")) {
      i++;
      if (i >= argc) {
        fprintf(stderr, "videoresize: need number of orbs\n");
        exit(1);
      }
      num_orbs = atoi(argv[i]);
      if (num_orbs < 1) {
        fprintf(stderr, "videoresize: number of orbs must be 1 or more\n");
        exit(1);
      }
    } else if (!strcmp(argv[i], "-target")) {
      i++;
      if (i >= argc) {
        fprintf(stderr, "videoresize: need target number of frames\n");
        exit(1);
      }
      target_frame_time = atoi(argv[i]) * 1000.0 / 60.0;
      if (target_frame_time <= 0.0) {
        fprintf(stderr, "videoresize: target frames must be 1 or more\n");
        exit(1);
      }
    } else if (!strcmp(argv[i], "-novidresize")) {
      hw_video_resizing = 0;
    } else if (!strcmp(argv[i], "-debug")) {
      debug = 1;
    } else if (!strcmp(argv[i], "-window")) {
      fullscreen = 0;
    } else if (!strcmp(argv[i], "-twosnaps")) {
      num_snaps = 2;
    } else if (!strcmp(argv[i], "-nice")) {
      sphere_quality = 2;
    } else {
      printf("usage: videoresize [-window] [-twosnaps] [-nice] [-target #] [-orbs #]\n");
      printf("  -target #    = target number of frame intervals to stay under (default=%g)\n", target_frame_time);
      printf("  -orbs #      = number of orbs to randomly position (default=%d)\n", num_orbs);
      printf("  -window      = do not go fullscreen\n");
      printf("  -nice        = use better tesselated spheres\n");
      printf("  -novidresize = even if videoresizing is supported, don't use it\n");
      printf("  -twosnaps    = averages over last two frames instead of just estimating\n");
      printf("                 based on the last frame\n");
      exit(1);
    }
  }
  glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE);
  glutCreateWindow("Dynamic video resizing for constant frame rates");
  if (fullscreen) {
    glutFullScreen();
    if (glutVideoResizeGet(GLUT_VIDEO_RESIZE_POSSIBLE)) {
      delta_w_resize = glutVideoResizeGet(GLUT_VIDEO_RESIZE_WIDTH_DELTA);
      delta_h_resize = glutVideoResizeGet(GLUT_VIDEO_RESIZE_HEIGHT_DELTA);
      show_cursor = 0;
      glutSetupVideoResizing();
      hw_exists = 1;
    } else {
      hw_video_resizing = 0;
    }
  } else {
    hw_video_resizing = 0;
  }
  if (video_resizing) {
    state = UNZOOMED;
  } else {
    state = STATIC;
  }
  glutReshapeFunc(reshape);
  glDisable(GL_CULL_FACE);  /* Makes us more fill limited. */
  glEnable(GL_LIGHT0);
  glColorMaterial(GL_FRONT, GL_DIFFUSE);
  glEnable(GL_COLOR_MATERIAL);
  glEnable(GL_NORMALIZE);
  glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient);
  glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse);
  glLightfv(GL_LIGHT0, GL_POSITION, light0_position);

  glNewList(1, GL_COMPILE);
  sphere(sphere_quality);
  glEndList();

  srand48(getpid() * 16 + glutGet(GLUT_ELAPSED_TIME));
  generate_orbs();

  glutDisplayFunc(display);
  glutVisibilityFunc(visible);
  glutKeyboardFunc(keyboard);
  glutSpecialFunc(special);
  set_cursor(show_cursor);
  glutMainLoop();
  return 0;             /* ANSI C requires main to return int. */
}