static void
shell_anamorphosis_effect_init (ShellAnamorphosisEffect *self)
{
  static CoglPipeline *pipeline_template;

  ShellAnamorphosisEffectPrivate *priv = shell_anamorphosis_effect_get_instance_private (self);

  if (G_UNLIKELY (pipeline_template == NULL))
    {
      CoglSnippet *snippet;
      CoglContext *ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());

      pipeline_template = cogl_pipeline_new (ctx);

      snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_TEXTURE_LOOKUP, anamorphosis_decls, NULL);
      cogl_snippet_set_pre (snippet, anamorphosis_pre);
      cogl_pipeline_add_layer_snippet (pipeline_template, 0, snippet);
      cogl_object_unref (snippet);

      cogl_pipeline_set_layer_null_texture (pipeline_template,
                                            0, /* layer number */
                                            COGL_TEXTURE_TYPE_2D);
    }

  priv->pipeline = cogl_pipeline_copy (pipeline_template);
  priv->tex_width_uniform = cogl_pipeline_get_uniform_location (priv->pipeline, "tex_width");
  priv->tex_height_uniform = cogl_pipeline_get_uniform_location (priv->pipeline, "tex_height");
  priv->_x_uniform = cogl_pipeline_get_uniform_location (priv->pipeline, "_x");
  priv->_y_uniform = cogl_pipeline_get_uniform_location (priv->pipeline, "_y");
  priv->_z_uniform = cogl_pipeline_get_uniform_location (priv->pipeline, "_z");

  update_uniforms (self);
}
void
shell_anamorphosis_effect_update (ShellAnamorphosisEffect *self, float x, float y, float z)

{
  ShellAnamorphosisEffectPrivate *priv = shell_anamorphosis_effect_get_instance_private (self);
  priv->_x = x;
  priv->_y = y;
  priv->_z = z;
  
  update_uniforms (self);
  clutter_effect_queue_repaint (CLUTTER_EFFECT (self));
}
Esempio n. 3
0
ENTRYPOINT void draw_wip24(ModeInfo *mi) {
    uint64_t frame_start = get_time();
    wip24_state* state = states + MI_SCREEN(mi);
    
    glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(state->glx_context));
    
    glBindFramebuffer(GL_FRAMEBUFFER, state->framebuffer);
    glDrawBuffer(GL_COLOR_ATTACHMENT0);
    glViewport(0, 0, MI_WIDTH(mi)/state->undersample, MI_HEIGHT(mi)/state->undersample);
    if (state->program) {
        glUseProgram(state->program);
        update_uniforms(mi, state);
        glRectf(-1.0f, -1.0f, 1.0f, 1.0f);
    }
    
    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    glViewport(0, 0, MI_WIDTH(mi), MI_HEIGHT(mi));
    glUseProgram(0);
    glBindTexture(GL_TEXTURE_2D, state->fb_texture);
    glBegin(GL_QUADS);
    glTexCoord2f(0.0f, 0.0f);
    glVertex2f(-1.0f, -1.0f);
    glTexCoord2f(1.0f, 0.0f);
    glVertex2f(1.0f, -1.0f);
    glTexCoord2f(1.0f, 1.0f);
    glVertex2f(1.0f, 1.0f);
    glTexCoord2f(0.0f, 1.0f);
    glVertex2f(-1.0f, 1.0f);
    glEnd();
    
    if (mi->fps_p) do_fps(mi);
    
    print_texture_label(MI_DISPLAY(mi), state->font, MI_WIDTH(mi), MI_HEIGHT(mi),
                        get_boolean_resource(MI_DISPLAY(mi), "fpsTop", "FPSTop")?2:1,
                        state->shader_info);
    
    glXSwapBuffers(MI_DISPLAY(mi), MI_WINDOW(mi));
    
    state->time_delta = get_time() - frame_start;
    state->frame_count++;
    
    float dest = mi->pause / 1000.0f;
    float current = state->time_delta / 1000000.0f;
    
    float* undersample = state->undersamples + state->frame_count%4;
    if (current > (dest+1.0f)) *undersample += 0.1f;
    else if (current<(dest-1.0f) && state->undersample>1.0f) *undersample -= 0.1f;
    else goto no_reshape;
    
    state->undersample = (state->undersamples[0]+state->undersamples[1]+
                          state->undersamples[2]+state->undersamples[3]) / 2.0f;
    state->undersample = state->undersample>undersample_max ? undersample_max:state->undersample;
    reshape_wip24(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
    no_reshape:
        ;
    
    mi->pause = dest>current ? dest-current : 0;
    
    if ((get_time() - state->start_time)/1000000000.0f > shader_duration)
        init_shader(mi, state);
}