Skip to content

Commit

Permalink
display: add_render_texture should set correct texture format
Browse files Browse the repository at this point in the history
  • Loading branch information
rdb committed Oct 5, 2017
1 parent 85a9cdd commit be8f4de
Showing 1 changed file with 35 additions and 20 deletions.
55 changes: 35 additions & 20 deletions panda/src/display/graphicsOutput.cxx
Expand Up @@ -227,14 +227,20 @@ clear_render_textures() {
* You can specify a bitplane to attach the texture to. the legal choices
* are:
*
* * RTP_depth * RTP_depth_stencil * RTP_color * RTP_aux_rgba_0 *
* RTP_aux_rgba_1 * RTP_aux_rgba_2 * RTP_aux_rgba_3
* - RTP_depth
* - 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
* will use a default based on the texture's format:
*
* * F_depth_component attaches to RTP_depth * F_depth_stencil attaches to
* RTP_depth_stencil * all other formats attach to RTP_color.
* - F_depth_component attaches to RTP_depth
* - 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
* which it is attached. For example, if you pass in an F_rgba texture and
Expand Down Expand Up @@ -283,32 +289,41 @@ add_render_texture(Texture *tex, RenderTextureMode mode,
// bitplane, while we're at it).

if (plane == RTP_depth) {
tex->set_format(Texture::F_depth_component);
_fb_properties.setup_depth_texture(tex);
tex->set_match_framebuffer_format(true);

} else if (plane == RTP_depth_stencil) {
tex->set_format(Texture::F_depth_stencil);
tex->set_component_type(Texture::T_unsigned_int_24_8);
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_match_framebuffer_format(true);
} else if ((plane == RTP_color)||
(plane == RTP_aux_rgba_0)||
(plane == RTP_aux_rgba_1)||
(plane == RTP_aux_rgba_2)||
(plane == RTP_aux_rgba_3)) {
tex->set_format(Texture::F_rgba);

} else if (plane == RTP_color ||
plane == RTP_aux_rgba_0 ||
plane == RTP_aux_rgba_1 ||
plane == RTP_aux_rgba_2 ||
plane == RTP_aux_rgba_3) {
_fb_properties.setup_color_texture(tex);
tex->set_match_framebuffer_format(true);
} else if ((plane == RTP_aux_hrgba_0)||
(plane == RTP_aux_hrgba_1)||
(plane == RTP_aux_hrgba_2)||
(plane == RTP_aux_hrgba_3)) {

} else if (plane == RTP_aux_hrgba_0 ||
plane == RTP_aux_hrgba_1 ||
plane == RTP_aux_hrgba_2 ||
plane == RTP_aux_hrgba_3) {
tex->set_format(Texture::F_rgba16);
tex->set_match_framebuffer_format(true);
} else if ((plane == RTP_aux_float_0)||
(plane == RTP_aux_float_1)||
(plane == RTP_aux_float_2)||
(plane == RTP_aux_float_3)) {

} else if (plane == RTP_aux_float_0 ||
plane == RTP_aux_float_1 ||
plane == RTP_aux_float_2 ||
plane == RTP_aux_float_3) {
tex->set_format(Texture::F_rgba32);
tex->set_component_type(Texture::T_float);
tex->set_match_framebuffer_format(true);

} else {
display_cat.error() <<
"add_render_texture: invalid bitplane specified.\n";
Expand Down

0 comments on commit be8f4de

Please sign in to comment.