mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
fix copy-to-cubemap
This commit is contained in:
parent
392b2fdceb
commit
f4c996c0b9
@ -2515,12 +2515,21 @@ framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr,
|
||||
CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), tc);
|
||||
GLenum target = get_texture_target(tex->get_texture_type());
|
||||
GLP(BindTexture)(target, gtc->_index);
|
||||
GLint internal_format = get_internal_image_format(tex->get_format());
|
||||
GLenum imagetarget = (z >= 0) ? (GL_TEXTURE_CUBE_MAP_POSITIVE_X + z) : GL_TEXTURE_2D;
|
||||
|
||||
// If the texture has never been uploaded before, create it.
|
||||
// We cannot use glCopyTexImage2D to create a texture that may be
|
||||
// larger than the screen, so use glTexImage2D with arbitrary data.
|
||||
GLint internal_format = get_internal_image_format(tex->get_format());
|
||||
|
||||
if (z >= 0) {
|
||||
// Copy to a cube map face. This doesn't seem to work too well
|
||||
// with CopyTexSubImage2D, so we always use CopyTexImage2D.
|
||||
GLP(CopyTexImage2D)(GL_TEXTURE_CUBE_MAP_POSITIVE_X + z, 0,
|
||||
get_internal_image_format(tex->get_format()),
|
||||
xo, yo, w, h, 0);
|
||||
|
||||
} else {
|
||||
// If the texture has never been uploaded before, create it. We
|
||||
// cannot use glCopyTexImage2D to create a texture that may be
|
||||
// larger than the screen, so use glTexImage2D with arbitrary
|
||||
// data.
|
||||
|
||||
if ((gtc->_already_applied == false)||
|
||||
(gtc->_internal_format != internal_format)||
|
||||
@ -2532,17 +2541,19 @@ framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr,
|
||||
memset(image, 128, tex->get_x_size() * tex->get_y_size());
|
||||
switch (tex->get_format()) {
|
||||
case Texture::F_depth_component:
|
||||
GLP(TexImage2D)(imagetarget, 0, internal_format,
|
||||
GLP(TexImage2D)(GL_TEXTURE_2D, 0, internal_format,
|
||||
tex->get_x_size(), tex->get_y_size(), 0,
|
||||
GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, image);
|
||||
break;
|
||||
|
||||
case Texture::F_stencil_index:
|
||||
GLP(TexImage2D)(imagetarget, 0, internal_format,
|
||||
GLP(TexImage2D)(GL_TEXTURE_2D, 0, internal_format,
|
||||
tex->get_x_size(), tex->get_y_size(), 0,
|
||||
GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, image);
|
||||
break;
|
||||
|
||||
default:
|
||||
GLP(TexImage2D)(imagetarget, 0, internal_format,
|
||||
GLP(TexImage2D)(GL_TEXTURE_2D, 0, internal_format,
|
||||
tex->get_x_size(), tex->get_y_size(), 0,
|
||||
GL_LUMINANCE, GL_UNSIGNED_BYTE, image);
|
||||
break;
|
||||
@ -2557,7 +2568,8 @@ framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr,
|
||||
}
|
||||
|
||||
// Copy the pixel data from the frame buffer.
|
||||
GLP(CopyTexSubImage2D)(imagetarget, 0, 0, 0, xo, yo, w, h);
|
||||
GLP(CopyTexSubImage2D)(GL_TEXTURE_2D, 0, 0, 0, xo, yo, w, h);
|
||||
}
|
||||
|
||||
report_my_gl_errors();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user