Move logic of flipY and premultiplyAlpha from jsb_opengl_manual.cpp to CCGLUtils.cpp. (#1249)

* Native Renderer supports GL_UNPACK_FLIP_Y_WEBGL & GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL.
And adds ccFlipYOrPremultiptyAlphaIfNeeded, ccIsUnpackFlipY, ccIsPremultiplyAlpha, ccPixelStorei GL utils.

* seval_to_TextureSubImageOption: uint16_t* -> uint32_t* since width * height * 4 may bigger than 65536 bytes.

* Move logic of flipY and premultiplyAlpha from jsb_opengl_manual.cpp to CCGLUtils.cpp.

* Reverts.
This commit is contained in:
James Chen
2018-05-18 15:53:28 +08:00
committed by minggo
parent 8a76997242
commit ee5faac763
7 changed files with 302 additions and 201 deletions
+11
View File
@@ -340,6 +340,17 @@ void RenderTexture::initTexture()
glBindTexture(GL_TEXTURE_2D, _texture);
unsigned char* texData = (unsigned char*)malloc(_width * _height * 3);
memset(texData, 0, _width * _height * 3);
GLint alignment = 1;
int bytesPerRow = _width * 3;
if (bytesPerRow % 8 == 0)
alignment = 8;
else if (bytesPerRow % 4 == 0)
alignment = 4;
else if (bytesPerRow % 2 == 0)
alignment = 2;
glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGB,