Init layers as fully black (transparent if alpha channel is enabled)

This commit is contained in:
Marcel Hellkamp 2018-03-29 15:55:55 +02:00
parent 003a7f0938
commit 7269957ce5

View file

@ -46,18 +46,7 @@ static CanvasLayer* canvas_layer_alloc(int size, int alpha) {
layer->format = alpha ? GL_RGBA : GL_RGB; layer->format = alpha ? GL_RGBA : GL_RGB;
layer->mem = size * size * (alpha ? 4 : 3); layer->mem = size * size * (alpha ? 4 : 3);
layer->data = malloc(sizeof(GLubyte) * layer->mem); layer->data = malloc(sizeof(GLubyte) * layer->mem);
memset(layer->data, 0, layer->mem);
GLubyte* pt;
for(int x=0; x<size; x++) {
for(int y=0; y<size; y++) {
pt = layer->data + (((y * size) + x) * (alpha ? 4 : 3));
pt[0] = x%255;
pt[1] = y%255;
if(alpha)
pt[3] = 0;
}
}
return layer; return layer;
} }