Fixed problems with fbo's depth texture not rendering because of texture unit

dev
Shariq Shah 9 years ago
parent f815dafd82
commit b58fa413bc
  1. 2
      orgfile.org
  2. 4
      src/framebuffer.c
  3. 8
      src/renderer.c

@ -69,6 +69,8 @@ All the code in this repository is under GPLv3, see LICENSE for more information
** DONE Heirarchical Transforms
** DONE Materials with textures
- State "DONE" from "TODO" [2015-10-15 Thu 21:21]
** TODO Lights!
** TODO Fix problems with texture units
** TODO Fix problems with frustrum culling
** TODO 2d drawing routines
** TODO Gui

@ -47,12 +47,12 @@ int framebuffer_create(int width, int height, int has_depth, int has_color)
glGenRenderbuffers(1, &renderbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
glRenderbufferStorage(GL_RENDERBUFFER,
GL_DEPTH24_STENCIL8,
GL_DEPTH_COMPONENT,
width,
height);
renderer_check_glerror("framebuffer:create");
glFramebufferRenderbuffer(GL_FRAMEBUFFER,
GL_DEPTH_STENCIL_ATTACHMENT,
GL_DEPTH_ATTACHMENT,
GL_RENDERBUFFER,
renderbuffer);
renderer_check_glerror("framebuffer:create");

@ -115,7 +115,7 @@ void renderer_init(GLFWwindow* window)
texture_set_param(def_uv_tex, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
def_depth_tex = texture_create("def_depth_texture",
TU_SHADOWMAP1,
TU_DIFFUSE,
width, height,
GL_DEPTH_COMPONENT,
GL_DEPTH_COMPONENT32F,
@ -134,7 +134,7 @@ void renderer_init(GLFWwindow* window)
framebuffer_set_texture(def_fbo, def_normal_tex, GL_COLOR_ATTACHMENT0 + 2);
framebuffer_set_texture(def_fbo, def_uv_tex, GL_COLOR_ATTACHMENT0 + 3);
framebuffer_set_texture(def_fbo, def_depth_tex, GL_DEPTH_ATTACHMENT);
fbo_shader = shader_create("fbo.vert", "fbo.frag");
}
@ -197,9 +197,9 @@ void renderer_draw(void)
texture_unbind(def_normal_tex);
glViewport(width / 2, 0, width / 2, height / 2);
texture_bind(def_uv_tex);
texture_bind(def_depth_tex);
geom_render(quad_geo);
texture_unbind(def_uv_tex);
texture_unbind(def_depth_tex);
shader_unbind();
}

Loading…
Cancel
Save