X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=render.h;h=a4005ddbcec76028b77fd873c6b9b8dca479a7b1;hb=8c376ed2e4021a18b0a6c6e800109d67ad09d198;hp=b920983d7970b18b24b83faa25a4854ee988eac1;hpb=be8ea6efdbfd9c0fdad97401ed7d92041d8c8778;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/render.h b/render.h index b920983..a4005dd 100644 --- a/render.h +++ b/render.h @@ -58,8 +58,9 @@ struct framebuffer{ enum framebuffer_attachment_type{ k_framebuffer_attachment_type_none, - k_framebuffer_attachment_type_colour, - k_framebuffer_attachment_type_renderbuffer + k_framebuffer_attachment_type_texture, + k_framebuffer_attachment_type_renderbuffer, + k_framebuffer_attachment_type_texture_depth } purpose; @@ -95,7 +96,7 @@ framebuffers[] = .attachments = { { - "colour", k_framebuffer_attachment_type_colour, + "colour", k_framebuffer_attachment_type_texture, .internalformat = GL_RGB, .format = GL_RGB, @@ -103,7 +104,7 @@ framebuffers[] = .attachment = GL_COLOR_ATTACHMENT0 }, { - "motion", k_framebuffer_attachment_type_colour, + "motion", k_framebuffer_attachment_type_texture, .quality = k_framebuffer_quality_high_only, .internalformat = GL_RG16F, @@ -117,7 +118,7 @@ framebuffers[] = .internalformat = GL_DEPTH24_STENCIL8, #else - "depth_stencil", k_framebuffer_attachment_type_colour, + "depth_stencil", k_framebuffer_attachment_type_texture_depth, .internalformat = GL_DEPTH24_STENCIL8, .format = GL_DEPTH_STENCIL, .type = GL_UNSIGNED_INT_24_8, @@ -136,7 +137,7 @@ framebuffers[] = .attachments = { { - "colour", k_framebuffer_attachment_type_colour, + "colour", k_framebuffer_attachment_type_texture, .internalformat = GL_RGB, .format = GL_RGB, .type = GL_UNSIGNED_BYTE, @@ -161,7 +162,7 @@ framebuffers[] = .attachments = { { - "colour", k_framebuffer_attachment_type_colour, + "colour", k_framebuffer_attachment_type_texture, .internalformat = GL_RED, .format = GL_RED, .type = GL_UNSIGNED_BYTE, @@ -240,8 +241,10 @@ VG_STATIC void render_fb_bind_texture( framebuffer *fb, { struct framebuffer_attachment *at = &fb->attachments[attachment]; - if( at->purpose != k_framebuffer_attachment_type_colour ){ - vg_fatal_exit_loop( "illegal operation: bind non-colour framebuffer" + if( (at->purpose != k_framebuffer_attachment_type_texture) && + (at->purpose != k_framebuffer_attachment_type_texture_depth) ) + { + vg_fatal_exit_loop( "illegal operation: bind non-texture framebuffer" " attachment to texture slot" ); } @@ -388,7 +391,9 @@ VG_STATIC void render_fb_allocate_texture( struct framebuffer *fb, glBindRenderbuffer( GL_RENDERBUFFER, a->id ); glRenderbufferStorage( GL_RENDERBUFFER, a->internalformat, rx, ry ); } - else if( a->purpose == k_framebuffer_attachment_type_colour ){ + else if( a->purpose == k_framebuffer_attachment_type_texture || + a->purpose == k_framebuffer_attachment_type_texture_depth ) + { glBindTexture( GL_TEXTURE_2D, a->id ); glTexImage2D( GL_TEXTURE_2D, 0, a->internalformat, rx, ry, 0, a->format, a->type, NULL ); @@ -429,7 +434,9 @@ VG_STATIC void render_fb_allocate( struct framebuffer *fb ) GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, attachment->id ); } - else if( attachment->purpose == k_framebuffer_attachment_type_colour ){ + else if( attachment->purpose == k_framebuffer_attachment_type_texture || + attachment->purpose == k_framebuffer_attachment_type_texture_depth ) + { glGenTextures( 1, &attachment->id ); render_fb_allocate_texture( fb, attachment ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); @@ -440,7 +447,8 @@ VG_STATIC void render_fb_allocate( struct framebuffer *fb ) glFramebufferTexture2D( GL_FRAMEBUFFER, attachment->attachment, GL_TEXTURE_2D, attachment->id, 0 ); - colour_attachments[ colour_count ++ ] = attachment->attachment; + if( attachment->purpose == k_framebuffer_attachment_type_texture ) + colour_attachments[ colour_count ++ ] = attachment->attachment; } }