Created
August 20, 2014 07:01
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sprite *createBlankSprite(const Color4B& color, Size size) | |
{ | |
GLubyte *buffer = (GLubyte *)malloc(sizeof(GLubyte)*4); | |
buffer[0] = color.r; | |
buffer[1] = color.g; | |
buffer[2] = color.b; | |
buffer[3] = color.a; | |
auto tex = new Texture2D(); | |
tex->initWithData(buffer, sizeof(GLubyte)*4, Texture2D::PixelFormat::RGBA8888, 1, 1, size); | |
auto sprite = Sprite::create(); | |
sprite->setTexture(tex); | |
sprite->setTextureRect(Rect(0, 0, size.width, size.height)); | |
tex->release(); | |
free(buffer); | |
return sprite; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment