diff options
Diffstat (limited to 'drivers/gles3')
-rw-r--r-- | drivers/gles3/rasterizer_canvas_gles3.cpp | 134 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_canvas_gles3.h | 3 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_gles3.cpp | 77 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_scene_gles3.cpp | 21 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_storage_gles3.cpp | 93 | ||||
-rw-r--r-- | drivers/gles3/shader_gles3.cpp | 6 |
6 files changed, 220 insertions, 114 deletions
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index 10a8912561..1f23387516 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -274,17 +274,7 @@ void RasterizerCanvasGLES3::_draw_polygon(int p_vertex_count, const int* p_indic } if (p_indices) { -#ifdef GLEW_ENABLED glDrawElements(GL_TRIANGLES, p_vertex_count, GL_UNSIGNED_INT, p_indices ); -#else - static const int _max_draw_poly_indices = 16*1024; // change this size if needed!!! - ERR_FAIL_COND(p_vertex_count > _max_draw_poly_indices); - static uint16_t _draw_poly_indices[_max_draw_poly_indices]; - for (int i=0; i<p_vertex_count; i++) { - _draw_poly_indices[i] = p_indices[i]; - }; - glDrawElements(GL_TRIANGLES, p_vertex_count, GL_UNSIGNED_SHORT, _draw_poly_indices ); -#endif } else { glDrawArrays(GL_TRIANGLES,0,p_vertex_count); } @@ -370,77 +360,59 @@ void RasterizerCanvasGLES3::_draw_gui_primitive(int p_points, const Vector2 *p_v //#define GLES_USE_PRIMITIVE_BUFFER -#ifndef GLES_NO_CLIENT_ARRAYS + int version=0; + int color_ofs=0; + int uv_ofs=0; + int stride=2; - glEnableVertexAttribArray(VS::ARRAY_VERTEX); - glVertexAttribPointer( VS::ARRAY_VERTEX, 2 ,GL_FLOAT, false, sizeof(Vector2), p_vertices ); - - if (p_colors) { - - glEnableVertexAttribArray(VS::ARRAY_COLOR); - glVertexAttribPointer( VS::ARRAY_COLOR, 4 ,GL_FLOAT, false, sizeof(Color), p_colors ); - } else { - glDisableVertexAttribArray(VS::ARRAY_COLOR); + if (p_colors) { //color + version|=1; + color_ofs=stride; + stride+=4; } - if (p_uvs) { - - glEnableVertexAttribArray(VS::ARRAY_TEX_UV); - glVertexAttribPointer( VS::ARRAY_TEX_UV, 2 ,GL_FLOAT, false, sizeof(Vector2), p_uvs ); - } else { - glDisableVertexAttribArray(VS::ARRAY_TEX_UV); + if (p_uvs) { //uv + version|=2; + uv_ofs=stride; + stride+=2; } - glDrawArrays(prim[p_points],0,p_points); -#else + float b[(2+2+4)]; + - glBindBuffer(GL_ARRAY_BUFFER,gui_quad_buffer); - float b[32]; - int ofs=0; - glEnableVertexAttribArray(VS::ARRAY_VERTEX); - glVertexAttribPointer( VS::ARRAY_VERTEX, 2 ,GL_FLOAT, false, sizeof(float)*2, ((float*)0)+ofs ); for(int i=0;i<p_points;i++) { - b[ofs++]=p_vertices[i].x; - b[ofs++]=p_vertices[i].y; + b[stride*i+0]=p_vertices[i].x; + b[stride*i+1]=p_vertices[i].y; } if (p_colors) { - glEnableVertexAttribArray(VS::ARRAY_COLOR); - glVertexAttribPointer( VS::ARRAY_COLOR, 4 ,GL_FLOAT, false, sizeof(float)*4, ((float*)0)+ofs ); for(int i=0;i<p_points;i++) { - b[ofs++]=p_colors[i].r; - b[ofs++]=p_colors[i].g; - b[ofs++]=p_colors[i].b; - b[ofs++]=p_colors[i].a; + b[stride*i+color_ofs+0]=p_colors[i].r; + b[stride*i+color_ofs+1]=p_colors[i].g; + b[stride*i+color_ofs+2]=p_colors[i].b; + b[stride*i+color_ofs+3]=p_colors[i].a; } - } else { - glDisableVertexAttribArray(VS::ARRAY_COLOR); } - if (p_uvs) { - glEnableVertexAttribArray(VS::ARRAY_TEX_UV); - glVertexAttribPointer( VS::ARRAY_TEX_UV, 2 ,GL_FLOAT, false, sizeof(float)*2, ((float*)0)+ofs ); for(int i=0;i<p_points;i++) { - b[ofs++]=p_uvs[i].x; - b[ofs++]=p_uvs[i].y; + b[stride*i+uv_ofs+0]=p_uvs[i].x; + b[stride*i+uv_ofs+1]=p_uvs[i].y; } - } else { - glDisableVertexAttribArray(VS::ARRAY_TEX_UV); } - glBufferSubData(GL_ARRAY_BUFFER,0,ofs*4,&b[0]); + glBindBuffer(GL_ARRAY_BUFFER,data.primitive_quad_buffer); + glBufferSubData(GL_ARRAY_BUFFER,0,p_points*stride*4,&b[0]); + glBindVertexArray(data.primitive_quad_buffer_arrays[version]); glDrawArrays(prim[p_points],0,p_points); + glBindVertexArray(0); glBindBuffer(GL_ARRAY_BUFFER,0); - -#endif - storage->frame.canvas_draw_commands++; } @@ -471,14 +443,14 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item,Item *curr Vector2(line->to.x,line->to.y) }; -#ifdef GLEW_ENABLED +#ifdef GLES_OVER_GL if (line->antialiased) glEnable(GL_LINE_SMOOTH); #endif - glLineWidth(line->width); + //glLineWidth(line->width); _draw_gui_primitive(2,verts,NULL,NULL); -#ifdef GLEW_ENABLED +#ifdef GLES_OVER_GL if (line->antialiased) glDisable(GL_LINE_SMOOTH); #endif @@ -1395,7 +1367,7 @@ void RasterizerCanvasGLES3::reset_canvas() { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } //glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); - glLineWidth(1.0); + //glLineWidth(1.0); glBindBuffer(GL_ARRAY_BUFFER,0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0); for(int i=0;i<VS::ARRAY_MAX;i++) { @@ -1482,9 +1454,53 @@ void RasterizerCanvasGLES3::initialize() { glBindBuffer(GL_ARRAY_BUFFER,0); //unbind } + { + + glGenBuffers(1,&data.primitive_quad_buffer); + glBindBuffer(GL_ARRAY_BUFFER,data.primitive_quad_buffer); + glBufferData(GL_ARRAY_BUFFER,sizeof(float)*2+sizeof(float)*2+sizeof(float)*4,NULL,GL_DYNAMIC_DRAW); //allocate max size + glBindBuffer(GL_ARRAY_BUFFER,0); + - store_transform(Transform(),state.canvas_item_ubo_data.projection_matrix); + for(int i=0;i<4;i++) { + glGenVertexArrays(1,&data.primitive_quad_buffer_arrays[i]); + glBindVertexArray(data.primitive_quad_buffer_arrays[i]); + glBindBuffer(GL_ARRAY_BUFFER,data.primitive_quad_buffer); + int uv_ofs=0; + int color_ofs=0; + int stride=2*4; + + if (i&1) { //color + color_ofs=stride; + stride+=4*4; + } + + if (i&2) { //uv + uv_ofs=stride; + stride+=2*4; + } + + + glEnableVertexAttribArray(VS::ARRAY_VERTEX); + glVertexAttribPointer(VS::ARRAY_VERTEX,2,GL_FLOAT,GL_FALSE,stride,((uint8_t*)NULL)+0); + + if (i&1) { + glEnableVertexAttribArray(VS::ARRAY_COLOR); + glVertexAttribPointer(VS::ARRAY_COLOR,4,GL_FLOAT,GL_FALSE,stride,((uint8_t*)NULL)+color_ofs); + } + + if (i&2) { + glEnableVertexAttribArray(VS::ARRAY_TEX_UV); + glVertexAttribPointer(VS::ARRAY_TEX_UV,2,GL_FLOAT,GL_FALSE,stride,((uint8_t*)NULL)+uv_ofs); + } + + glBindVertexArray(0); + } + } + + + store_transform(Transform(),state.canvas_item_ubo_data.projection_matrix); glGenBuffers(1, &state.canvas_item_ubo); diff --git a/drivers/gles3/rasterizer_canvas_gles3.h b/drivers/gles3/rasterizer_canvas_gles3.h index 8f34f07d06..670310068c 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.h +++ b/drivers/gles3/rasterizer_canvas_gles3.h @@ -21,6 +21,9 @@ public: GLuint canvas_quad_vertices; GLuint canvas_quad_array; + GLuint primitive_quad_buffer; + GLuint primitive_quad_buffer_arrays[4]; + } data; struct State { diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index 84fa349313..ebcedd5f05 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -18,46 +18,69 @@ RasterizerScene *RasterizerGLES3::get_scene() { return scene; } +#define _EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 +#define _EXT_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 +#define _EXT_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 +#define _EXT_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 +#define _EXT_DEBUG_SOURCE_API_ARB 0x8246 +#define _EXT_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 +#define _EXT_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 +#define _EXT_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 +#define _EXT_DEBUG_SOURCE_APPLICATION_ARB 0x824A +#define _EXT_DEBUG_SOURCE_OTHER_ARB 0x824B +#define _EXT_DEBUG_TYPE_ERROR_ARB 0x824C +#define _EXT_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D +#define _EXT_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E +#define _EXT_DEBUG_TYPE_PORTABILITY_ARB 0x824F +#define _EXT_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 +#define _EXT_DEBUG_TYPE_OTHER_ARB 0x8251 +#define _EXT_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 +#define _EXT_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 +#define _EXT_DEBUG_LOGGED_MESSAGES_ARB 0x9145 +#define _EXT_DEBUG_SEVERITY_HIGH_ARB 0x9146 +#define _EXT_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 +#define _EXT_DEBUG_SEVERITY_LOW_ARB 0x9148 +#define _EXT_DEBUG_OUTPUT 0x92E0 static void _gl_debug_print(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const GLvoid *userParam) { - if (type==GL_DEBUG_TYPE_OTHER_ARB) + if (type==_EXT_DEBUG_TYPE_OTHER_ARB) return; print_line("mesege"); char debSource[256], debType[256], debSev[256]; - if(source == GL_DEBUG_SOURCE_API_ARB) + if(source == _EXT_DEBUG_SOURCE_API_ARB) strcpy(debSource, "OpenGL"); - else if(source == GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB) + else if(source == _EXT_DEBUG_SOURCE_WINDOW_SYSTEM_ARB) strcpy(debSource, "Windows"); - else if(source == GL_DEBUG_SOURCE_SHADER_COMPILER_ARB) + else if(source == _EXT_DEBUG_SOURCE_SHADER_COMPILER_ARB) strcpy(debSource, "Shader Compiler"); - else if(source == GL_DEBUG_SOURCE_THIRD_PARTY_ARB) + else if(source == _EXT_DEBUG_SOURCE_THIRD_PARTY_ARB) strcpy(debSource, "Third Party"); - else if(source == GL_DEBUG_SOURCE_APPLICATION_ARB) + else if(source == _EXT_DEBUG_SOURCE_APPLICATION_ARB) strcpy(debSource, "Application"); - else if(source == GL_DEBUG_SOURCE_OTHER_ARB) + else if(source == _EXT_DEBUG_SOURCE_OTHER_ARB) strcpy(debSource, "Other"); - if(type == GL_DEBUG_TYPE_ERROR_ARB) + if(type == _EXT_DEBUG_TYPE_ERROR_ARB) strcpy(debType, "Error"); - else if(type == GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB) + else if(type == _EXT_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB) strcpy(debType, "Deprecated behavior"); - else if(type == GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB) + else if(type == _EXT_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB) strcpy(debType, "Undefined behavior"); - else if(type == GL_DEBUG_TYPE_PORTABILITY_ARB) + else if(type == _EXT_DEBUG_TYPE_PORTABILITY_ARB) strcpy(debType, "Portability"); - else if(type == GL_DEBUG_TYPE_PERFORMANCE_ARB) + else if(type == _EXT_DEBUG_TYPE_PERFORMANCE_ARB) strcpy(debType, "Performance"); - else if(type == GL_DEBUG_TYPE_OTHER_ARB) + else if(type == _EXT_DEBUG_TYPE_OTHER_ARB) strcpy(debType, "Other"); - if(severity == GL_DEBUG_SEVERITY_HIGH_ARB) + if(severity == _EXT_DEBUG_SEVERITY_HIGH_ARB) strcpy(debSev, "High"); - else if(severity == GL_DEBUG_SEVERITY_MEDIUM_ARB) + else if(severity == _EXT_DEBUG_SEVERITY_MEDIUM_ARB) strcpy(debSev, "Medium"); - else if(severity == GL_DEBUG_SEVERITY_LOW_ARB) + else if(severity == _EXT_DEBUG_SEVERITY_LOW_ARB) strcpy(debSev, "Low"); String output = String()+ "GL ERROR: Source: " + debSource + "\tType: " + debType + "\tID: " + itos(id) + "\tSeverity: " + debSev + "\tMessage: " + message; @@ -67,6 +90,16 @@ static void _gl_debug_print(GLenum source,GLenum type,GLuint id,GLenum severity, } +typedef void (*DEBUGPROCARB)(GLenum source, + GLenum type, + GLuint id, + GLenum severity, + GLsizei length, + const char* message, + const void* userParam); + +typedef void (* DebugMessageCallbackARB) (DEBUGPROCARB callback, const void *userParam); + void RasterizerGLES3::initialize() { if (OS::get_singleton()->is_stdout_verbose()) { @@ -91,9 +124,17 @@ void RasterizerGLES3::initialize() { } #endif - glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); +#ifdef GLAD_ENABLED + + if(!gladLoadGL()) { + ERR_PRINT("Error initializing GLAD"); + } + + glEnable(_EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB); glDebugMessageCallbackARB(_gl_debug_print, NULL); - glEnable(GL_DEBUG_OUTPUT); + glEnable(_EXT_DEBUG_OUTPUT); + +#endif /* glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_ERROR_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE); diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 54dc3b914b..f42eea45d4 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -934,7 +934,7 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material* p_m } if (state.current_line_width!=p_material->line_width) { - glLineWidth(p_material->line_width); + //glLineWidth(MAX(p_material->line_width,1.0)); state.current_line_width=p_material->line_width; } @@ -1109,17 +1109,17 @@ void RasterizerSceneGLES3::_setup_geometry(RenderList::Element *e) { int stride = (multi_mesh->xform_floats+multi_mesh->color_floats)*4; glEnableVertexAttribArray(8); glVertexAttribPointer(8,4,GL_FLOAT,GL_FALSE,stride,((uint8_t*)NULL)+0); - glVertexAttribDivisorARB(8,1); + glVertexAttribDivisor(8,1); glEnableVertexAttribArray(9); glVertexAttribPointer(9,4,GL_FLOAT,GL_FALSE,stride,((uint8_t*)NULL)+4*4); - glVertexAttribDivisorARB(9,1); + glVertexAttribDivisor(9,1); int color_ofs; if (multi_mesh->transform_format==VS::MULTIMESH_TRANSFORM_3D) { glEnableVertexAttribArray(10); glVertexAttribPointer(10,4,GL_FLOAT,GL_FALSE,stride,((uint8_t*)NULL)+8*4); - glVertexAttribDivisorARB(10,1); + glVertexAttribDivisor(10,1); color_ofs=12*4; } else { glDisableVertexAttribArray(10); @@ -1136,13 +1136,13 @@ void RasterizerSceneGLES3::_setup_geometry(RenderList::Element *e) { case VS::MULTIMESH_COLOR_8BIT: { glEnableVertexAttribArray(11); glVertexAttribPointer(11,4,GL_UNSIGNED_BYTE,GL_TRUE,stride,((uint8_t*)NULL)+color_ofs); - glVertexAttribDivisorARB(11,1); + glVertexAttribDivisor(11,1); } break; case VS::MULTIMESH_COLOR_FLOAT: { glEnableVertexAttribArray(11); glVertexAttribPointer(11,4,GL_FLOAT,GL_FALSE,stride,((uint8_t*)NULL)+color_ofs); - glVertexAttribDivisorARB(11,1); + glVertexAttribDivisor(11,1); } break; } @@ -1191,11 +1191,11 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) { if (s->index_array_len>0) { - glDrawElementsInstancedARB(gl_primitive[s->primitive],s->index_array_len, (s->array_len>=(1<<16))?GL_UNSIGNED_INT:GL_UNSIGNED_SHORT,0,amount); + glDrawElementsInstanced(gl_primitive[s->primitive],s->index_array_len, (s->array_len>=(1<<16))?GL_UNSIGNED_INT:GL_UNSIGNED_SHORT,0,amount); } else { - glDrawArraysInstancedARB(gl_primitive[s->primitive],0,s->array_len,amount); + glDrawArraysInstanced(gl_primitive[s->primitive],0,s->array_len,amount); } @@ -3648,10 +3648,9 @@ void RasterizerSceneGLES3::initialize() { } -#ifdef GLEW_ENABLED +#ifdef GLES_OVER_GL //"desktop" opengl needs this. - glEnable(GL_POINT_SPRITE); - glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); + glEnable(GL_PROGRAM_POINT_SIZE); #endif } diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index e5a0cded8e..60cbbc9023 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -62,7 +62,21 @@ #define _GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE #define _GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF - +#define _EXT_COMPRESSED_R11_EAC 0x9270 +#define _EXT_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define _EXT_COMPRESSED_RG11_EAC 0x9272 +#define _EXT_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define _EXT_COMPRESSED_RGB8_ETC2 0x9274 +#define _EXT_COMPRESSED_SRGB8_ETC2 0x9275 +#define _EXT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define _EXT_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define _EXT_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define _EXT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 + +#define _EXT_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C +#define _EXT_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D +#define _EXT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E +#define _EXT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F Image RasterizerStorageGLES3::_get_gl_image_and_format(const Image& p_image, Image::Format p_format, uint32_t p_flags,GLenum& r_gl_format,GLenum& r_gl_internal_format,GLenum &r_gl_type,bool &r_compressed,bool &srgb) { @@ -77,17 +91,16 @@ Image RasterizerStorageGLES3::_get_gl_image_and_format(const Image& p_image, Ima switch(p_format) { case Image::FORMAT_L8: { - r_gl_internal_format=GL_LUMINANCE; - r_gl_format=GL_LUMINANCE; + r_gl_internal_format=GL_R8; + r_gl_format=GL_RED; r_gl_type=GL_UNSIGNED_BYTE; } break; case Image::FORMAT_LA8: { - r_gl_internal_format=GL_LUMINANCE_ALPHA; - r_gl_format=GL_LUMINANCE_ALPHA; + r_gl_internal_format=GL_RG8; + r_gl_format=GL_RG; r_gl_type=GL_UNSIGNED_BYTE; - } break; case Image::FORMAT_R8: { @@ -120,8 +133,9 @@ Image RasterizerStorageGLES3::_get_gl_image_and_format(const Image& p_image, Ima } break; case Image::FORMAT_RGB565: { - - r_gl_internal_format=GL_RGB565; +#warning TODO: Convert tod 555 if 565 is not supported (GLES3.3-) + r_gl_internal_format=GL_RGB5; + //r_gl_internal_format=GL_RGB565; r_gl_format=GL_RGB; r_gl_type=GL_UNSIGNED_SHORT_5_6_5; @@ -287,7 +301,7 @@ Image RasterizerStorageGLES3::_get_gl_image_and_format(const Image& p_image, Ima if (config.bptc_supported) { - r_gl_internal_format=(config.srgb_decode_supported || p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:GL_COMPRESSED_RGBA_BPTC_UNORM; + r_gl_internal_format=(config.srgb_decode_supported || p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:_EXT_COMPRESSED_RGBA_BPTC_UNORM; r_gl_format=GL_RGBA; r_gl_type=GL_UNSIGNED_BYTE; r_compressed=true; @@ -303,7 +317,7 @@ Image RasterizerStorageGLES3::_get_gl_image_and_format(const Image& p_image, Ima if (config.bptc_supported) { - r_gl_internal_format=GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT; + r_gl_internal_format=_EXT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT; r_gl_format=GL_RGB; r_gl_type=GL_FLOAT; r_compressed=true; @@ -316,7 +330,7 @@ Image RasterizerStorageGLES3::_get_gl_image_and_format(const Image& p_image, Ima if (config.bptc_supported) { - r_gl_internal_format=GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT; + r_gl_internal_format=_EXT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT; r_gl_format=GL_RGB; r_gl_type=GL_FLOAT; r_compressed=true; @@ -413,7 +427,7 @@ Image RasterizerStorageGLES3::_get_gl_image_and_format(const Image& p_image, Ima if (config.etc2_supported) { - r_gl_internal_format=GL_COMPRESSED_R11_EAC; + r_gl_internal_format=_EXT_COMPRESSED_R11_EAC; r_gl_format=GL_RED; r_gl_type=GL_UNSIGNED_BYTE; r_compressed=true; @@ -427,7 +441,7 @@ Image RasterizerStorageGLES3::_get_gl_image_and_format(const Image& p_image, Ima if (config.etc2_supported) { - r_gl_internal_format=GL_COMPRESSED_SIGNED_R11_EAC; + r_gl_internal_format=_EXT_COMPRESSED_SIGNED_R11_EAC; r_gl_format=GL_RED; r_gl_type=GL_UNSIGNED_BYTE; r_compressed=true; @@ -441,7 +455,7 @@ Image RasterizerStorageGLES3::_get_gl_image_and_format(const Image& p_image, Ima if (config.etc2_supported) { - r_gl_internal_format=GL_COMPRESSED_RG11_EAC; + r_gl_internal_format=_EXT_COMPRESSED_RG11_EAC; r_gl_format=GL_RG; r_gl_type=GL_UNSIGNED_BYTE; r_compressed=true; @@ -454,7 +468,7 @@ Image RasterizerStorageGLES3::_get_gl_image_and_format(const Image& p_image, Ima case Image::FORMAT_ETC2_RG11S: { if (config.etc2_supported) { - r_gl_internal_format=GL_COMPRESSED_SIGNED_RG11_EAC; + r_gl_internal_format=_EXT_COMPRESSED_SIGNED_RG11_EAC; r_gl_format=GL_RG; r_gl_type=GL_UNSIGNED_BYTE; r_compressed=true; @@ -467,7 +481,7 @@ Image RasterizerStorageGLES3::_get_gl_image_and_format(const Image& p_image, Ima if (config.etc2_supported) { - r_gl_internal_format=(config.srgb_decode_supported || p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?GL_COMPRESSED_SRGB8_ETC2:GL_COMPRESSED_RGB8_ETC2; + r_gl_internal_format=(config.srgb_decode_supported || p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_COMPRESSED_SRGB8_ETC2:_EXT_COMPRESSED_RGB8_ETC2; r_gl_format=GL_RGB; r_gl_type=GL_UNSIGNED_BYTE; r_compressed=true; @@ -483,7 +497,7 @@ Image RasterizerStorageGLES3::_get_gl_image_and_format(const Image& p_image, Ima if (config.etc2_supported) { - r_gl_internal_format=(config.srgb_decode_supported || p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:GL_COMPRESSED_RGBA8_ETC2_EAC; + r_gl_internal_format=(config.srgb_decode_supported || p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:_EXT_COMPRESSED_RGBA8_ETC2_EAC; r_gl_format=GL_RGBA; r_gl_type=GL_UNSIGNED_BYTE; r_compressed=true; @@ -499,7 +513,7 @@ Image RasterizerStorageGLES3::_get_gl_image_and_format(const Image& p_image, Ima if (config.etc2_supported) { - r_gl_internal_format=(config.srgb_decode_supported || p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; + r_gl_internal_format=(config.srgb_decode_supported || p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:_EXT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; r_gl_format=GL_RGBA; r_gl_type=GL_UNSIGNED_BYTE; r_compressed=true; @@ -709,6 +723,32 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture,const Image& p_image glTexParameterf( texture->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); } + //set swizle for older format compatibility + switch(texture->format) { + + case Image::FORMAT_L8: { + glTexParameteri(texture->target,GL_TEXTURE_SWIZZLE_R,GL_RED); + glTexParameteri(texture->target,GL_TEXTURE_SWIZZLE_G,GL_RED); + glTexParameteri(texture->target,GL_TEXTURE_SWIZZLE_B,GL_RED); + glTexParameteri(texture->target,GL_TEXTURE_SWIZZLE_A,GL_ONE); + + } break; + case Image::FORMAT_LA8: { + + glTexParameteri(texture->target,GL_TEXTURE_SWIZZLE_R,GL_RED); + glTexParameteri(texture->target,GL_TEXTURE_SWIZZLE_G,GL_RED); + glTexParameteri(texture->target,GL_TEXTURE_SWIZZLE_B,GL_RED); + glTexParameteri(texture->target,GL_TEXTURE_SWIZZLE_A,GL_GREEN); + } break; + default: { + glTexParameteri(texture->target,GL_TEXTURE_SWIZZLE_R,GL_RED); + glTexParameteri(texture->target,GL_TEXTURE_SWIZZLE_G,GL_GREEN); + glTexParameteri(texture->target,GL_TEXTURE_SWIZZLE_B,GL_BLUE); + glTexParameteri(texture->target,GL_TEXTURE_SWIZZLE_A,GL_ALPHA); + + } break; + + } if (config.use_anisotropic_filter) { if (texture->flags&VS::TEXTURE_FLAG_ANISOTROPIC_FILTER) { @@ -782,7 +822,7 @@ Image RasterizerStorageGLES3::texture_get_data(RID p_texture,VS::CubeMapSide p_c ERR_FAIL_COND_V(texture->data_size==0,Image()); ERR_FAIL_COND_V(texture->render_target,Image()); -#ifdef GLEW_ENABLED +#ifdef GLES_OVER_GL DVector<uint8_t> data; @@ -5068,9 +5108,14 @@ void RasterizerStorageGLES3::initialize() { /// { - Vector<String> ext= String((const char*)glGetString( GL_EXTENSIONS )).split(" ",false); - for(int i=0;i<ext.size();i++) { - config.extensions.insert(ext[i]); + + int max_extensions=0; + glGetIntegerv(GL_NUM_EXTENSIONS,&max_extensions); + for(int i=0;i<max_extensions;i++) { + const GLubyte *s = glGetStringi( GL_EXTENSIONS,i ); + if (!s) + break; + config.extensions.insert((const char*)s); } } @@ -5082,7 +5127,7 @@ void RasterizerStorageGLES3::initialize() { config.etc_supported=config.extensions.has("GL_OES_compressed_ETC1_RGB8_texture"); config.latc_supported=config.extensions.has("GL_EXT_texture_compression_latc"); config.bptc_supported=config.extensions.has("GL_ARB_texture_compression_bptc"); -#ifdef GLEW_ENABLED +#ifdef GLES_OVER_GL config.etc2_supported=false; #else config.etc2_supported=true; @@ -5166,7 +5211,7 @@ void RasterizerStorageGLES3::initialize() { glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS,&config.max_texture_image_units); glGetIntegerv(GL_MAX_TEXTURE_SIZE,&config.max_texture_size); -#ifdef GLEW_ENABLED +#ifdef GLES_OVER_GL config.use_rgba_2d_shadows=false; #else config.use_rgba_2d_shadows=true; diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp index 6f0616035a..0a25f6c3b3 100644 --- a/drivers/gles3/shader_gles3.cpp +++ b/drivers/gles3/shader_gles3.cpp @@ -220,7 +220,7 @@ ShaderGLES3::Version* ShaderGLES3::get_current_version() { /* SETUP CONDITIONALS */ Vector<const char*> strings; -#ifdef GLEW_ENABLED +#ifdef GLES_OVER_GL //strings.push_back("#version 330\n"); strings.push_back("#version 300 es\n"); #else @@ -709,6 +709,8 @@ void ShaderGLES3::setup(const char** p_conditional_defines, int p_conditional_co } } + glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS,&max_image_units); + } void ShaderGLES3::finish() { @@ -804,7 +806,7 @@ ShaderGLES3::ShaderGLES3() { last_custom_code=1; uniforms_dirty = true; base_material_tex_index=0; - glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS,&max_image_units); + } |