More OpenGL ES stuff

This commit is contained in:
rdb 2009-06-15 18:09:44 +00:00
parent 86e921716d
commit ca03ef35ac
2 changed files with 212 additions and 176 deletions

View File

@ -10,6 +10,7 @@
// license. You should have received a copy of this license along // license. You should have received a copy of this license along
// with this source code in a file named "LICENSE." // with this source code in a file named "LICENSE."
// //
////////////////////////////////////////////////////////////////////
TypeHandle CLP(GraphicsBuffer)::_type_handle; TypeHandle CLP(GraphicsBuffer)::_type_handle;
@ -39,16 +40,16 @@ CLP(GraphicsBuffer)(GraphicsEngine *engine, GraphicsPipe *pipe,
_fbo_multisample = 0; _fbo_multisample = 0;
DCAST_INTO_V(glgsg, _gsg); DCAST_INTO_V(glgsg, _gsg);
if ( glgsg->get_supports_framebuffer_multisample() && glgsg->get_supports_framebuffer_blit() ) { if (glgsg->get_supports_framebuffer_multisample() && glgsg->get_supports_framebuffer_blit()) {
_requested_multisamples = fb_prop.get_multisamples(); _requested_multisamples = fb_prop.get_multisamples();
} else { } else {
_requested_multisamples = 0; _requested_multisamples = 0;
} }
if ( glgsg->get_supports_framebuffer_multisample_coverage_nv() && glgsg->get_supports_framebuffer_blit() ) { if (glgsg->get_supports_framebuffer_multisample_coverage_nv() && glgsg->get_supports_framebuffer_blit()) {
_requested_coverage_samples = fb_prop.get_coverage_samples(); _requested_coverage_samples = fb_prop.get_coverage_samples();
// Note: Only 4 and 8 actual samples are supported by the extension, with 8 or 16 coverage samples. // Note: Only 4 and 8 actual samples are supported by the extension, with 8 or 16 coverage samples.
if ( (_requested_coverage_samples <= 8) && (_requested_coverage_samples > 0) ) { if ((_requested_coverage_samples <= 8) && (_requested_coverage_samples > 0)) {
_requested_multisamples = 4; _requested_multisamples = 4;
_requested_coverage_samples = 8; _requested_coverage_samples = 8;
} else if (_requested_coverage_samples > 8) { } else if (_requested_coverage_samples > 8) {
@ -177,6 +178,8 @@ check_fbo() {
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
GLCAT.error() << "EXT_framebuffer_object reports non-framebuffer-completeness.\n"; GLCAT.error() << "EXT_framebuffer_object reports non-framebuffer-completeness.\n";
switch(status) { switch(status) {
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
GLCAT.error() << "FRAMEBUFFER_UNSUPPORTED_EXT\n"; break;
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
GLCAT.error() << "FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT\n"; break; GLCAT.error() << "FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT\n"; break;
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
@ -185,14 +188,14 @@ check_fbo() {
GLCAT.error() << "FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT\n"; break; GLCAT.error() << "FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT\n"; break;
case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
GLCAT.error() << "FRAMEBUFFER_INCOMPLETE_FORMATS_EXT\n"; break; GLCAT.error() << "FRAMEBUFFER_INCOMPLETE_FORMATS_EXT\n"; break;
#ifndef OPENGLES
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
GLCAT.error() << "FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT\n"; break; GLCAT.error() << "FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT\n"; break;
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
GLCAT.error() << "FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT\n"; break; GLCAT.error() << "FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT\n"; break;
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
GLCAT.error() << "FRAMEBUFFER_UNSUPPORTED_EXT\n"; break;
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT: case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT:
GLCAT.error() << "FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT\n"; break; GLCAT.error() << "FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT\n"; break;
#endif
default: default:
GLCAT.error() << "OTHER PROBLEM\n"; break; GLCAT.error() << "OTHER PROBLEM\n"; break;
} }
@ -310,6 +313,7 @@ rebuild_bitplanes() {
// bind_slot(rb_resize, attach, RTP_depth_stencil, GL_DEPTH_ATTACHMENT_EXT); // bind_slot(rb_resize, attach, RTP_depth_stencil, GL_DEPTH_ATTACHMENT_EXT);
bind_slot(rb_resize, attach, RTP_depth, GL_DEPTH_ATTACHMENT_EXT); bind_slot(rb_resize, attach, RTP_depth, GL_DEPTH_ATTACHMENT_EXT);
bind_slot(rb_resize, attach, RTP_color, GL_COLOR_ATTACHMENT0_EXT); bind_slot(rb_resize, attach, RTP_color, GL_COLOR_ATTACHMENT0_EXT);
#ifndef OPENGLES
int next = GL_COLOR_ATTACHMENT1_EXT; int next = GL_COLOR_ATTACHMENT1_EXT;
for (int i=0; i<_fb_properties.get_aux_rgba(); i++) { for (int i=0; i<_fb_properties.get_aux_rgba(); i++) {
bind_slot(rb_resize, attach, (RenderTexturePlane)(RTP_aux_rgba_0+i), next); bind_slot(rb_resize, attach, (RenderTexturePlane)(RTP_aux_rgba_0+i), next);
@ -344,13 +348,12 @@ rebuild_bitplanes() {
bind_slot_multisample(rb_resize, attach, (RenderTexturePlane)(RTP_aux_float_0+i), next); bind_slot_multisample(rb_resize, attach, (RenderTexturePlane)(RTP_aux_float_0+i), next);
next += 1; next += 1;
} }
glEnable(GL_MULTISAMPLE_ARB); glEnable(GL_MULTISAMPLE);
} else {
glDisable(GL_MULTISAMPLE);
} }
else { #endif // OPENGLES
glDisable(GL_MULTISAMPLE_ARB); } else {
}
}
else {
// make an FBO for each cubemap face // make an FBO for each cubemap face
int update; int update;
@ -390,9 +393,9 @@ rebuild_bitplanes() {
case RTP_depth_stencil: case RTP_depth_stencil:
// also case RTP_depth_stencil // also case RTP_depth_stencil
for (int f = 0; f < 6; f++) { for (int f = 0; f < 6; f++) {
glgsg -> bind_fbo(_cubemap_fbo [f]); glgsg->bind_fbo(_cubemap_fbo [f]);
glgsg -> _glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, glgsg->_glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB + f, GL_TEXTURE_CUBE_MAP_POSITIVE_X + f,
gtc->_index, 0); gtc->_index, 0);
} }
break; break;
@ -411,9 +414,9 @@ rebuild_bitplanes() {
case RTP_aux_float_2: case RTP_aux_float_2:
case RTP_aux_float_3: case RTP_aux_float_3:
for (int f = 0; f < 6; f++) { for (int f = 0; f < 6; f++) {
glgsg -> bind_fbo(_cubemap_fbo [f]); glgsg->bind_fbo(_cubemap_fbo [f]);
glgsg -> _glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, color_attachment, glgsg->_glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, color_attachment,
GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB + f, GL_TEXTURE_CUBE_MAP_POSITIVE_X + f,
gtc->_index, 0); gtc->_index, 0);
} }
color_attachment++; color_attachment++;
@ -425,18 +428,19 @@ rebuild_bitplanes() {
} }
} }
glgsg -> bind_fbo(_cubemap_fbo [0]); glgsg->bind_fbo(_cubemap_fbo [0]);
} }
if ( (_fb_properties.get_rgb_color() > 0) || #ifndef OPENGLES
(_fb_properties.get_aux_hrgba() > 0) ) { if ((_fb_properties.get_rgb_color() > 0) ||
(_fb_properties.get_aux_hrgba() > 0)) {
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT); glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
} } else {
else {
glDrawBuffer(GL_NONE); glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE); glReadBuffer(GL_NONE);
} }
#endif
_cube_face_active = 0; _cube_face_active = 0;
report_my_gl_errors(); report_my_gl_errors();
@ -454,21 +458,22 @@ bind_slot(bool rb_resize, Texture **attach, RenderTexturePlane slot, GLenum atta
DCAST_INTO_V(glgsg, _gsg); DCAST_INTO_V(glgsg, _gsg);
GLuint glFormat = GL_RGBA; GLuint glFormat = GL_RGBA;
#ifndef OPENGLES
switch (slot) { switch (slot) {
case RTP_aux_rgba_0: case RTP_aux_rgba_0:
case RTP_aux_rgba_1: case RTP_aux_rgba_1:
case RTP_aux_rgba_2: case RTP_aux_rgba_2:
case RTP_aux_rgba_3: case RTP_aux_rgba_3:
glFormat = GL_RGBA; glFormat = GL_RGBA;
break; break;
case RTP_aux_hrgba_0: case RTP_aux_hrgba_0:
case RTP_aux_hrgba_1: case RTP_aux_hrgba_1:
case RTP_aux_hrgba_2: case RTP_aux_hrgba_2:
case RTP_aux_hrgba_3: case RTP_aux_hrgba_3:
glFormat = GL_RGBA16F_ARB; glFormat = GL_RGBA16F_ARB;
break; break;
}; };
#endif
Texture *tex = attach[slot]; Texture *tex = attach[slot];
if (tex) { if (tex) {
@ -500,7 +505,7 @@ bind_slot(bool rb_resize, Texture **attach, RenderTexturePlane slot, GLenum atta
GL_TEXTURE_2D, gtc->_index, 0); GL_TEXTURE_2D, gtc->_index, 0);
} else { } else {
glgsg->_glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, glgsg->_glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, GL_TEXTURE_CUBE_MAP_POSITIVE_X,
gtc->_index, 0); gtc->_index, 0);
} }
if (_use_depth_stencil) { if (_use_depth_stencil) {
@ -509,15 +514,20 @@ bind_slot(bool rb_resize, Texture **attach, RenderTexturePlane slot, GLenum atta
GL_TEXTURE_2D, gtc->_index, 0); GL_TEXTURE_2D, gtc->_index, 0);
} else { } else {
glgsg->_glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, glgsg->_glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, GL_TEXTURE_CUBE_MAP_POSITIVE_X,
gtc->_index, 0); gtc->_index, 0);
} }
} }
} else { } else {
if (glFormat == GL_RGBA16F_ARB) #ifdef OPENGLES
tex->set_format(Texture::F_rgba);
#else
if (glFormat == GL_RGBA16F_ARB) {
tex->set_format(Texture::F_rgba16); tex->set_format(Texture::F_rgba16);
else } else {
tex->set_format(Texture::F_rgba); tex->set_format(Texture::F_rgba);
}
#endif
TextureContext *tc = tex->prepare_now(glgsg->get_prepared_objects(), glgsg); TextureContext *tc = tex->prepare_now(glgsg->get_prepared_objects(), glgsg);
nassertv(tc != (TextureContext *)NULL); nassertv(tc != (TextureContext *)NULL);
@ -528,7 +538,7 @@ bind_slot(bool rb_resize, Texture **attach, RenderTexturePlane slot, GLenum atta
GL_TEXTURE_2D, gtc->_index, 0); GL_TEXTURE_2D, gtc->_index, 0);
} else { } else {
glgsg->_glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, attachpoint, glgsg->_glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, attachpoint,
GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, GL_TEXTURE_CUBE_MAP_POSITIVE_X,
gtc->_index, 0); gtc->_index, 0);
} }
} }
@ -558,6 +568,7 @@ bind_slot(bool rb_resize, Texture **attach, RenderTexturePlane slot, GLenum atta
// Allocate and bind the renderbuffer. // Allocate and bind the renderbuffer.
glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, _rb[slot]); glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, _rb[slot]);
if (attachpoint == GL_DEPTH_ATTACHMENT_EXT) { if (attachpoint == GL_DEPTH_ATTACHMENT_EXT) {
#ifndef OPENGLES_2
if (_gsg->get_supports_depth_stencil() && slot == RTP_depth_stencil) { if (_gsg->get_supports_depth_stencil() && slot == RTP_depth_stencil) {
glgsg->_glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_DEPTH_STENCIL_EXT, glgsg->_glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_DEPTH_STENCIL_EXT,
_rb_size_x, _rb_size_y); _rb_size_x, _rb_size_y);
@ -576,6 +587,7 @@ bind_slot(bool rb_resize, Texture **attach, RenderTexturePlane slot, GLenum atta
glgsg->_glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, glgsg->_glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, rb); GL_RENDERBUFFER_EXT, rb);
} else { } else {
#endif
glgsg->_glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, glgsg->_glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
_rb_size_x, _rb_size_y); _rb_size_x, _rb_size_y);
glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, 0); glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, 0);
@ -589,7 +601,9 @@ bind_slot(bool rb_resize, Texture **attach, RenderTexturePlane slot, GLenum atta
glgsg->_glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, glgsg->_glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, rb); GL_RENDERBUFFER_EXT, rb);
#ifndef OPENGLES_2
} }
#endif
} else { } else {
glgsg->_glRenderbufferStorage(GL_RENDERBUFFER_EXT, glFormat, glgsg->_glRenderbufferStorage(GL_RENDERBUFFER_EXT, glFormat,
_rb_size_x, _rb_size_y); _rb_size_x, _rb_size_y);
@ -629,77 +643,90 @@ bind_slot_multisample(bool rb_resize, Texture **attach, RenderTexturePlane slot,
Texture *tex = attach[slot];// if there is a texture map, use it's format as needed. Texture *tex = attach[slot];// if there is a texture map, use it's format as needed.
if (attachpoint == GL_DEPTH_ATTACHMENT_EXT) { if (attachpoint == GL_DEPTH_ATTACHMENT_EXT) {
if ( _gsg->get_supports_depth_stencil() && _use_depth_stencil ) { #ifndef OPENGLES_2
if (_gsg->get_supports_depth_stencil() && _use_depth_stencil) {
glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, _rbm[slot]); glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, _rbm[slot]);
if (_requested_coverage_samples) if (_requested_coverage_samples) {
glgsg->_glRenderbufferStorageMultisampleCoverage(GL_RENDERBUFFER_EXT, _requested_coverage_samples, glgsg->_glRenderbufferStorageMultisampleCoverage(GL_RENDERBUFFER_EXT, _requested_coverage_samples,
_requested_multisamples, GL_DEPTH_STENCIL_EXT, _requested_multisamples, GL_DEPTH_STENCIL_EXT,
_rb_size_x, _rb_size_y); _rb_size_x, _rb_size_y);
else } else {
glgsg->_glRenderbufferStorageMultisample(GL_RENDERBUFFER_EXT, _requested_multisamples, GL_DEPTH_STENCIL_EXT, glgsg->_glRenderbufferStorageMultisample(GL_RENDERBUFFER_EXT, _requested_multisamples, GL_DEPTH_STENCIL_EXT,
_rb_size_x, _rb_size_y); _rb_size_x, _rb_size_y);
}
#ifndef OPENGLES
GLint givenSamples = -1; GLint givenSamples = -1;
glgsg->_glGetRenderbufferParameteriv( GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_SAMPLES_EXT, &givenSamples); glgsg->_glGetRenderbufferParameteriv( GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_SAMPLES_EXT, &givenSamples);
#endif
glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, 0); glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, 0);
glgsg->_glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, glgsg->_glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, _rbm[slot]); GL_RENDERBUFFER_EXT, _rbm[slot]);
glgsg->_glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, glgsg->_glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, _rbm[slot]); GL_RENDERBUFFER_EXT, _rbm[slot]);
} else { } else {
#endif
glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, _rbm[slot]); glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, _rbm[slot]);
GLuint format = GL_DEPTH_COMPONENT; GLuint format = GL_DEPTH_COMPONENT;
if (tex) if (tex) {
{ if (tex->get_format() == Texture::F_depth_component16)
if (tex->get_format() == Texture::F_depth_component16) format = GL_DEPTH_COMPONENT16;
format = GL_DEPTH_COMPONENT16; if (tex->get_format() == Texture::F_depth_component24)
if (tex->get_format() == Texture::F_depth_component24) format = GL_DEPTH_COMPONENT24;
format = GL_DEPTH_COMPONENT24; if (tex->get_format() == Texture::F_depth_component32)
if (tex->get_format() == Texture::F_depth_component32) format = GL_DEPTH_COMPONENT32;
format = GL_DEPTH_COMPONENT32;
} }
if (_requested_coverage_samples) if (_requested_coverage_samples) {
glgsg->_glRenderbufferStorageMultisampleCoverage(GL_RENDERBUFFER_EXT, _requested_coverage_samples, glgsg->_glRenderbufferStorageMultisampleCoverage(GL_RENDERBUFFER_EXT, _requested_coverage_samples,
_requested_multisamples, format, _requested_multisamples, format,
_rb_size_x, _rb_size_y); _rb_size_x, _rb_size_y);
else } else {
glgsg->_glRenderbufferStorageMultisample(GL_RENDERBUFFER_EXT, _requested_multisamples, format, glgsg->_glRenderbufferStorageMultisample(GL_RENDERBUFFER_EXT, _requested_multisamples, format,
_rb_size_x, _rb_size_y); _rb_size_x, _rb_size_y);
#ifndef OPENGLES_2
}
#endif
#ifndef OPENGLES
GLint givenSamples = -1; GLint givenSamples = -1;
glgsg->_glGetRenderbufferParameteriv( GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_SAMPLES_EXT, &givenSamples); glgsg->_glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_SAMPLES_EXT, &givenSamples);
#endif
glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, 0); glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, 0);
glgsg->_glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, glgsg->_glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, _rbm[slot]); GL_RENDERBUFFER_EXT, _rbm[slot]);
} }
} } else {
else { Texture *Tex = attach[slot];
Texture *Tex = attach[slot]; GLuint glFormat = GL_RGBA;
GLuint glFormat = GL_RGBA; #ifndef OPENGLES
switch (slot) { switch (slot) {
case RTP_aux_rgba_0: case RTP_aux_rgba_0:
case RTP_aux_rgba_1: case RTP_aux_rgba_1:
case RTP_aux_rgba_2: case RTP_aux_rgba_2:
case RTP_aux_rgba_3: case RTP_aux_rgba_3:
glFormat = GL_RGBA; glFormat = GL_RGBA;
break; break;
case RTP_aux_hrgba_0: case RTP_aux_hrgba_0:
case RTP_aux_hrgba_1: case RTP_aux_hrgba_1:
case RTP_aux_hrgba_2: case RTP_aux_hrgba_2:
case RTP_aux_hrgba_3: case RTP_aux_hrgba_3:
glFormat = GL_RGBA16F_ARB; glFormat = GL_RGBA16F_ARB;
break; break;
}; };
glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, _rbm[slot]); #endif
if (_requested_coverage_samples) glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, _rbm[slot]);
glgsg->_glRenderbufferStorageMultisampleCoverage(GL_RENDERBUFFER_EXT, _requested_coverage_samples, if (_requested_coverage_samples) {
_requested_multisamples, glFormat, _rb_size_x, _rb_size_y); glgsg->_glRenderbufferStorageMultisampleCoverage(GL_RENDERBUFFER_EXT, _requested_coverage_samples,
else _requested_multisamples, glFormat, _rb_size_x, _rb_size_y);
glgsg->_glRenderbufferStorageMultisample(GL_RENDERBUFFER_EXT, _requested_multisamples, glFormat, } else {
_rb_size_x, _rb_size_y); glgsg->_glRenderbufferStorageMultisample(GL_RENDERBUFFER_EXT, _requested_multisamples, glFormat,
GLint givenSamples = -1; _rb_size_x, _rb_size_y);
glgsg->_glGetRenderbufferParameteriv( GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_SAMPLES_EXT, &givenSamples); }
glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, 0); #ifndef OPENGLES
glgsg->_glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER_EXT, attachpoint, GLint givenSamples = -1;
GL_RENDERBUFFER_EXT, _rbm[slot]); glgsg->_glGetRenderbufferParameteriv( GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_SAMPLES_EXT, &givenSamples);
#endif
glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, 0);
glgsg->_glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER_EXT, attachpoint,
GL_RENDERBUFFER_EXT, _rbm[slot]);
} }
glgsg->report_my_gl_errors(); glgsg->report_my_gl_errors();
} }
@ -742,8 +769,7 @@ generate_mipmaps() {
// after rendering is completed for a given frame. It // after rendering is completed for a given frame. It
// should do whatever finalization is required. // should do whatever finalization is required.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void CLP(GraphicsBuffer):: void CLP(GraphicsBuffer)::end_frame(FrameMode mode, Thread *current_thread) {
end_frame(FrameMode mode, Thread *current_thread) {
end_frame_spam(mode); end_frame_spam(mode);
nassertv(_gsg != (GraphicsStateGuardian *)NULL); nassertv(_gsg != (GraphicsStateGuardian *)NULL);
@ -781,19 +807,22 @@ void CLP(GraphicsBuffer)::
} }
} }
} }
if ( max_sort_order == this->get_sort() ) if (max_sort_order == this->get_sort()) {
do_depth_blit = 1; do_depth_blit = 1;
} }
else } else {
do_depth_blit = 1; do_depth_blit = 1;
if (do_depth_blit) }
if (do_depth_blit) {
glgsg->_glBlitFramebuffer(0, 0, _rb_size_x, _rb_size_y, 0, 0, _rb_size_x, _rb_size_y, glgsg->_glBlitFramebuffer(0, 0, _rb_size_x, _rb_size_y, 0, 0, _rb_size_x, _rb_size_y,
GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT,
GL_NEAREST); GL_NEAREST);
else } else {
glgsg->_glBlitFramebuffer(0, 0, _rb_size_x, _rb_size_y, 0, 0, _rb_size_x, _rb_size_y, glgsg->_glBlitFramebuffer(0, 0, _rb_size_x, _rb_size_y, 0, 0, _rb_size_x, _rb_size_y,
GL_COLOR_BUFFER_BIT, GL_COLOR_BUFFER_BIT,
GL_NEAREST); GL_NEAREST);
}
#ifndef OPENGLES
// Now handle the other color buffers. // Now handle the other color buffers.
int next = GL_COLOR_ATTACHMENT1_EXT; int next = GL_COLOR_ATTACHMENT1_EXT;
for (int i=0; i<_fb_properties.get_aux_rgba(); i++) { for (int i=0; i<_fb_properties.get_aux_rgba(); i++) {
@ -817,8 +846,10 @@ void CLP(GraphicsBuffer)::
GL_COLOR_BUFFER_BIT, GL_NEAREST); GL_COLOR_BUFFER_BIT, GL_NEAREST);
next += 1; next += 1;
} }
glReadBuffer( GL_COLOR_ATTACHMENT0_EXT );
glDrawBuffer( GL_COLOR_ATTACHMENT0_EXT ); glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
#endif
glgsg->report_my_gl_errors(); glgsg->report_my_gl_errors();
} }
glgsg->bind_fbo(0); glgsg->bind_fbo(0);

