From 3dfe05f4ccd4cef6d85da2f19e9f40d8ca76add5 Mon Sep 17 00:00:00 2001 From: James Chen Date: Sat, 14 Apr 2018 13:43:44 +0800 Subject: [PATCH] glBindXXX glActiveTexture cache. --- .../cocos2d_libs.xcodeproj/project.pbxproj | 12 ++ native/cocos/Android.mk | 1 + native/cocos/base/CCGLUtils.cpp | 106 ++++++++++++++++++ native/cocos/base/CCGLUtils.h | 36 ++++++ native/cocos/math/CCGeometry.h | 1 - .../ios/CCCanvasRenderingContext2D-ios.mm | 2 +- .../mac/CCCanvasRenderingContext2D-mac.mm | 6 +- .../js-bindings/manual/jsb_opengl_manual.cpp | 99 +++++++--------- 8 files changed, 199 insertions(+), 64 deletions(-) create mode 100644 native/cocos/base/CCGLUtils.cpp create mode 100644 native/cocos/base/CCGLUtils.h diff --git a/native/build/cocos2d_libs.xcodeproj/project.pbxproj b/native/build/cocos2d_libs.xcodeproj/project.pbxproj index b83c15f621..9af004949e 100644 --- a/native/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/native/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -7,6 +7,10 @@ objects = { /* Begin PBXBuildFile section */ + 1A14FD912080B4E300E10ABE /* CCGLUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A14FD8F2080B4E300E10ABE /* CCGLUtils.cpp */; }; + 1A14FD922080B4E300E10ABE /* CCGLUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A14FD8F2080B4E300E10ABE /* CCGLUtils.cpp */; }; + 1A14FD932080B4E300E10ABE /* CCGLUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A14FD902080B4E300E10ABE /* CCGLUtils.h */; }; + 1A14FD942080B4E300E10ABE /* CCGLUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A14FD902080B4E300E10ABE /* CCGLUtils.h */; }; 1A28FF4D1F20AFAB007A1D9D /* SRDelegateController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A28FF1F1F20AFAB007A1D9D /* SRDelegateController.h */; }; 1A28FF4E1F20AFAB007A1D9D /* SRDelegateController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A28FF1F1F20AFAB007A1D9D /* SRDelegateController.h */; }; 1A28FF4F1F20AFAB007A1D9D /* SRDelegateController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A28FF201F20AFAB007A1D9D /* SRDelegateController.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; @@ -1016,6 +1020,8 @@ /* Begin PBXFileReference section */ 1551A33F158F2AB200E66CFE /* libcocos2d Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libcocos2d Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 1551A342158F2AB200E66CFE /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 1A14FD8F2080B4E300E10ABE /* CCGLUtils.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCGLUtils.cpp; sourceTree = ""; }; + 1A14FD902080B4E300E10ABE /* CCGLUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCGLUtils.h; sourceTree = ""; }; 1A28FF1F1F20AFAB007A1D9D /* SRDelegateController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SRDelegateController.h; sourceTree = ""; }; 1A28FF201F20AFAB007A1D9D /* SRDelegateController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SRDelegateController.m; sourceTree = ""; }; 1A28FF221F20AFAB007A1D9D /* SRIOConsumer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SRIOConsumer.h; sourceTree = ""; }; @@ -2264,6 +2270,8 @@ 46FDDB43202ADDCE00931238 /* CCValue.cpp */, 46FDDB44202ADDCE00931238 /* firePngData.h */, 46FDDB45202ADDCE00931238 /* ccCArray.h */, + 1A14FD8F2080B4E300E10ABE /* CCGLUtils.cpp */, + 1A14FD902080B4E300E10ABE /* CCGLUtils.h */, ); name = base; path = ../cocos/base; @@ -2981,6 +2989,7 @@ 1A28FF7D1F20AFAB007A1D9D /* SRMutex.h in Headers */, 1A28FF711F20AFAB007A1D9D /* SRHash.h in Headers */, 469301CF203FC696004A3D6C /* CCConfiguration.h in Headers */, + 1A14FD932080B4E300E10ABE /* CCGLUtils.h in Headers */, 50ABC0171926664800A911A9 /* CCImage.h in Headers */, ED30577F1BEC76C90083C3ED /* ioapi_mem.h in Headers */, 4617864B20522469008256E1 /* HttpCookie.h in Headers */, @@ -3209,6 +3218,7 @@ 46FDDC30202AEAC500931238 /* Assertions.h in Headers */, 4617862620522469008256E1 /* CCDownloader.h in Headers */, 46FDDBD2202ADDCE00931238 /* ccUTF8.h in Headers */, + 1A14FD942080B4E300E10ABE /* CCGLUtils.h in Headers */, 46FDDC2A202AEAC500931238 /* Casting.h in Headers */, 50ABBD5F1925AB0000A911A9 /* Vec3.h in Headers */, 46FDDC02202ADDCE00931238 /* ccCArray.h in Headers */, @@ -3395,6 +3405,7 @@ BA68D78D1D62F4A500B7A3F9 /* sweep.cc in Sources */, 4693042E2046AE06004A3D6C /* jsb_helper.cpp in Sources */, 1A52DB31205BCD9200350EE3 /* inspector_agent.cc in Sources */, + 1A14FD912080B4E300E10ABE /* CCGLUtils.cpp in Sources */, 469303A02046AE05004A3D6C /* ScriptEngine.mm in Sources */, 46FDDAB5202ACC6A00931238 /* Program.cpp in Sources */, 46FDDBF9202ADDCE00931238 /* etc1.cpp in Sources */, @@ -3646,6 +3657,7 @@ 469304092046AE06004A3D6C /* jsb_global.cpp in Sources */, 46FDDA70202ACC6A00931238 /* Pass.cpp in Sources */, 1A52DB7A205BCDD000350EE3 /* ScriptEngine.cpp in Sources */, + 1A14FD922080B4E300E10ABE /* CCGLUtils.cpp in Sources */, 46FDDBBA202ADDCE00931238 /* CCNS.cpp in Sources */, 1A28FF741F20AFAB007A1D9D /* SRHash.m in Sources */, 46FDDB70202ADDCE00931238 /* ZipUtils.cpp in Sources */, diff --git a/native/cocos/Android.mk b/native/cocos/Android.mk index cff9bb4c6c..77290a0b1e 100644 --- a/native/cocos/Android.mk +++ b/native/cocos/Android.mk @@ -51,6 +51,7 @@ base/pvr.cpp \ base/CCLog.cpp \ base/CCScheduler.cpp \ base/csscolorparser.cpp \ +base/CCGLUtils.cpp \ renderer/Types.cpp \ renderer/gfx/DeviceGraphics.cpp \ renderer/gfx/FrameBuffer.cpp \ diff --git a/native/cocos/base/CCGLUtils.cpp b/native/cocos/base/CCGLUtils.cpp new file mode 100644 index 0000000000..44df7b70b5 --- /dev/null +++ b/native/cocos/base/CCGLUtils.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** + Copyright (c) 2018 Xiamen Yaji Software Co., Ltd. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCGLUtils.h" +#include + +NS_CC_BEGIN + +namespace { + const int MAX_ACTIVE_TEXTURE = 16; + GLuint __currentArrayBufferId = -1; + GLuint __currentElementArrayBufferId = -1; + GLenum __activeTexture = -1; + GLuint __currentBoundTexture[MAX_ACTIVE_TEXTURE] = { + (GLuint)-1,(GLuint)-1,(GLuint)-1,(GLuint)-1, + (GLuint)-1,(GLuint)-1,(GLuint)-1,(GLuint)-1, + (GLuint)-1,(GLuint)-1,(GLuint)-1,(GLuint)-1, + (GLuint)-1,(GLuint)-1,(GLuint)-1,(GLuint)-1 + }; +} + +void ccActiveTexture(GLenum texture) +{ + if (__activeTexture != texture) + { + __activeTexture = texture; + glActiveTexture(__activeTexture); + } +} + +void ccBindBuffer(GLenum target, GLuint buffer) +{ + if (target == GL_ARRAY_BUFFER) + { + if (__currentArrayBufferId != buffer) + { + __currentArrayBufferId = buffer; + glBindBuffer(target, buffer); + } + else + { + printf("glBindBuffer(GL_ARRAY_BUFFER, %u) isn't needed!\n", buffer); + } + } + else if (target == GL_ELEMENT_ARRAY_BUFFER) + { + if (__currentElementArrayBufferId != buffer) + { + __currentElementArrayBufferId = buffer; + glBindBuffer(target, buffer); + } + else + { + printf("glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, %u) isn't needed!\n", buffer); + } + } + else + { + glBindBuffer(target, buffer); + } +} + +void ccBindTexture(GLenum target, GLuint texture) +{ + if (target == GL_TEXTURE_2D) + { + GLuint textureUnit = __activeTexture - GL_TEXTURE0; + CCASSERT(textureUnit < MAX_ACTIVE_TEXTURE, "textureUnit is too big"); + if (__currentBoundTexture[textureUnit] != texture) + { + __currentBoundTexture[textureUnit] = texture; + glBindTexture(target, texture); + } + else + { + printf("glBindTexture(GL_TEXTURE_2D, %u) isn't needed!\n", texture); + } + } + else + { + glBindTexture(target, texture); + } +} + +NS_CC_END diff --git a/native/cocos/base/CCGLUtils.h b/native/cocos/base/CCGLUtils.h new file mode 100644 index 0000000000..4d4d0590af --- /dev/null +++ b/native/cocos/base/CCGLUtils.h @@ -0,0 +1,36 @@ +/**************************************************************************** + Copyright (c) 2018 Xiamen Yaji Software Co., Ltd. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#pragma once + +#include "base/ccMacros.h" +#include "platform/CCGL.h" + +NS_CC_BEGIN + +void ccActiveTexture(GLenum texture); +void ccBindBuffer(GLenum target, GLuint buffer); +void ccBindTexture(GLenum target, GLuint texture); + +NS_CC_END diff --git a/native/cocos/math/CCGeometry.h b/native/cocos/math/CCGeometry.h index 4fc12c046f..2ca95ed389 100644 --- a/native/cocos/math/CCGeometry.h +++ b/native/cocos/math/CCGeometry.h @@ -27,7 +27,6 @@ THE SOFTWARE. #ifndef __MATH_CCGEOMETRY_H__ #define __MATH_CCGEOMETRY_H__ -#include "base/ccMacros.h" #include "base/ccMacros.h" #include "math/CCMath.h" diff --git a/native/cocos/platform/ios/CCCanvasRenderingContext2D-ios.mm b/native/cocos/platform/ios/CCCanvasRenderingContext2D-ios.mm index 4bd22fe51e..4046514157 100644 --- a/native/cocos/platform/ios/CCCanvasRenderingContext2D-ios.mm +++ b/native/cocos/platform/ios/CCCanvasRenderingContext2D-ios.mm @@ -285,7 +285,7 @@ namespace { if (rect.size.width < 1 || rect.size.height < 1) return; //TODO: - assert(rect.origin.x == 0 && rect.origin.y == 0); +// assert(rect.origin.x == 0 && rect.origin.y == 0); memset((void*)_imageData.getBytes(), 0x00, _imageData.getSize()); } diff --git a/native/cocos/platform/mac/CCCanvasRenderingContext2D-mac.mm b/native/cocos/platform/mac/CCCanvasRenderingContext2D-mac.mm index 447601114d..ac918acdcc 100644 --- a/native/cocos/platform/mac/CCCanvasRenderingContext2D-mac.mm +++ b/native/cocos/platform/mac/CCCanvasRenderingContext2D-mac.mm @@ -277,9 +277,9 @@ namespace { if (rect.size.width < 1 || rect.size.height < 1) return; //TODO: - assert(rect.origin.x == 0 && rect.origin.y == 0); +// assert(rect.origin.x == 0 && rect.origin.y == 0); // NSLog(@"clearRect, image:%f, %f", _image.size.width, _image.size.height); - assert(rect.size.width <= _image.size.width && rect.size.height <= _image.size.height); +// assert(rect.size.width <= _image.size.width && rect.size.height <= _image.size.height); [_image lockFocus]; [[NSColor clearColor] set]; @@ -378,7 +378,7 @@ void CanvasRenderingContext2D::fillRect(float x, float y, float width, float hei void CanvasRenderingContext2D::fillText(const std::string& text, float x, float y, float maxWidth) { -// SE_LOGD("CanvasRenderingContext2D::fillText: %s, %f, %f, %f\n", text.c_str(), x, y, maxWidth); + SE_LOGD("CanvasRenderingContext2D(%p)::fillText: %s, %f, %f, %f\n", this, text.c_str(), x, y, maxWidth); if (text.empty()) return; if (_isBufferSizeDirty) diff --git a/native/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp b/native/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp index 0b6206a3ba..c4d4fa9eea 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp @@ -29,9 +29,12 @@ #include "cocos/scripting/js-bindings/manual/jsb_global.h" #include "cocos/scripting/js-bindings/manual/jsb_opengl_utils.hpp" #include "platform/CCGL.h" +#include "cocos/base/CCGLUtils.h" #include +using namespace cocos2d; + namespace { const uint32_t GL_COMMAND_ACTIVE_TEXTURE = 0; @@ -160,7 +163,7 @@ namespace { bool __unpackFlipY = false; bool __premultiplyAlpha = false; - void WEBGL_framebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) + inline void WEBGL_framebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) { if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { @@ -173,7 +176,7 @@ namespace { } } - void WEBGL_renderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) + inline void WEBGL_renderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) { if (internalformat == GL_DEPTH_STENCIL ) internalformat = GL_DEPTH24_STENCIL8; @@ -181,6 +184,27 @@ namespace { glRenderbufferStorage(target, internalformat, width, height); } + inline void WEBGL_pixelStorei(GLenum pname, GLint param) + { + if (pname == GL_UNPACK_FLIP_Y_WEBGL) + { + __unpackFlipY = param == 0 ? false : true; + return; + } + else if (pname == GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL) + { + __premultiplyAlpha = param == 0 ? false : true; + return; + } + else if (pname == GL_UNPACK_COLORSPACE_CONVERSION_WEBGL) + { + SE_LOGE("Warning: UNPACK_COLORSPACE_CONVERSION_WEBGL is unsupported\n"); + return; + } + + glPixelStorei(pname, param); + } + class WebGLObject { public: @@ -628,7 +652,7 @@ static bool JSB_glActiveTexture(se::State& s) { ok &= seval_to_uint32(args[0], &arg0 ); SE_PRECONDITION2(ok, false, "Error processing arguments"); - JSB_GL_CHECK(glActiveTexture((GLenum)arg0)); + JSB_GL_CHECK(ccActiveTexture((GLenum)arg0)); return true; } @@ -678,12 +702,7 @@ static bool JSB_glBindAttribLocation(se::State& s) { } SE_BIND_FUNC(JSB_glBindAttribLocation) -uint32_t __bindBufferCount = 0; - -// Arguments: GLenum, GLuint -// Ret value: void static bool JSB_glBindBuffer(se::State& s) { - ++__bindBufferCount; const auto& args = s.args(); int argc = (int)args.size(); SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); @@ -694,7 +713,7 @@ static bool JSB_glBindBuffer(se::State& s) { ok &= seval_to_native_ptr(args[1], &arg1 ); SE_PRECONDITION2(ok, false, "Error processing arguments"); GLuint bufferId = arg1 != nullptr ? arg1->_id : 0; - JSB_GL_CHECK(glBindBuffer((GLenum)arg0 , bufferId)); + JSB_GL_CHECK(ccBindBuffer((GLenum)arg0 , bufferId)); return true; } SE_BIND_FUNC(JSB_glBindBuffer) @@ -752,8 +771,7 @@ static bool JSB_glBindTexture(se::State& s) { SE_PRECONDITION2(ok, false, "Error processing arguments"); GLuint textureId = arg1 != nullptr ? arg1->_id : 0; - JSB_GL_CHECK(glBindTexture((GLenum)arg0 , textureId)); - + JSB_GL_CHECK(ccBindTexture((GLenum)arg0 , textureId)); return true; } SE_BIND_FUNC(JSB_glBindTexture) @@ -1847,24 +1865,7 @@ static bool JSB_glPixelStorei(se::State& s) { ok &= seval_to_int32(args[1], &arg1 ); SE_PRECONDITION2(ok, false, "Error processing arguments"); - if (arg0 == GL_UNPACK_FLIP_Y_WEBGL) - { - __unpackFlipY = arg1 == 0 ? false : true; - return true; - } - else if (arg0 == GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL) - { - __premultiplyAlpha = arg1 == 0 ? false : true; - return true; - } - else if (arg0 == GL_UNPACK_COLORSPACE_CONVERSION_WEBGL) - { - SE_LOGE("Warning: UNPACK_COLORSPACE_CONVERSION_WEBGL is unsupported\n"); - return true; - } - - JSB_GL_CHECK(glPixelStorei((GLenum)arg0 , (GLint)arg1 )); - + JSB_GL_CHECK(WEBGL_pixelStorei((GLenum)arg0 , (GLint)arg1 )); return true; } SE_BIND_FUNC(JSB_glPixelStorei) @@ -2197,9 +2198,7 @@ static bool JSB_glTexParameteri(se::State& s) { ok &= seval_to_uint32(args[1], &arg1 ); ok &= seval_to_int32(args[2], &arg2 ); SE_PRECONDITION2(ok, false, "Error processing arguments"); - JSB_GL_CHECK(glTexParameteri((GLenum)arg0 , (GLenum)arg1 , (GLint)arg2 )); - return true; } SE_BIND_FUNC(JSB_glTexParameteri) @@ -2672,13 +2671,12 @@ static bool JSB_glValidateProgram(se::State& s) { int argc = (int)args.size(); SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); + WebGLProgram* arg0; + ok &= seval_to_native_ptr(args[0], &arg0); SE_PRECONDITION2(ok, false, "Error processing arguments"); - JSB_GL_CHECK(glValidateProgram((GLuint)arg0 )); - + GLuint id = arg0 != nullptr ? arg0->_id : 0; + JSB_GL_CHECK(glValidateProgram(id)); return true; } SE_BIND_FUNC(JSB_glValidateProgram) @@ -3788,7 +3786,7 @@ static bool JSB_glFlushCommand(se::State& s) { testindex++; uint32_t commandID = (uint32_t)p[0]; if (commandID == GL_COMMAND_ACTIVE_TEXTURE) { - JSB_GL_CHECK(glActiveTexture((GLenum)p[1])); + JSB_GL_CHECK(ccActiveTexture((GLenum)p[1])); p += 2; } else if (commandID == GL_COMMAND_ATTACH_SHADER) { @@ -3796,7 +3794,8 @@ static bool JSB_glFlushCommand(se::State& s) { p += 3; } else if (commandID == GL_COMMAND_BIND_BUFFER) { - JSB_GL_CHECK(glBindBuffer((GLenum)p[1], (GLuint)p[2])); + GLuint bufferId = (GLuint)p[2]; + JSB_GL_CHECK(ccBindBuffer((GLenum)p[1], bufferId)); p += 3; } else if (commandID == GL_COMMAND_BIND_FRAME_BUFFER) { @@ -3811,7 +3810,7 @@ static bool JSB_glFlushCommand(se::State& s) { p += 3; } else if (commandID == GL_COMMAND_BIND_TEXTURE) { - JSB_GL_CHECK(glBindTexture((GLenum)p[1], (GLuint)p[2])); + JSB_GL_CHECK(ccBindTexture((GLenum)p[1], (GLuint)p[2])); p += 3; } else if (commandID == GL_COMMAND_BLEND_COLOR) { @@ -3983,25 +3982,7 @@ static bool JSB_glFlushCommand(se::State& s) { p += 2; } else if (commandID == GL_COMMAND_PIXEL_STOREI) { - GLenum arg0 = p[1]; - GLint arg1 = (GLint)p[2]; - if (arg0 == GL_UNPACK_FLIP_Y_WEBGL) - { - __unpackFlipY = arg1 == 0 ? false : true; - return true; - } - else if (arg0 == GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL) - { - __premultiplyAlpha = arg1 == 0 ? false : true; - return true; - } - else if (arg0 == GL_UNPACK_COLORSPACE_CONVERSION_WEBGL) - { - SE_LOGE("Warning: UNPACK_COLORSPACE_CONVERSION_WEBGL is unsupported\n"); - return true; - } - - JSB_GL_CHECK(glPixelStorei(arg0, arg1)); + JSB_GL_CHECK(WEBGL_pixelStorei((GLenum)p[1], (GLint)p[2])); p += 3; } else if (commandID == GL_COMMAND_POLYGON_OFFSET) { @@ -4378,7 +4359,7 @@ bool JSB_register_opengl(se::Object* obj) __glObj->defineFunction("uniformMatrix3fv", _SE(JSB_glUniformMatrix3fv)); __glObj->defineFunction("uniformMatrix4fv", _SE(JSB_glUniformMatrix4fv)); __glObj->defineFunction("useProgram", _SE(JSB_glUseProgram)); - __glObj->defineFunction("_validateProgram", _SE(JSB_glValidateProgram)); + __glObj->defineFunction("validateProgram", _SE(JSB_glValidateProgram)); __glObj->defineFunction("vertexAttrib1f", _SE(JSB_glVertexAttrib1f)); __glObj->defineFunction("vertexAttrib1fv", _SE(JSB_glVertexAttrib1fv)); __glObj->defineFunction("vertexAttrib2f", _SE(JSB_glVertexAttrib2f));