Beispiel #1
0
int main(int argc, const char *argv[])
{
  glutInitDisplayString("rgba>=8 depth double");
  glutInitWindowSize(500, 500);
  glutInit( &argc, (char **) argv);
  glutCreateWindow("dreamtorus");

  // Regal workaround for OSX GLUT

  #ifdef __APPLE__
  RegalMakeCurrent(CGLGetCurrentContext());
  #endif

  RegalSetErrorCallback(myError);

  // Exercise REGAL_extension_query extension

  if (glIsSupportedREGAL("GL_REGAL_extension_query"))
  {
    printf("GL_REGAL_extension_query is supported.\n");

    if (glIsSupportedREGAL("GL_EXT_debug_marker"))
      printf("GL_EXT_debug_marker is supported.\n");
    else
      printf("GL_EXT_debug_marker is not supported.\n");

    if (glIsSupportedREGAL("GL_EXT_framebuffer_object"))
      printf("GL_EXT_framebuffer_object is supported.\n");
    else
      printf("GL_EXT_framebuffer_object is not supported.\n");

    if (glIsSupportedREGAL("GL_EXT_direct_state_access"))
      printf("GL_EXT_direct_state_access is supported.\n");
    else
      printf("GL_EXT_direct_state_access is not supported.\n");

    if (glIsSupportedREGAL("GL_NV_path_rendering"))
      printf("GL_NV_path_rendering is supported.\n");
    else
      printf("GL_NV_path_rendering is not supported.\n");
  }

  glutTimerFunc(16, myTick, 0);
  glutDisplayFunc(myDisplay);
  glutReshapeFunc(reshape);
  glutKeyboardFunc(myKeyboard);
  glutMainLoop();
  return 0;
}
Beispiel #2
0
void dreamTorusDisplay( bool clear )
{
    static float r = 0.0f;
    static int count = 0;

    if( count == 0 ) {
        init();
    }

    glPushGroupMarkerEXT(0, "display");

#if 1
    if( count == 0 ) {
        RegalSetErrorCallback( regalerr );
    } else if( count == 11 ) {
        RegalSetErrorCallback( NULL );
    }
    count++;
#endif

    glUseProgram( 0 );
    if( clear ) {
        glClearDepth( 1.0 );
        glClearColor( r / 400.f, 0, 0, 0);
        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    }
    glEnable( GL_DEPTH_TEST );

    for( int i = 0; i < 8; i++ ) {
        glActiveTexture( GL_TEXTURE0 + i );
        glDisable( GL_TEXTURE_2D );
    }

    glBindMultiTextureEXT( texunit, GL_TEXTURE_2D, tex );
    glActiveTexture( texunit );
    glEnable( GL_TEXTURE_2D );


    float sc = 2.0f * fabs( ( count % 800 ) / 400.0f - 1.0f ) + 1.0f;

    glMatrixLoadIdentityEXT( texunit );
    glMatrixScalefEXT( texunit, sc, 1, 1 );

    float osc = sc * 0.5f;


    glEnable( GL_FOG );

    if( ( count % 7 ) == 0 || ( count % 17 ) == 0 ) {
        glDisable( GL_NORMALIZE );
        glEnable( GL_RESCALE_NORMAL );
        glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
        glMatrixMode( GL_MODELVIEW );
        glPushMatrix();
        glRotatef( (float) count, -1.0f, 1.0f, 0.0f );
        glScalef( osc, osc, osc );
        drawAnObject();
        glPopMatrix();
    } else {
        glEnable( GL_NORMALIZE );
        glDisable( GL_RESCALE_NORMAL );
        glMultiTexEnviEXT( texunit, GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
        glMatrixPushEXT( GL_MODELVIEW );
        glMatrixRotatefEXT( GL_MODELVIEW, (float) count, -1.0f, 1.0f, 0.0f );
        glMatrixScalefEXT( GL_MODELVIEW, osc, osc, osc );
        drawAnObject();
        glMatrixPopEXT( GL_MODELVIEW );
    }

    r += 1.0f;
    if( r > 399 ) {
        r = 0.0f;
    }

    glPopGroupMarkerEXT();

  //printf( "Draw with r=%f\n", r );
}
Beispiel #3
0
int main(int argc, const char *argv[])
{
  glutInitDisplayString("rgba>=8 depth double");
  glutInitWindowSize(500, 500);
  glutInit( &argc, (char **) argv);
  glutCreateWindow("dreamtorus");

  glLogMessageCallbackREGAL(myOutput);

  // Regal workaround for OSX GLUT

  #ifdef __APPLE__
  RegalMakeCurrent(CGLGetCurrentContext());
  #endif

  // Regal workaround for Emscripten GLUT emulation

  #ifdef EMSCRIPTEN
  RegalMakeCurrent((RegalSystemContext)1);
  #endif

  RegalSetErrorCallback(myError);

  // Exercise REGAL_extension_query extension

  if (glIsSupportedREGAL("GL_REGAL_extension_query"))
  {
    printf("GL_REGAL_extension_query is supported.\n");

    if (glIsSupportedREGAL("GL_EXT_debug_marker"))
      printf("GL_EXT_debug_marker is supported.\n");
    else
      printf("GL_EXT_debug_marker is not supported.\n");

    if (glIsSupportedREGAL("GL_EXT_framebuffer_object"))
      printf("GL_EXT_framebuffer_object is supported.\n");
    else
      printf("GL_EXT_framebuffer_object is not supported.\n");

    if (glIsSupportedREGAL("GL_EXT_direct_state_access"))
      printf("GL_EXT_direct_state_access is supported.\n");
    else
      printf("GL_EXT_direct_state_access is not supported.\n");

    if (glIsSupportedREGAL("GL_NV_path_rendering"))
      printf("GL_NV_path_rendering is supported.\n");
    else
      printf("GL_NV_path_rendering is not supported.\n");
  }

  printf("\n");
  printf("E - Toggle GL error checking.\n");
  printf("D - Toggle debug checking.\n");
  printf("L - Toggle driver logging.\n");
  printf("M - Toggle emulation.\n");
  printf("R - Toggle driver calls.\n");
  printf("\n");

  glutTimerFunc(16, myTick, 0);
  glutDisplayFunc(myDisplay);
  glutReshapeFunc(dreamTorusReshape);
  glutKeyboardFunc(myKeyboard);
  glutMainLoop();
  return 0;
}