Example #1
0
int main (int argc, char *argv[])
{
   bcm_host_init();

   // Clear application state
   memset( state, 0, sizeof( *state ) );

   setup_user_options(argc, argv);

   // Start OGLES
   init_egl();
   init_textures();
   build_gears();
   
   // setup the scene based on rendering mode
   if (state->useGLES2) {
	 init_scene_GLES2();
     // Setup the model projection/world
     init_model_projGLES2();
   }
   else { // using gles1
     init_scene_GLES1();
     // Setup the model projection/world
     init_model_projGLES1();
   }

   // animate the gears
   run_gears();

   exit_func();

   return 0;
}
Example #2
0
int
main(int argc, char *argv[])
{
    int major, minor;
    EGLContext ctx;
    EGLSurface surface;
    EGLConfig configs[MAX_CONFIGS];
    EGLint numConfigs, i;
    EGLBoolean b;
    EGLDisplay d;
    EGLint screenAttribs[10];
    GLboolean printInfo = GL_FALSE;
    EGLint width = 300, height = 300;

    /* parse cmd line args */
    for (i = 1; i < argc; i++)
    {
        if (strcmp(argv[i], "-info") == 0)
        {
            printInfo = GL_TRUE;
        }
        else
            printf("Warning: unknown parameter: %s\n", argv[i]);
    }

    /* DBR : Create EGL context/surface etc */
    d = eglGetDisplay((EGLNativeDisplayType)"!EGL_i915");
    assert(d);

    if (!eglInitialize(d, &major, &minor)) {
        printf("peglgears: eglInitialize failed\n");
        return 0;
    }

    printf("peglgears: EGL version = %d.%d\n", major, minor);
    printf("peglgears: EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR));

    eglGetConfigs(d, configs, MAX_CONFIGS, &numConfigs);

    eglBindAPI(EGL_OPENGL_API);

    ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL);
    if (ctx == EGL_NO_CONTEXT) {
        printf("peglgears: failed to create context\n");
        return 0;
    }

    /* build up screenAttribs array */
    i = 0;
    screenAttribs[i++] = EGL_WIDTH;
    screenAttribs[i++] = width;
    screenAttribs[i++] = EGL_HEIGHT;
    screenAttribs[i++] = height;
    screenAttribs[i++] = EGL_NONE;

    surface = eglCreatePbufferSurface(d, configs[0], screenAttribs);
    if (surface == EGL_NO_SURFACE) {
        printf("peglgears: failed to create pbuffer surface\n");
        return 0;
    }

    b = eglMakeCurrent(d, surface, surface, ctx);
    if (!b) {
        printf("peglgears: make current failed\n");
        return 0;
    }

    if (printInfo)
    {
        printf("GL_RENDERER   = %s\n", (char *) glGetString(GL_RENDERER));
        printf("GL_VERSION    = %s\n", (char *) glGetString(GL_VERSION));
        printf("GL_VENDOR     = %s\n", (char *) glGetString(GL_VENDOR));
        printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
    }

    init();
    reshape(width, height);

    glDrawBuffer( GL_BACK );

    run_gears(d, surface, 5.0);

    eglDestroySurface(d, surface);
    eglDestroyContext(d, ctx);
    eglTerminate(d);

    return 0;
}