Fix OpenGL ES compiler errors

This commit is contained in:
rdb 2015-02-11 21:41:48 +01:00
parent 5a51a7e08d
commit 4d2dcdcef7
13 changed files with 150 additions and 115 deletions

View File

@ -1,5 +1,5 @@
// Filename: eglGraphicsBuffer.cxx // Filename: eglGraphicsBuffer.cxx
// Created by: pro-rsoft (13Jun09) // Created by: rdb (13Jun09)
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// //
@ -28,7 +28,7 @@ TypeHandle eglGraphicsBuffer::_type_handle;
// Description: // Description:
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
eglGraphicsBuffer:: eglGraphicsBuffer::
eglGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, eglGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe,
const string &name, const string &name,
const FrameBufferProperties &fb_prop, const FrameBufferProperties &fb_prop,
const WindowProperties &win_prop, const WindowProperties &win_prop,
@ -187,7 +187,7 @@ open_buffer() {
_gsg = eglgsg; _gsg = eglgsg;
} }
} }
if (eglgsg->_fbconfig == None) { if (eglgsg->_fbconfig == None) {
// If we didn't use an fbconfig to create the GSG, we can't create // If we didn't use an fbconfig to create the GSG, we can't create
// a PBuffer. // a PBuffer.
@ -195,11 +195,11 @@ open_buffer() {
} }
int attrib_list[] = { int attrib_list[] = {
EGL_WIDTH, _x_size, EGL_WIDTH, _size.get_x(),
EGL_HEIGHT, _y_size, EGL_HEIGHT, _size.get_y(),
EGL_NONE EGL_NONE
}; };
_pbuffer = eglCreatePbufferSurface(eglgsg->_egl_display, eglgsg->_fbconfig, attrib_list); _pbuffer = eglCreatePbufferSurface(eglgsg->_egl_display, eglgsg->_fbconfig, attrib_list);
if (_pbuffer == EGL_NO_SURFACE) { if (_pbuffer == EGL_NO_SURFACE) {
@ -224,7 +224,7 @@ open_buffer() {
return false; return false;
} }
_fb_properties = eglgsg->get_fb_properties(); _fb_properties = eglgsg->get_fb_properties();
_is_valid = true; _is_valid = true;
return true; return true;
} }

View File

@ -1,5 +1,5 @@
// Filename: eglGraphicsBuffer.h // Filename: eglGraphicsBuffer.h
// Created by: pro-rsoft (13Jun09) // Created by: rdb (13Jun09)
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// //

View File

@ -1,5 +1,5 @@
// Filename: eglGraphicsPixmap.cxx // Filename: eglGraphicsPixmap.cxx
// Created by: pro-rsoft (13Jun09) // Created by: rdb (13Jun09)
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// //
@ -29,7 +29,7 @@ TypeHandle eglGraphicsPixmap::_type_handle;
// Description: // Description:
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
eglGraphicsPixmap:: eglGraphicsPixmap::
eglGraphicsPixmap(GraphicsEngine *engine, GraphicsPipe *pipe, eglGraphicsPixmap(GraphicsEngine *engine, GraphicsPipe *pipe,
const string &name, const string &name,
const FrameBufferProperties &fb_prop, const FrameBufferProperties &fb_prop,
const WindowProperties &win_prop, const WindowProperties &win_prop,
@ -105,7 +105,7 @@ begin_frame(FrameMode mode, Thread *current_thread) {
} }
clear_cube_map_selection(); clear_cube_map_selection();
} }
_gsg->set_current_properties(&get_fb_properties()); _gsg->set_current_properties(&get_fb_properties());
return _gsg->begin_frame(current_thread); return _gsg->begin_frame(current_thread);
} }
@ -195,7 +195,7 @@ open_buffer() {
_gsg = eglgsg; _gsg = eglgsg;
} }
} }
if (eglgsg->_fbconfig == None) { if (eglgsg->_fbconfig == None) {
// If we didn't use an fbconfig to create the GSG, we can't create // If we didn't use an fbconfig to create the GSG, we can't create
// a PBuffer. // a PBuffer.
@ -221,8 +221,8 @@ open_buffer() {
} }
} }
_x_pixmap = XCreatePixmap(_display, _drawable, _x_pixmap = XCreatePixmap(_display, _drawable,
_x_size, _y_size, visual_info->depth); _size.get_x(), _size.get_y(), visual_info->depth);
if (_x_pixmap == None) { if (_x_pixmap == None) {
egldisplay_cat.error() egldisplay_cat.error()
<< "Failed to create X pixmap.\n"; << "Failed to create X pixmap.\n";
@ -253,7 +253,7 @@ open_buffer() {
return false; return false;
} }
_fb_properties = eglgsg->get_fb_properties(); _fb_properties = eglgsg->get_fb_properties();
_is_valid = true; _is_valid = true;
return true; return true;
} }

View File

