Пример #1
0
static DFBResult
RenderTexture( Test    *test,
               Texture *texture )
{
     DFBResult ret;

     /* 
      * Bind the OpenGL rendering context to our primary surface
      */
     ret = test->gl2context->Bind( test->gl2context, texture->surface, texture->surface );
     if (ret) {
          D_DERROR( ret, "IDirectFBGL2Context::Bind() failed!\n" );
          return ret;
     }

     /* Update the projection matrix */
     perspective(ProjectionMatrix, 60.0, texture->size.w / (float)texture->size.h, 1.0, 1024.0);

     /* Setup the viewport */
     glViewport( 0, 0, (GLint) texture->size.w, (GLint) texture->size.h );

     gears_draw( false );

     /* Unbind the OpenGL rendering context */
     test->gl2context->Unbind( test->gl2context );

     return DFB_OK;
}
Пример #2
0
int
rsxgltest_draw()
{
  gears_idle();
  gears_draw();

  return 1;
}
Пример #3
0
static gboolean
paint_cb (void *user_data)
{
    Data *data = user_data;
    double elapsed = g_timer_elapsed (data->timer, NULL);
    double dt = elapsed - data->last_elapsed;
    GError *error = NULL;

    /* Draw scene with GLES2 */
    if (!cogl_push_gles2_context (data->ctx,
                                  data->gles2_ctx,
                                  data->fb,
                                  data->fb,
                                  &error))
    {
        g_error ("Failed to push gles2 context: %s\n", error->message);
    }

    gears_draw ();

    cogl_pop_gles2_context (data->ctx);

    cogl_onscreen_swap_buffers (COGL_ONSCREEN (data->fb));

    /* advance rotation for next frame */
    angle += 70.0 * dt;  /* 70 degrees per second */
    if (angle > 3600.0)
        angle -= 3600.0;

    data->frames++;

    if (elapsed > 5.0) {
        GLfloat fps = data->frames / elapsed;
        printf ("%d frames in %3.1f seconds = %6.3f FPS\n",
                data->frames, elapsed, fps);
        g_timer_reset (data->timer);
        data->last_elapsed = 0;
        data->frames = 0;
    }else
      data->last_elapsed = elapsed;

    /* If the driver can deliver swap complete events then we can remove
     * the idle paint callback until we next get a swap complete event
     * otherwise we keep the idle paint callback installed and simply
     * paint as fast as the driver will allow... */
    if (cogl_has_feature (data->ctx, COGL_FEATURE_ID_SWAP_BUFFERS_EVENT))
      return FALSE; /* remove the callback */
    else
      return TRUE;
}
Пример #4
0
static gboolean
paint_cb (void *user_data)
{
    Data *data = user_data;
    double elapsed = g_timer_elapsed (data->timer, NULL);
    double dt = elapsed - data->last_elapsed;
    CoglError *error = NULL;

    /* Draw scene with GLES2 */
    if (!cogl_push_gles2_context (data->ctx,
                                  data->gles2_ctx,
                                  data->fb,
                                  data->fb,
                                  &error))
    {
        g_error ("Failed to push gles2 context: %s\n", error->message);
    }

    gears_draw ();

    cogl_pop_gles2_context (data->ctx);

    cogl_onscreen_swap_buffers (COGL_ONSCREEN (data->fb));

    /* advance rotation for next frame */
    angle += 70.0 * dt;  /* 70 degrees per second */
    if (angle > 3600.0)
        angle -= 3600.0;

    data->frames++;

    if (elapsed > 5.0) {
        GLfloat fps = data->frames / elapsed;
        printf ("%d frames in %3.1f seconds = %6.3f FPS\n",
                data->frames, elapsed, fps);
        g_timer_reset (data->timer);
        data->last_elapsed = 0;
        data->frames = 0;
    }else
      data->last_elapsed = elapsed;

    return FALSE; /* remove the callback */
}
Пример #5
0
static DFBResult
RenderGL( Test *test )
{
     DFBResult ret;

     /* 
      * Bind the OpenGL rendering context to our primary surface
      */
     ret = test->gl2context->Bind( test->gl2context, test->primary, test->primary );
     if (ret) {
          D_DERROR( ret, "IDirectFBGL2Context::Bind() failed!\n" );
          return ret;
     }

     gears_draw();

     /* Unbind the OpenGL rendering context */
     test->gl2context->Unbind( test->gl2context );

     return DFB_OK;
}
static void render_gears(GLData *gld)
{
   gears_draw(gld);

   gld->angle += 2.0;
}