mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user