コード例 #1
0
ファイル: glass.c プロジェクト: crtc-demos/the-scary-demo
static void
ghost_uninit_effect (void *params, backbuffer_info *bbuf)
{
  glass_data *gdata = (glass_data *) params;

  free_shader (gdata->refraction_shader);
  free_shader (gdata->refraction_postpass_shader);
  free (gdata->grabbed_texture);
}
コード例 #2
0
ファイル: resources.c プロジェクト: m1nuz/neon-core
extern void
resources_cleanup(void) {
    for (int i = 0; i < MAX_TEXTURES; i++)
        if (all_resources.textures[i].id != 0)
            free_texture(&all_resources.textures[i]);

    for (int i = 0; i < MAX_SAMPLERS; i++)
        if (all_resources.samplers[i].id != 0)
            free_sampler(&all_resources.samplers[i]);

    for (int i = 0; i < MAX_RENDERBUFFERS; i++)
        if (all_resources.renderbuffers[i].id)
            free_renderbuffer(&all_resources.renderbuffers[i]);

    for (int i = 0; i < MAX_FRAMEBUFFERS; i++)
        if (all_resources.framebuffers[i].id)
            free_framebuffer(&all_resources.framebuffers[i]);

    for (int i = 0; i < MAX_BUFFERS; i++)
        if (all_resources.buffers[i].id)
            free_video_buffer(&all_resources.buffers[i]);

    for (int i = 0; i < MAX_VERTEX_ARRAYS; i++)
        if (all_resources.arrays[i].id)
            free_vertex_array(&all_resources.arrays[i]);

    for (int i = 0; i < MAX_SHADERS; i++)
        free_shader(&all_resources.shaders[i]);        
}
コード例 #3
0
ファイル: greets.c プロジェクト: crtc-demos/the-scary-demo
static void
greets_uninit_effect (void *params, backbuffer_info *bbuf)
{
  greets_data *gdata = (greets_data *) params;

  free_world (gdata->world);
  free (gdata->tileidx);
  free_shader (gdata->tile_shader);
}
コード例 #4
0
ファイル: cube.c プロジェクト: a-johnston/dungeon
static void destroy(void *void_data) {
    struct cube_data *data = (struct cube_data*) void_data;

    free_mesh(data->mesh);
    free_shader(data->shader);
    list_free_keep_elements(data->uniforms);

    free(data);
}
コード例 #5
0
ファイル: skybox.c プロジェクト: crtc-demos/the-scary-demo
void
free_skybox (skybox_info *skybox)
{
  int i;
  
  for (i = 0; i < 6; i++)
    free_shader (skybox->face_shader[i]);

  free (skybox);
}
コード例 #6
0
void
free_cubemap (cubemap_info *cubemap)
{
  int i;
  
  for (i = 0; i < 6; i++)
    {
      free (cubemap->texels[i]);
      free_shader (cubemap->face_shader[i]);
    }

  free (cubemap->sphtexels);
  free (cubemap);
}
コード例 #7
0
ファイル: eg_render_backend.c プロジェクト: vaplv/foo
static int
create_shader
  (struct rbi* rbi,
   struct rb_context* ctxt,
   struct render_shader** out_shader)
{
  int err = 0;

  const char* vs_source =
    "#version 330\n"
    "uniform mat4x4 view;\n"
    "uniform mat4x4 proj;\n"
    "layout (location = 0) in vec3 in_position;\n"
    "layout (location = 1) in vec3 in_color; \n"
    "smooth out vec3 theColor;\n"
    "void main()\n"
    "{\n"
    " theColor = in_color;\n"
    " gl_Position = proj * view * vec4(in_position, 1.f); \n"
    "}\n";

  const char* fs_source =
    "#version 330\n"
    "smooth in vec3 theColor;\n"
    "out vec4 color;\n"
    "void main()\n"
    "{\n"
    " color = vec4(theColor, 1.f);\n"
    "}\n";

  struct render_shader* shader = NULL;
  size_t length = 0;

  if(!out_shader) {
    err = -1;
    goto error;
  }

  shader = malloc(sizeof(struct render_shader));
  if(!shader) {
    err = -1;
    goto error;
  }
  memset(shader, 0, sizeof(struct render_shader));

  length = strlen(vs_source);
  err = rbi->create_shader
    (ctxt, RB_VERTEX_SHADER, vs_source, length, &shader->vertex_shader);
  if(err != 0) {
    if(shader->vertex_shader) {
      const char* log = NULL;
      CHECK(rbi->get_shader_log(shader->vertex_shader, &log));
      if(log)
        fprintf(stderr, "error: vertex shader\n%s", log);
    }
    goto error;
  }

  length = strlen(fs_source);
  err = rbi->create_shader
    (ctxt, RB_FRAGMENT_SHADER, fs_source, length, &shader->fragment_shader);
  if(err != 0) {
    if(shader->fragment_shader) {
      const char* log = NULL;
      CHECK(rbi->get_shader_log(shader->fragment_shader, &log));
      if(log)
        fprintf(stderr, "error: pixel shader\n%s", log);
    }
    goto error;
  }

  CHECK(rbi->create_program(ctxt, &shader->program));
  CHECK(rbi->attach_shader(shader->program, shader->vertex_shader));
  CHECK(rbi->attach_shader(shader->program, shader->fragment_shader));

  err = rbi->link_program(shader->program);
  if(err != 0) {
    const char* log = NULL;
    CHECK(rbi->get_program_log(shader->program, &log));
    if(log)
      fprintf(stderr, "error: program link\n%s", log);
    goto error;
  }

  CHECK(rbi->get_named_uniform
        (ctxt, shader->program, "view", &shader->view_uniform));
  CHECK(rbi->get_named_uniform
        (ctxt, shader->program, "proj", &shader->proj_uniform));

  *out_shader = shader;

exit:
  return err;

error:
  if(shader)
    free_shader(rbi, ctxt, shader);

  goto exit;
}