Init layers as fully black (transparent if alpha channel is enabled)
This commit is contained in:
parent
003a7f0938
commit
7269957ce5
1 changed files with 1 additions and 12 deletions
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue