Modified camera fbos to not create renderbuffers for color instead they always create texture

dev
Shariq Shah 9 years ago
parent 6909a1cda6
commit 8210ba663c
  1. 12
      src/camera.c
  2. 2
      src/game.c

@ -140,10 +140,12 @@ void camera_attach_fbo(struct Camera* camera,
log_error("camera:attach_fbo", "Camera already has fbo attached!");
return;
}
camera->fbo = framebuffer_create(width, height, has_depth, has_color, resizeable);
camera->fbo = framebuffer_create(width, height, has_depth, 0, resizeable);
if(camera->fbo > -1)
{
char tex_name[128];
if(has_color)
{
snprintf(tex_name, 128, "cam_render_tex_%d", camera->node);
camera->render_tex = texture_create(tex_name,
TU_DIFFUSE,
@ -156,8 +158,13 @@ void camera_attach_fbo(struct Camera* camera,
texture_set_param(camera->render_tex, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
texture_set_param(camera->render_tex, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
texture_set_param(camera->render_tex, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
framebuffer_set_texture(camera->fbo, camera->render_tex, FA_COLOR_ATTACHMENT0);
}
memset(tex_name, '\0', 128);
if(has_depth)
{
snprintf(tex_name, 128, "cam_depth_tex_%d", camera->node);
camera->depth_tex = texture_create(tex_name,
TU_SHADOWMAP1,
@ -172,10 +179,9 @@ void camera_attach_fbo(struct Camera* camera,
texture_set_param(camera->depth_tex, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
texture_set_param(camera->depth_tex, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
texture_set_param(camera->depth_tex, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
framebuffer_set_texture(camera->fbo, camera->render_tex, FA_COLOR_ATTACHMENT0);
framebuffer_set_texture(camera->fbo, camera->depth_tex, FA_DEPTH_ATTACHMENT);
}
}
else
{
log_error("camera:attach_fbo", "Framebuffer not attached to camera!");

@ -102,7 +102,7 @@ void scene_setup(void)
render_width = 1024;
render_height = 768;
struct Camera* camera = entity_component_add(player, C_CAMERA, render_width, render_height);
camera_attach_fbo(camera, render_width, render_height, 1, 0, 1);
camera_attach_fbo(camera, render_width, render_height, 1, 1, 1);
vec4_fill(&camera->clear_color, 0.3f, 0.6f, 0.9f, 1.0f);
camera_set_primary_viewer(camera);

Loading…
Cancel
Save