Skip to content

Instantly share code, notes, and snippets.

@Mazyod
Created August 20, 2014 07:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mazyod/208e5fb2d7a56290a261 to your computer and use it in GitHub Desktop.
Save Mazyod/208e5fb2d7a56290a261 to your computer and use it in GitHub Desktop.
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