mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
various fixes for FBOs and image formats, including tobspr's patch for F_r16, F_rg16, F_rgb16 support.
This commit is contained in:
parent
05400a547e
commit
64c598abb1
@ -574,36 +574,47 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot,
|
||||
|
||||
// Adjust the texture format based on the requested framebuffer settings.
|
||||
switch (slot) {
|
||||
case RTP_depth:
|
||||
if (_fb_properties.get_depth_bits() >= 32) {
|
||||
tex->set_format(Texture::F_depth_component32);
|
||||
} else if (_fb_properties.get_depth_bits() > 16) {
|
||||
tex->set_format(Texture::F_depth_component24);
|
||||
} else if (_fb_properties.get_depth_bits() > 8) {
|
||||
tex->set_format(Texture::F_depth_component16);
|
||||
} else {
|
||||
tex->set_format(Texture::F_depth_component);
|
||||
}
|
||||
break;
|
||||
case RTP_depth_stencil:
|
||||
tex->set_format(Texture::F_depth_stencil);
|
||||
tex->set_component_type(Texture::T_unsigned_int_24_8);
|
||||
break;
|
||||
case RTP_aux_hrgba_0:
|
||||
case RTP_aux_hrgba_1:
|
||||
case RTP_aux_hrgba_2:
|
||||
case RTP_aux_hrgba_3:
|
||||
tex->set_format(Texture::F_rgba16);
|
||||
break;
|
||||
case RTP_aux_float_0:
|
||||
case RTP_aux_float_1:
|
||||
case RTP_aux_float_2:
|
||||
case RTP_aux_float_3:
|
||||
case RTP_depth:
|
||||
if (_fb_properties.get_depth_bits() > 24) {
|
||||
tex->set_format(Texture::F_depth_component32);
|
||||
} else if (_fb_properties.get_depth_bits() > 16) {
|
||||
tex->set_format(Texture::F_depth_component24);
|
||||
} else if (_fb_properties.get_depth_bits() > 8) {
|
||||
tex->set_format(Texture::F_depth_component16);
|
||||
} else {
|
||||
tex->set_format(Texture::F_depth_component);
|
||||
}
|
||||
break;
|
||||
case RTP_depth_stencil:
|
||||
tex->set_format(Texture::F_depth_stencil);
|
||||
tex->set_component_type(Texture::T_unsigned_int_24_8);
|
||||
break;
|
||||
case RTP_aux_hrgba_0:
|
||||
case RTP_aux_hrgba_1:
|
||||
case RTP_aux_hrgba_2:
|
||||
case RTP_aux_hrgba_3:
|
||||
tex->set_format(Texture::F_rgba16);
|
||||
tex->set_component_type(Texture::T_float);
|
||||
break;
|
||||
case RTP_aux_float_0:
|
||||
case RTP_aux_float_1:
|
||||
case RTP_aux_float_2:
|
||||
case RTP_aux_float_3:
|
||||
tex->set_format(Texture::F_rgba32);
|
||||
tex->set_component_type(Texture::T_float);
|
||||
break;
|
||||
default:
|
||||
if (_fb_properties.get_color_bits() > 48) {
|
||||
tex->set_format(Texture::F_rgba32);
|
||||
// Currently a float format. Should change.
|
||||
tex->set_component_type(Texture::T_float);
|
||||
break;
|
||||
default:
|
||||
} else if (_fb_properties.get_color_bits() > 24) {
|
||||
tex->set_format(Texture::F_rgba16);
|
||||
// Currently a float format. Should change.
|
||||
tex->set_component_type(Texture::T_float);
|
||||
} else {
|
||||
tex->set_format(Texture::F_rgba);
|
||||
}
|
||||
}
|
||||
|
||||
// Create the OpenGL texture object.
|
||||
@ -713,22 +724,44 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot,
|
||||
#ifdef OPENGLES
|
||||
GLuint gl_format = GL_RGBA4;
|
||||
switch (slot) {
|
||||
case RTP_depth_stencil:
|
||||
gl_format = GL_DEPTH_STENCIL_OES;
|
||||
break;
|
||||
case RTP_depth:
|
||||
case RTP_depth_stencil:
|
||||
gl_format = GL_DEPTH_STENCIL_OES;
|
||||
break;
|
||||
case RTP_depth:
|
||||
if (_fb_properties.get_depth_bits() > 24 && glgsg->_supports_depth32) {
|
||||
gl_format = GL_DEPTH_COMPONENT32_OES;
|
||||
} else if (_fb_properties.get_depth_bits() > 16 && glgsg->_supports_depth24) {
|
||||
gl_format = GL_DEPTH_COMPONENT24_OES;
|
||||
} else {
|
||||
gl_format = GL_DEPTH_COMPONENT16;
|
||||
break;
|
||||
//case RTP_stencil:
|
||||
// gl_format = GL_STENCIL_INDEX8;
|
||||
// break
|
||||
default:
|
||||
if (_fb_properties.get_alpha_bits() == 0) {
|
||||
gl_format = GL_RGB565;
|
||||
} else if (_fb_properties.get_color_bits() == 15
|
||||
&& _fb_properties.get_alpha_bits() == 1) {
|
||||
gl_format = GL_RGB5_A1;
|
||||
}
|
||||
break;
|
||||
//case RTP_stencil:
|
||||
// gl_format = GL_STENCIL_INDEX8;
|
||||
// break
|
||||
default:
|
||||
if (_fb_properties.get_alpha_bits() == 0) {
|
||||
if (_fb_properties.get_color_bits() <= 16) {
|
||||
gl_format = GL_RGB565_OES;
|
||||
} else if (_fb_properties.get_color_bits() <= 24) {
|
||||
gl_format = GL_RGB8_OES;
|
||||
} else {
|
||||
gl_format = GL_RGB10_EXT;
|
||||
}
|
||||
} else if (_fb_properties.get_color_bits() == 0) {
|
||||
gl_format = GL_ALPHA8_OES;
|
||||
} else if (_fb_properties.get_color_bits() <= 12
|
||||
&& _fb_properties.get_alpha_bits() <= 4) {
|
||||
gl_format = GL_RGBA4_OES;
|
||||
} else if (_fb_properties.get_color_bits() <= 15
|
||||
&& _fb_properties.get_alpha_bits() == 1) {
|
||||
gl_format = GL_RGB5_A1_EXT;
|
||||
} else if (_fb_properties.get_color_bits() <= 30
|
||||
&& _fb_properties.get_alpha_bits() <= 2) {
|
||||
gl_format = GL_RGB10_A2_OES;
|
||||
} else {
|
||||
gl_format = GL_RGBA8_OES;
|
||||
}
|
||||
}
|
||||
#else
|
||||
GLuint gl_format = GL_RGBA;
|
||||
@ -737,7 +770,7 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot,
|
||||
gl_format = GL_DEPTH_STENCIL_EXT;
|
||||
break;
|
||||
case RTP_depth:
|
||||
if (_fb_properties.get_depth_bits() >= 32) {
|
||||
if (_fb_properties.get_depth_bits() > 24) {
|
||||
gl_format = GL_DEPTH_COMPONENT32;
|
||||
} else if (_fb_properties.get_depth_bits() > 16) {
|
||||
gl_format = GL_DEPTH_COMPONENT24;
|
||||
@ -1231,6 +1264,28 @@ open_buffer() {
|
||||
_fb_properties.set_accum_bits(0);
|
||||
_fb_properties.set_multisamples(_host->get_fb_properties().get_multisamples());
|
||||
|
||||
// Update aux settings to reflect the GL_MAX_DRAW_BUFFERS limit.
|
||||
int availcolor = glgsg->_max_draw_buffers;
|
||||
if (totalcolor > availcolor) {
|
||||
int aux_rgba = _fb_properties.get_aux_rgba();
|
||||
int aux_hrgba = _fb_properties.get_aux_hrgba();
|
||||
int aux_float = _fb_properties.get_aux_float();
|
||||
|
||||
if (_fb_properties.get_color_bits() > 0 && availcolor > 0) {
|
||||
--availcolor;
|
||||
}
|
||||
aux_rgba = min(aux_rgba, availcolor);
|
||||
availcolor -= aux_rgba;
|
||||
aux_hrgba = min(aux_hrgba, availcolor);
|
||||
availcolor -= aux_hrgba;
|
||||
aux_float = min(aux_float, availcolor);
|
||||
availcolor -= aux_float;
|
||||
|
||||
_fb_properties.set_aux_rgba(aux_rgba);
|
||||
_fb_properties.set_aux_hrgba(aux_hrgba);
|
||||
_fb_properties.set_aux_float(aux_float);
|
||||
}
|
||||
|
||||
_fb_properties.set_back_buffers(0);
|
||||
_fb_properties.set_indexed_color(0);
|
||||
_fb_properties.set_rgb_color(1);
|
||||
@ -1314,13 +1369,19 @@ share_depth_buffer(GraphicsOutput *graphics_output) {
|
||||
CLP(GraphicsBuffer) *input_graphics_output;
|
||||
|
||||
state = false;
|
||||
input_graphics_output = DCAST (CLP(GraphicsBuffer), graphics_output);
|
||||
input_graphics_output = DCAST(CLP(GraphicsBuffer), graphics_output);
|
||||
if (this != input_graphics_output && input_graphics_output) {
|
||||
|
||||
state = true;
|
||||
this->unshare_depth_buffer();
|
||||
|
||||
// check buffer sizes
|
||||
// Make sure that the buffers are both FBOs.
|
||||
if (!input_graphics_output->is_of_type(CLP(GraphicsBuffer)::get_class_type())) {
|
||||
GLCAT.error() << "share_depth_buffer: non-matching type\n";
|
||||
state = false;
|
||||
}
|
||||
|
||||
// Check buffer size.
|
||||
if (this->get_x_size() != input_graphics_output->get_x_size()) {
|
||||
GLCAT.error() << "share_depth_buffer: non-matching width\n";
|
||||
state = false;
|
||||
@ -1338,7 +1399,7 @@ share_depth_buffer(GraphicsOutput *graphics_output) {
|
||||
}
|
||||
|
||||
if (this->get_coverage_sample_count() != input_graphics_output->get_coverage_sample_count()) {
|
||||
GLCAT.error() << "share_depth_buffer: non-matching multisamples\n";
|
||||
GLCAT.error() << "share_depth_buffer: non-matching coverage samples\n";
|
||||
state = false;
|
||||
}
|
||||
|
||||
|
@ -559,8 +559,9 @@ reset() {
|
||||
}
|
||||
|
||||
#ifdef OPENGLES
|
||||
_supports_depth_texture = has_extension("GL_OES_depth_texture") ||
|
||||
has_extension("GL_OES_depth24") || has_extension("GL_OES_depth32");
|
||||
_supports_depth_texture = has_extension("GL_OES_depth_texture");
|
||||
_supports_depth24 = has_extension("GL_OES_depth24");
|
||||
_supports_depth32 = has_extension("GL_OES_depth32");
|
||||
#else
|
||||
_supports_depth_texture =
|
||||
has_extension("GL_ARB_depth_texture") || is_at_least_gl_version(1, 4);
|
||||
@ -4474,11 +4475,9 @@ framebuffer_copy_to_ram(Texture *tex, int z, const DisplayRegion *dr,
|
||||
case GL_DEPTH_COMPONENT:
|
||||
GLCAT.spam(false) << "GL_DEPTH_COMPONENT, ";
|
||||
break;
|
||||
#ifndef OPENGLES_2
|
||||
case GL_DEPTH_STENCIL_EXT:
|
||||
GLCAT.spam(false) << "GL_DEPTH_STENCIL, ";
|
||||
break;
|
||||
#endif
|
||||
case GL_RGB:
|
||||
GLCAT.spam(false) << "GL_RGB, ";
|
||||
break;
|
||||
@ -5096,10 +5095,10 @@ do_issue_material() {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef OPENGLES
|
||||
GLP(LightModeli)(GL_LIGHT_MODEL_LOCAL_VIEWER, material->get_local());
|
||||
GLP(LightModeli)(GL_LIGHT_MODEL_TWO_SIDE, material->get_twoside());
|
||||
|
||||
#ifndef OPENGLES
|
||||
if (CLP(separate_specular_color)) {
|
||||
GLP(LightModeli)(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
|
||||
} else {
|
||||
@ -6258,15 +6257,11 @@ get_component_type(Texture::ComponentType component_type) {
|
||||
case Texture::T_float:
|
||||
return GL_FLOAT;
|
||||
case Texture::T_unsigned_int_24_8:
|
||||
#ifdef OPENGLES_2
|
||||
return GL_UNSIGNED_BYTE;
|
||||
#else
|
||||
if (_supports_depth_stencil) {
|
||||
return GL_UNSIGNED_INT_24_8_EXT;
|
||||
} else {
|
||||
return GL_UNSIGNED_BYTE;
|
||||
}
|
||||
#endif // OPENGLES_2
|
||||
default:
|
||||
GLCAT.error() << "Invalid Texture::Type value!\n";
|
||||
return GL_UNSIGNED_BYTE;
|
||||
@ -6294,31 +6289,38 @@ get_external_image_format(Texture *tex) const {
|
||||
// This shouldn't be possible.
|
||||
nassertr(false, GL_RGB);
|
||||
break;
|
||||
|
||||
|
||||
case Texture::F_rgba:
|
||||
case Texture::F_rgbm:
|
||||
case Texture::F_rgba4:
|
||||
case Texture::F_rgba8:
|
||||
case Texture::F_rgba12:
|
||||
return GL_COMPRESSED_RGBA;
|
||||
|
||||
|
||||
case Texture::F_rgb:
|
||||
case Texture::F_rgb5:
|
||||
case Texture::F_rgba5:
|
||||
case Texture::F_rgb8:
|
||||
case Texture::F_rgb12:
|
||||
case Texture::F_rgb332:
|
||||
case Texture::F_rgb16:
|
||||
return GL_COMPRESSED_RGB;
|
||||
|
||||
|
||||
case Texture::F_alpha:
|
||||
return GL_COMPRESSED_ALPHA;
|
||||
|
||||
|
||||
case Texture::F_red:
|
||||
case Texture::F_green:
|
||||
case Texture::F_blue:
|
||||
case Texture::F_r16:
|
||||
return GL_COMPRESSED_RED;
|
||||
|
||||
case Texture::F_rg16:
|
||||
return GL_COMPRESSED_RG;
|
||||
|
||||
case Texture::F_luminance:
|
||||
return GL_COMPRESSED_LUMINANCE;
|
||||
|
||||
|
||||
case Texture::F_luminance_alpha:
|
||||
case Texture::F_luminance_alphamask:
|
||||
return GL_COMPRESSED_LUMINANCE_ALPHA;
|
||||
@ -6386,6 +6388,7 @@ get_external_image_format(Texture *tex) const {
|
||||
return _supports_depth_stencil ? GL_DEPTH_STENCIL_EXT : GL_DEPTH_COMPONENT;
|
||||
#ifndef OPENGLES
|
||||
case Texture::F_red:
|
||||
case Texture::F_r16:
|
||||
return GL_RED;
|
||||
case Texture::F_green:
|
||||
return GL_GREEN;
|
||||
@ -6394,11 +6397,14 @@ get_external_image_format(Texture *tex) const {
|
||||
#endif
|
||||
case Texture::F_alpha:
|
||||
return GL_ALPHA;
|
||||
case Texture::F_rg16:
|
||||
return GL_RG;
|
||||
case Texture::F_rgb:
|
||||
case Texture::F_rgb5:
|
||||
case Texture::F_rgb8:
|
||||
case Texture::F_rgb12:
|
||||
case Texture::F_rgb332:
|
||||
case Texture::F_rgb16:
|
||||
#ifdef OPENGLES
|
||||
return GL_RGB;
|
||||
#else
|
||||
@ -6465,7 +6471,7 @@ get_internal_image_format(Texture *tex) const {
|
||||
case Texture::F_depth_stencil:
|
||||
// Unsupported; fall through to below.
|
||||
break;
|
||||
|
||||
|
||||
case Texture::F_rgbm:
|
||||
if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
|
||||
return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
||||
@ -6473,7 +6479,7 @@ get_internal_image_format(Texture *tex) const {
|
||||
return GL_COMPRESSED_RGBA_FXT1_3DFX;
|
||||
}
|
||||
return GL_COMPRESSED_RGBA;
|
||||
|
||||
|
||||
case Texture::F_rgba4:
|
||||
if (get_supports_compressed_texture_format(Texture::CM_dxt3) && !is_3d) {
|
||||
return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
|
||||
@ -6481,7 +6487,7 @@ get_internal_image_format(Texture *tex) const {
|
||||
return GL_COMPRESSED_RGBA_FXT1_3DFX;
|
||||
}
|
||||
return GL_COMPRESSED_RGBA;
|
||||
|
||||
|
||||
case Texture::F_rgba:
|
||||
case Texture::F_rgba8:
|
||||
case Texture::F_rgba12:
|
||||
@ -6491,20 +6497,21 @@ get_internal_image_format(Texture *tex) const {
|
||||
return GL_COMPRESSED_RGBA_FXT1_3DFX;
|
||||
}
|
||||
return GL_COMPRESSED_RGBA;
|
||||
|
||||
|
||||
case Texture::F_rgb:
|
||||
case Texture::F_rgb5:
|
||||
case Texture::F_rgba5:
|
||||
case Texture::F_rgb8:
|
||||
case Texture::F_rgb12:
|
||||
case Texture::F_rgb332:
|
||||
case Texture::F_rgb16:
|
||||
if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
|
||||
return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
|
||||
} else if (get_supports_compressed_texture_format(Texture::CM_fxt1) && !is_3d) {
|
||||
return GL_COMPRESSED_RGB_FXT1_3DFX;
|
||||
}
|
||||
return GL_COMPRESSED_RGB;
|
||||
|
||||
|
||||
case Texture::F_alpha:
|
||||
if (get_supports_compressed_texture_format(Texture::CM_dxt5) && !is_3d) {
|
||||
return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
||||
@ -6512,10 +6519,26 @@ get_internal_image_format(Texture *tex) const {
|
||||
return GL_COMPRESSED_RGBA_FXT1_3DFX;
|
||||
}
|
||||
return GL_COMPRESSED_ALPHA;
|
||||
|
||||
|
||||
case Texture::F_red:
|
||||
case Texture::F_green:
|
||||
case Texture::F_blue:
|
||||
case Texture::F_r16:
|
||||
if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
|
||||
return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
|
||||
} else if (get_supports_compressed_texture_format(Texture::CM_fxt1) && !is_3d) {
|
||||
return GL_COMPRESSED_RGB_FXT1_3DFX;
|
||||
}
|
||||
return GL_COMPRESSED_RED;
|
||||
|
||||
case Texture::F_rg16:
|
||||
if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
|
||||
return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
|
||||
} else if (get_supports_compressed_texture_format(Texture::CM_fxt1) && !is_3d) {
|
||||
return GL_COMPRESSED_RGB_FXT1_3DFX;
|
||||
}
|
||||
return GL_COMPRESSED_RG;
|
||||
|
||||
case Texture::F_luminance:
|
||||
if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
|
||||
return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
|
||||
@ -6589,41 +6612,55 @@ get_internal_image_format(Texture *tex) const {
|
||||
return GL_COLOR_INDEX;
|
||||
#endif
|
||||
case Texture::F_depth_component:
|
||||
#ifndef OPENGLES
|
||||
if (tex->get_component_type() == Texture::T_float) {
|
||||
return GL_DEPTH_COMPONENT32F;
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
return GL_DEPTH_COMPONENT;
|
||||
}
|
||||
case Texture::F_depth_component16:
|
||||
#ifdef OPENGLES_1
|
||||
#ifdef OPENGLES
|
||||
return GL_DEPTH_COMPONENT16_OES;
|
||||
#else
|
||||
return GL_DEPTH_COMPONENT16;
|
||||
#endif
|
||||
|
||||
case Texture::F_depth_component24:
|
||||
#ifdef OPENGLES
|
||||
return GL_DEPTH_COMPONENT24_OES;
|
||||
case Texture::F_depth_component32:
|
||||
return GL_DEPTH_COMPONENT32_OES;
|
||||
if (_supports_depth24) {
|
||||
return GL_DEPTH_COMPONENT24_OES;
|
||||
} else {
|
||||
return GL_DEPTH_COMPONENT16_OES;
|
||||
}
|
||||
#else
|
||||
return GL_DEPTH_COMPONENT24;
|
||||
#endif
|
||||
|
||||
case Texture::F_depth_component32:
|
||||
#ifdef OPENGLES
|
||||
if (_supports_depth32) {
|
||||
return GL_DEPTH_COMPONENT32_OES;
|
||||
} else if (_supports_depth24) {
|
||||
return GL_DEPTH_COMPONENT24_OES;
|
||||
} else {
|
||||
return GL_DEPTH_COMPONENT16_OES;
|
||||
}
|
||||
#else
|
||||
if (tex->get_component_type() == Texture::T_float) {
|
||||
return GL_DEPTH_COMPONENT32F;
|
||||
} else {
|
||||
return GL_DEPTH_COMPONENT32;
|
||||
}
|
||||
#endif
|
||||
|
||||
case Texture::F_depth_stencil:
|
||||
#ifndef OPENGLES_2
|
||||
if (_supports_depth_stencil) {
|
||||
return GL_DEPTH_STENCIL_EXT;
|
||||
} else {
|
||||
return GL_DEPTH_COMPONENT;
|
||||
}
|
||||
#else
|
||||
return GL_DEPTH_COMPONENT;
|
||||
#endif
|
||||
|
||||
case Texture::F_rgba:
|
||||
case Texture::F_rgbm:
|
||||
@ -6633,10 +6670,13 @@ get_internal_image_format(Texture *tex) const {
|
||||
|
||||
#ifdef OPENGLES
|
||||
case Texture::F_rgba8:
|
||||
return GL_RGBA8_OES;
|
||||
case Texture::F_rgba12:
|
||||
case Texture::F_rgba16:
|
||||
case Texture::F_rgba32:
|
||||
return GL_RGBA;
|
||||
case Texture::F_rgba16:
|
||||
return GL_RGBA16F_EXT;
|
||||
case Texture::F_rgba32:
|
||||
return GL_RGBA32F_EXT;
|
||||
#else
|
||||
case Texture::F_rgba8:
|
||||
return GL_RGBA8;
|
||||
@ -6650,8 +6690,11 @@ get_internal_image_format(Texture *tex) const {
|
||||
|
||||
case Texture::F_rgb:
|
||||
return GL_RGB;
|
||||
#ifndef OPENGLES
|
||||
case Texture::F_rgb5:
|
||||
#ifdef OPENGLES
|
||||
// Close enough.
|
||||
return GL_RGB565_OES;
|
||||
#else
|
||||
return GL_RGB5;
|
||||
#endif
|
||||
case Texture::F_rgba5:
|
||||
@ -6659,13 +6702,22 @@ get_internal_image_format(Texture *tex) const {
|
||||
|
||||
#ifdef OPENGLES
|
||||
case Texture::F_rgb8:
|
||||
return GL_RGB8_OES;
|
||||
case Texture::F_rgb12:
|
||||
return GL_RGB;
|
||||
case Texture::F_rgb16:
|
||||
return GL_RGB16F_EXT;
|
||||
#else
|
||||
case Texture::F_rgb8:
|
||||
return GL_RGB8;
|
||||
case Texture::F_rgb12:
|
||||
return GL_RGB12;
|
||||
case Texture::F_rgb16:
|
||||
if (tex->get_component_type() == Texture::T_float) {
|
||||
return GL_RGB16F;
|
||||
} else {
|
||||
return GL_RGB16;
|
||||
}
|
||||
#endif // OPENGLES
|
||||
|
||||
#ifndef OPENGLES
|
||||
@ -6673,12 +6725,34 @@ get_internal_image_format(Texture *tex) const {
|
||||
return GL_R3_G3_B2;
|
||||
#endif
|
||||
|
||||
#ifdef OPENGLES
|
||||
case Texture::F_r16:
|
||||
return GL_R16F_EXT;
|
||||
case Texture::F_rg16:
|
||||
return GL_RG16F_EXT;
|
||||
#else
|
||||
case Texture::F_r16:
|
||||
if (tex->get_component_type() == Texture::T_float) {
|
||||
return GL_R16F;
|
||||
} else {
|
||||
return GL_R16;
|
||||
}
|
||||
case Texture::F_rg16:
|
||||
if (tex->get_component_type() == Texture::T_float) {
|
||||
return GL_RG16F;
|
||||
} else {
|
||||
return GL_RG16;
|
||||
}
|
||||
#endif
|
||||
|
||||
case Texture::F_alpha:
|
||||
return GL_ALPHA;
|
||||
|
||||
case Texture::F_red:
|
||||
case Texture::F_green:
|
||||
case Texture::F_blue:
|
||||
return GL_RED;
|
||||
|
||||
case Texture::F_luminance:
|
||||
return GL_LUMINANCE;
|
||||
case Texture::F_luminance_alpha:
|
||||
@ -7836,10 +7910,16 @@ update_standard_texture_bindings() {
|
||||
#ifndef OPENGLES_2
|
||||
// Then, turn on the current texture mode.
|
||||
GLenum target = get_texture_target(texture->get_texture_type());
|
||||
if (target == GL_NONE || target == GL_TEXTURE_2D_ARRAY_EXT) {
|
||||
if (target == GL_NONE) {
|
||||
// Unsupported texture mode.
|
||||
continue;
|
||||
}
|
||||
#ifndef OPENGLES
|
||||
if (target == GL_TEXTURE_2D_ARRAY_EXT) {
|
||||
// Cannot be applied via the FFP.
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
GLP(Enable)(target);
|
||||
#endif
|
||||
|
||||
@ -9225,24 +9305,24 @@ upload_texture_image(CLP(TextureContext) *gtc,
|
||||
}
|
||||
|
||||
if (num_ram_mipmap_levels == 0) {
|
||||
#ifndef OPENGLES_2
|
||||
if ((external_format == GL_DEPTH_STENCIL_EXT) && get_supports_depth_stencil()) {
|
||||
#ifdef OPENGLES_1
|
||||
#ifdef OPENGLES
|
||||
component_type = GL_UNSIGNED_INT_24_8_OES;
|
||||
#else
|
||||
component_type = GL_UNSIGNED_INT_24_8_EXT;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
// We don't have any RAM mipmap levels, so we create an uninitialized OpenGL
|
||||
// texture. Presumably this will be used later for render-to-texture or so.
|
||||
switch (page_target) {
|
||||
#ifndef OPENGLES
|
||||
case GL_TEXTURE_1D:
|
||||
GLP(TexImage1D)(page_target, 0, internal_format, width, 0, external_format, component_type, NULL);
|
||||
break;
|
||||
case GL_TEXTURE_3D:
|
||||
case GL_TEXTURE_2D_ARRAY:
|
||||
#endif
|
||||
case GL_TEXTURE_3D:
|
||||
_glTexImage3D(page_target, 0, internal_format, width, height, depth, 0, external_format, component_type, NULL);
|
||||
break;
|
||||
default:
|
||||
@ -9554,8 +9634,8 @@ get_texture_memory_size(Texture *tex) {
|
||||
if (_supports_3d_texture || _supports_2d_texture_array) {
|
||||
GLP(GetTexLevelParameteriv)(page_target, 0, GL_TEXTURE_DEPTH, &depth);
|
||||
}
|
||||
|
||||
report_my_gl_errors();
|
||||
|
||||
report_my_gl_errors();
|
||||
|
||||
size_t num_bits = (red_size + green_size + blue_size + alpha_size + luminance_size + intensity_size + depth_size);
|
||||
size_t num_bytes = (num_bits + 7) / 8;
|
||||
@ -9672,15 +9752,15 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
|
||||
if (target != GL_TEXTURE_1D) {
|
||||
GLP(GetTexLevelParameteriv)(page_target, 0, GL_TEXTURE_HEIGHT, &height);
|
||||
}
|
||||
|
||||
|
||||
if (_supports_3d_texture && target == GL_TEXTURE_3D) {
|
||||
GLP(GetTexLevelParameteriv)(page_target, 0, GL_TEXTURE_DEPTH, &depth);
|
||||
}
|
||||
}
|
||||
#ifndef OPENGLES
|
||||
else if (_supports_2d_texture_array && target == GL_TEXTURE_2D_ARRAY_EXT) {
|
||||
GLP(GetTexLevelParameteriv)(page_target, 0, GL_TEXTURE_DEPTH, &depth);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
else if (target == GL_TEXTURE_CUBE_MAP) {
|
||||
depth = 6;
|
||||
}
|
||||
@ -9721,22 +9801,20 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
|
||||
case GL_DEPTH_COMPONENT:
|
||||
#endif
|
||||
case GL_DEPTH_COMPONENT16:
|
||||
case GL_DEPTH_COMPONENT24:
|
||||
case GL_DEPTH_COMPONENT32:
|
||||
type = Texture::T_unsigned_short;
|
||||
format = Texture::F_depth_component;
|
||||
break;
|
||||
case GL_DEPTH_COMPONENT24:
|
||||
case GL_DEPTH_COMPONENT32:
|
||||
case GL_DEPTH_COMPONENT32F:
|
||||
type = Texture::T_float;
|
||||
format = Texture::F_depth_component;
|
||||
break;
|
||||
#ifndef OPENGLES_2
|
||||
case GL_DEPTH_STENCIL_EXT:
|
||||
case GL_DEPTH24_STENCIL8_EXT:
|
||||
type = Texture::T_unsigned_int_24_8;
|
||||
format = Texture::F_depth_stencil;
|
||||
break;
|
||||
#endif
|
||||
case GL_RGBA:
|
||||
case 4:
|
||||
format = Texture::F_rgba;
|
||||
@ -9744,7 +9822,11 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
|
||||
case GL_RGBA4:
|
||||
format = Texture::F_rgba4;
|
||||
break;
|
||||
#ifndef OPENGLES_2
|
||||
#ifdef OPENGLES
|
||||
case GL_RGBA8_OES:
|
||||
format = Texture::F_rgba8;
|
||||
break;
|
||||
#else
|
||||
case GL_RGBA8:
|
||||
format = Texture::F_rgba8;
|
||||
break;
|
||||
@ -9755,6 +9837,10 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
|
||||
format = Texture::F_rgba12;
|
||||
break;
|
||||
#endif
|
||||
case GL_RGBA16F:
|
||||
type = Texture::T_float;
|
||||
format = Texture::F_rgba16;
|
||||
break;
|
||||
|
||||
case GL_RGB:
|
||||
case 3:
|
||||
@ -9777,7 +9863,44 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
|
||||
break;
|
||||
case GL_R3_G3_B2:
|
||||
format = Texture::F_rgb332;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case GL_RGB16F:
|
||||
type = Texture::T_float;
|
||||
format = Texture::F_rgb16;
|
||||
break;
|
||||
case GL_RG16F:
|
||||
type = Texture::T_float;
|
||||
format = Texture::F_rg16;
|
||||
break;
|
||||
case GL_R16F:
|
||||
type = Texture::T_float;
|
||||
format = Texture::F_r16;
|
||||
break;
|
||||
|
||||
#ifndef OPENGLES
|
||||
case GL_RGB16:
|
||||
type = Texture::T_unsigned_short;
|
||||
format = Texture::F_rgb16;
|
||||
break;
|
||||
case GL_RG16:
|
||||
type = Texture::T_unsigned_short;
|
||||
format = Texture::F_rg16;
|
||||
break;
|
||||
case GL_R16:
|
||||
type = Texture::T_unsigned_short;
|
||||
format = Texture::F_r16;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef OPENGLES_2
|
||||
case GL_RED_EXT:
|
||||
case GL_R8_EXT:
|
||||
format = Texture::F_red;
|
||||
break;
|
||||
#endif
|
||||
#ifndef OPENGLES
|
||||
case GL_RED:
|
||||
format = Texture::F_red;
|
||||
break;
|
||||
|
@ -521,7 +521,12 @@ protected:
|
||||
int _num_active_texture_stages;
|
||||
PN_stdfloat _max_anisotropy;
|
||||
bool _supports_anisotropy;
|
||||
|
||||
|
||||
#ifdef OPENGLES
|
||||
bool _supports_depth24;
|
||||
bool _supports_depth32;
|
||||
#endif
|
||||
|
||||
int _error_count;
|
||||
|
||||
string _gl_vendor;
|
||||
|
@ -567,6 +567,16 @@ estimate_texture_memory() const {
|
||||
bpp = 16;
|
||||
break;
|
||||
|
||||
case Texture::F_r16:
|
||||
bpp = 2;
|
||||
break;
|
||||
case Texture::F_rg16:
|
||||
bpp = 4;
|
||||
break;
|
||||
case Texture::F_rgb16:
|
||||
bpp = 6;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -1670,6 +1680,16 @@ write(ostream &out, int indent_level) const {
|
||||
case F_luminance_alphamask:
|
||||
out << "luminance_alphamask";
|
||||
break;
|
||||
|
||||
case F_r16:
|
||||
out << "r16";
|
||||
break;
|
||||
case F_rg16:
|
||||
out << "rg16";
|
||||
break;
|
||||
case F_rgb16:
|
||||
out << "rgb16";
|
||||
break;
|
||||
}
|
||||
|
||||
if (cdata->_compression != CM_default) {
|
||||
@ -2086,6 +2106,12 @@ format_format(Format format) {
|
||||
return "rgba16";
|
||||
case F_rgba32:
|
||||
return "rgba32";
|
||||
case F_r16:
|
||||
return "r16";
|
||||
case F_rg16:
|
||||
return "rg16";
|
||||
case F_rgb16:
|
||||
return "rgb16";
|
||||
}
|
||||
return "**invalid**";
|
||||
}
|
||||
@ -2150,6 +2176,12 @@ string_format(const string &str) {
|
||||
return F_rgba16;
|
||||
} else if (cmp_nocase(str, "rgba32") == 0 || cmp_nocase(str, "r32g32b32a32") == 0) {
|
||||
return F_rgba32;
|
||||
} else if (cmp_nocase(str, "r16") == 0 || cmp_nocase(str, "red16") == 0) {
|
||||
return F_r16;
|
||||
} else if (cmp_nocase(str, "rg16") == 0 || cmp_nocase(str, "r16g16") == 0) {
|
||||
return F_rg16;
|
||||
} else if (cmp_nocase(str, "rgb16") == 0 || cmp_nocase(str, "r16g16b16") == 0) {
|
||||
return F_rgb16;
|
||||
}
|
||||
|
||||
gobj_cat->error()
|
||||
@ -4968,11 +5000,13 @@ do_set_format(CData *cdata, Texture::Format format) {
|
||||
case F_blue:
|
||||
case F_alpha:
|
||||
case F_luminance:
|
||||
case F_r16:
|
||||
cdata->_num_components = 1;
|
||||
break;
|
||||
|
||||
case F_luminance_alpha:
|
||||
case F_luminance_alphamask:
|
||||
case F_rg16:
|
||||
cdata->_num_components = 2;
|
||||
break;
|
||||
|
||||
@ -4981,6 +5015,7 @@ do_set_format(CData *cdata, Texture::Format format) {
|
||||
case F_rgb8:
|
||||
case F_rgb12:
|
||||
case F_rgb332:
|
||||
case F_rgb16:
|
||||
cdata->_num_components = 3;
|
||||
break;
|
||||
|
||||
|
@ -128,6 +128,10 @@ PUBLISHED:
|
||||
F_depth_component16,
|
||||
F_depth_component24,
|
||||
F_depth_component32,
|
||||
|
||||
F_r16,
|
||||
F_rg16,
|
||||
F_rgb16,
|
||||
};
|
||||
|
||||
enum FilterType {
|
||||
|
Loading…
x
Reference in New Issue
Block a user