mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 09:23:03 -04:00
OpenGL ES 2 optimizations and better support
This commit is contained in:
parent
4976345486
commit
cda7c1f171
@ -113,6 +113,13 @@ typedef char GLchar;
|
||||
#define GL_R32F GL_R32F_EXT
|
||||
#define GL_RG32F GL_RG32F_EXT
|
||||
#define GL_RGB8 GL_RGB8_OES
|
||||
#define GL_TEXTURE_COMPARE_FUNC_ARB GL_TEXTURE_COMPARE_FUNC_EXT
|
||||
#define GL_TEXTURE_COMPARE_MODE_ARB GL_TEXTURE_COMPARE_MODE_EXT
|
||||
#define GL_COMPARE_R_TO_TEXTURE_ARB GL_COMPARE_REF_TO_TEXTURE_EXT
|
||||
#define GL_SAMPLER_2D_SHADOW GL_SAMPLER_2D_SHADOW_EXT
|
||||
#define GL_MAX_DRAW_BUFFERS GL_MAX_DRAW_BUFFERS_NV
|
||||
#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE
|
||||
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE
|
||||
|
||||
#undef SUPPORT_IMMEDIATE_MODE
|
||||
#define APIENTRY
|
||||
|
@ -118,6 +118,7 @@
|
||||
#define GL_ALPHA8 GL_ALPHA8_EXT
|
||||
#define GL_LUMINANCE8 GL_LUMINANCE8_EXT
|
||||
#define GL_LUMINANCE8_ALPHA8 GL_LUMINANCE8_ALPHA8_EXT
|
||||
#define GL_MAX_VERTEX_UNITS_ARB GL_MAX_VERTEX_UNITS_OES
|
||||
|
||||
#undef SUPPORT_IMMEDIATE_MODE
|
||||
#define APIENTRY
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef __panda_esglext_h_
|
||||
#define __panda_esglext_h_
|
||||
|
||||
/* $Revision$ on $Date$ */
|
||||
/* $Revision: 20798 $ on $Date:: 2013-03-07 01:19:34 -0800 #$ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -1055,10 +1055,10 @@ typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum
|
||||
#ifndef GL_EXT_multi_draw_arrays
|
||||
#define GL_EXT_multi_draw_arrays 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GL_API void GL_APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei);
|
||||
GL_API void GL_APIENTRY glMultiDrawArraysEXT (GLenum, const GLint *, const GLsizei *, GLsizei);
|
||||
GL_API void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei);
|
||||
#endif /* GL_GLEXT_PROTOTYPES */
|
||||
typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
|
||||
typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
|
||||
typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
|
||||
#endif
|
||||
|
||||
@ -1275,3 +1275,4 @@ typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask);
|
||||
#endif
|
||||
|
||||
#endif /* __glext_h_ */
|
||||
|
||||
|
@ -532,6 +532,7 @@ enable_depth_test(bool val) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef OPENGLES_2
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GLGraphicsStateGuardian::enable_fog
|
||||
// Access:
|
||||
@ -539,7 +540,6 @@ enable_depth_test(bool val) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void CLP(GraphicsStateGuardian)::
|
||||
enable_fog(bool val) {
|
||||
#ifndef OPENGLES_2
|
||||
if (_fog_enabled != val) {
|
||||
_fog_enabled = val;
|
||||
if (val) {
|
||||
@ -556,9 +556,10 @@ enable_fog(bool val) {
|
||||
glDisable(GL_FOG);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OPENGLES_2
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GLGraphicsStateGuardian::enable_alpha_test
|
||||
// Access:
|
||||
@ -566,7 +567,6 @@ enable_fog(bool val) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void CLP(GraphicsStateGuardian)::
|
||||
enable_alpha_test(bool val) {
|
||||
#ifndef OPENGLES_2
|
||||
if (_alpha_test_enabled != val) {
|
||||
_alpha_test_enabled = val;
|
||||
if (val) {
|
||||
@ -583,9 +583,8 @@ enable_alpha_test(bool val) {
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
}
|
||||
}
|
||||
#endif // OPENGLES_2
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GLGraphicsStateGuardian::enable_polygon_offset
|
||||
@ -645,6 +644,7 @@ clear_color_write_mask() {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef OPENGLES_2
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GLGraphicsStateGuardian::call_glFogfv
|
||||
// Access: Public
|
||||
@ -653,16 +653,16 @@ clear_color_write_mask() {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void CLP(GraphicsStateGuardian)::
|
||||
call_glFogfv(GLenum pname, const LColor &color) {
|
||||
#ifndef OPENGLES_2
|
||||
#ifndef STDFLOAT_DOUBLE
|
||||
glFogfv(pname, color.get_data());
|
||||
#else // STDFLOAT_DOUBLE
|
||||
LColorf fcolor = LCAST(float, color);
|
||||
glFogfv(pname, fcolor.get_data());
|
||||
#endif // STDFLOAT_DOUBLE
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OPENGLES_2
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GLGraphicsStateGuardian::call_glMaterialfv
|
||||
// Access: Public
|
||||
@ -671,16 +671,16 @@ call_glFogfv(GLenum pname, const LColor &color) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void CLP(GraphicsStateGuardian)::
|
||||
call_glMaterialfv(GLenum face, GLenum pname, const LColor &color) {
|
||||
#ifndef OPENGLES_2
|
||||
#ifndef STDFLOAT_DOUBLE
|
||||
glMaterialfv(face, pname, color.get_data());
|
||||
#else // STDFLOAT_DOUBLE
|
||||
LColorf fcolor = LCAST(float, color);
|
||||
glMaterialfv(face, pname, fcolor.get_data());
|
||||
#endif // STDFLOAT_DOUBLE
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OPENGLES_2
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GLGraphicsStateGuardian::call_glLightfv
|
||||
// Access: Public
|
||||
@ -689,16 +689,16 @@ call_glMaterialfv(GLenum face, GLenum pname, const LColor &color) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void CLP(GraphicsStateGuardian)::
|
||||
call_glLightfv(GLenum light, GLenum pname, const LVecBase4 &value) {
|
||||
#ifndef OPENGLES_2
|
||||
#ifndef STDFLOAT_DOUBLE
|
||||
glLightfv(light, pname, value.get_data());
|
||||
#else // STDFLOAT_DOUBLE
|
||||
LVecBase4f fvalue = LCAST(float, value);
|
||||
glLightfv(light, pname, fvalue.get_data());
|
||||
#endif // STDFLOAT_DOUBLE
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OPENGLES_2
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GLGraphicsStateGuardian::call_glLightfv
|
||||
// Access: Public
|
||||
@ -707,16 +707,16 @@ call_glLightfv(GLenum light, GLenum pname, const LVecBase4 &value) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void CLP(GraphicsStateGuardian)::
|
||||
call_glLightfv(GLenum light, GLenum pname, const LVecBase3 &value) {
|
||||
#ifndef OPENGLES_2
|
||||
#ifndef STDFLOAT_DOUBLE
|
||||
glLightfv(light, pname, value.get_data());
|
||||
#else // STDFLOAT_DOUBLE
|
||||
LVecBase3f fvalue = LCAST(float, value);
|
||||
glLightfv(light, pname, fvalue.get_data());
|
||||
#endif // STDFLOAT_DOUBLE
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OPENGLES_2
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GLGraphicsStateGuardian::call_glLightModelfv
|
||||
// Access: Public
|
||||
@ -725,16 +725,16 @@ call_glLightfv(GLenum light, GLenum pname, const LVecBase3 &value) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void CLP(GraphicsStateGuardian)::
|
||||
call_glLightModelfv(GLenum pname, const LVecBase4 &value) {
|
||||
#ifndef OPENGLES_2
|
||||
#ifndef STDFLOAT_DOUBLE
|
||||
glLightModelfv(pname, value.get_data());
|
||||
#else // STDFLOAT_DOUBLE
|
||||
LVecBase4f fvalue = LCAST(float, value);
|
||||
glLightModelfv(pname, fvalue.get_data());
|
||||
#endif // STDFLOAT_DOUBLE
|
||||
#endif // OPENGLES_2
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OPENGLES_2
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GLGraphicsStateGuardian::call_glTexEnvfv
|
||||
// Access: Public
|
||||
@ -743,15 +743,14 @@ call_glLightModelfv(GLenum pname, const LVecBase4 &value) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void CLP(GraphicsStateGuardian)::
|
||||
call_glTexEnvfv(GLenum target, GLenum pname, const LVecBase4 &value) {
|
||||
#ifndef OPENGLES_2
|
||||
#ifndef STDFLOAT_DOUBLE
|
||||
glTexEnvfv(target, pname, value.get_data());
|
||||
#else // STDFLOAT_DOUBLE
|
||||
LVecBase4f fvalue = LCAST(float, value);
|
||||
glTexEnvfv(target, pname, fvalue.get_data());
|
||||
#endif // STDFLOAT_DOUBLE
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GLGraphicsStateGuardian::call_glTexParameterfv
|
||||
@ -769,6 +768,7 @@ call_glTexParameterfv(GLenum target, GLenum pname, const LVecBase4 &value) {
|
||||
#endif // STDFLOAT_DOUBLE
|
||||
}
|
||||
|
||||
#ifndef OPENGLES_2
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GLGraphicsStateGuardian::get_light_id
|
||||
// Access: Public
|
||||
@ -776,13 +776,11 @@ call_glTexParameterfv(GLenum target, GLenum pname, const LVecBase4 &value) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE GLenum CLP(GraphicsStateGuardian)::
|
||||
get_light_id(int index) const {
|
||||
#ifndef OPENGLES_2
|
||||
return GL_LIGHT0 + index;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OPENGLES_2
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GLGraphicsStateGuardian::get_clip_plane_id
|
||||
// Access: Public
|
||||
@ -790,12 +788,9 @@ get_light_id(int index) const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE GLenum CLP(GraphicsStateGuardian)::
|
||||
get_clip_plane_id(int index) const {
|
||||
#ifndef OPENGLES_2
|
||||
return GL_CLIP_PLANE0 + index;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CLP(GraphicsStateGuardian)::get_supports_framebuffer_multisample
|
||||
@ -805,7 +800,7 @@ get_clip_plane_id(int index) const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool CLP(GraphicsStateGuardian)::
|
||||
get_supports_framebuffer_multisample() {
|
||||
return _supports_framebuffer_multisample;
|
||||
return _supports_framebuffer_multisample;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -816,7 +811,7 @@ get_supports_framebuffer_multisample() {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool CLP(GraphicsStateGuardian)::
|
||||
get_supports_framebuffer_multisample_coverage_nv() {
|
||||
return _supports_framebuffer_multisample_coverage_nv;
|
||||
return _supports_framebuffer_multisample_coverage_nv;
|
||||
}
|
||||
|
||||
|
||||
@ -828,7 +823,7 @@ get_supports_framebuffer_multisample_coverage_nv() {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool CLP(GraphicsStateGuardian)::
|
||||
get_supports_framebuffer_blit() {
|
||||
return _supports_framebuffer_blit;
|
||||
return _supports_framebuffer_blit;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -184,6 +184,8 @@ typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size,
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor);
|
||||
typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
|
||||
typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
|
||||
#endif // OPENGLES_1
|
||||
#ifndef OPENGLES
|
||||
typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers);
|
||||
@ -194,8 +196,6 @@ typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pna
|
||||
typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param);
|
||||
typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param);
|
||||
typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value);
|
||||
typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
|
||||
typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
|
||||
typedef void (APIENTRYP PFNGLCLEARTEXIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data);
|
||||
typedef void (APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data);
|
||||
typedef void (APIENTRYP PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures);
|
||||
@ -281,15 +281,19 @@ public:
|
||||
bool force);
|
||||
virtual void end_draw_primitives();
|
||||
|
||||
#ifndef OPENGLES
|
||||
void issue_memory_barrier(GLbitfield barrier);
|
||||
#endif
|
||||
|
||||
virtual TextureContext *prepare_texture(Texture *tex, int view);
|
||||
virtual bool update_texture(TextureContext *tc, bool force);
|
||||
virtual void release_texture(TextureContext *tc);
|
||||
virtual bool extract_texture_data(Texture *tex);
|
||||
|
||||
#ifndef OPENGLES
|
||||
virtual SamplerContext *prepare_sampler(const SamplerState &sampler);
|
||||
virtual void release_sampler(SamplerContext *sc);
|
||||
#endif
|
||||
|
||||
virtual GeomContext *prepare_geom(Geom *geom);
|
||||
virtual void release_geom(GeomContext *gc);
|
||||
@ -318,12 +322,16 @@ public:
|
||||
const GeomPrimitivePipelineReader *reader,
|
||||
bool force);
|
||||
|
||||
#ifndef OPENGLES
|
||||
virtual void begin_occlusion_query();
|
||||
virtual PT(OcclusionQueryContext) end_occlusion_query();
|
||||
#endif
|
||||
|
||||
virtual PT(TimerQueryContext) issue_timer_query(int pstats_index);
|
||||
|
||||
#ifndef OPENGLES
|
||||
virtual void dispatch_compute(int size_x, int size_y, int size_z);
|
||||
#endif
|
||||
|
||||
virtual PT(GeomMunger) make_geom_munger(const RenderState *state,
|
||||
Thread *current_thread);
|
||||
@ -337,6 +345,7 @@ public:
|
||||
virtual bool framebuffer_copy_to_ram
|
||||
(Texture *tex, int view, int z, const DisplayRegion *dr, const RenderBuffer &rb);
|
||||
|
||||
#ifndef OPENGLES_2
|
||||
void apply_fog(Fog *fog);
|
||||
|
||||
virtual void bind_light(PointLight *light_obj, const NodePath &light,
|
||||
@ -345,6 +354,7 @@ public:
|
||||
int light_id);
|
||||
virtual void bind_light(Spotlight *light_obj, const NodePath &light,
|
||||
int light_id);
|
||||
#endif
|
||||
|
||||
void print_gfx_visual();
|
||||
|
||||
@ -380,18 +390,26 @@ protected:
|
||||
void do_issue_rescale_normal();
|
||||
void do_issue_color_write();
|
||||
void do_issue_depth_test();
|
||||
#ifndef OPENGLES_2
|
||||
void do_issue_alpha_test();
|
||||
#endif
|
||||
void do_issue_depth_write();
|
||||
void do_issue_cull_face();
|
||||
#ifndef OPENGLES_2
|
||||
void do_issue_fog();
|
||||
#endif
|
||||
void do_issue_depth_offset();
|
||||
void do_issue_shade_model();
|
||||
void do_issue_shader(bool state_has_changed = false);
|
||||
#ifndef OPENGLES_2
|
||||
void do_issue_material();
|
||||
#endif
|
||||
void do_issue_texture();
|
||||
void do_issue_blending();
|
||||
#ifndef OPENGLES_2
|
||||
void do_issue_tex_gen();
|
||||
void do_issue_tex_matrix();
|
||||
#endif
|
||||
void do_issue_stencil();
|
||||
void do_issue_scissor();
|
||||
|
||||
@ -414,6 +432,8 @@ protected:
|
||||
virtual void *do_get_extension_func(const char *name);
|
||||
|
||||
virtual void reissue_transforms();
|
||||
|
||||
#ifndef OPENGLES_2
|
||||
virtual void enable_lighting(bool enable);
|
||||
virtual void set_ambient_light(const LColor &color);
|
||||
virtual void enable_light(int light_id, bool enable);
|
||||
@ -424,6 +444,7 @@ protected:
|
||||
virtual void begin_bind_clip_planes();
|
||||
virtual void bind_clip_plane(const NodePath &plane, int plane_id);
|
||||
virtual void end_bind_clip_planes();
|
||||
#endif
|
||||
|
||||
virtual void free_pointers();
|
||||
|
||||
@ -447,16 +468,21 @@ protected:
|
||||
INLINE void set_color_write_mask(int mask);
|
||||
INLINE void clear_color_write_mask();
|
||||
|
||||
#ifndef OPENGLES_2
|
||||
INLINE void call_glFogfv(GLenum pname, const LColor &color);
|
||||
INLINE void call_glMaterialfv(GLenum face, GLenum pname, const LColor &color);
|
||||
INLINE void call_glLightfv(GLenum light, GLenum pname, const LVecBase4 &value);
|
||||
INLINE void call_glLightfv(GLenum light, GLenum pname, const LVecBase3 &value);
|
||||
INLINE void call_glLightModelfv(GLenum pname, const LVecBase4 &value);
|
||||
INLINE void call_glTexEnvfv(GLenum target, GLenum pname, const LVecBase4 &value);
|
||||
#endif
|
||||
|
||||
INLINE void call_glTexParameterfv(GLenum target, GLenum pname, const LVecBase4 &value);
|
||||
|
||||
#ifndef OPENGLES_2
|
||||
INLINE GLenum get_light_id(int index) const;
|
||||
INLINE GLenum get_clip_plane_id(int index) const;
|
||||
#endif
|
||||
|
||||
void set_draw_buffer(int rbtype);
|
||||
void set_read_buffer(int rbtype);
|
||||
@ -485,10 +511,12 @@ protected:
|
||||
static GLenum get_usage(Geom::UsageHint usage_hint);
|
||||
|
||||
void unbind_buffers();
|
||||
#ifndef OPENGLES_2
|
||||
void disable_standard_vertex_arrays();
|
||||
bool update_standard_vertex_arrays(bool force);
|
||||
void disable_standard_texture_bindings();
|
||||
void update_standard_texture_bindings();
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
void update_show_usage_texture_bindings(int show_stage_index);
|
||||
@ -570,7 +598,7 @@ protected:
|
||||
ShaderContext *_texture_binding_shader_context;
|
||||
#endif
|
||||
#ifdef OPENGLES_2
|
||||
static PT(Shader) _default_shader;
|
||||
static PT(Shader) _default_shader;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CG
|
||||
@ -640,21 +668,25 @@ public:
|
||||
PFNGLWEIGHTDVARBPROC _glWeightdv;
|
||||
|
||||
bool _supports_matrix_palette;
|
||||
#ifdef OPENGLES
|
||||
#ifdef OPENGLES_1
|
||||
PFNGLCURRENTPALETTEMATRIXOESPROC _glCurrentPaletteMatrix;
|
||||
PFNGLMATRIXINDEXPOINTEROESPROC _glMatrixIndexPointer;
|
||||
#else
|
||||
#endif
|
||||
#ifndef OPENGLES
|
||||
PFNGLCURRENTPALETTEMATRIXARBPROC _glCurrentPaletteMatrix;
|
||||
PFNGLMATRIXINDEXPOINTERARBPROC _glMatrixIndexPointer;
|
||||
PFNGLMATRIXINDEXUIVARBPROC _glMatrixIndexuiv;
|
||||
#endif
|
||||
|
||||
bool _supports_draw_range_elements;
|
||||
#ifndef OPENGLES
|
||||
PFNGLDRAWRANGEELEMENTSPROC _glDrawRangeElements;
|
||||
#endif
|
||||
|
||||
#ifndef OPENGLES_1
|
||||
PFNGLTEXIMAGE3DPROC_P _glTexImage3D;
|
||||
PFNGLTEXSUBIMAGE3DPROC _glTexSubImage3D;
|
||||
PFNGLCOPYTEXSUBIMAGE3DPROC _glCopyTexSubImage3D;
|
||||
#endif
|
||||
|
||||
bool _supports_tex_storage;
|
||||
PFNGLTEXSTORAGE1DPROC _glTexStorage1D;
|
||||
@ -678,8 +710,9 @@ public:
|
||||
bool _supports_rescale_normal;
|
||||
bool _supports_packed_dabc;
|
||||
|
||||
bool _supports_multitexture;
|
||||
PFNGLACTIVETEXTUREPROC _glActiveTexture;
|
||||
#ifndef OPENGLES_2
|
||||
bool _supports_multitexture;
|
||||
PFNGLCLIENTACTIVETEXTUREPROC _glClientActiveTexture;
|
||||
PFNGLMULTITEXCOORD1FPROC _glMultiTexCoord1f;
|
||||
PFNGLMULTITEXCOORD2FPROC _glMultiTexCoord2f;
|
||||
@ -689,6 +722,7 @@ public:
|
||||
PFNGLMULTITEXCOORD2DPROC _glMultiTexCoord2d;
|
||||
PFNGLMULTITEXCOORD3DPROC _glMultiTexCoord3d;
|
||||
PFNGLMULTITEXCOORD4DPROC _glMultiTexCoord4d;
|
||||
#endif
|
||||
|
||||
bool _supports_buffers;
|
||||
PFNGLGENBUFFERSPROC _glGenBuffers;
|
||||
@ -798,7 +832,9 @@ public:
|
||||
PFNGLVERTEXATTRIBIPOINTERPROC _glVertexAttribIPointer;
|
||||
PFNGLVERTEXATTRIBLPOINTERPROC _glVertexAttribLPointer;
|
||||
PFNGLVERTEXATTRIBDIVISORPROC _glVertexAttribDivisor;
|
||||
#endif // OPENGLES_1
|
||||
PFNGLDRAWARRAYSINSTANCEDPROC _glDrawArraysInstanced;
|
||||
PFNGLDRAWELEMENTSINSTANCEDPROC _glDrawElementsInstanced;
|
||||
#endif // !OPENGLES_1
|
||||
#ifndef OPENGLES
|
||||
PFNGLGENSAMPLERSPROC _glGenSamplers;
|
||||
PFNGLDELETESAMPLERSPROC _glDeleteSamplers;
|
||||
@ -809,8 +845,6 @@ public:
|
||||
PFNGLSAMPLERPARAMETERFVPROC _glSamplerParameterfv;
|
||||
PFNGLPROGRAMPARAMETERIPROC _glProgramParameteri;
|
||||
PFNGLPATCHPARAMETERIPROC _glPatchParameteri;
|
||||
PFNGLDRAWARRAYSINSTANCEDPROC _glDrawArraysInstanced;
|
||||
PFNGLDRAWELEMENTSINSTANCEDPROC _glDrawElementsInstanced;
|
||||
PFNGLBINDTEXTURESPROC _glBindTextures;
|
||||
PFNGLBINDSAMPLERSPROC _glBindSamplers;
|
||||
PFNGLBINDIMAGETEXTUREPROC _glBindImageTexture;
|
||||
@ -828,7 +862,7 @@ public:
|
||||
PFNGLMAKETEXTUREHANDLENONRESIDENTPROC _glMakeTextureHandleNonResident;
|
||||
PFNGLUNIFORMHANDLEUI64PROC _glUniformHandleui64;
|
||||
PFNGLUNIFORMHANDLEUI64VPROC _glUniformHandleui64v;
|
||||
#endif // OPENGLES
|
||||
#endif // !OPENGLES
|
||||
|
||||
GLenum _edge_clamp;
|
||||
GLenum _border_clamp;
|
||||
@ -836,7 +870,7 @@ public:
|
||||
GLenum _mirror_clamp;
|
||||
GLenum _mirror_edge_clamp;
|
||||
GLenum _mirror_border_clamp;
|
||||
#ifndef OPENGLES
|
||||
#ifndef OPENGLES_1
|
||||
GLsizei _instance_count;
|
||||
#endif
|
||||
|
||||
|
@ -196,6 +196,7 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext
|
||||
_glgsg = glgsg;
|
||||
_glsl_program = 0;
|
||||
_uses_standard_vertex_arrays = false;
|
||||
_has_divisor = false;
|
||||
|
||||
nassertv(s->get_language() == Shader::SL_GLSL);
|
||||
|
||||
@ -537,8 +538,8 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext
|
||||
continue; }
|
||||
case GL_INT_SAMPLER_2D:
|
||||
case GL_UNSIGNED_INT_SAMPLER_2D:
|
||||
case GL_SAMPLER_2D_SHADOW:
|
||||
#endif
|
||||
case GL_SAMPLER_2D_SHADOW:
|
||||
case GL_SAMPLER_2D: {
|
||||
_glgsg->_glUniform1i(p, s->_tex_spec.size());
|
||||
Shader::ShaderTexSpec bind;
|
||||
@ -553,13 +554,18 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext
|
||||
case GL_UNSIGNED_INT_SAMPLER_3D:
|
||||
#endif
|
||||
case GL_SAMPLER_3D: {
|
||||
_glgsg->_glUniform1i(p, s->_tex_spec.size());
|
||||
Shader::ShaderTexSpec bind;
|
||||
bind._id = arg_id;
|
||||
bind._name = InternalName::make(param_name);
|
||||
bind._desired_type = Texture::TT_3d_texture;
|
||||
bind._stage = texunitno++;
|
||||
s->_tex_spec.push_back(bind);
|
||||
if (_glgsg->_supports_3d_texture) {
|
||||
_glgsg->_glUniform1i(p, s->_tex_spec.size());
|
||||
Shader::ShaderTexSpec bind;
|
||||
bind._id = arg_id;
|
||||
bind._name = InternalName::make(param_name);
|
||||
bind._desired_type = Texture::TT_3d_texture;
|
||||
bind._stage = texunitno++;
|
||||
s->_tex_spec.push_back(bind);
|
||||
} else {
|
||||
GLCAT.error()
|
||||
<< "GLSL shader uses 3D texture, which is unsupported by the driver.\n";
|
||||
}
|
||||
continue; }
|
||||
#ifndef OPENGLES
|
||||
case GL_INT_SAMPLER_CUBE:
|
||||
@ -567,26 +573,36 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext
|
||||
case GL_SAMPLER_CUBE_SHADOW:
|
||||
#endif
|
||||
case GL_SAMPLER_CUBE: {
|
||||
_glgsg->_glUniform1i(p, s->_tex_spec.size());
|
||||
Shader::ShaderTexSpec bind;
|
||||
bind._id = arg_id;
|
||||
bind._name = InternalName::make(param_name);
|
||||
bind._desired_type = Texture::TT_cube_map;
|
||||
bind._stage = texunitno++;
|
||||
s->_tex_spec.push_back(bind);
|
||||
if (_glgsg->_supports_cube_map) {
|
||||
_glgsg->_glUniform1i(p, s->_tex_spec.size());
|
||||
Shader::ShaderTexSpec bind;
|
||||
bind._id = arg_id;
|
||||
bind._name = InternalName::make(param_name);
|
||||
bind._desired_type = Texture::TT_cube_map;
|
||||
bind._stage = texunitno++;
|
||||
s->_tex_spec.push_back(bind);
|
||||
} else {
|
||||
GLCAT.error()
|
||||
<< "GLSL shader uses cube map, which is unsupported by the driver.\n";
|
||||
}
|
||||
continue; }
|
||||
#ifndef OPENGLES
|
||||
case GL_INT_SAMPLER_2D_ARRAY:
|
||||
case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
|
||||
case GL_SAMPLER_2D_ARRAY_SHADOW:
|
||||
case GL_SAMPLER_2D_ARRAY: {
|
||||
_glgsg->_glUniform1i(p, s->_tex_spec.size());
|
||||
Shader::ShaderTexSpec bind;
|
||||
bind._id = arg_id;
|
||||
bind._name = InternalName::make(param_name);
|
||||
bind._desired_type = Texture::TT_2d_texture_array;
|
||||
bind._stage = texunitno++;
|
||||
s->_tex_spec.push_back(bind);
|
||||
if (_glgsg->_supports_2d_texture_array) {
|
||||
_glgsg->_glUniform1i(p, s->_tex_spec.size());
|
||||
Shader::ShaderTexSpec bind;
|
||||
bind._id = arg_id;
|
||||
bind._name = InternalName::make(param_name);
|
||||
bind._desired_type = Texture::TT_2d_texture_array;
|
||||
bind._stage = texunitno++;
|
||||
s->_tex_spec.push_back(bind);
|
||||
} else {
|
||||
GLCAT.error()
|
||||
<< "GLSL shader uses 2D texture array, which is unsupported by the driver.\n";
|
||||
}
|
||||
continue; }
|
||||
#endif
|
||||
case GL_FLOAT_MAT2:
|
||||
@ -1202,7 +1218,7 @@ disable_shader_vertex_arrays() {
|
||||
for (int i=0; i<(int)_shader->_var_spec.size(); i++) {
|
||||
const Shader::ShaderVarSpec &bind = _shader->_var_spec[i];
|
||||
const GLint p = _glsl_parameter_map[bind._id._seqno];
|
||||
if (_glgsg->_supports_vertex_attrib_divisor) {
|
||||
if (_has_divisor) {
|
||||
_glgsg->_glVertexAttribDivisor(p, 0);
|
||||
}
|
||||
for (int i = 0; i < bind._elements; ++i) {
|
||||
@ -1291,6 +1307,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) {
|
||||
|
||||
if (_glgsg->_supports_vertex_attrib_divisor) {
|
||||
_glgsg->_glVertexAttribDivisor(p, divisor);
|
||||
_has_divisor = true;
|
||||
}
|
||||
|
||||
++p;
|
||||
@ -1342,22 +1359,32 @@ disable_shader_texture_bindings() {
|
||||
|
||||
_glgsg->_glActiveTexture(GL_TEXTURE0 + i);
|
||||
|
||||
switch (_shader->_tex_spec[i]._desired_type) {
|
||||
case Texture::TT_1d_texture:
|
||||
#ifndef OPENGLES
|
||||
glBindTexture(GL_TEXTURE_1D, 0);
|
||||
#endif // OPENGLES
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
#ifndef OPENGLES_1
|
||||
if (_glgsg->_supports_3d_texture) {
|
||||
glBindTexture(GL_TEXTURE_3D, 0);
|
||||
}
|
||||
#endif // OPENGLES_1
|
||||
#ifndef OPENGLES
|
||||
if (_glgsg->_supports_2d_texture_array) {
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY_EXT, 0);
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_1D, 0);
|
||||
#endif
|
||||
if (_glgsg->_supports_cube_map) {
|
||||
break;
|
||||
|
||||
case Texture::TT_2d_texture:
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
break;
|
||||
|
||||
case Texture::TT_3d_texture:
|
||||
#ifndef OPENGLES_1
|
||||
glBindTexture(GL_TEXTURE_3D, 0);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case Texture::TT_2d_texture_array:
|
||||
#ifndef OPENGLES
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY_EXT, 0);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case Texture::TT_cube_map:
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,7 @@ private:
|
||||
CLP(GraphicsStateGuardian) *_glgsg;
|
||||
|
||||
bool _uses_standard_vertex_arrays;
|
||||
bool _has_divisor;
|
||||
|
||||
void glsl_report_shader_errors(GLuint shader, Shader::ShaderType type, bool fatal);
|
||||
void glsl_report_program_errors(GLuint program, bool fatal);
|
||||
|
Loading…
x
Reference in New Issue
Block a user