mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
properly test for GL_BGR
This commit is contained in:
parent
7e1501fd18
commit
cfaf59d494
@ -11,6 +11,7 @@
|
|||||||
putil linmath mathutil pnmimage
|
putil linmath mathutil pnmimage
|
||||||
|
|
||||||
#define INSTALL_HEADERS \
|
#define INSTALL_HEADERS \
|
||||||
|
glext.h \
|
||||||
glstuff_src.cxx \
|
glstuff_src.cxx \
|
||||||
glstuff_src.h \
|
glstuff_src.h \
|
||||||
glstuff_undef_src.h \
|
glstuff_undef_src.h \
|
||||||
|
@ -57,12 +57,6 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#if !defined(GL_BGR) && defined(GL_BGR_EXT)
|
|
||||||
// These symbols are sometimes defined as _EXT variants.
|
|
||||||
#define GL_BGR GL_BGR_EXT
|
|
||||||
#define GL_BGRA GL_BGRA_EXT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TypeHandle CLP(GraphicsStateGuardian)::_type_handle;
|
TypeHandle CLP(GraphicsStateGuardian)::_type_handle;
|
||||||
|
|
||||||
#if !defined(CPPPARSER) && defined(DO_PSTATS)
|
#if !defined(CPPPARSER) && defined(DO_PSTATS)
|
||||||
@ -430,6 +424,8 @@ reset() {
|
|||||||
get_extra_extensions();
|
get_extra_extensions();
|
||||||
report_extensions();
|
report_extensions();
|
||||||
|
|
||||||
|
_supports_bgr = has_extension("GL_EXT_bgra");
|
||||||
|
|
||||||
report_gl_errors();
|
report_gl_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2046,14 +2042,12 @@ copy_pixel_buffer(PixelBuffer *pb, const DisplayRegion *dr) {
|
|||||||
case GL_RGBA:
|
case GL_RGBA:
|
||||||
GLCAT.debug(false) << "GL_RGBA, ";
|
GLCAT.debug(false) << "GL_RGBA, ";
|
||||||
break;
|
break;
|
||||||
#ifdef GL_BGR
|
|
||||||
case GL_BGR:
|
case GL_BGR:
|
||||||
GLCAT.debug(false) << "GL_BGR, ";
|
GLCAT.debug(false) << "GL_BGR, ";
|
||||||
break;
|
break;
|
||||||
case GL_BGRA:
|
case GL_BGRA:
|
||||||
GLCAT.debug(false) << "GL_BGRA, ";
|
GLCAT.debug(false) << "GL_BGRA, ";
|
||||||
break;
|
break;
|
||||||
#endif // GL_BGR
|
|
||||||
default:
|
default:
|
||||||
GLCAT.debug(false) << "unknown, ";
|
GLCAT.debug(false) << "unknown, ";
|
||||||
break;
|
break;
|
||||||
@ -2904,16 +2898,12 @@ compute_gl_image_size(int xsize, int ysize, int external_format, int type) {
|
|||||||
num_components = 2;
|
num_components = 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef GL_BGR
|
|
||||||
case GL_BGR:
|
case GL_BGR:
|
||||||
#endif
|
|
||||||
case GL_RGB:
|
case GL_RGB:
|
||||||
num_components = 3;
|
num_components = 3;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef GL_BGR
|
|
||||||
case GL_BGRA:
|
case GL_BGRA:
|
||||||
#endif
|
|
||||||
case GL_RGBA:
|
case GL_RGBA:
|
||||||
num_components = 4;
|
num_components = 4;
|
||||||
break;
|
break;
|
||||||
@ -2970,7 +2960,7 @@ apply_texture_immediate(Texture *tex) {
|
|||||||
GLenum type = get_image_type(pb->get_image_type());
|
GLenum type = get_image_type(pb->get_image_type());
|
||||||
|
|
||||||
PTA_uchar image = pb->_image;
|
PTA_uchar image = pb->_image;
|
||||||
if (!CLP(supports_bgr)) {
|
if (!_supports_bgr) {
|
||||||
// If the GL doesn't claim to support BGR, we may have to reverse
|
// If the GL doesn't claim to support BGR, we may have to reverse
|
||||||
// the component ordering of the image.
|
// the component ordering of the image.
|
||||||
image = fix_component_ordering(external_format, pb);
|
image = fix_component_ordering(external_format, pb);
|
||||||
@ -3202,14 +3192,12 @@ draw_pixel_buffer(PixelBuffer *pb, const DisplayRegion *dr) {
|
|||||||
case GL_RGBA:
|
case GL_RGBA:
|
||||||
GLCAT.debug(false) << "GL_RGBA, ";
|
GLCAT.debug(false) << "GL_RGBA, ";
|
||||||
break;
|
break;
|
||||||
#ifdef GL_BGR
|
|
||||||
case GL_BGR:
|
case GL_BGR:
|
||||||
GLCAT.debug(false) << "GL_BGR, ";
|
GLCAT.debug(false) << "GL_BGR, ";
|
||||||
break;
|
break;
|
||||||
case GL_BGRA:
|
case GL_BGRA:
|
||||||
GLCAT.debug(false) << "GL_BGRA, ";
|
GLCAT.debug(false) << "GL_BGRA, ";
|
||||||
break;
|
break;
|
||||||
#endif // GL_BGR
|
|
||||||
default:
|
default:
|
||||||
GLCAT.debug(false) << "unknown, ";
|
GLCAT.debug(false) << "unknown, ";
|
||||||
break;
|
break;
|
||||||
@ -3386,22 +3374,14 @@ get_external_image_format(PixelBuffer::Format format) {
|
|||||||
case PixelBuffer::F_rgb8:
|
case PixelBuffer::F_rgb8:
|
||||||
case PixelBuffer::F_rgb12:
|
case PixelBuffer::F_rgb12:
|
||||||
case PixelBuffer::F_rgb332:
|
case PixelBuffer::F_rgb332:
|
||||||
#ifdef GL_BGR
|
return _supports_bgr ? GL_BGR : GL_RGB;
|
||||||
return CLP(supports_bgr) ? GL_BGR : GL_RGB;
|
|
||||||
#else
|
|
||||||
return GL_RGB;
|
|
||||||
#endif // GL_BGR
|
|
||||||
case PixelBuffer::F_rgba:
|
case PixelBuffer::F_rgba:
|
||||||
case PixelBuffer::F_rgbm:
|
case PixelBuffer::F_rgbm:
|
||||||
case PixelBuffer::F_rgba4:
|
case PixelBuffer::F_rgba4:
|
||||||
case PixelBuffer::F_rgba5:
|
case PixelBuffer::F_rgba5:
|
||||||
case PixelBuffer::F_rgba8:
|
case PixelBuffer::F_rgba8:
|
||||||
case PixelBuffer::F_rgba12:
|
case PixelBuffer::F_rgba12:
|
||||||
#ifdef GL_BGR
|
return _supports_bgr ? GL_BGRA : GL_RGBA;
|
||||||
return CLP(supports_bgr) ? GL_BGRA : GL_RGBA;
|
|
||||||
#else
|
|
||||||
return GL_RGBA;
|
|
||||||
#endif // GL_BGR
|
|
||||||
case PixelBuffer::F_luminance:
|
case PixelBuffer::F_luminance:
|
||||||
return GL_LUMINANCE;
|
return GL_LUMINANCE;
|
||||||
case PixelBuffer::F_luminance_alphamask:
|
case PixelBuffer::F_luminance_alphamask:
|
||||||
@ -4591,7 +4571,6 @@ ostream &output_gl_enum(ostream &out, GLenum v) {
|
|||||||
return out << "GL_ONE_MINUS_DST_ALPHA";
|
return out << "GL_ONE_MINUS_DST_ALPHA";
|
||||||
case GL_SRC_ALPHA_SATURATE:
|
case GL_SRC_ALPHA_SATURATE:
|
||||||
return out << "GL_SRC_ALPHA_SATURATE";
|
return out << "GL_SRC_ALPHA_SATURATE";
|
||||||
#ifdef USING_OPENGL_1_2 //[
|
|
||||||
case GL_CONSTANT_COLOR:
|
case GL_CONSTANT_COLOR:
|
||||||
return out << "GL_CONSTANT_COLOR";
|
return out << "GL_CONSTANT_COLOR";
|
||||||
case GL_ONE_MINUS_CONSTANT_COLOR:
|
case GL_ONE_MINUS_CONSTANT_COLOR:
|
||||||
@ -4600,7 +4579,6 @@ ostream &output_gl_enum(ostream &out, GLenum v) {
|
|||||||
return out << "GL_CONSTANT_ALPHA";
|
return out << "GL_CONSTANT_ALPHA";
|
||||||
case GL_ONE_MINUS_CONSTANT_ALPHA:
|
case GL_ONE_MINUS_CONSTANT_ALPHA:
|
||||||
return out << "GL_ONE_MINUS_CONSTANT_ALPHA";
|
return out << "GL_ONE_MINUS_CONSTANT_ALPHA";
|
||||||
#endif //]
|
|
||||||
|
|
||||||
/* Render Mode */
|
/* Render Mode */
|
||||||
case GL_FEEDBACK:
|
case GL_FEEDBACK:
|
||||||
@ -5192,7 +5170,6 @@ ostream &output_gl_enum(ostream &out, GLenum v) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* GL 1.2 texturing */
|
/* GL 1.2 texturing */
|
||||||
#ifdef USING_OPENGL_1_2 //[
|
|
||||||
case GL_PACK_SKIP_IMAGES:
|
case GL_PACK_SKIP_IMAGES:
|
||||||
return out << "GL_PACK_SKIP_IMAGES";
|
return out << "GL_PACK_SKIP_IMAGES";
|
||||||
case GL_PACK_IMAGE_HEIGHT:
|
case GL_PACK_IMAGE_HEIGHT:
|
||||||
@ -5211,11 +5188,8 @@ ostream &output_gl_enum(ostream &out, GLenum v) {
|
|||||||
return out << "GL_TEXTURE_WRAP_R";
|
return out << "GL_TEXTURE_WRAP_R";
|
||||||
case GL_MAX_3D_TEXTURE_SIZE:
|
case GL_MAX_3D_TEXTURE_SIZE:
|
||||||
return out << "GL_MAX_3D_TEXTURE_SIZE";
|
return out << "GL_MAX_3D_TEXTURE_SIZE";
|
||||||
#ifdef GL_TEXTURE_BINDING_3D
|
|
||||||
case GL_TEXTURE_BINDING_3D:
|
case GL_TEXTURE_BINDING_3D:
|
||||||
return out << "GL_TEXTURE_BINDING_3D";
|
return out << "GL_TEXTURE_BINDING_3D";
|
||||||
#endif
|
|
||||||
#endif //]
|
|
||||||
|
|
||||||
/* Internal texture formats (GL 1.1) */
|
/* Internal texture formats (GL 1.1) */
|
||||||
case GL_ALPHA4:
|
case GL_ALPHA4:
|
||||||
@ -5310,7 +5284,6 @@ ostream &output_gl_enum(ostream &out, GLenum v) {
|
|||||||
return out << "GL_OUT_OF_MEMORY";
|
return out << "GL_OUT_OF_MEMORY";
|
||||||
|
|
||||||
/* OpenGL 1.2 */
|
/* OpenGL 1.2 */
|
||||||
#ifdef USING_OPENGL_1_2 //[
|
|
||||||
case GL_RESCALE_NORMAL:
|
case GL_RESCALE_NORMAL:
|
||||||
return out << "GL_RESCALE_NORMAL";
|
return out << "GL_RESCALE_NORMAL";
|
||||||
case GL_CLAMP_TO_EDGE:
|
case GL_CLAMP_TO_EDGE:
|
||||||
@ -5361,7 +5334,6 @@ ostream &output_gl_enum(ostream &out, GLenum v) {
|
|||||||
return out << "GL_TEXTURE_BASE_LEVEL";
|
return out << "GL_TEXTURE_BASE_LEVEL";
|
||||||
case GL_TEXTURE_MAX_LEVEL:
|
case GL_TEXTURE_MAX_LEVEL:
|
||||||
return out << "GL_TEXTURE_MAX_LEVEL";
|
return out << "GL_TEXTURE_MAX_LEVEL";
|
||||||
#endif //]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return out << (int)v;
|
return out << (int)v;
|
||||||
|
@ -303,6 +303,7 @@ protected:
|
|||||||
int _pass_number;
|
int _pass_number;
|
||||||
|
|
||||||
pset<string> _extensions;
|
pset<string> _extensions;
|
||||||
|
bool _supports_bgr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static GraphicsStateGuardian *
|
static GraphicsStateGuardian *
|
||||||
|
5912
panda/src/glstuff/glext.h
Normal file
5912
panda/src/glstuff/glext.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -62,17 +62,6 @@ bool CLP(auto_normalize_lighting) = CONFIGOBJ.GetBool("auto-normalize-lighting",
|
|||||||
// rendering method instead.
|
// rendering method instead.
|
||||||
bool CLP(depth_offset_decals) = CONFIGOBJ.GetBool("depth-offset-decals", false);
|
bool CLP(depth_offset_decals) = CONFIGOBJ.GetBool("depth-offset-decals", false);
|
||||||
|
|
||||||
// Configure this true to indicate the current version of GL fully
|
|
||||||
// supports textures with B, G, R ordering; false if it only supports
|
|
||||||
// R, G, B. false will always work, but true might be faster if the
|
|
||||||
// implementation supports it.
|
|
||||||
#ifdef GL_BGR
|
|
||||||
bool CLP(supports_bgr) = CONFIGOBJ.GetBool("gl-supports-bgr", false);
|
|
||||||
#else
|
|
||||||
// If it's not even defined, we can't use it.
|
|
||||||
bool CLP(supports_bgr) = false;
|
|
||||||
#endif // GL_BGR
|
|
||||||
|
|
||||||
// Configure this false if your GL's implementation of GLP(ColorMask)()
|
// Configure this false if your GL's implementation of GLP(ColorMask)()
|
||||||
// is broken (some are). This will force the use of a (presumably)
|
// is broken (some are). This will force the use of a (presumably)
|
||||||
// more expensive blending operation instead.
|
// more expensive blending operation instead.
|
||||||
|
@ -30,7 +30,6 @@ extern bool CLP(show_mipmaps);
|
|||||||
extern bool CLP(save_mipmaps);
|
extern bool CLP(save_mipmaps);
|
||||||
extern bool CLP(auto_normalize_lighting);
|
extern bool CLP(auto_normalize_lighting);
|
||||||
extern bool CLP(depth_offset_decals);
|
extern bool CLP(depth_offset_decals);
|
||||||
extern bool CLP(supports_bgr);
|
|
||||||
extern bool CLP(color_mask);
|
extern bool CLP(color_mask);
|
||||||
|
|
||||||
extern EXPCL_GL void CLP(init_classes)();
|
extern EXPCL_GL void CLP(init_classes)();
|
||||||
|
@ -29,12 +29,14 @@
|
|||||||
// #define GLCAT: a Notify category, e.g. glgsg_cat
|
// #define GLCAT: a Notify category, e.g. glgsg_cat
|
||||||
// #define EXPCL_GL, EXPTP_GL: according to the DLL currently being compiled.
|
// #define EXPCL_GL, EXPTP_GL: according to the DLL currently being compiled.
|
||||||
|
|
||||||
// Also, be sure you include the appropriate GL.h header file to get
|
// Also, be sure you include the appropriate gl.h and glu.h header
|
||||||
// all the GL symbols declared.
|
// files to get all the standard GL symbols declared. GL extensions
|
||||||
|
// are included here via glext.h.
|
||||||
|
|
||||||
// This file is not protected from multiple inclusion; it may need to
|
// This file is not protected from multiple inclusion; it may need to
|
||||||
// be included multiple times.
|
// be included multiple times.
|
||||||
|
|
||||||
|
#include "glext.h"
|
||||||
|
|
||||||
#include "glmisc_src.h"
|
#include "glmisc_src.h"
|
||||||
#include "glGeomNodeContext_src.h"
|
#include "glGeomNodeContext_src.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user