mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -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
@ -575,7 +575,7 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot,
|
|||||||
// Adjust the texture format based on the requested framebuffer settings.
|
// Adjust the texture format based on the requested framebuffer settings.
|
||||||
switch (slot) {
|
switch (slot) {
|
||||||
case RTP_depth:
|
case RTP_depth:
|
||||||
if (_fb_properties.get_depth_bits() >= 32) {
|
if (_fb_properties.get_depth_bits() > 24) {
|
||||||
tex->set_format(Texture::F_depth_component32);
|
tex->set_format(Texture::F_depth_component32);
|
||||||
} else if (_fb_properties.get_depth_bits() > 16) {
|
} else if (_fb_properties.get_depth_bits() > 16) {
|
||||||
tex->set_format(Texture::F_depth_component24);
|
tex->set_format(Texture::F_depth_component24);
|
||||||
@ -594,6 +594,7 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot,
|
|||||||
case RTP_aux_hrgba_2:
|
case RTP_aux_hrgba_2:
|
||||||
case RTP_aux_hrgba_3:
|
case RTP_aux_hrgba_3:
|
||||||
tex->set_format(Texture::F_rgba16);
|
tex->set_format(Texture::F_rgba16);
|
||||||
|
tex->set_component_type(Texture::T_float);
|
||||||
break;
|
break;
|
||||||
case RTP_aux_float_0:
|
case RTP_aux_float_0:
|
||||||
case RTP_aux_float_1:
|
case RTP_aux_float_1:
|
||||||
@ -603,8 +604,18 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot,
|
|||||||
tex->set_component_type(Texture::T_float);
|
tex->set_component_type(Texture::T_float);
|
||||||
break;
|
break;
|
||||||
default:
|
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);
|
||||||
|
} 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);
|
tex->set_format(Texture::F_rgba);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create the OpenGL texture object.
|
// Create the OpenGL texture object.
|
||||||
TextureContext *tc = tex->prepare_now(0, glgsg->get_prepared_objects(), glgsg);
|
TextureContext *tc = tex->prepare_now(0, glgsg->get_prepared_objects(), glgsg);
|
||||||
@ -717,17 +728,39 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot,
|
|||||||
gl_format = GL_DEPTH_STENCIL_OES;
|
gl_format = GL_DEPTH_STENCIL_OES;
|
||||||
break;
|
break;
|
||||||
case RTP_depth:
|
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;
|
gl_format = GL_DEPTH_COMPONENT16;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
//case RTP_stencil:
|
//case RTP_stencil:
|
||||||
// gl_format = GL_STENCIL_INDEX8;
|
// gl_format = GL_STENCIL_INDEX8;
|
||||||
// break
|
// break
|
||||||
default:
|
default:
|
||||||
if (_fb_properties.get_alpha_bits() == 0) {
|
if (_fb_properties.get_alpha_bits() == 0) {
|
||||||
gl_format = GL_RGB565;
|
if (_fb_properties.get_color_bits() <= 16) {
|
||||||
} else if (_fb_properties.get_color_bits() == 15
|
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) {
|
&& _fb_properties.get_alpha_bits() == 1) {
|
||||||
gl_format = GL_RGB5_A1;
|
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
|
#else
|
||||||
@ -737,7 +770,7 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot,
|
|||||||
gl_format = GL_DEPTH_STENCIL_EXT;
|
gl_format = GL_DEPTH_STENCIL_EXT;
|
||||||
break;
|
break;
|
||||||
case RTP_depth:
|
case RTP_depth:
|
||||||
if (_fb_properties.get_depth_bits() >= 32) {
|
if (_fb_properties.get_depth_bits() > 24) {
|
||||||
gl_format = GL_DEPTH_COMPONENT32;
|
gl_format = GL_DEPTH_COMPONENT32;
|
||||||
} else if (_fb_properties.get_depth_bits() > 16) {
|
} else if (_fb_properties.get_depth_bits() > 16) {
|
||||||
gl_format = GL_DEPTH_COMPONENT24;
|
gl_format = GL_DEPTH_COMPONENT24;
|
||||||
@ -1231,6 +1264,28 @@ open_buffer() {
|
|||||||
_fb_properties.set_accum_bits(0);
|
_fb_properties.set_accum_bits(0);
|
||||||
_fb_properties.set_multisamples(_host->get_fb_properties().get_multisamples());
|
_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_back_buffers(0);
|
||||||
_fb_properties.set_indexed_color(0);
|
_fb_properties.set_indexed_color(0);
|
||||||
_fb_properties.set_rgb_color(1);
|
_fb_properties.set_rgb_color(1);
|
||||||
@ -1320,7 +1375,13 @@ share_depth_buffer(GraphicsOutput *graphics_output) {
|
|||||||
state = true;
|
state = true;
|
||||||
this->unshare_depth_buffer();
|
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()) {
|
if (this->get_x_size() != input_graphics_output->get_x_size()) {
|
||||||
GLCAT.error() << "share_depth_buffer: non-matching width\n";
|
GLCAT.error() << "share_depth_buffer: non-matching width\n";
|
||||||
state = false;
|
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()) {
|
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;
|
state = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -559,8 +559,9 @@ reset() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OPENGLES
|
#ifdef OPENGLES
|
||||||
_supports_depth_texture = has_extension("GL_OES_depth_texture") ||
|
_supports_depth_texture = has_extension("GL_OES_depth_texture");
|
||||||
has_extension("GL_OES_depth24") || has_extension("GL_OES_depth32");
|
_supports_depth24 = has_extension("GL_OES_depth24");
|
||||||
|
_supports_depth32 = has_extension("GL_OES_depth32");
|
||||||
#else
|
#else
|
||||||
_supports_depth_texture =
|
_supports_depth_texture =
|
||||||
has_extension("GL_ARB_depth_texture") || is_at_least_gl_version(1, 4);
|
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:
|
case GL_DEPTH_COMPONENT:
|
||||||
GLCAT.spam(false) << "GL_DEPTH_COMPONENT, ";
|
GLCAT.spam(false) << "GL_DEPTH_COMPONENT, ";
|
||||||
break;
|
break;
|
||||||
#ifndef OPENGLES_2
|
|
||||||
case GL_DEPTH_STENCIL_EXT:
|
case GL_DEPTH_STENCIL_EXT:
|
||||||
GLCAT.spam(false) << "GL_DEPTH_STENCIL, ";
|
GLCAT.spam(false) << "GL_DEPTH_STENCIL, ";
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
case GL_RGB:
|
case GL_RGB:
|
||||||
GLCAT.spam(false) << "GL_RGB, ";
|
GLCAT.spam(false) << "GL_RGB, ";
|
||||||
break;
|
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_LOCAL_VIEWER, material->get_local());
|
||||||
GLP(LightModeli)(GL_LIGHT_MODEL_TWO_SIDE, material->get_twoside());
|
GLP(LightModeli)(GL_LIGHT_MODEL_TWO_SIDE, material->get_twoside());
|
||||||
|
|
||||||
#ifndef OPENGLES
|
|
||||||
if (CLP(separate_specular_color)) {
|
if (CLP(separate_specular_color)) {
|
||||||
GLP(LightModeli)(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
|
GLP(LightModeli)(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
|
||||||
} else {
|
} else {
|
||||||
@ -6258,15 +6257,11 @@ get_component_type(Texture::ComponentType component_type) {
|
|||||||
case Texture::T_float:
|
case Texture::T_float:
|
||||||
return GL_FLOAT;
|
return GL_FLOAT;
|
||||||
case Texture::T_unsigned_int_24_8:
|
case Texture::T_unsigned_int_24_8:
|
||||||
#ifdef OPENGLES_2
|
|
||||||
return GL_UNSIGNED_BYTE;
|
|
||||||
#else
|
|
||||||
if (_supports_depth_stencil) {
|
if (_supports_depth_stencil) {
|
||||||
return GL_UNSIGNED_INT_24_8_EXT;
|
return GL_UNSIGNED_INT_24_8_EXT;
|
||||||
} else {
|
} else {
|
||||||
return GL_UNSIGNED_BYTE;
|
return GL_UNSIGNED_BYTE;
|
||||||
}
|
}
|
||||||
#endif // OPENGLES_2
|
|
||||||
default:
|
default:
|
||||||
GLCAT.error() << "Invalid Texture::Type value!\n";
|
GLCAT.error() << "Invalid Texture::Type value!\n";
|
||||||
return GL_UNSIGNED_BYTE;
|
return GL_UNSIGNED_BYTE;
|
||||||
@ -6308,6 +6303,7 @@ get_external_image_format(Texture *tex) const {
|
|||||||
case Texture::F_rgb8:
|
case Texture::F_rgb8:
|
||||||
case Texture::F_rgb12:
|
case Texture::F_rgb12:
|
||||||
case Texture::F_rgb332:
|
case Texture::F_rgb332:
|
||||||
|
case Texture::F_rgb16:
|
||||||
return GL_COMPRESSED_RGB;
|
return GL_COMPRESSED_RGB;
|
||||||
|
|
||||||
case Texture::F_alpha:
|
case Texture::F_alpha:
|
||||||
@ -6316,6 +6312,12 @@ get_external_image_format(Texture *tex) const {
|
|||||||
case Texture::F_red:
|
case Texture::F_red:
|
||||||
case Texture::F_green:
|
case Texture::F_green:
|
||||||
case Texture::F_blue:
|
case Texture::F_blue:
|
||||||
|
case Texture::F_r16:
|
||||||
|
return GL_COMPRESSED_RED;
|
||||||
|
|
||||||
|
case Texture::F_rg16:
|
||||||
|
return GL_COMPRESSED_RG;
|
||||||
|
|
||||||
case Texture::F_luminance:
|
case Texture::F_luminance:
|
||||||
return GL_COMPRESSED_LUMINANCE;
|
return GL_COMPRESSED_LUMINANCE;
|
||||||
|
|
||||||
@ -6386,6 +6388,7 @@ get_external_image_format(Texture *tex) const {
|
|||||||
return _supports_depth_stencil ? GL_DEPTH_STENCIL_EXT : GL_DEPTH_COMPONENT;
|
return _supports_depth_stencil ? GL_DEPTH_STENCIL_EXT : GL_DEPTH_COMPONENT;
|
||||||
#ifndef OPENGLES
|
#ifndef OPENGLES
|
||||||
case Texture::F_red:
|
case Texture::F_red:
|
||||||
|
case Texture::F_r16:
|
||||||
return GL_RED;
|
return GL_RED;
|
||||||
case Texture::F_green:
|
case Texture::F_green:
|
||||||
return GL_GREEN;
|
return GL_GREEN;
|
||||||
@ -6394,11 +6397,14 @@ get_external_image_format(Texture *tex) const {
|
|||||||
#endif
|
#endif
|
||||||
case Texture::F_alpha:
|
case Texture::F_alpha:
|
||||||
return GL_ALPHA;
|
return GL_ALPHA;
|
||||||
|
case Texture::F_rg16:
|
||||||
|
return GL_RG;
|
||||||
case Texture::F_rgb:
|
case Texture::F_rgb:
|
||||||
case Texture::F_rgb5:
|
case Texture::F_rgb5:
|
||||||
case Texture::F_rgb8:
|
case Texture::F_rgb8:
|
||||||
case Texture::F_rgb12:
|
case Texture::F_rgb12:
|
||||||
case Texture::F_rgb332:
|
case Texture::F_rgb332:
|
||||||
|
case Texture::F_rgb16:
|
||||||
#ifdef OPENGLES
|
#ifdef OPENGLES
|
||||||
return GL_RGB;
|
return GL_RGB;
|
||||||
#else
|
#else
|
||||||
@ -6498,6 +6504,7 @@ get_internal_image_format(Texture *tex) const {
|
|||||||
case Texture::F_rgb8:
|
case Texture::F_rgb8:
|
||||||
case Texture::F_rgb12:
|
case Texture::F_rgb12:
|
||||||
case Texture::F_rgb332:
|
case Texture::F_rgb332:
|
||||||
|
case Texture::F_rgb16:
|
||||||
if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
|
if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
|
||||||
return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
|
return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
|
||||||
} else if (get_supports_compressed_texture_format(Texture::CM_fxt1) && !is_3d) {
|
} else if (get_supports_compressed_texture_format(Texture::CM_fxt1) && !is_3d) {
|
||||||
@ -6516,6 +6523,22 @@ get_internal_image_format(Texture *tex) const {
|
|||||||
case Texture::F_red:
|
case Texture::F_red:
|
||||||
case Texture::F_green:
|
case Texture::F_green:
|
||||||
case Texture::F_blue:
|
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:
|
case Texture::F_luminance:
|
||||||
if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
|
if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
|
||||||
return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
|
return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
|
||||||
@ -6589,41 +6612,55 @@ get_internal_image_format(Texture *tex) const {
|
|||||||
return GL_COLOR_INDEX;
|
return GL_COLOR_INDEX;
|
||||||
#endif
|
#endif
|
||||||
case Texture::F_depth_component:
|
case Texture::F_depth_component:
|
||||||
|
#ifndef OPENGLES
|
||||||
if (tex->get_component_type() == Texture::T_float) {
|
if (tex->get_component_type() == Texture::T_float) {
|
||||||
return GL_DEPTH_COMPONENT32F;
|
return GL_DEPTH_COMPONENT32F;
|
||||||
} else {
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
return GL_DEPTH_COMPONENT;
|
return GL_DEPTH_COMPONENT;
|
||||||
}
|
}
|
||||||
case Texture::F_depth_component16:
|
case Texture::F_depth_component16:
|
||||||
#ifdef OPENGLES_1
|
#ifdef OPENGLES
|
||||||
return GL_DEPTH_COMPONENT16_OES;
|
return GL_DEPTH_COMPONENT16_OES;
|
||||||
#else
|
#else
|
||||||
return GL_DEPTH_COMPONENT16;
|
return GL_DEPTH_COMPONENT16;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case Texture::F_depth_component24:
|
case Texture::F_depth_component24:
|
||||||
#ifdef OPENGLES
|
#ifdef OPENGLES
|
||||||
|
if (_supports_depth24) {
|
||||||
return GL_DEPTH_COMPONENT24_OES;
|
return GL_DEPTH_COMPONENT24_OES;
|
||||||
case Texture::F_depth_component32:
|
} else {
|
||||||
return GL_DEPTH_COMPONENT32_OES;
|
return GL_DEPTH_COMPONENT16_OES;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
return GL_DEPTH_COMPONENT24;
|
return GL_DEPTH_COMPONENT24;
|
||||||
|
#endif
|
||||||
|
|
||||||
case Texture::F_depth_component32:
|
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) {
|
if (tex->get_component_type() == Texture::T_float) {
|
||||||
return GL_DEPTH_COMPONENT32F;
|
return GL_DEPTH_COMPONENT32F;
|
||||||
} else {
|
} else {
|
||||||
return GL_DEPTH_COMPONENT32;
|
return GL_DEPTH_COMPONENT32;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case Texture::F_depth_stencil:
|
case Texture::F_depth_stencil:
|
||||||
#ifndef OPENGLES_2
|
|
||||||
if (_supports_depth_stencil) {
|
if (_supports_depth_stencil) {
|
||||||
return GL_DEPTH_STENCIL_EXT;
|
return GL_DEPTH_STENCIL_EXT;
|
||||||
} else {
|
} else {
|
||||||
return GL_DEPTH_COMPONENT;
|
return GL_DEPTH_COMPONENT;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
return GL_DEPTH_COMPONENT;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case Texture::F_rgba:
|
case Texture::F_rgba:
|
||||||
case Texture::F_rgbm:
|
case Texture::F_rgbm:
|
||||||
@ -6633,10 +6670,13 @@ get_internal_image_format(Texture *tex) const {
|
|||||||
|
|
||||||
#ifdef OPENGLES
|
#ifdef OPENGLES
|
||||||
case Texture::F_rgba8:
|
case Texture::F_rgba8:
|
||||||
|
return GL_RGBA8_OES;
|
||||||
case Texture::F_rgba12:
|
case Texture::F_rgba12:
|
||||||
case Texture::F_rgba16:
|
|
||||||
case Texture::F_rgba32:
|
|
||||||
return GL_RGBA;
|
return GL_RGBA;
|
||||||
|
case Texture::F_rgba16:
|
||||||
|
return GL_RGBA16F_EXT;
|
||||||
|
case Texture::F_rgba32:
|
||||||
|
return GL_RGBA32F_EXT;
|
||||||
#else
|
#else
|
||||||
case Texture::F_rgba8:
|
case Texture::F_rgba8:
|
||||||
return GL_RGBA8;
|
return GL_RGBA8;
|
||||||
@ -6650,8 +6690,11 @@ get_internal_image_format(Texture *tex) const {
|
|||||||
|
|
||||||
case Texture::F_rgb:
|
case Texture::F_rgb:
|
||||||
return GL_RGB;
|
return GL_RGB;
|
||||||
#ifndef OPENGLES
|
|
||||||
case Texture::F_rgb5:
|
case Texture::F_rgb5:
|
||||||
|
#ifdef OPENGLES
|
||||||
|
// Close enough.
|
||||||
|
return GL_RGB565_OES;
|
||||||
|
#else
|
||||||
return GL_RGB5;
|
return GL_RGB5;
|
||||||
#endif
|
#endif
|
||||||
case Texture::F_rgba5:
|
case Texture::F_rgba5:
|
||||||
@ -6659,13 +6702,22 @@ get_internal_image_format(Texture *tex) const {
|
|||||||
|
|
||||||
#ifdef OPENGLES
|
#ifdef OPENGLES
|
||||||
case Texture::F_rgb8:
|
case Texture::F_rgb8:
|
||||||
|
return GL_RGB8_OES;
|
||||||
case Texture::F_rgb12:
|
case Texture::F_rgb12:
|
||||||
return GL_RGB;
|
return GL_RGB;
|
||||||
|
case Texture::F_rgb16:
|
||||||
|
return GL_RGB16F_EXT;
|
||||||
#else
|
#else
|
||||||
case Texture::F_rgb8:
|
case Texture::F_rgb8:
|
||||||
return GL_RGB8;
|
return GL_RGB8;
|
||||||
case Texture::F_rgb12:
|
case Texture::F_rgb12:
|
||||||
return GL_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
|
#endif // OPENGLES
|
||||||
|
|
||||||
#ifndef OPENGLES
|
#ifndef OPENGLES
|
||||||
@ -6673,12 +6725,34 @@ get_internal_image_format(Texture *tex) const {
|
|||||||
return GL_R3_G3_B2;
|
return GL_R3_G3_B2;
|
||||||
#endif
|
#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:
|
case Texture::F_alpha:
|
||||||
return GL_ALPHA;
|
return GL_ALPHA;
|
||||||
|
|
||||||
case Texture::F_red:
|
case Texture::F_red:
|
||||||
case Texture::F_green:
|
case Texture::F_green:
|
||||||
case Texture::F_blue:
|
case Texture::F_blue:
|
||||||
|
return GL_RED;
|
||||||
|
|
||||||
case Texture::F_luminance:
|
case Texture::F_luminance:
|
||||||
return GL_LUMINANCE;
|
return GL_LUMINANCE;
|
||||||
case Texture::F_luminance_alpha:
|
case Texture::F_luminance_alpha:
|
||||||
@ -7836,10 +7910,16 @@ update_standard_texture_bindings() {
|
|||||||
#ifndef OPENGLES_2
|
#ifndef OPENGLES_2
|
||||||
// Then, turn on the current texture mode.
|
// Then, turn on the current texture mode.
|
||||||
GLenum target = get_texture_target(texture->get_texture_type());
|
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.
|
// Unsupported texture mode.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
#ifndef OPENGLES
|
||||||
|
if (target == GL_TEXTURE_2D_ARRAY_EXT) {
|
||||||
|
// Cannot be applied via the FFP.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
GLP(Enable)(target);
|
GLP(Enable)(target);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -9225,24 +9305,24 @@ upload_texture_image(CLP(TextureContext) *gtc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (num_ram_mipmap_levels == 0) {
|
if (num_ram_mipmap_levels == 0) {
|
||||||
#ifndef OPENGLES_2
|
|
||||||
if ((external_format == GL_DEPTH_STENCIL_EXT) && get_supports_depth_stencil()) {
|
if ((external_format == GL_DEPTH_STENCIL_EXT) && get_supports_depth_stencil()) {
|
||||||
#ifdef OPENGLES_1
|
#ifdef OPENGLES
|
||||||
component_type = GL_UNSIGNED_INT_24_8_OES;
|
component_type = GL_UNSIGNED_INT_24_8_OES;
|
||||||
#else
|
#else
|
||||||
component_type = GL_UNSIGNED_INT_24_8_EXT;
|
component_type = GL_UNSIGNED_INT_24_8_EXT;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// We don't have any RAM mipmap levels, so we create an uninitialized OpenGL
|
// 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.
|
// texture. Presumably this will be used later for render-to-texture or so.
|
||||||
switch (page_target) {
|
switch (page_target) {
|
||||||
|
#ifndef OPENGLES
|
||||||
case GL_TEXTURE_1D:
|
case GL_TEXTURE_1D:
|
||||||
GLP(TexImage1D)(page_target, 0, internal_format, width, 0, external_format, component_type, NULL);
|
GLP(TexImage1D)(page_target, 0, internal_format, width, 0, external_format, component_type, NULL);
|
||||||
break;
|
break;
|
||||||
case GL_TEXTURE_3D:
|
|
||||||
case GL_TEXTURE_2D_ARRAY:
|
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);
|
_glTexImage3D(page_target, 0, internal_format, width, height, depth, 0, external_format, component_type, NULL);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -9721,22 +9801,20 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
|
|||||||
case GL_DEPTH_COMPONENT:
|
case GL_DEPTH_COMPONENT:
|
||||||
#endif
|
#endif
|
||||||
case GL_DEPTH_COMPONENT16:
|
case GL_DEPTH_COMPONENT16:
|
||||||
|
case GL_DEPTH_COMPONENT24:
|
||||||
|
case GL_DEPTH_COMPONENT32:
|
||||||
type = Texture::T_unsigned_short;
|
type = Texture::T_unsigned_short;
|
||||||
format = Texture::F_depth_component;
|
format = Texture::F_depth_component;
|
||||||
break;
|
break;
|
||||||
case GL_DEPTH_COMPONENT24:
|
|
||||||
case GL_DEPTH_COMPONENT32:
|
|
||||||
case GL_DEPTH_COMPONENT32F:
|
case GL_DEPTH_COMPONENT32F:
|
||||||
type = Texture::T_float;
|
type = Texture::T_float;
|
||||||
format = Texture::F_depth_component;
|
format = Texture::F_depth_component;
|
||||||
break;
|
break;
|
||||||
#ifndef OPENGLES_2
|
|
||||||
case GL_DEPTH_STENCIL_EXT:
|
case GL_DEPTH_STENCIL_EXT:
|
||||||
case GL_DEPTH24_STENCIL8_EXT:
|
case GL_DEPTH24_STENCIL8_EXT:
|
||||||
type = Texture::T_unsigned_int_24_8;
|
type = Texture::T_unsigned_int_24_8;
|
||||||
format = Texture::F_depth_stencil;
|
format = Texture::F_depth_stencil;
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
case GL_RGBA:
|
case GL_RGBA:
|
||||||
case 4:
|
case 4:
|
||||||
format = Texture::F_rgba;
|
format = Texture::F_rgba;
|
||||||
@ -9744,7 +9822,11 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
|
|||||||
case GL_RGBA4:
|
case GL_RGBA4:
|
||||||
format = Texture::F_rgba4;
|
format = Texture::F_rgba4;
|
||||||
break;
|
break;
|
||||||
#ifndef OPENGLES_2
|
#ifdef OPENGLES
|
||||||
|
case GL_RGBA8_OES:
|
||||||
|
format = Texture::F_rgba8;
|
||||||
|
break;
|
||||||
|
#else
|
||||||
case GL_RGBA8:
|
case GL_RGBA8:
|
||||||
format = Texture::F_rgba8;
|
format = Texture::F_rgba8;
|
||||||
break;
|
break;
|
||||||
@ -9755,6 +9837,10 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
|
|||||||
format = Texture::F_rgba12;
|
format = Texture::F_rgba12;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
case GL_RGBA16F:
|
||||||
|
type = Texture::T_float;
|
||||||
|
format = Texture::F_rgba16;
|
||||||
|
break;
|
||||||
|
|
||||||
case GL_RGB:
|
case GL_RGB:
|
||||||
case 3:
|
case 3:
|
||||||
@ -9777,7 +9863,44 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
|
|||||||
break;
|
break;
|
||||||
case GL_R3_G3_B2:
|
case GL_R3_G3_B2:
|
||||||
format = Texture::F_rgb332;
|
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:
|
case GL_RED:
|
||||||
format = Texture::F_red;
|
format = Texture::F_red;
|
||||||
break;
|
break;
|
||||||
|
@ -522,6 +522,11 @@ protected:
|
|||||||
PN_stdfloat _max_anisotropy;
|
PN_stdfloat _max_anisotropy;
|
||||||
bool _supports_anisotropy;
|
bool _supports_anisotropy;
|
||||||
|
|
||||||
|
#ifdef OPENGLES
|
||||||
|
bool _supports_depth24;
|
||||||
|
bool _supports_depth32;
|
||||||
|
#endif
|
||||||
|
|
||||||
int _error_count;
|
int _error_count;
|
||||||
|
|
||||||
string _gl_vendor;
|
string _gl_vendor;
|
||||||
|
@ -567,6 +567,16 @@ estimate_texture_memory() const {
|
|||||||
bpp = 16;
|
bpp = 16;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Texture::F_r16:
|
||||||
|
bpp = 2;
|
||||||
|
break;
|
||||||
|
case Texture::F_rg16:
|
||||||
|
bpp = 4;
|
||||||
|
break;
|
||||||
|
case Texture::F_rgb16:
|
||||||
|
bpp = 6;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1670,6 +1680,16 @@ write(ostream &out, int indent_level) const {
|
|||||||
case F_luminance_alphamask:
|
case F_luminance_alphamask:
|
||||||
out << "luminance_alphamask";
|
out << "luminance_alphamask";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case F_r16:
|
||||||
|
out << "r16";
|
||||||
|
break;
|
||||||
|
case F_rg16:
|
||||||
|
out << "rg16";
|
||||||
|
break;
|
||||||
|
case F_rgb16:
|
||||||
|
out << "rgb16";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cdata->_compression != CM_default) {
|
if (cdata->_compression != CM_default) {
|
||||||
@ -2086,6 +2106,12 @@ format_format(Format format) {
|
|||||||
return "rgba16";
|
return "rgba16";
|
||||||
case F_rgba32:
|
case F_rgba32:
|
||||||
return "rgba32";
|
return "rgba32";
|
||||||
|
case F_r16:
|
||||||
|
return "r16";
|
||||||
|
case F_rg16:
|
||||||
|
return "rg16";
|
||||||
|
case F_rgb16:
|
||||||
|
return "rgb16";
|
||||||
}
|
}
|
||||||
return "**invalid**";
|
return "**invalid**";
|
||||||
}
|
}
|
||||||
@ -2150,6 +2176,12 @@ string_format(const string &str) {
|
|||||||
return F_rgba16;
|
return F_rgba16;
|
||||||
} else if (cmp_nocase(str, "rgba32") == 0 || cmp_nocase(str, "r32g32b32a32") == 0) {
|
} else if (cmp_nocase(str, "rgba32") == 0 || cmp_nocase(str, "r32g32b32a32") == 0) {
|
||||||
return F_rgba32;
|
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()
|
gobj_cat->error()
|
||||||
@ -4968,11 +5000,13 @@ do_set_format(CData *cdata, Texture::Format format) {
|
|||||||
case F_blue:
|
case F_blue:
|
||||||
case F_alpha:
|
case F_alpha:
|
||||||
case F_luminance:
|
case F_luminance:
|
||||||
|
case F_r16:
|
||||||
cdata->_num_components = 1;
|
cdata->_num_components = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case F_luminance_alpha:
|
case F_luminance_alpha:
|
||||||
case F_luminance_alphamask:
|
case F_luminance_alphamask:
|
||||||
|
case F_rg16:
|
||||||
cdata->_num_components = 2;
|
cdata->_num_components = 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -4981,6 +5015,7 @@ do_set_format(CData *cdata, Texture::Format format) {
|
|||||||
case F_rgb8:
|
case F_rgb8:
|
||||||
case F_rgb12:
|
case F_rgb12:
|
||||||
case F_rgb332:
|
case F_rgb332:
|
||||||
|
case F_rgb16:
|
||||||
cdata->_num_components = 3;
|
cdata->_num_components = 3;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -128,6 +128,10 @@ PUBLISHED:
|
|||||||
F_depth_component16,
|
F_depth_component16,
|
||||||
F_depth_component24,
|
F_depth_component24,
|
||||||
F_depth_component32,
|
F_depth_component32,
|
||||||
|
|
||||||
|
F_r16,
|
||||||
|
F_rg16,
|
||||||
|
F_rgb16,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum FilterType {
|
enum FilterType {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user