Fixed a bug in copy_to_texture for depth buffers

This commit is contained in:
Josh Yelon 2008-03-03 22:45:06 +00:00
parent 8c39891d66
commit 0a4633cf81
4 changed files with 45 additions and 3 deletions

View File

@ -27,3 +27,33 @@
DrawableRegion:: DrawableRegion::
~DrawableRegion() { ~DrawableRegion() {
} }
////////////////////////////////////////////////////////////////////
// Function: DrawableRegion::get_renderbuffer_type
// Access: Static, Published
// Description: Returns the RenderBuffer::Type that corresponds
// to a RenderTexturePlane.
////////////////////////////////////////////////////////////////////
int DrawableRegion::
get_renderbuffer_type(int rtp) {
switch(rtp) {
case RTP_stencil: return RenderBuffer::T_stencil;
case RTP_depth: return RenderBuffer::T_depth;
case RTP_color: return RenderBuffer::T_color;
case RTP_aux_rgba_0: return RenderBuffer::T_aux_rgba_0;
case RTP_aux_rgba_1: return RenderBuffer::T_aux_rgba_1;
case RTP_aux_rgba_2: return RenderBuffer::T_aux_rgba_2;
case RTP_aux_rgba_3: return RenderBuffer::T_aux_rgba_3;
case RTP_aux_hrgba_0: return RenderBuffer::T_aux_hrgba_0;
case RTP_aux_hrgba_1: return RenderBuffer::T_aux_hrgba_1;
case RTP_aux_hrgba_2: return RenderBuffer::T_aux_hrgba_2;
case RTP_aux_hrgba_3: return RenderBuffer::T_aux_hrgba_3;
case RTP_aux_float_0: return RenderBuffer::T_aux_float_0;
case RTP_aux_float_1: return RenderBuffer::T_aux_float_1;
case RTP_aux_float_2: return RenderBuffer::T_aux_float_2;
case RTP_aux_float_3: return RenderBuffer::T_aux_float_3;
default:
display_cat.error() << "DrawableRegion::get_renderbuffer_type unexpected case!\n";
return 0;
};
}

View File

@ -95,6 +95,8 @@ PUBLISHED:
INLINE bool is_any_clear_active() const; INLINE bool is_any_clear_active() const;
static int get_renderbuffer_type(int plane);
public: public:
INLINE int get_screenshot_buffer_type() const; INLINE int get_screenshot_buffer_type() const;
INLINE int get_draw_buffer_type() const; INLINE int get_draw_buffer_type() const;

View File

@ -1007,8 +1007,13 @@ copy_to_textures() {
display_cat.debug() display_cat.debug()
<< "cube_map_index = " << _cube_map_index << "\n"; << "cube_map_index = " << _cube_map_index << "\n";
} }
RenderBuffer buffer = _gsg->get_render_buffer(get_draw_buffer_type(), int plane = get_texture_plane(i);
get_fb_properties()); RenderBuffer buffer(_gsg, DrawableRegion::get_renderbuffer_type(plane));
if (plane == RTP_color) {
buffer = _gsg->get_render_buffer(get_draw_buffer_type(),
get_fb_properties());
}
if (_cube_map_dr != (DisplayRegion *)NULL) { if (_cube_map_dr != (DisplayRegion *)NULL) {
if ((rtm_mode == RTM_copy_ram)||(rtm_mode == RTM_triggered_copy_ram)) { if ((rtm_mode == RTM_copy_ram)||(rtm_mode == RTM_triggered_copy_ram)) {
_gsg->framebuffer_copy_to_ram(texture, _cube_map_index, _gsg->framebuffer_copy_to_ram(texture, _cube_map_index,

View File

@ -4800,6 +4800,11 @@ set_draw_buffer(int rbtype) {
void CLP(GraphicsStateGuardian):: void CLP(GraphicsStateGuardian)::
set_read_buffer(int rbtype) { set_read_buffer(int rbtype) {
if (rbtype & (RenderBuffer::T_depth | RenderBuffer::T_stencil)) {
// Special case: don't have to call ReadBuffer for these.
return;
}
if (_current_fbo) { if (_current_fbo) {
GLuint buffer = GL_COLOR_ATTACHMENT0_EXT; GLuint buffer = GL_COLOR_ATTACHMENT0_EXT;