mirror of https://github.com/buggins/dlangui.git
Scene3d Texture colors fixed
This commit is contained in:
parent
8d882659e3
commit
156ce94f37
src/dlangui/graphics
|
@ -970,17 +970,29 @@ class ColorDrawBuf : ColorDrawBufBase {
|
||||||
fill(0xFFFFFFFF);
|
fill(0xFFFFFFFF);
|
||||||
drawRescaled(Rect(0, 0, dx, dy), v, Rect(0, 0, v.width, v.height));
|
drawRescaled(Rect(0, 0, dx, dy), v, Rect(0, 0, v.width, v.height));
|
||||||
}
|
}
|
||||||
|
|
||||||
void invertAlpha() {
|
void invertAlpha() {
|
||||||
foreach(ref pixel; _buf)
|
foreach(ref pixel; _buf)
|
||||||
pixel ^= 0xFF000000;
|
pixel ^= 0xFF000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
void invertByteOrder() {
|
void invertByteOrder() {
|
||||||
foreach(pixel; _buf) {
|
foreach(ref pixel; _buf) {
|
||||||
pixel = (pixel & 0xFF00FF00) |
|
pixel = (pixel & 0xFF00FF00) |
|
||||||
((pixel & 0xFF0000) >> 16) |
|
((pixel & 0xFF0000) >> 16) |
|
||||||
((pixel & 0xFF) << 16);
|
((pixel & 0xFF) << 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// for passing of image to OpenGL texture
|
||||||
|
void invertAlphaAndByteOrder() {
|
||||||
|
foreach(ref pixel; _buf) {
|
||||||
|
pixel = ((pixel & 0xFF00FF00) |
|
||||||
|
((pixel & 0xFF0000) >> 16) |
|
||||||
|
((pixel & 0xFF) << 16));
|
||||||
|
pixel ^= 0xFF000000;
|
||||||
|
}
|
||||||
|
}
|
||||||
override uint * scanLine(int y) {
|
override uint * scanLine(int y) {
|
||||||
if (y >= 0 && y < _dy)
|
if (y >= 0 && y < _dy)
|
||||||
return _buf.ptr + _dx * y;
|
return _buf.ptr + _dx * y;
|
||||||
|
|
|
@ -852,14 +852,14 @@ static class GLTexture : RefCountedObject {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint * pixels = buf.scanLine(0);
|
uint * pixels = buf.scanLine(0);
|
||||||
buf.invertAlpha();
|
buf.invertAlphaAndByteOrder();
|
||||||
if (!glSupport.setTextureImage(_texture, buf.width, buf.height, cast(ubyte*)pixels, mipmapLevels)) {
|
if (!glSupport.setTextureImage(_texture, buf.width, buf.height, cast(ubyte*)pixels, mipmapLevels)) {
|
||||||
destroy(_texture);
|
destroy(_texture);
|
||||||
_texture = null;
|
_texture = null;
|
||||||
buf.invertAlpha();
|
buf.invertAlphaAndByteOrder();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
buf.invertAlpha();
|
buf.invertAlphaAndByteOrder();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue