Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions Sources/kha/graphics4/Graphics2.hx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ class ImageShaderPainter {

g.setTexture(pipeline.textureLocation, null);

if (end || (bufferStart + bufferIndex + 1) * 4 >= bufferSize) {
if (end || bufferIndex + 1 >= bufferSize) {
bufferStart = 0;
bufferIndex = 0;
rectVertices = rectVertexBuffer.lock(0);
Expand All @@ -288,7 +288,7 @@ class ImageShaderPainter {
public inline function drawImage(img: kha.Image, bottomleftx: FastFloat, bottomlefty: FastFloat, topleftx: FastFloat, toplefty: FastFloat,
toprightx: FastFloat, toprighty: FastFloat, bottomrightx: FastFloat, bottomrighty: FastFloat, opacity: FastFloat, color: Color): Void {
var tex = img;
if (bufferStart + bufferIndex + 1 >= bufferSize || (lastTexture != null && tex != lastTexture))
if (bufferIndex + 1 >= bufferSize || (lastTexture != null && tex != lastTexture))
drawBuffer(false);

setRectColor(color.R, color.G, color.B, color.A * opacity);
Expand All @@ -303,7 +303,7 @@ class ImageShaderPainter {
bottomlefty: FastFloat, topleftx: FastFloat, toplefty: FastFloat, toprightx: FastFloat, toprighty: FastFloat, bottomrightx: FastFloat,
bottomrighty: FastFloat, opacity: FastFloat, color: Color): Void {
var tex = img;
if (bufferStart + bufferIndex + 1 >= bufferSize || (lastTexture != null && tex != lastTexture))
if (bufferIndex + 1 >= bufferSize || (lastTexture != null && tex != lastTexture))
drawBuffer(false);

setRectTexCoords(sx / tex.realWidth, sy / tex.realHeight, (sx + sw) / tex.realWidth, (sy + sh) / tex.realHeight);
Expand All @@ -314,20 +314,6 @@ class ImageShaderPainter {
lastTexture = tex;
}

public inline function drawImageScale(img: kha.Image, sx: FastFloat, sy: FastFloat, sw: FastFloat, sh: FastFloat, left: FastFloat, top: FastFloat,
right: FastFloat, bottom: FastFloat, opacity: FastFloat, color: Color): Void {
var tex = img;
if (bufferStart + bufferIndex + 1 >= bufferSize || (lastTexture != null && tex != lastTexture))
drawBuffer(false);

setRectTexCoords(sx / tex.realWidth, sy / tex.realHeight, (sx + sw) / tex.realWidth, (sy + sh) / tex.realHeight);
setRectColor(color.R, color.G, color.B, opacity);
setRectVertices(left, bottom, left, top, right, top, right, bottom);

++bufferIndex;
lastTexture = tex;
}

public function end(): Void {
if (bufferIndex > 0) {
drawBuffer(true);
Expand Down
Loading