View File

@ -407,7 +407,7 @@ reset() {
} }
} }
#ifndef OPENGLES_2 #ifndef OPENGLES
if (_supports_vertex_blend) { if (_supports_vertex_blend) {
GLP(Enable)(GL_WEIGHT_SUM_UNITY_ARB); GLP(Enable)(GL_WEIGHT_SUM_UNITY_ARB);
@ -477,13 +477,12 @@ reset() {
if (_supports_matrix_palette) { if (_supports_matrix_palette) {
GLint max_palette_matrices = 0; GLint max_palette_matrices = 0;
#ifndef OPENGLES_2
#ifdef OPENGLES_1 #ifdef OPENGLES_1
GLP(GetIntegerv)(GL_MAX_PALETTE_MATRICES_OES, &max_palette_matrices); GLP(GetIntegerv)(GL_MAX_PALETTE_MATRICES_OES, &max_palette_matrices);
#else #endif
#ifndef OPENGLES
GLP(GetIntegerv)(GL_MAX_PALETTE_MATRICES_ARB, &max_palette_matrices); GLP(GetIntegerv)(GL_MAX_PALETTE_MATRICES_ARB, &max_palette_matrices);
#endif // OPENGLES_1 #endif
#endif // OPENGLES_2
_max_vertex_transform_indices = max_palette_matrices; _max_vertex_transform_indices = max_palette_matrices;
if (GLCAT.is_debug()) { if (GLCAT.is_debug()) {
GLCAT.debug() GLCAT.debug()
@ -562,13 +561,17 @@ reset() {
} }
} }
#ifdef OPENGLES_2
_supports_cube_map = true;
#else
_supports_cube_map = _supports_cube_map =
has_extension("GL_ARB_texture_cube_map") || is_at_least_gl_version(1, 3) || has_extension("GL_ARB_texture_cube_map") || is_at_least_gl_version(1, 3) ||
has_extension("GL_OES_texture_cube_map"); has_extension("GL_OES_texture_cube_map");
#endif
_supports_compressed_texture = false; _supports_compressed_texture = false;
#ifndef OPENGLES_2 #ifndef OPENGLES
if (is_at_least_gl_version(1, 3)) { if (is_at_least_gl_version(1, 3)) {
_supports_compressed_texture = true; _supports_compressed_texture = true;
@ -961,7 +964,7 @@ reset() {
get_extension_func(GLPREFIX_QUOTED, "BlitFramebufferEXT"); get_extension_func(GLPREFIX_QUOTED, "BlitFramebufferEXT");
} }
#ifndef OPENGLES_2 #ifndef OPENGLES
_glDrawBuffers = NULL; _glDrawBuffers = NULL;
if (is_at_least_gl_version(2, 0)) { if (is_at_least_gl_version(2, 0)) {
_glDrawBuffers = (PFNGLDRAWBUFFERSPROC) _glDrawBuffers = (PFNGLDRAWBUFFERSPROC)
@ -977,7 +980,7 @@ reset() {
_max_draw_buffers = max_draw_buffers; _max_draw_buffers = max_draw_buffers;
_maximum_simultaneous_render_targets = max_draw_buffers; _maximum_simultaneous_render_targets = max_draw_buffers;
} }
#endif // OPENGLES_2 #endif // OPENGLES
_max_fb_samples = 0; _max_fb_samples = 0;
#ifndef OPENGLES #ifndef OPENGLES
@ -1023,7 +1026,7 @@ reset() {
} }
} }
#ifndef OPENGLES_2 #ifndef OPENGLES
if (_supports_occlusion_query) { if (_supports_occlusion_query) {
if (_glGenQueries == NULL || _glBeginQuery == NULL || if (_glGenQueries == NULL || _glBeginQuery == NULL ||
_glEndQuery == NULL || _glDeleteQueries == NULL || _glEndQuery == NULL || _glDeleteQueries == NULL ||
@ -1087,7 +1090,7 @@ reset() {
_glBlendColor = null_glBlendColor; _glBlendColor = null_glBlendColor;
} }
#ifdef OPENGLES_2 #ifdef OPENGLES
_edge_clamp = GL_CLAMP_TO_EDGE; _edge_clamp = GL_CLAMP_TO_EDGE;
#else #else
_edge_clamp = GL_CLAMP; _edge_clamp = GL_CLAMP;
@ -1098,7 +1101,7 @@ reset() {
#endif #endif
_border_clamp = _edge_clamp; _border_clamp = _edge_clamp;
#ifndef OPENGLES_2 #ifndef OPENGLES
if (CLP(support_clamp_to_border) && if (CLP(support_clamp_to_border) &&
(has_extension("GL_ARB_texture_border_clamp") || (has_extension("GL_ARB_texture_border_clamp") ||
is_at_least_gl_version(1, 3))) { is_at_least_gl_version(1, 3))) {
@ -1116,7 +1119,7 @@ reset() {
_mirror_clamp = _edge_clamp; _mirror_clamp = _edge_clamp;
_mirror_edge_clamp = _edge_clamp; _mirror_edge_clamp = _edge_clamp;
_mirror_border_clamp = _border_clamp; _mirror_border_clamp = _border_clamp;
#ifndef OPENGLES_2 #ifndef OPENGLES
if (has_extension("GL_EXT_texture_mirror_clamp")) { if (has_extension("GL_EXT_texture_mirror_clamp")) {
_mirror_clamp = GL_MIRROR_CLAMP_EXT; _mirror_clamp = GL_MIRROR_CLAMP_EXT;
_mirror_edge_clamp = GL_MIRROR_CLAMP_TO_EDGE_EXT; _mirror_edge_clamp = GL_MIRROR_CLAMP_TO_EDGE_EXT;
@ -1146,9 +1149,7 @@ reset() {
_max_texture_dimension = max_texture_size; _max_texture_dimension = max_texture_size;
if (_supports_3d_texture) { if (_supports_3d_texture) {
#ifdef OPENGLES_2 #ifndef OPENGLES_1
GLP(GetIntegerv)(GL_MAX_3D_TEXTURE_SIZE_OES, &max_3d_texture_size);
#else
GLP(GetIntegerv)(GL_MAX_3D_TEXTURE_SIZE, &max_3d_texture_size); GLP(GetIntegerv)(GL_MAX_3D_TEXTURE_SIZE, &max_3d_texture_size);
#endif #endif
_max_3d_texture_dimension = max_3d_texture_size; _max_3d_texture_dimension = max_3d_texture_size;
@ -1220,7 +1221,7 @@ reset() {
GLP(GetIntegerv)(GL_COMPRESSED_TEXTURE_FORMATS, formats); GLP(GetIntegerv)(GL_COMPRESSED_TEXTURE_FORMATS, formats);
for (int i = 0; i < num_compressed_formats; ++i) { for (int i = 0; i < num_compressed_formats; ++i) {
switch (formats[i]) { switch (formats[i]) {
#ifndef OPENGLES_2 #ifndef OPENGLES
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
GLCAT.debug(false) << " GL_COMPRESSED_RGB_S3TC_DXT1_EXT\n"; GLCAT.debug(false) << " GL_COMPRESSED_RGB_S3TC_DXT1_EXT\n";
break; break;
@ -1615,7 +1616,7 @@ clear(DrawableRegion *clearable) {
if (mask & GL_STENCIL_BUFFER_BIT) { if (mask & GL_STENCIL_BUFFER_BIT) {
GLCAT.spam(false) << "GL_STENCIL_BUFFER_BIT|"; GLCAT.spam(false) << "GL_STENCIL_BUFFER_BIT|";
} }
#ifndef OPENGLES_2 #ifndef OPENGLES
if (mask & GL_ACCUM_BUFFER_BIT) { if (mask & GL_ACCUM_BUFFER_BIT) {
GLCAT.spam(false) << "GL_ACCUM_BUFFER_BIT|"; GLCAT.spam(false) << "GL_ACCUM_BUFFER_BIT|";
} }
@ -1999,7 +2000,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
const GeomVertexAnimationSpec &animation = const GeomVertexAnimationSpec &animation =
_data_reader->get_format()->get_animation(); _data_reader->get_format()->get_animation();
bool hardware_animation = (animation.get_animation_type() == Geom::AT_hardware); bool hardware_animation = (animation.get_animation_type() == Geom::AT_hardware);
#ifndef OPENGLES_2 #ifndef OPENGLES
if (hardware_animation) { if (hardware_animation) {
// Set up the transform matrices for vertex blending. // Set up the transform matrices for vertex blending.
nassertr(_supports_vertex_blend, false); nassertr(_supports_vertex_blend, false);
@ -2388,6 +2389,7 @@ update_standard_vertex_arrays(bool force) {
} }
_last_max_stage_index = max_stage_index; _last_max_stage_index = max_stage_index;
#ifndef OPENGLES
if (_supports_vertex_blend) { if (_supports_vertex_blend) {
if (hardware_animation) { if (hardware_animation) {
// Issue the weights and/or transform indices for vertex blending. // Issue the weights and/or transform indices for vertex blending.
@ -2427,6 +2429,7 @@ update_standard_vertex_arrays(bool force) {
} }
} }
} }
#endif
// There's no requirement that we add vertices last, but we do // There's no requirement that we add vertices last, but we do
// anyway. // anyway.
@ -2503,12 +2506,14 @@ disable_standard_vertex_arrays()
_last_max_stage_index = 0; _last_max_stage_index = 0;
report_my_gl_errors(); report_my_gl_errors();
#ifndef OPENGLES
if (_supports_vertex_blend) { if (_supports_vertex_blend) {
GLP(DisableClientState)(GL_WEIGHT_ARRAY_ARB); GLP(DisableClientState)(GL_WEIGHT_ARRAY_ARB);
if (_supports_matrix_palette) { if (_supports_matrix_palette) {
GLP(DisableClientState)(GL_MATRIX_INDEX_ARRAY_ARB); GLP(DisableClientState)(GL_MATRIX_INDEX_ARRAY_ARB);
} }
} }
#endif
GLP(DisableClientState)(GL_VERTEX_ARRAY); GLP(DisableClientState)(GL_VERTEX_ARRAY);
report_my_gl_errors(); report_my_gl_errors();
@ -2839,9 +2844,7 @@ end_draw_primitives() {
_primitive_batches_display_list_pcollector.add_level(1); _primitive_batches_display_list_pcollector.add_level(1);
} }
_geom_display_list = 0; _geom_display_list = 0;
#endif // OPENGLES
#ifndef OPENGLES_2
// Clean up the vertex blending state. // Clean up the vertex blending state.
if (_vertex_blending_enabled) { if (_vertex_blending_enabled) {
GLP(Disable)(GL_VERTEX_BLEND_ARB); GLP(Disable)(GL_VERTEX_BLEND_ARB);
@ -2850,7 +2853,9 @@ end_draw_primitives() {
} }
_vertex_blending_enabled = false; _vertex_blending_enabled = false;
} }
#endif
#ifndef OPENGLES_2
if (_transform_stale) { if (_transform_stale) {
GLP(MatrixMode)(GL_MODELVIEW); GLP(MatrixMode)(GL_MODELVIEW);
GLP(LoadMatrixf)(_internal_transform->get_mat().get_data()); GLP(LoadMatrixf)(_internal_transform->get_mat().get_data());
@ -3677,9 +3682,6 @@ framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr,
} }
if (new_image) { if (new_image) {
if (internal_format == GL_RGBA) {
internal_format = GL_RGB;
}
// We have to create a new image. // We have to create a new image.
// It seems that OpenGL accepts a size higher than the framebuffer, // It seems that OpenGL accepts a size higher than the framebuffer,
// but if we run into trouble we'll have to replace this with // but if we run into trouble we'll have to replace this with
@ -3806,10 +3808,12 @@ framebuffer_copy_to_ram(Texture *tex, int z, const DisplayRegion *dr,
case GL_RGBA: case GL_RGBA:
GLCAT.spam(false) << "GL_RGBA, "; GLCAT.spam(false) << "GL_RGBA, ";
break; break;
#ifndef OPENGLES_2 #ifndef OPENGLES
case GL_BGR: case GL_BGR:
GLCAT.spam(false) << "GL_BGR, "; GLCAT.spam(false) << "GL_BGR, ";
break; break;
#endif
#ifndef OPENGLES_2
case GL_BGRA: case GL_BGRA:
GLCAT.spam(false) << "GL_BGRA, "; GLCAT.spam(false) << "GL_BGRA, ";
break; break;
@ -5262,8 +5266,10 @@ get_numeric_type(Geom::NumericType numeric_type) {
case Geom::NT_uint16: case Geom::NT_uint16:
return GL_UNSIGNED_SHORT; return GL_UNSIGNED_SHORT;
#ifndef OPENGLES_1
case Geom::NT_uint32: case Geom::NT_uint32:
return GL_UNSIGNED_INT; return GL_UNSIGNED_INT;
#endif
case Geom::NT_uint8: case Geom::NT_uint8:
case Geom::NT_packed_dcba: case Geom::NT_packed_dcba:
@ -5288,7 +5294,7 @@ get_numeric_type(Geom::NumericType numeric_type) {
GLenum CLP(GraphicsStateGuardian):: GLenum CLP(GraphicsStateGuardian)::
get_texture_target(Texture::TextureType texture_type) const { get_texture_target(Texture::TextureType texture_type) const {
switch (texture_type) { switch (texture_type) {
#ifndef OPENGLES_2 #ifndef OPENGLES
case Texture::TT_1d_texture: case Texture::TT_1d_texture:
return GL_TEXTURE_1D; return GL_TEXTURE_1D;
#endif #endif
@ -5298,10 +5304,7 @@ get_texture_target(Texture::TextureType texture_type) const {
case Texture::TT_3d_texture: case Texture::TT_3d_texture:
if (_supports_3d_texture) { if (_supports_3d_texture) {
#ifdef OPENGLES_2 #ifndef OPENGLES_1
return GL_TEXTURE_3D_OES;
#endif
#ifndef OPENGLES
return GL_TEXTURE_3D; return GL_TEXTURE_3D;
#endif #endif
} else { } else {
@ -5363,13 +5366,13 @@ get_texture_wrap_mode(Texture::WrapMode wm) const {
Texture::WrapMode CLP(GraphicsStateGuardian):: Texture::WrapMode CLP(GraphicsStateGuardian)::
get_panda_wrap_mode(GLenum wm) { get_panda_wrap_mode(GLenum wm) {
switch (wm) { switch (wm) {
#ifndef OPENGLES_2 #ifndef OPENGLES
case GL_CLAMP: case GL_CLAMP:
#endif #endif
case GL_CLAMP_TO_EDGE: case GL_CLAMP_TO_EDGE:
return Texture::WM_clamp; return Texture::WM_clamp;
#ifndef OPENGLES_2 #ifndef OPENGLES
case GL_CLAMP_TO_BORDER: case GL_CLAMP_TO_BORDER:
return Texture::WM_border_color; return Texture::WM_border_color;
#endif #endif
@ -5377,7 +5380,7 @@ get_panda_wrap_mode(GLenum wm) {
case GL_REPEAT: case GL_REPEAT:
return Texture::WM_repeat; return Texture::WM_repeat;
#ifndef OPENGLES_2 #ifndef OPENGLES
case GL_MIRROR_CLAMP_EXT: case GL_MIRROR_CLAMP_EXT:
case GL_MIRROR_CLAMP_TO_EDGE_EXT: case GL_MIRROR_CLAMP_TO_EDGE_EXT:
return Texture::WM_mirror; return Texture::WM_mirror;
@ -5489,11 +5492,7 @@ get_component_type(Texture::ComponentType component_type) {
return GL_UNSIGNED_BYTE; return GL_UNSIGNED_BYTE;
#else #else
if (_supports_depth_stencil) { if (_supports_depth_stencil) {
#ifdef OPENGLES_1
return GL_UNSIGNED_INT_24_8_OES;
#else
return GL_UNSIGNED_INT_24_8_EXT; return GL_UNSIGNED_INT_24_8_EXT;
#endif // OPENGLES_1
} else { } else {
return GL_UNSIGNED_BYTE; return GL_UNSIGNED_BYTE;
} }
@ -5513,7 +5512,7 @@ get_component_type(Texture::ComponentType component_type) {
GLint CLP(GraphicsStateGuardian):: GLint CLP(GraphicsStateGuardian)::
get_external_image_format(Texture *tex) const { get_external_image_format(Texture *tex) const {
Texture::CompressionMode compression = tex->get_ram_image_compression(); Texture::CompressionMode compression = tex->get_ram_image_compression();
#ifndef OPENGLES_2 #ifndef OPENGLES
if (compression != Texture::CM_off && if (compression != Texture::CM_off &&
get_supports_compressed_texture_format(compression)) { get_supports_compressed_texture_format(compression)) {
switch (compression) { switch (compression) {
@ -5588,7 +5587,7 @@ get_external_image_format(Texture *tex) const {
#endif #endif
switch (tex->get_format()) { switch (tex->get_format()) {
#ifndef OPENGLES_2 #ifndef OPENGLES
case Texture::F_color_index: case Texture::F_color_index:
return GL_COLOR_INDEX; return GL_COLOR_INDEX;
#endif #endif
@ -5603,6 +5602,8 @@ get_external_image_format(Texture *tex) const {
return GL_DEPTH_COMPONENT; return GL_DEPTH_COMPONENT;
#ifndef OPENGLES_2 #ifndef OPENGLES_2
} }
#endif
#ifndef OPENGLES
case Texture::F_red: case Texture::F_red:
return GL_RED; return GL_RED;
case Texture::F_green: case Texture::F_green:
@ -5617,7 +5618,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:
#ifdef OPENGLES_2 #ifdef OPENGLES
return GL_RGB; return GL_RGB;
#else #else
return _supports_bgr ? GL_BGR : GL_RGB; return _supports_bgr ? GL_BGR : GL_RGB;
@ -5665,7 +5666,7 @@ get_internal_image_format(Texture *tex) const {
} }
bool is_3d = (tex->get_texture_type() == Texture::TT_3d_texture); bool is_3d = (tex->get_texture_type() == Texture::TT_3d_texture);
#ifndef OPENGLES_2 #ifndef OPENGLES
if (get_supports_compressed_texture_format(compression)) { if (get_supports_compressed_texture_format(compression)) {
switch (compression) { switch (compression) {
case Texture::CM_on: case Texture::CM_on:
@ -5789,7 +5790,7 @@ get_internal_image_format(Texture *tex) const {
#endif #endif
switch (tex->get_format()) { switch (tex->get_format()) {
#ifndef OPENGLES_2 #ifndef OPENGLES
case Texture::F_color_index: case Texture::F_color_index:
return GL_COLOR_INDEX; return GL_COLOR_INDEX;
#endif #endif
@ -5847,7 +5848,7 @@ get_internal_image_format(Texture *tex) const {
case Texture::F_rgb: case Texture::F_rgb:
return GL_RGB; return GL_RGB;
#ifndef OPENGLES_2 #ifndef OPENGLES
case Texture::F_rgb5: case Texture::F_rgb5:
return GL_RGB5; return GL_RGB5;
#endif #endif
@ -5865,7 +5866,7 @@ get_internal_image_format(Texture *tex) const {
return GL_RGB12; return GL_RGB12;
#endif // OPENGLES #endif // OPENGLES
#ifndef OPENGLES_2 #ifndef OPENGLES
case Texture::F_rgb332: case Texture::F_rgb332:
return GL_R3_G3_B2; return GL_R3_G3_B2;
#endif #endif
@ -5919,7 +5920,7 @@ is_mipmap_filter(GLenum min_filter) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
bool CLP(GraphicsStateGuardian):: bool CLP(GraphicsStateGuardian)::
is_compressed_format(GLenum format) { is_compressed_format(GLenum format) {
#ifndef OPENGLES_2 #ifndef OPENGLES
switch (format) { switch (format) {
case GL_COMPRESSED_RGB: case GL_COMPRESSED_RGB:
case GL_COMPRESSED_RGBA: case GL_COMPRESSED_RGBA:
@ -6115,7 +6116,7 @@ get_blend_equation_type(ColorBlendAttrib::Mode mode) {
case ColorBlendAttrib::M_inv_subtract: case ColorBlendAttrib::M_inv_subtract:
return GL_FUNC_REVERSE_SUBTRACT; return GL_FUNC_REVERSE_SUBTRACT;
#ifndef OPENGLES_2 #ifndef OPENGLES
case ColorBlendAttrib::M_min: case ColorBlendAttrib::M_min:
return GL_MIN; return GL_MIN;
@ -6168,6 +6169,7 @@ get_blend_func(ColorBlendAttrib::Operand operand) {
case ColorBlendAttrib::O_one_minus_fbuffer_alpha: case ColorBlendAttrib::O_one_minus_fbuffer_alpha:
return GL_ONE_MINUS_DST_ALPHA; return GL_ONE_MINUS_DST_ALPHA;
#ifndef OPENGLES_1
case ColorBlendAttrib::O_constant_color: case ColorBlendAttrib::O_constant_color:
case ColorBlendAttrib::O_color_scale: case ColorBlendAttrib::O_color_scale:
return GL_CONSTANT_COLOR; return GL_CONSTANT_COLOR;
@ -6183,6 +6185,7 @@ get_blend_func(ColorBlendAttrib::Operand operand) {
case ColorBlendAttrib::O_one_minus_constant_alpha: case ColorBlendAttrib::O_one_minus_constant_alpha:
case ColorBlendAttrib::O_one_minus_alpha_scale: case ColorBlendAttrib::O_one_minus_alpha_scale:
return GL_ONE_MINUS_CONSTANT_ALPHA; return GL_ONE_MINUS_CONSTANT_ALPHA;
#endif
case ColorBlendAttrib::O_incoming_color_saturate: case ColorBlendAttrib::O_incoming_color_saturate:
return GL_SRC_ALPHA_SATURATE; return GL_SRC_ALPHA_SATURATE;
@ -6242,7 +6245,7 @@ print_gfx_visual() {
GLP(GetIntegerv)( GL_BLUE_BITS, &i ); cout << i << " "; GLP(GetIntegerv)( GL_BLUE_BITS, &i ); cout << i << " ";
GLP(GetIntegerv)( GL_ALPHA_BITS, &i ); cout << i << endl; GLP(GetIntegerv)( GL_ALPHA_BITS, &i ); cout << i << endl;
#ifndef OPENGLES_2 #ifndef OPENGLES
cout << "Accum RGBA: "; cout << "Accum RGBA: ";
GLP(GetIntegerv)( GL_ACCUM_RED_BITS, &i ); cout << i << " "; GLP(GetIntegerv)( GL_ACCUM_RED_BITS, &i ); cout << i << " ";
GLP(GetIntegerv)( GL_ACCUM_GREEN_BITS, &i ); cout << i << " "; GLP(GetIntegerv)( GL_ACCUM_GREEN_BITS, &i ); cout << i << " ";
@ -6256,7 +6259,7 @@ print_gfx_visual() {
GLP(GetIntegerv)( GL_ALPHA_BITS, &i ); cout << "Alpha: " << i << endl; GLP(GetIntegerv)( GL_ALPHA_BITS, &i ); cout << "Alpha: " << i << endl;
GLP(GetIntegerv)( GL_STENCIL_BITS, &i ); cout << "Stencil: " << i << endl; GLP(GetIntegerv)( GL_STENCIL_BITS, &i ); cout << "Stencil: " << i << endl;
#ifndef OPENGLES_2 #ifndef OPENGLES
GLP(GetBooleanv)( GL_DOUBLEBUFFER, &j ); cout << "DoubleBuffer? " GLP(GetBooleanv)( GL_DOUBLEBUFFER, &j ); cout << "DoubleBuffer? "
<< (int)j << endl; << (int)j << endl;
@ -6276,7 +6279,9 @@ print_gfx_visual() {
<< (int)j << endl; << (int)j << endl;
GLP(GetBooleanv)( GL_LINE_SMOOTH, &j ); cout << "Line Smooth? " GLP(GetBooleanv)( GL_LINE_SMOOTH, &j ); cout << "Line Smooth? "
<< (int)j << endl; << (int)j << endl;
#endif
#ifndef OPENGLES
GLP(GetIntegerv)( GL_AUX_BUFFERS, &i ); cout << "Aux Buffers: " << i << endl; GLP(GetIntegerv)( GL_AUX_BUFFERS, &i ); cout << "Aux Buffers: " << i << endl;
#endif #endif
} }
@ -6980,13 +6985,10 @@ update_standard_texture_bindings() {
// First, turn off the previous texture mode. // First, turn off the previous texture mode.
#ifndef OPENGLES #ifndef OPENGLES
GLP(Disable)(GL_TEXTURE_1D); GLP(Disable)(GL_TEXTURE_1D);
#endif // OPENGLES #endif
GLP(Disable)(GL_TEXTURE_2D); GLP(Disable)(GL_TEXTURE_2D);
if (_supports_3d_texture) { if (_supports_3d_texture) {
#ifdef OPENGLES_2 #ifndef OPENGLES_1
GLP(Disable)(GL_TEXTURE_3D_OES);
#endif
#ifndef OPENGLES
GLP(Disable)(GL_TEXTURE_3D); GLP(Disable)(GL_TEXTURE_3D);
#endif #endif
} }
@ -7145,10 +7147,7 @@ update_standard_texture_bindings() {
#endif // OPENGLES #endif // OPENGLES
GLP(Disable)(GL_TEXTURE_2D); GLP(Disable)(GL_TEXTURE_2D);
if (_supports_3d_texture) { if (_supports_3d_texture) {
#ifdef OPENGLES_2 #ifndef OPENGLES_1
GLP(Disable)(GL_TEXTURE_3D_OES);
#endif
#ifndef OPENGLES
GLP(Disable)(GL_TEXTURE_3D); GLP(Disable)(GL_TEXTURE_3D);
#endif #endif
} }
@ -7207,14 +7206,12 @@ update_show_usage_texture_bindings(int show_stage_index) {
// Disable all texture stages. // Disable all texture stages.
for (i = 0; i < _num_active_texture_stages; i++) { for (i = 0; i < _num_active_texture_stages; i++) {
_glActiveTexture(GL_TEXTURE0 + i); _glActiveTexture(GL_TEXTURE0 + i);
#ifndef OPENGLES_2 #ifndef OPENGLES
GLP(Disable)(GL_TEXTURE_1D); GLP(Disable)(GL_TEXTURE_1D);
#endif #endif
GLP(Disable)(GL_TEXTURE_2D); GLP(Disable)(GL_TEXTURE_2D);
if (_supports_3d_texture) { if (_supports_3d_texture) {
#ifdef OPENGLES_2 #ifndef OPENGLES_1
GLP(Disable)(GL_TEXTURE_3D_OES);
#else
GLP(Disable)(GL_TEXTURE_3D); GLP(Disable)(GL_TEXTURE_3D);
#endif #endif
} }
@ -7345,14 +7342,12 @@ disable_standard_texture_bindings() {
// Disable the texture stages that are no longer used. // Disable the texture stages that are no longer used.
for (int i = 0; i < _num_active_texture_stages; i++) { for (int i = 0; i < _num_active_texture_stages; i++) {
_glActiveTexture(GL_TEXTURE0 + i); _glActiveTexture(GL_TEXTURE0 + i);
#ifndef OPENGLES_2 #ifndef OPENGLES
GLP(Disable)(GL_TEXTURE_1D); GLP(Disable)(GL_TEXTURE_1D);
#endif #endif
GLP(Disable)(GL_TEXTURE_2D); GLP(Disable)(GL_TEXTURE_2D);
if (_supports_3d_texture) { if (_supports_3d_texture) {
#ifdef OPENGLES_2 #ifndef OPENGLES_1
GLP(Disable)(GL_TEXTURE_3D_OES);
#else
GLP(Disable)(GL_TEXTURE_3D); GLP(Disable)(GL_TEXTURE_3D);
#endif #endif
} }
@ -7706,7 +7701,7 @@ specify_texture(CLP(TextureContext) *gtc) {
GLP(TexParameteri)(target, GL_TEXTURE_WRAP_S, GLP(TexParameteri)(target, GL_TEXTURE_WRAP_S,
get_texture_wrap_mode(tex->get_wrap_u())); get_texture_wrap_mode(tex->get_wrap_u()));
#ifndef OPENGLES_2 #ifndef OPENGLES
if (target != GL_TEXTURE_1D) { if (target != GL_TEXTURE_1D) {
GLP(TexParameteri)(target, GL_TEXTURE_WRAP_T, GLP(TexParameteri)(target, GL_TEXTURE_WRAP_T,
get_texture_wrap_mode(tex->get_wrap_v())); get_texture_wrap_mode(tex->get_wrap_v()));
@ -7717,14 +7712,13 @@ specify_texture(CLP(TextureContext) *gtc) {
GLP(TexParameteri)(target, GL_TEXTURE_WRAP_R_OES, GLP(TexParameteri)(target, GL_TEXTURE_WRAP_R_OES,
get_texture_wrap_mode(tex->get_wrap_w())); get_texture_wrap_mode(tex->get_wrap_w()));
} }
#else #endif
#ifndef OPENGLES
if (target == GL_TEXTURE_3D) { if (target == GL_TEXTURE_3D) {
GLP(TexParameteri)(target, GL_TEXTURE_WRAP_R, GLP(TexParameteri)(target, GL_TEXTURE_WRAP_R,
get_texture_wrap_mode(tex->get_wrap_w())); get_texture_wrap_mode(tex->get_wrap_w()));
} }
#endif
#ifndef OPENGLES
Colorf border_color = tex->get_border_color(); Colorf border_color = tex->get_border_color();
GLP(TexParameterfv)(target, GL_TEXTURE_BORDER_COLOR, GLP(TexParameterfv)(target, GL_TEXTURE_BORDER_COLOR,
border_color.get_data()); border_color.get_data());
@ -7770,7 +7764,7 @@ specify_texture(CLP(TextureContext) *gtc) {
GLP(TexParameterf)(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy); GLP(TexParameterf)(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy);
} }
#ifndef OPENGLES_2 #ifndef OPENGLES
if (tex->get_format() == Texture::F_depth_stencil || if (tex->get_format() == Texture::F_depth_stencil ||
tex->get_format() == Texture::F_depth_component) { tex->get_format() == Texture::F_depth_component) {
GLP(TexParameteri)(target, GL_DEPTH_TEXTURE_MODE_ARB, GL_INTENSITY); GLP(TexParameteri)(target, GL_DEPTH_TEXTURE_MODE_ARB, GL_INTENSITY);
@ -7956,7 +7950,7 @@ upload_texture(CLP(TextureContext) *gtc, bool force) {
if (image_compression != Texture::CM_off) { if (image_compression != Texture::CM_off) {
Texture::QualityLevel quality_level = tex->get_effective_quality_level(); Texture::QualityLevel quality_level = tex->get_effective_quality_level();
#ifndef OPENGLES_2 #ifndef OPENGLES
switch (quality_level) { switch (quality_level) {
case Texture::QL_fastest: case Texture::QL_fastest:
GLP(Hint)(GL_TEXTURE_COMPRESSION_HINT, GL_FASTEST); GLP(Hint)(GL_TEXTURE_COMPRESSION_HINT, GL_FASTEST);
@ -8274,9 +8268,11 @@ upload_texture_image(CLP(TextureContext) *gtc,
#ifdef OPENGLES_2 #ifdef OPENGLES_2
case GL_TEXTURE_3D_OES: case GL_TEXTURE_3D_OES:
#else #endif
#ifndef OPENGLES
case GL_TEXTURE_3D: case GL_TEXTURE_3D:
#endif #endif
#ifndef OPENGLES_1
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,
@ -8290,7 +8286,7 @@ upload_texture_image(CLP(TextureContext) *gtc,
return false; return false;
} }
break; break;
#endif
default: default:
if (image_compression == Texture::CM_off) { if (image_compression == Texture::CM_off) {
if (n==0) { if (n==0) {
@ -8405,9 +8401,11 @@ upload_texture_image(CLP(TextureContext) *gtc,
#ifndef OPENGLES_1 // 3-d textures not supported by OpenGL ES 1. Fall through. #ifndef OPENGLES_1 // 3-d textures not supported by OpenGL ES 1. Fall through.
#ifdef OPENGLES_2 #ifdef OPENGLES_2
case GL_TEXTURE_3D_OES: case GL_TEXTURE_3D_OES:
#else #endif
#ifndef OPENGLES
case GL_TEXTURE_3D: case GL_TEXTURE_3D:
#endif #endif
#ifndef OPENGLES_1
if (_supports_3d_texture) { if (_supports_3d_texture) {
if (image_compression == Texture::CM_off) { if (image_compression == Texture::CM_off) {
_glTexImage3D(page_target, n - mipmap_bias, internal_format, _glTexImage3D(page_target, n - mipmap_bias, internal_format,
@ -8423,6 +8421,7 @@ upload_texture_image(CLP(TextureContext) *gtc,
return false; return false;
} }
break; break;
#endif
#endif // OPENGLES // OpenGL ES will fall through. #endif // OPENGLES // OpenGL ES will fall through.
default: default:
@ -8452,7 +8451,7 @@ upload_texture_image(CLP(TextureContext) *gtc,
} }
} }
#ifndef OPENGLES_2 // OpenGL ES 2.0 doesn't have GL_TEXTURE_MAX_LEVEL. #ifndef OPENGLES // OpenGL ES doesn't have GL_TEXTURE_MAX_LEVEL.
if (is_at_least_gl_version(1, 2)) { if (is_at_least_gl_version(1, 2)) {
if (load_ram_mipmaps) { if (load_ram_mipmaps) {
// By the time we get here, we have successfully loaded a certain // By the time we get here, we have successfully loaded a certain
@ -8524,7 +8523,7 @@ upload_simple_texture(CLP(TextureContext) *gtc) {
<< "loading simple image for " << tex->get_name() << "\n"; << "loading simple image for " << tex->get_name() << "\n";
} }
#ifndef OPENGLES_2 #ifndef OPENGLES
// Turn off mipmaps for the simple texture. // Turn off mipmaps for the simple texture.
if (tex->uses_mipmaps()) { if (tex->uses_mipmaps()) {
if (is_at_least_gl_version(1, 2)) { if (is_at_least_gl_version(1, 2)) {
@ -8715,7 +8714,8 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
if (_supports_3d_texture) { if (_supports_3d_texture) {
#ifdef OPENGLES_2 #ifdef OPENGLES_2
GLP(GetTexParameteriv)(target, GL_TEXTURE_WRAP_R_OES, &wrap_w); GLP(GetTexParameteriv)(target, GL_TEXTURE_WRAP_R_OES, &wrap_w);
#else #endif
#ifndef OPENGLES
GLP(GetTexParameteriv)(target, GL_TEXTURE_WRAP_R, &wrap_w); GLP(GetTexParameteriv)(target, GL_TEXTURE_WRAP_R, &wrap_w);
#endif #endif
} }
@ -8725,7 +8725,7 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
magfilter = GL_LINEAR; magfilter = GL_LINEAR;
// GLP(GetTexParameteriv)(target, GL_TEXTURE_MAG_FILTER, &magfilter); // GLP(GetTexParameteriv)(target, GL_TEXTURE_MAG_FILTER, &magfilter);
#ifndef OPENGLES_2 #ifndef OPENGLES
GLP(GetTexParameterfv)(target, GL_TEXTURE_BORDER_COLOR, border_color); GLP(GetTexParameterfv)(target, GL_TEXTURE_BORDER_COLOR, border_color);
#endif #endif
@ -8776,7 +8776,7 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
Texture::CompressionMode compression = Texture::CM_off; Texture::CompressionMode compression = Texture::CM_off;
switch (internal_format) { switch (internal_format) {
#ifndef OPENGLES_2 #ifndef OPENGLES
case GL_COLOR_INDEX: case GL_COLOR_INDEX:
format = Texture::F_color_index; format = Texture::F_color_index;
break; break;
@ -8791,12 +8791,6 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
type = Texture::T_float; type = Texture::T_float;
format = Texture::F_depth_stencil; format = Texture::F_depth_stencil;
break; break;
#endif
#ifdef OPENGLES_1
case GL_DEPTH24_STENCIL8_OES:
type = Texture::T_float;
format = Texture::F_depth_stencil;
break;
#endif #endif
case GL_RGBA: case GL_RGBA:
case 4: case 4:
@ -8809,6 +8803,8 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
case GL_RGBA8: case GL_RGBA8:
format = Texture::F_rgba8; format = Texture::F_rgba8;
break; break;
#endif
#ifndef OPENGLES
case GL_RGBA12: case GL_RGBA12:
type = Texture::T_unsigned_short; type = Texture::T_unsigned_short;
format = Texture::F_rgba12; format = Texture::F_rgba12;
@ -8819,7 +8815,7 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
case 3: case 3:
format = Texture::F_rgb; format = Texture::F_rgb;
break; break;
#ifndef OPENGLES_2 #ifndef OPENGLES
case GL_RGB5: case GL_RGB5:
format = Texture::F_rgb5; format = Texture::F_rgb5;
break; break;
@ -8827,7 +8823,7 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
case GL_RGB5_A1: case GL_RGB5_A1:
format = Texture::F_rgba5; format = Texture::F_rgba5;
break; break;
#ifndef OPENGLES_2 #ifndef OPENGLES
case GL_RGB8: case GL_RGB8:
format = Texture::F_rgb8; format = Texture::F_rgb8;
break; break;
@ -8942,7 +8938,7 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
// Also get the mipmap levels. // Also get the mipmap levels.
GLint num_expected_levels = tex->get_expected_num_mipmap_levels(); GLint num_expected_levels = tex->get_expected_num_mipmap_levels();
GLint highest_level = num_expected_levels; GLint highest_level = num_expected_levels;
#ifndef OPENGLES_2 #ifndef OPENGLES
if (is_at_least_gl_version(1, 2)) { if (is_at_least_gl_version(1, 2)) {
GLP(GetTexParameteriv)(target, GL_TEXTURE_MAX_LEVEL, &highest_level); GLP(GetTexParameteriv)(target, GL_TEXTURE_MAX_LEVEL, &highest_level);
highest_level = min(highest_level, num_expected_levels); highest_level = min(highest_level, num_expected_levels);
@ -9143,7 +9139,11 @@ bind_fbo(GLuint fbo) {
nassertv(_glBindFramebuffer != 0); nassertv(_glBindFramebuffer != 0);
#ifdef OPENGLES_2 #ifdef OPENGLES_2
_glBindFramebuffer(GL_FRAMEBUFFER, fbo); _glBindFramebuffer(GL_FRAMEBUFFER, fbo);
#else #endif
#ifdef OPENGLES_1
_glBindFramebuffer(GL_FRAMEBUFFER_OES, fbo);
#endif
#ifndef OPENGLES
_glBindFramebuffer(GL_FRAMEBUFFER_EXT, fbo); _glBindFramebuffer(GL_FRAMEBUFFER_EXT, fbo);
#endif #endif
_current_fbo = fbo; _current_fbo = fbo;
@ -9169,8 +9169,13 @@ static int gl_stencil_operations_array [ ] = {
GL_KEEP, GL_KEEP,
GL_ZERO, GL_ZERO,
GL_REPLACE, GL_REPLACE,
#ifdef OPENGLES_1
GL_INCR_WRAP_OES,
GL_DECR_WRAP_OES,
#else
GL_INCR_WRAP, GL_INCR_WRAP,
GL_DECR_WRAP, GL_DECR_WRAP,
#endif
GL_INVERT, GL_INVERT,
GL_INCR, GL_INCR,
@ -9268,7 +9273,7 @@ void gl_stencil_function (StencilRenderStates::StencilRenderState stencil_render
glDisable (GL_STENCIL_TEST); glDisable (GL_STENCIL_TEST);
} }
break; break;
#ifndef OPENGLES_2 #ifndef OPENGLES
case StencilRenderStates::SRS_back_enable: case StencilRenderStates::SRS_back_enable:
if (supports_two_sided_stencil) { if (supports_two_sided_stencil) {
if (render_state_value) { if (render_state_value) {