display: add_render_texture should set correct texture format

This commit is contained in:
rdb 2017-10-05 17:35:31 +02:00
parent 85a9cdd052
commit be8f4de337

View File

@ -227,14 +227,20 @@ clear_render_textures() {
* You can specify a bitplane to attach the texture to. the legal choices * You can specify a bitplane to attach the texture to. the legal choices
* are: * are:
* *
* * RTP_depth * RTP_depth_stencil * RTP_color * RTP_aux_rgba_0 * * - RTP_depth
* RTP_aux_rgba_1 * RTP_aux_rgba_2 * RTP_aux_rgba_3 * - RTP_depth_stencil
* - RTP_color
* - RTP_aux_rgba_0
* - RTP_aux_rgba_1
* - RTP_aux_rgba_2
* - RTP_aux_rgba_3
* *
* If you do not specify a bitplane to attach the texture to, this routine * If you do not specify a bitplane to attach the texture to, this routine
* will use a default based on the texture's format: * will use a default based on the texture's format:
* *
* * F_depth_component attaches to RTP_depth * F_depth_stencil attaches to * - F_depth_component attaches to RTP_depth
* RTP_depth_stencil * all other formats attach to RTP_color. * - F_depth_stencil attaches to RTP_depth_stencil
* - all other formats attach to RTP_color.
* *
* The texture's format will be changed to match the format of the bitplane to * The texture's format will be changed to match the format of the bitplane to
* which it is attached. For example, if you pass in an F_rgba texture and * which it is attached. For example, if you pass in an F_rgba texture and
@ -283,32 +289,41 @@ add_render_texture(Texture *tex, RenderTextureMode mode,
// bitplane, while we're at it). // bitplane, while we're at it).
if (plane == RTP_depth) { if (plane == RTP_depth) {
tex->set_format(Texture::F_depth_component); _fb_properties.setup_depth_texture(tex);
tex->set_match_framebuffer_format(true); tex->set_match_framebuffer_format(true);
} else if (plane == RTP_depth_stencil) { } else if (plane == RTP_depth_stencil) {
tex->set_format(Texture::F_depth_stencil); tex->set_format(Texture::F_depth_stencil);
if (_fb_properties.get_float_depth()) {
tex->set_component_type(Texture::T_float);
} else {
tex->set_component_type(Texture::T_unsigned_int_24_8); tex->set_component_type(Texture::T_unsigned_int_24_8);
}
tex->set_match_framebuffer_format(true); tex->set_match_framebuffer_format(true);
} else if ((plane == RTP_color)||
(plane == RTP_aux_rgba_0)|| } else if (plane == RTP_color ||
(plane == RTP_aux_rgba_1)|| plane == RTP_aux_rgba_0 ||
(plane == RTP_aux_rgba_2)|| plane == RTP_aux_rgba_1 ||
(plane == RTP_aux_rgba_3)) { plane == RTP_aux_rgba_2 ||
tex->set_format(Texture::F_rgba); plane == RTP_aux_rgba_3) {
_fb_properties.setup_color_texture(tex);
tex->set_match_framebuffer_format(true); tex->set_match_framebuffer_format(true);
} else if ((plane == RTP_aux_hrgba_0)||
(plane == RTP_aux_hrgba_1)|| } else if (plane == RTP_aux_hrgba_0 ||
(plane == RTP_aux_hrgba_2)|| plane == RTP_aux_hrgba_1 ||
(plane == RTP_aux_hrgba_3)) { plane == RTP_aux_hrgba_2 ||
plane == RTP_aux_hrgba_3) {
tex->set_format(Texture::F_rgba16); tex->set_format(Texture::F_rgba16);
tex->set_match_framebuffer_format(true); tex->set_match_framebuffer_format(true);
} else if ((plane == RTP_aux_float_0)||
(plane == RTP_aux_float_1)|| } else if (plane == RTP_aux_float_0 ||
(plane == RTP_aux_float_2)|| plane == RTP_aux_float_1 ||
(plane == RTP_aux_float_3)) { plane == RTP_aux_float_2 ||
plane == RTP_aux_float_3) {
tex->set_format(Texture::F_rgba32); tex->set_format(Texture::F_rgba32);
tex->set_component_type(Texture::T_float); tex->set_component_type(Texture::T_float);
tex->set_match_framebuffer_format(true); tex->set_match_framebuffer_format(true);
} else { } else {
display_cat.error() << display_cat.error() <<
"add_render_texture: invalid bitplane specified.\n"; "add_render_texture: invalid bitplane specified.\n";