Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
xpenatan committed May 15, 2024
1 parent d277168 commit 04957f2
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 553 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ public class PixmapEmu implements Disposable {

public static PixmapEmu createFromFrameBuffer(int x, int y, int w, int h) {
Gdx.gl.glPixelStorei(GL20.GL_PACK_ALIGNMENT, 1);

final PixmapEmu pixmap = new PixmapEmu(w, h, PixmapEmu.FormatEmu.RGBA8888);
final PixmapEmu pixmap = new PixmapEmu(w, h, FormatEmu.RGBA8888);
ByteBuffer pixels = pixmap.getPixels();
Gdx.gl.glReadPixels(x, y, w, h, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, pixels);

return pixmap;
}

Expand Down Expand Up @@ -63,7 +61,7 @@ public static int toGlType (FormatEmu format) {
return Gdx2DPixmapEmu.toGlType(toGdx2DPixmapFormat(format));
}
}

Uint8ArrayWrapper nativePixels;
ByteBuffer buffer;
BlendingEmu blending = PixmapEmu.BlendingEmu.SourceOver;
FilterEmu filter = PixmapEmu.FilterEmu.BiLinear;
Expand Down Expand Up @@ -121,12 +119,14 @@ public PixmapEmu(ByteBuffer encodedData, int offset, int len) {

public PixmapEmu(int width, int height, FormatEmu format) {
nativePixmap = new Gdx2DPixmapEmu(width, height, PixmapEmu.FormatEmu.toGdx2DPixmapFormat(format));
setColor(0, 0, 0, 0);
fill();
initPixmapEmu();
}

private void initPixmapEmu() {
if(nativePixmap != null) {
Uint8ArrayWrapper nativePixels = nativePixmap.getPixels();
nativePixels = nativePixmap.getPixels();
byte[] byteArray = TypedArrays.toByteArray(nativePixels);
buffer = ByteBuffer.wrap(byteArray);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.utils.Disposable;
import com.badlogic.gdx.utils.GdxRuntimeException;
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.Int8ArrayWrapper;
import com.github.xpenatan.gdx.backends.teavm.dom.typedarray.Uint8ArrayWrapper;
import java.io.IOException;
import com.github.xpenatan.gdx.backends.teavm.gen.Emulate;
import java.io.InputStream;
import java.nio.ByteBuffer;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSByRef;

@Emulate(Gdx2DPixmap.class)
public class Gdx2DPixmapEmu implements Disposable {
public static final int GDX2D_FORMAT_ALPHA = 1;
public static final int GDX2D_FORMAT_LUMINANCE_ALPHA = 2;
Expand Down
1 change: 0 additions & 1 deletion backends/backend-teavm/jni/gdx/src/GDX/gdx2d/gdx2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ gdx2d_pixmap* gdx2d_new(uint32_t width, uint32_t height, uint32_t format) {
free((void*)pixmap);
return 0;
}
memset(pixels, 0, size);
return pixmap;
}
void gdx2d_free(const gdx2d_pixmap* pixmap) {
Expand Down
Loading

0 comments on commit 04957f2

Please sign in to comment.