@ -1,5 +1,5 @@
// Filename: eglGraphicsPixmap.h // Filename: eglGraphicsPixmap.h
// Created by: pro-rsoft (13Jun09) // Created by: rdb (13Jun09)
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// //
@ -29,7 +29,7 @@
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
class eglGraphicsPixmap : public GraphicsBuffer { class eglGraphicsPixmap : public GraphicsBuffer {
public: public:
eglGraphicsPixmap(GraphicsEngine *engine, GraphicsPipe *pipe, eglGraphicsPixmap(GraphicsEngine *engine, GraphicsPipe *pipe,
const string &name, const string &name,
const FrameBufferProperties &fb_prop, const FrameBufferProperties &fb_prop,
const WindowProperties &win_prop, const WindowProperties &win_prop,

View File

@ -57,7 +57,7 @@
// #include <GLES2/gl2ext.h> // #include <GLES2/gl2ext.h>
#endif #endif
#include "panda_esgl2ext.h" #include "panda_esgl2ext.h"
// This helps to keep the source clean of hundreds of #ifdefs. // This helps to keep the source clean of hundreds of #ifdefs.
typedef char GLchar; typedef char GLchar;
@ -100,20 +100,19 @@ typedef char GLchar;
#define GL_RGBA16F GL_RGBA16F_EXT #define GL_RGBA16F GL_RGBA16F_EXT
#define GL_RGB32F GL_RGB32F_EXT #define GL_RGB32F GL_RGB32F_EXT
#define GL_RGBA32F GL_RGBA32F_EXT #define GL_RGBA32F GL_RGBA32F_EXT
#define GL_DEBUG_SEVERITY_HIGH GL_DEBUG_SEVERITY_HIGH_KHR
#define GL_DEBUG_SEVERITY_MEDIUM GL_DEBUG_SEVERITY_MEDIUM_KHR
#define GL_DEBUG_SEVERITY_LOW GL_DEBUG_SEVERITY_LOW_KHR
#define GL_DEBUG_SEVERITY_NOTIFICATION GL_DEBUG_SEVERITY_NOTIFICATION_KHR
#define GL_DEBUG_OUTPUT_SYNCHRONOUS GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR
#define GL_FRAMEBUFFER_SRGB GL_FRAMEBUFFER_SRGB_EXT
#define GL_SRGB GL_SRGB_EXT #define GL_SRGB GL_SRGB_EXT
#define GL_SRGB_ALPHA GL_SRGB_ALPHA_EXT #define GL_SRGB_ALPHA GL_SRGB_ALPHA_EXT
#define GL_SRGB8 GL_SRGB8_EXT #define GL_SRGB8_ALPHA8 GL_SRGB8_ALPHA8_EXT
#define GL_SRGB8_ALPHA GL_SRGB8_ALPHA_EXT #define GL_RGBA8 GL_RGBA8_OES
#define GL_SLUMINANCE GL_SLUMINANCE_NV #define GL_R8 GL_R8_EXT
#define GL_SLUMINANCE_ALPHA GL_SLUMINANCE_ALPHA_NV #define GL_RG8 GL_RG8_EXT
#define GL_SLUMINANCE8 GL_SLUMINANCE8_NV #define GL_ALPHA8 GL_ALPHA8_OES
#define GL_SLUMINANCE8_ALPHA GL_SLUMINANCE8_ALPHA_NV #define GL_LUMINANCE8 GL_LUMINANCE8_OES
#define GL_LUMINANCE8_ALPHA8 GL_LUMINANCE8_ALPHA8_EXT
#define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_EXT
#define GL_R32F GL_R32F_EXT
#define GL_RG32F GL_RG32F_EXT
#define GL_RGB8 GL_RGB8_OES
#undef SUPPORT_IMMEDIATE_MODE #undef SUPPORT_IMMEDIATE_MODE
#define APIENTRY #define APIENTRY

View File

@ -115,6 +115,9 @@
#define GL_RGBA16F GL_RGBA16F_EXT #define GL_RGBA16F GL_RGBA16F_EXT
#define GL_RGB32F GL_RGB32F_EXT #define GL_RGB32F GL_RGB32F_EXT
#define GL_RGBA32F GL_RGBA32F_EXT #define GL_RGBA32F GL_RGBA32F_EXT
#define GL_ALPHA8 GL_ALPHA8_EXT
#define GL_LUMINANCE8 GL_LUMINANCE8_EXT
#define GL_LUMINANCE8_ALPHA8 GL_LUMINANCE8_ALPHA8_EXT
#undef SUPPORT_IMMEDIATE_MODE #undef SUPPORT_IMMEDIATE_MODE
#define APIENTRY #define APIENTRY

View File

@ -1674,7 +1674,7 @@ resolve_multisamples() {
GL_NEAREST); GL_NEAREST);
} }
// Now handle the other color buffers. // Now handle the other color buffers.
#ifndef OPENGLES_1 #ifndef OPENGLES
int next = GL_COLOR_ATTACHMENT1_EXT; int next = GL_COLOR_ATTACHMENT1_EXT;
if (_fb_properties.is_stereo()) { if (_fb_properties.is_stereo()) {
glReadBuffer(next); glReadBuffer(next);

View File

@ -745,9 +745,12 @@ call_glTexParameterfv(GLenum target, GLenum pname, const LVecBase4 &value) {
// Access: Public // Access: Public
// Description: Convert index to gl light id // Description: Convert index to gl light id
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE GLenum CLP(GraphicsStateGuardian)::get_light_id(int index) const { INLINE GLenum CLP(GraphicsStateGuardian)::
get_light_id(int index) const {
#ifndef OPENGLES_2 #ifndef OPENGLES_2
return GL_LIGHT0 + index; return GL_LIGHT0 + index;
#else
return 0;
#endif #endif
} }
@ -760,6 +763,8 @@ INLINE GLenum CLP(GraphicsStateGuardian)::
get_clip_plane_id(int index) const { get_clip_plane_id(int index) const {
#ifndef OPENGLES_2 #ifndef OPENGLES_2
return GL_CLIP_PLANE0 + index; return GL_CLIP_PLANE0 + index;
#else
return 0;
#endif #endif
} }

View File

@ -127,16 +127,16 @@ null_glBlendColor(GLclampf, GLclampf, GLclampf, GLclampf) {
// a fixed-function pipeline. // a fixed-function pipeline.
// This default shader just outputs a red color, telling // This default shader just outputs a red color, telling
// the user that something went wrong. // the user that something went wrong.
CPT(Shader::ShaderFile) default_shader_name = new Shader::ShaderFile("default-shader"); static const string default_vshader =
CPT(Shader::ShaderFile) default_shader_body = new Shader::ShaderFile("\ "uniform mediump mat4 p3d_ModelViewProjectionMatrix;\n"
uniform mediump mat4 p3d_ModelViewProjectionMatrix;\ "attribute highp vec4 p3d_Vertex;\n"
attribute highp vec4 p3d_Vertex;\ "void main(void) {\n"
void main(void) {\ " gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;\n"
gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;\ "}\n";
}\n", static const string default_fshader =
"void main(void) {\ "void main(void) {\n"
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\ " gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
}\n", "", "", ""); "}\n";
#endif #endif
@ -1370,7 +1370,7 @@ reset() {
// if it failed to compile. This default shader just outputs // if it failed to compile. This default shader just outputs
// a red color, indicating that something went wrong. // a red color, indicating that something went wrong.
if (_default_shader == NULL) { if (_default_shader == NULL) {
_default_shader = new Shader(default_shader_name, default_shader_body, Shader::SL_GLSL); _default_shader = Shader::load(Shader::SL_GLSL, default_vshader, default_fshader);
} }
#endif #endif
@ -1915,6 +1915,8 @@ reset() {
} }
_supports_sampler_objects = false; _supports_sampler_objects = false;
#ifndef OPENGLES
if (gl_support_sampler_objects && if (gl_support_sampler_objects &&
((is_at_least_gl_version(3, 3) || has_extension("GL_ARB_sampler_objects")))) { ((is_at_least_gl_version(3, 3) || has_extension("GL_ARB_sampler_objects")))) {
_glGenSamplers = (PFNGLGENSAMPLERSPROC) get_extension_func("glGenSamplers"); _glGenSamplers = (PFNGLGENSAMPLERSPROC) get_extension_func("glGenSamplers");
@ -1935,6 +1937,7 @@ reset() {
_supports_sampler_objects = true; _supports_sampler_objects = true;
} }
} }
#endif // OPENGLES
// Check availability of multi-bind functions. // Check availability of multi-bind functions.
_supports_multi_bind = false; _supports_multi_bind = false;
@ -1944,10 +1947,12 @@ reset() {
_glBindImageTextures = (PFNGLBINDIMAGETEXTURESPROC) _glBindImageTextures = (PFNGLBINDIMAGETEXTURESPROC)
get_extension_func("glBindImageTextures"); get_extension_func("glBindImageTextures");
#ifndef OPENGLES
if (_supports_sampler_objects) { if (_supports_sampler_objects) {
_glBindSamplers = (PFNGLBINDSAMPLERSPROC) _glBindSamplers = (PFNGLBINDSAMPLERSPROC)
get_extension_func("glBindSamplers"); get_extension_func("glBindSamplers");
} }
#endif // OPENGLES
if (_glBindTextures != NULL && _glBindImageTextures != NULL) { if (_glBindTextures != NULL && _glBindImageTextures != NULL) {
_supports_multi_bind = true; _supports_multi_bind = true;
@ -2011,14 +2016,18 @@ reset() {
_supports_stencil_wrap = _supports_stencil_wrap =
has_extension("GL_EXT_stencil_wrap") || has_extension("GL_OES_stencil_wrap"); has_extension("GL_EXT_stencil_wrap") || has_extension("GL_OES_stencil_wrap");
_supports_two_sided_stencil = has_extension("GL_EXT_stencil_two_side");
if (_supports_two_sided_stencil) {
_supports_two_sided_stencil = false;
#ifndef OPENGLES
if (has_extension("GL_EXT_stencil_two_side")) {
_glActiveStencilFaceEXT = (PFNGLACTIVESTENCILFACEEXTPROC) _glActiveStencilFaceEXT = (PFNGLACTIVESTENCILFACEEXTPROC)
get_extension_func("glActiveStencilFaceEXT"); get_extension_func("glActiveStencilFaceEXT");
} _supports_two_sided_stencil = true;
else { } else {
_glActiveStencilFaceEXT = 0; _glActiveStencilFaceEXT = 0;
} }
#endif
#ifndef OPENGLES #ifndef OPENGLES
// Some drivers expose one, some expose the other. ARB seems to be the newer one. // Some drivers expose one, some expose the other. ARB seems to be the newer one.
@ -2618,9 +2627,11 @@ clear_before_callback() {
// Clear the bound sampler object, so that we do not inadvertently // Clear the bound sampler object, so that we do not inadvertently
// override the callback's desired sampler settings. // override the callback's desired sampler settings.
#ifndef OPENGLES
if (_supports_sampler_objects) { if (_supports_sampler_objects) {
_glBindSampler(0, 0); _glBindSampler(0, 0);
} }
#endif
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -2761,7 +2772,7 @@ begin_frame(Thread *current_thread) {
}*/ }*/
#endif #endif
#ifndef OPENGLES_1 #ifndef OPENGLES
if (_current_properties->get_srgb_color()) { if (_current_properties->get_srgb_color()) {
glEnable(GL_FRAMEBUFFER_SRGB); glEnable(GL_FRAMEBUFFER_SRGB);
} }
@ -2819,7 +2830,7 @@ void CLP(GraphicsStateGuardian)::
end_frame(Thread *current_thread) { end_frame(Thread *current_thread) {
report_my_gl_errors(); report_my_gl_errors();
#ifndef OPENGLES_1 #ifndef OPENGLES
if (_current_properties->get_srgb_color()) { if (_current_properties->get_srgb_color()) {
glDisable(GL_FRAMEBUFFER_SRGB); glDisable(GL_FRAMEBUFFER_SRGB);
} }
@ -4521,8 +4532,10 @@ prepare_sampler(const SamplerState &sampler) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void CLP(GraphicsStateGuardian):: void CLP(GraphicsStateGuardian)::
release_sampler(SamplerContext *sc) { release_sampler(SamplerContext *sc) {
#ifndef OPENGLES
CLP(SamplerContext) *gsc = DCAST(CLP(SamplerContext), sc); CLP(SamplerContext) *gsc = DCAST(CLP(SamplerContext), sc);
delete gsc; delete gsc;
#endif
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -5205,7 +5218,7 @@ make_geom_munger(const RenderState *state, Thread *current_thread) {
// from the camera plane. The point is assumed to be // from the camera plane. The point is assumed to be
// in the GSG's internal coordinate system. // in the GSG's internal coordinate system.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
PN_stdfloat GLGraphicsStateGuardian:: PN_stdfloat CLP(GraphicsStateGuardian)::
compute_distance_to(const LPoint3 &point) const { compute_distance_to(const LPoint3 &point) const {
return -point[2]; return -point[2];
} }
@ -7447,7 +7460,7 @@ get_external_image_format(Texture *tex) const {
break; break;
case Texture::CM_dxt1: case Texture::CM_dxt1:
#ifndef OPENGLES_1 #ifndef OPENGLES
if (format == Texture::F_srgb_alpha) { if (format == Texture::F_srgb_alpha) {
return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
} else if (format == Texture::F_srgb) { } else if (format == Texture::F_srgb) {
@ -7484,13 +7497,13 @@ get_external_image_format(Texture *tex) const {
#else #else
case Texture::CM_pvr1_2bpp: case Texture::CM_pvr1_2bpp:
#ifndef OPENGLES_1 #ifndef OPENGLES
if (format == Texture::F_srgb_alpha) { if (format == Texture::F_srgb_alpha) {
return GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT; return GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT;
} else if (format == Texture::F_srgb) { } else if (format == Texture::F_srgb) {
return GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT; return GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT;
} else } else
#endif // OPENGLES_1 #endif // OPENGLES
if (Texture::has_alpha(format)) { if (Texture::has_alpha(format)) {
return GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; return GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
} else { } else {
@ -7498,13 +7511,13 @@ get_external_image_format(Texture *tex) const {
} }
case Texture::CM_pvr1_4bpp: case Texture::CM_pvr1_4bpp:
#ifndef OPENGLES_1 #ifndef OPENGLES
if (format == Texture::F_srgb_alpha) { if (format == Texture::F_srgb_alpha) {
return GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT; return GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT;
} else if (format == Texture::F_srgb) { } else if (format == Texture::F_srgb) {
return GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT; return GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT;
} else } else
#endif // OPENGLES_1 #endif // OPENGLES
if (Texture::has_alpha(format)) { if (Texture::has_alpha(format)) {
return GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; return GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
} else { } else {
@ -7762,7 +7775,7 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
#endif #endif
case Texture::CM_dxt1: case Texture::CM_dxt1:
#ifndef OPENGLES_1 #ifndef OPENGLES
if (format == Texture::F_srgb_alpha) { if (format == Texture::F_srgb_alpha) {
return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
} else if (format == Texture::F_srgb) { } else if (format == Texture::F_srgb) {
@ -7798,13 +7811,6 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
} }
#else #else
case Texture::CM_pvr1_2bpp: case Texture::CM_pvr1_2bpp:
#ifndef OPENGLES_1
if (format == Texture::F_srgb_alpha) {
return GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT;
} else if (format == Texture::F_srgb) {
return GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT;
} else
#endif // OPENGLES_1
if (Texture::has_alpha(format)) { if (Texture::has_alpha(format)) {
return GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; return GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
} else { } else {
@ -7812,13 +7818,6 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
} }
case Texture::CM_pvr1_4bpp: case Texture::CM_pvr1_4bpp:
#ifndef OPENGLES_1
if (format == Texture::F_srgb_alpha) {
return GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT;
} else if (format == Texture::F_srgb) {
return GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT;
} else
#endif // OPENGLES_1
if (Texture::has_alpha(format)) { if (Texture::has_alpha(format)) {
return GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; return GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
} else { } else {
@ -7843,7 +7842,7 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
case Texture::F_depth_stencil: case Texture::F_depth_stencil:
if (_supports_depth_stencil) { if (_supports_depth_stencil) {
#ifndef OPENGLES_1 #ifndef OPENGLES
if (tex->get_component_type() == Texture::T_float) { if (tex->get_component_type() == Texture::T_float) {
return GL_DEPTH32F_STENCIL8; return GL_DEPTH32F_STENCIL8;
} else } else
@ -7903,7 +7902,10 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
#ifndef OPENGLES_1 #ifndef OPENGLES_1
if (tex->get_component_type() == Texture::T_float) { if (tex->get_component_type() == Texture::T_float) {
return GL_RGBA16F; return GL_RGBA16F;
} else if (tex->get_component_type() == Texture::T_unsigned_short) { } else
#endif
#ifndef OPENGLES
if (tex->get_component_type() == Texture::T_unsigned_short) {
return GL_RGBA16; return GL_RGBA16;
} else } else
#endif #endif
@ -7949,7 +7951,7 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
case Texture::F_rgba12: case Texture::F_rgba12:
return GL_RGBA12; return GL_RGBA12;
#endif // OPENGLES #endif // OPENGLES
#ifndef OPENGLES_1 #ifndef OPENGLES
case Texture::F_rgba16: case Texture::F_rgba16:
if (tex->get_component_type() == Texture::T_float) { if (tex->get_component_type() == Texture::T_float) {
return GL_RGBA16F; return GL_RGBA16F;
@ -8040,26 +8042,36 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
return force_sized ? GL_ALPHA8 : GL_ALPHA; return force_sized ? GL_ALPHA8 : GL_ALPHA;
case Texture::F_luminance: case Texture::F_luminance:
#ifndef OPENGLES
if (tex->get_component_type() == Texture::T_float) { if (tex->get_component_type() == Texture::T_float) {
return GL_LUMINANCE16F_ARB; return GL_LUMINANCE16F_ARB;
} else if (tex->get_component_type() == Texture::T_unsigned_short) { } else if (tex->get_component_type() == Texture::T_unsigned_short) {
return GL_LUMINANCE16; return GL_LUMINANCE16;
} else { } else
#endif // OPENGLES
{
return force_sized ? GL_LUMINANCE8 : GL_LUMINANCE; return force_sized ? GL_LUMINANCE8 : GL_LUMINANCE;
} }
case Texture::F_luminance_alpha: case Texture::F_luminance_alpha:
case Texture::F_luminance_alphamask: case Texture::F_luminance_alphamask:
#ifndef OPENGLES
if (tex->get_component_type() == Texture::T_float || tex->get_component_type() == Texture::T_unsigned_short) { if (tex->get_component_type() == Texture::T_float || tex->get_component_type() == Texture::T_unsigned_short) {
return GL_LUMINANCE_ALPHA16F_ARB; return GL_LUMINANCE_ALPHA16F_ARB;
} else { } else
#endif // OPENGLES
{
return force_sized ? GL_LUMINANCE8_ALPHA8 : GL_LUMINANCE_ALPHA; return force_sized ? GL_LUMINANCE8_ALPHA8 : GL_LUMINANCE_ALPHA;
} }
#ifndef OPENGLES_1 #ifndef OPENGLES_1
case Texture::F_srgb: case Texture::F_srgb:
#ifndef OPENGLES
return GL_SRGB8; return GL_SRGB8;
#endif
case Texture::F_srgb_alpha: case Texture::F_srgb_alpha:
return GL_SRGB8_ALPHA8; return GL_SRGB8_ALPHA8;
#endif
#ifndef OPENGLES
case Texture::F_sluminance: case Texture::F_sluminance:
return GL_SLUMINANCE8; return GL_SLUMINANCE8;
case Texture::F_sluminance_alpha: case Texture::F_sluminance_alpha:
@ -9043,7 +9055,7 @@ set_state_and_transform(const RenderState *target,
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void CLP(GraphicsStateGuardian):: void CLP(GraphicsStateGuardian)::
free_pointers() { free_pointers() {
#ifdef HAVE_CG #if defined(HAVE_CG) && !defined(OPENGLES)
if (_cg_context != 0) { if (_cg_context != 0) {
cgDestroyContext(_cg_context); cgDestroyContext(_cg_context);
_cg_context = 0; _cg_context = 0;
@ -10081,6 +10093,7 @@ bool CLP(GraphicsStateGuardian)::
apply_sampler(GLuint unit, const SamplerState &sampler, TextureContext *tc) { apply_sampler(GLuint unit, const SamplerState &sampler, TextureContext *tc) {
CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), tc); CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), tc);
#ifndef OPENGLES
if (_supports_sampler_objects) { if (_supports_sampler_objects) {
// We support sampler objects. Prepare the sampler object and // We support sampler objects. Prepare the sampler object and
// bind it to the indicated texture unit. // bind it to the indicated texture unit.
@ -10097,7 +10110,9 @@ apply_sampler(GLuint unit, const SamplerState &sampler, TextureContext *tc) {
<< "bind " << unit << " " << sampler << "\n"; << "bind " << unit << " " << sampler << "\n";
} }
} else { } else
#endif // OPENGLES
{
// We don't support sampler objects. We'll have to bind the // We don't support sampler objects. We'll have to bind the
// texture and change the texture parameters if they don't match. // texture and change the texture parameters if they don't match.
if (gtc->_active_sampler != sampler) { if (gtc->_active_sampler != sampler) {
@ -10678,6 +10693,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload,
if (tex->has_clear_color()) { if (tex->has_clear_color()) {
// The texture has a clear color, so we should fill this mipmap // The texture has a clear color, so we should fill this mipmap
// level to a solid color. // level to a solid color.
#ifndef OPENGLES
if (_supports_clear_texture) { if (_supports_clear_texture) {
// We can do that with the convenient glClearTexImage function. // We can do that with the convenient glClearTexImage function.
string clear_data = tex->get_clear_data(); string clear_data = tex->get_clear_data();
@ -10685,12 +10701,13 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload,
_glClearTexImage(gtc->_index, n - mipmap_bias, external_format, _glClearTexImage(gtc->_index, n - mipmap_bias, external_format,
component_type, (void *)clear_data.data()); component_type, (void *)clear_data.data());
continue; continue;
} else {
// Ask the Texture class to create the mipmap level in RAM.
// It'll fill it in with the correct clear color, which we
// can then upload.
ptimage = tex->make_ram_mipmap_image(n);
} }
#endif // OPENGLES
// Ask the Texture class to create the mipmap level in RAM.
// It'll fill it in with the correct clear color, which we
// can then upload.
ptimage = tex->make_ram_mipmap_image(n);
} else { } else {
// No clear color and no more images. // No clear color and no more images.
break; break;
@ -10726,13 +10743,8 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload,
_data_transferred_pcollector.add_level(view_size); _data_transferred_pcollector.add_level(view_size);
#endif #endif
switch (texture_target) { switch (texture_target) {
#ifdef OPENGLES_2
case GL_TEXTURE_3D_OES:
#endif
#ifndef OPENGLES
case GL_TEXTURE_3D:
#endif
#ifndef OPENGLES_1 #ifndef OPENGLES_1
case GL_TEXTURE_3D:
if (_supports_3d_texture) { if (_supports_3d_texture) {
if (image_compression == Texture::CM_off) { if (image_compression == Texture::CM_off) {
_glTexSubImage3D(page_target, n - mipmap_bias, 0, 0, 0, width, height, depth, _glTexSubImage3D(page_target, n - mipmap_bias, 0, 0, 0, width, height, depth,
@ -10746,7 +10758,9 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload,
return false; return false;
} }
break; break;
#endif // OPENGLES_1
#ifndef OPENGLES
case GL_TEXTURE_1D: case GL_TEXTURE_1D:
if (image_compression == Texture::CM_off) { if (image_compression == Texture::CM_off) {
glTexSubImage1D(page_target, n - mipmap_bias, 0, width, glTexSubImage1D(page_target, n - mipmap_bias, 0, width,
@ -10756,7 +10770,8 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload,
external_format, view_size, image_ptr); external_format, view_size, image_ptr);
} }
break; break;
#endif #endif // OPENGLES
#ifndef OPENGLES #ifndef OPENGLES
case GL_TEXTURE_2D_ARRAY_EXT: case GL_TEXTURE_2D_ARRAY_EXT:
if (_supports_2d_texture_array) { if (_supports_2d_texture_array) {
@ -10772,7 +10787,8 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload,
return false; return false;
} }
break; break;
#endif #endif // OPENGLES
default: default:
if (image_compression == Texture::CM_off) { if (image_compression == Texture::CM_off) {
if (n==0) { if (n==0) {
@ -11319,7 +11335,7 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
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;
#ifndef OPENGLES_1 #ifndef OPENGLES
case GL_DEPTH32F_STENCIL8: case GL_DEPTH32F_STENCIL8:
type = Texture::T_float; type = Texture::T_float;
format = Texture::F_depth_stencil; format = Texture::F_depth_stencil;
@ -11483,26 +11499,34 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
format = Texture::F_alpha; format = Texture::F_alpha;
break; break;
case GL_LUMINANCE: case GL_LUMINANCE:
#ifndef OPENGLES
case GL_LUMINANCE16: case GL_LUMINANCE16:
case GL_LUMINANCE16F_ARB: case GL_LUMINANCE16F_ARB:
#endif
case 1: case 1:
format = Texture::F_luminance; format = Texture::F_luminance;
break; break;
case GL_LUMINANCE_ALPHA: case GL_LUMINANCE_ALPHA:
#ifndef OPENGLES
case GL_LUMINANCE_ALPHA16F_ARB: case GL_LUMINANCE_ALPHA16F_ARB:
#endif
case 2: case 2:
format = Texture::F_luminance_alpha; format = Texture::F_luminance_alpha;
break; break;
#ifndef OPENGLES_1 #ifndef OPENGLES_1
case GL_SRGB: case GL_SRGB:
#ifndef OPENGLES
case GL_SRGB8: case GL_SRGB8:
#endif
format = Texture::F_srgb; format = Texture::F_srgb;
break; break;
case GL_SRGB_ALPHA: case GL_SRGB_ALPHA:
case GL_SRGB8_ALPHA8: case GL_SRGB8_ALPHA8:
format = Texture::F_srgb_alpha; format = Texture::F_srgb_alpha;
break; break;
#endif // OPENGLES_1
#ifndef OPENGLES
case GL_SLUMINANCE: case GL_SLUMINANCE:
case GL_SLUMINANCE8: case GL_SLUMINANCE8:
format = Texture::F_sluminance; format = Texture::F_sluminance;
@ -11511,7 +11535,7 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
case GL_SLUMINANCE8_ALPHA8: case GL_SLUMINANCE8_ALPHA8:
format = Texture::F_sluminance_alpha; format = Texture::F_sluminance_alpha;
break; break;
#endif #endif // OPENGLES
#ifndef OPENGLES #ifndef OPENGLES
case GL_COMPRESSED_RGB: case GL_COMPRESSED_RGB:
@ -11561,7 +11585,7 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
format = Texture::F_rgbm; format = Texture::F_rgbm;
compression = Texture::CM_dxt1; compression = Texture::CM_dxt1;
break; break;
#ifndef OPENGLES_1 #ifndef OPENGLES
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
format = Texture::F_srgb; format = Texture::F_srgb;
compression = Texture::CM_dxt1; compression = Texture::CM_dxt1;
@ -11572,25 +11596,6 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
break; break;
#endif #endif
#ifdef OPENGLES_2
case GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT:
format = Texture::F_srgb;
compression = Texture::CM_pvr1_2bpp;
break;
case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT:
format = Texture::F_srgb_alpha;
compression = Texture::CM_pvr1_2bpp;
break;
case GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT:
format = Texture::F_srgb;
compression = Texture::CM_pvr1_4bpp;
break;
case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT:
format = Texture::F_srgb_alpha;
compression = Texture::CM_pvr1_4bpp;
break;
#endif // OPENGLES_2
#ifdef OPENGLES #ifdef OPENGLES
case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
format = Texture::F_rgb; format = Texture::F_rgb;
@ -11963,6 +11968,7 @@ do_issue_stencil() {
<< "SRS_back_stencil_pass_z_pass_operation " << (int)stencil->get_render_state(StencilAttrib::SRS_back_stencil_pass_z_pass_operation) << "\n"; << "SRS_back_stencil_pass_z_pass_operation " << (int)stencil->get_render_state(StencilAttrib::SRS_back_stencil_pass_z_pass_operation) << "\n";
} }
#ifndef OPENGLES
if (_supports_two_sided_stencil) { if (_supports_two_sided_stencil) {
//TODO: add support for OpenGL 2.0-style glStencilFuncSeparate. //TODO: add support for OpenGL 2.0-style glStencilFuncSeparate.
unsigned int back_compare; unsigned int back_compare;
@ -11989,6 +11995,7 @@ do_issue_stencil() {
_glActiveStencilFaceEXT(GL_FRONT); _glActiveStencilFaceEXT(GL_FRONT);
} }
#endif // OPENGLES
unsigned int front_compare; unsigned int front_compare;
front_compare = stencil->get_render_state(StencilAttrib::SRS_front_comparison_function); front_compare = stencil->get_render_state(StencilAttrib::SRS_front_comparison_function);
@ -12018,9 +12025,11 @@ do_issue_stencil() {
} }
} else { } else {
glDisable(GL_STENCIL_TEST); glDisable(GL_STENCIL_TEST);
#ifndef OPENGLES
if (_supports_two_sided_stencil) { if (_supports_two_sided_stencil) {
glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT); glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT);
} }
#endif // OPENGLES
} }
} }
@ -12067,9 +12076,12 @@ do_issue_scissor() {
if (_scissor_array.size() > 0) { if (_scissor_array.size() > 0) {
// Scissoring is enabled on the display region. // Scissoring is enabled on the display region.
// Revert to the scissor state specified in the DisplayRegion. // Revert to the scissor state specified in the DisplayRegion.
#ifndef OPENGLES
if (_supports_viewport_arrays) { if (_supports_viewport_arrays) {
_glScissorArrayv(0, _scissor_array.size(), _scissor_array[0].get_data()); _glScissorArrayv(0, _scissor_array.size(), _scissor_array[0].get_data());
} else { } else
#endif // OPENGLES
{
const LVecBase4i sr = _scissor_array[0]; const LVecBase4i sr = _scissor_array[0];
glScissor(sr[0], sr[1], sr[2], sr[3]); glScissor(sr[0], sr[1], sr[2], sr[3]);
} }

View File

@ -14,6 +14,8 @@
#include "pnotify.h" #include "pnotify.h"
#ifndef OPENGLES
TypeHandle CLP(SamplerContext)::_type_handle; TypeHandle CLP(SamplerContext)::_type_handle;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -81,3 +83,5 @@ reset_data() {
// re-load the sampler later. // re-load the sampler later.
//glGenSamplers(1, &_index); //glGenSamplers(1, &_index);
} }
#endif // OPENGLES

View File

@ -12,6 +12,8 @@
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#ifndef OPENGLES
#include "pandabase.h" #include "pandabase.h"
#include "samplerContext.h" #include "samplerContext.h"
#include "deletedChain.h" #include "deletedChain.h"
@ -56,3 +58,5 @@ public:
private: private:
static TypeHandle _type_handle; static TypeHandle _type_handle;
}; };
#endif // OPENGLES

View File

@ -821,10 +821,12 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext
param_type == GL_INT_VEC2 || param_type == GL_INT_VEC2 ||
param_type == GL_INT_VEC3 || param_type == GL_INT_VEC3 ||
param_type == GL_INT_VEC4 || param_type == GL_INT_VEC4 ||
param_type == GL_UNSIGNED_INT || #ifndef OPENGLES
param_type == GL_UNSIGNED_INT_VEC2 || param_type == GL_UNSIGNED_INT_VEC2 ||
param_type == GL_UNSIGNED_INT_VEC3 || param_type == GL_UNSIGNED_INT_VEC3 ||
param_type == GL_UNSIGNED_INT_VEC4); param_type == GL_UNSIGNED_INT_VEC4 ||
#endif
param_type == GL_UNSIGNED_INT );
if (noprefix.empty()) { if (noprefix.empty()) {
// Arbitrarily named attribute. // Arbitrarily named attribute.
@ -863,12 +865,16 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext
// Get the number of bind points. // Get the number of bind points.
switch (param_type) { switch (param_type) {
case GL_FLOAT_MAT3: case GL_FLOAT_MAT3:
#ifndef OPENGLES
case GL_DOUBLE_MAT3: case GL_DOUBLE_MAT3:
#endif
bind._elements = 3 * param_size; bind._elements = 3 * param_size;
break; break;
case GL_FLOAT_MAT4: case GL_FLOAT_MAT4:
#ifndef OPENGLES
case GL_DOUBLE_MAT4: case GL_DOUBLE_MAT4:
#endif
bind._elements = 4 * param_size; bind._elements = 4 * param_size;
break; break;

View File

@ -283,7 +283,9 @@ void CLP(init_classes)() {
CLP(ShaderContext)::init_type(); CLP(ShaderContext)::init_type();
#endif #endif
CLP(TextureContext)::init_type(); CLP(TextureContext)::init_type();
#ifndef OPENGLES
CLP(SamplerContext)::init_type(); CLP(SamplerContext)::init_type();
#endif
CLP(VertexBufferContext)::init_type(); CLP(VertexBufferContext)::init_type();
CLP(GraphicsBuffer)::init_type(); CLP(GraphicsBuffer)::init_type();