Update #50 - Bug fixes and shader improvements

This commit is contained in:
lax1dude
2025-02-22 16:52:35 -08:00
parent b0a2739fe1
commit 7e772e2502
133 changed files with 3064 additions and 2299 deletions

View File

@ -51,13 +51,13 @@ class OpenGLObjects {
}
static class BufferArrayGL implements IBufferArrayGL {
static class VertexArrayGL implements IVertexArrayGL {
private static int hashGen = 0;
final WebGLVertexArray ptr;
final int hash;
BufferArrayGL(WebGLVertexArray ptr) {
VertexArrayGL(WebGLVertexArray ptr) {
this.ptr = ptr;
this.hash = ++hashGen;
}

View File

@ -405,7 +405,6 @@ public class PlatformInput {
handleWindowFocus();
SortedTouchEvent sorted = new SortedTouchEvent(evt, touchUIDMapperCreate);
currentTouchState = sorted;
List<OffsetTouch> lst = sorted.getEventTouches();
synchronized(touchEvents) {
touchEvents.add(sorted);
if(touchEvents.size() > 64) {

View File

@ -149,7 +149,7 @@ public class PlatformOpenGL {
}
}
public static final List<String> dumpActiveExtensions() {
public static List<String> dumpActiveExtensions() {
List<String> exts = new ArrayList<>();
if(hasANGLEInstancedArrays) exts.add("ANGLE_instanced_arrays");
if(hasEXTColorBufferFloat) exts.add("EXT_color_buffer_float");
@ -166,64 +166,64 @@ public class PlatformOpenGL {
return exts;
}
public static final void _wglEnable(int glEnum) {
public static void _wglEnable(int glEnum) {
ctx.enable(glEnum);
}
public static final void _wglDisable(int glEnum) {
public static void _wglDisable(int glEnum) {
ctx.disable(glEnum);
}
public static final void _wglClearColor(float r, float g, float b, float a) {
public static void _wglClearColor(float r, float g, float b, float a) {
ctx.clearColor(r, g, b, a);
}
public static final void _wglClearDepth(float f) {
public static void _wglClearDepth(float f) {
ctx.clearDepth(f);
}
public static final void _wglClear(int bits) {
public static void _wglClear(int bits) {
ctx.clear(bits);
}
public static final void _wglDepthFunc(int glEnum) {
public static void _wglDepthFunc(int glEnum) {
ctx.depthFunc(glEnum);
}
public static final void _wglDepthMask(boolean mask) {
public static void _wglDepthMask(boolean mask) {
ctx.depthMask(mask);
}
public static final void _wglCullFace(int glEnum) {
public static void _wglCullFace(int glEnum) {
ctx.cullFace(glEnum);
}
public static final void _wglViewport(int x, int y, int w, int h) {
public static void _wglViewport(int x, int y, int w, int h) {
ctx.viewport(x, y, w, h);
}
public static final void _wglBlendFunc(int src, int dst) {
public static void _wglBlendFunc(int src, int dst) {
ctx.blendFunc(src, dst);
}
public static final void _wglBlendFuncSeparate(int srcColor, int dstColor,
public static void _wglBlendFuncSeparate(int srcColor, int dstColor,
int srcAlpha, int dstAlpha) {
ctx.blendFuncSeparate(srcColor, dstColor, srcAlpha, dstAlpha);
}
public static final void _wglBlendEquation(int glEnum) {
public static void _wglBlendEquation(int glEnum) {
ctx.blendEquation(glEnum);
}
public static final void _wglBlendColor(float r, float g, float b, float a) {
public static void _wglBlendColor(float r, float g, float b, float a) {
ctx.blendColor(r, g, b, a);
}
public static final void _wglColorMask(boolean r, boolean g, boolean b, boolean a) {
public static void _wglColorMask(boolean r, boolean g, boolean b, boolean a) {
ctx.colorMask(r, g, b, a);
}
public static final void _wglDrawBuffers(int buffer) {
public static void _wglDrawBuffers(int buffer) {
if(glesVers == 200) {
if(buffer != 0x8CE0) { // GL_COLOR_ATTACHMENT0
throw new UnsupportedOperationException();
@ -233,7 +233,7 @@ public class PlatformOpenGL {
}
}
public static final void _wglDrawBuffers(int[] buffers) {
public static void _wglDrawBuffers(int[] buffers) {
if(glesVers == 200) {
if(buffers.length != 1 || buffers[0] != 0x8CE0) { // GL_COLOR_ATTACHMENT0
throw new UnsupportedOperationException();
@ -243,83 +243,83 @@ public class PlatformOpenGL {
}
}
public static final void _wglReadBuffer(int buffer) {
public static void _wglReadBuffer(int buffer) {
ctx.readBuffer(buffer);
}
public static final void _wglReadPixels(int x, int y, int width, int height, int format, int type, ByteBuffer data) {
public static void _wglReadPixels(int x, int y, int width, int height, int format, int type, ByteBuffer data) {
ctx.readPixels(x, y, width, height, format, type, EaglerArrayBufferAllocator.getDataView8Unsigned(data));
}
public static final void _wglReadPixels_u16(int x, int y, int width, int height, int format, int type, ByteBuffer data) {
public static void _wglReadPixels_u16(int x, int y, int width, int height, int format, int type, ByteBuffer data) {
ctx.readPixels(x, y, width, height, format, type, EaglerArrayBufferAllocator.getDataView16Unsigned(data));
}
public static final void _wglReadPixels(int x, int y, int width, int height, int format, int type, IntBuffer data) {
public static void _wglReadPixels(int x, int y, int width, int height, int format, int type, IntBuffer data) {
ctx.readPixels(x, y, width, height, format, type, EaglerArrayBufferAllocator.getDataView32(data));
}
public static final void _wglReadPixels(int x, int y, int width, int height, int format, int type, FloatBuffer data) {
public static void _wglReadPixels(int x, int y, int width, int height, int format, int type, FloatBuffer data) {
ctx.readPixels(x, y, width, height, format, type, EaglerArrayBufferAllocator.getDataView32F(data));
}
public static final void _wglPolygonOffset(float f1, float f2) {
public static void _wglPolygonOffset(float f1, float f2) {
ctx.polygonOffset(f1, f2);
}
public static final void _wglLineWidth(float width) {
public static void _wglLineWidth(float width) {
ctx.lineWidth(width);
}
public static final IBufferGL _wglGenBuffers() {
public static IBufferGL _wglGenBuffers() {
return new OpenGLObjects.BufferGL(ctx.createBuffer());
}
public static final ITextureGL _wglGenTextures() {
public static ITextureGL _wglGenTextures() {
return new OpenGLObjects.TextureGL(ctx.createTexture());
}
public static final IBufferArrayGL _wglGenVertexArrays() {
public static IVertexArrayGL _wglGenVertexArrays() {
switch(vertexArrayImpl) {
case VAO_IMPL_CORE:
return new OpenGLObjects.BufferArrayGL(ctx.createVertexArray());
return new OpenGLObjects.VertexArrayGL(ctx.createVertexArray());
case VAO_IMPL_OES:
return new OpenGLObjects.BufferArrayGL(OESVertexArrayObject.createVertexArrayOES());
return new OpenGLObjects.VertexArrayGL(OESVertexArrayObject.createVertexArrayOES());
default:
throw new UnsupportedOperationException();
}
}
public static final IProgramGL _wglCreateProgram() {
public static IProgramGL _wglCreateProgram() {
return new OpenGLObjects.ProgramGL(ctx.createProgram());
}
public static final IShaderGL _wglCreateShader(int type) {
public static IShaderGL _wglCreateShader(int type) {
return new OpenGLObjects.ShaderGL(ctx.createShader(type));
}
public static final IFramebufferGL _wglCreateFramebuffer() {
public static IFramebufferGL _wglCreateFramebuffer() {
return new OpenGLObjects.FramebufferGL(ctx.createFramebuffer());
}
public static final IRenderbufferGL _wglCreateRenderbuffer() {
public static IRenderbufferGL _wglCreateRenderbuffer() {
return new OpenGLObjects.RenderbufferGL(ctx.createRenderbuffer());
}
public static final IQueryGL _wglGenQueries() {
public static IQueryGL _wglGenQueries() {
return new OpenGLObjects.QueryGL(ctx.createQuery());
}
public static final void _wglDeleteBuffers(IBufferGL obj) {
public static void _wglDeleteBuffers(IBufferGL obj) {
ctx.deleteBuffer(((OpenGLObjects.BufferGL)obj).ptr);
}
public static final void _wglDeleteTextures(ITextureGL obj) {
public static void _wglDeleteTextures(ITextureGL obj) {
ctx.deleteTexture(((OpenGLObjects.TextureGL)obj).ptr);
}
public static final void _wglDeleteVertexArrays(IBufferArrayGL obj) {
WebGLVertexArray ptr = ((OpenGLObjects.BufferArrayGL)obj).ptr;
public static void _wglDeleteVertexArrays(IVertexArrayGL obj) {
WebGLVertexArray ptr = ((OpenGLObjects.VertexArrayGL)obj).ptr;
switch(vertexArrayImpl) {
case VAO_IMPL_CORE:
ctx.deleteVertexArray(ptr);
@ -332,60 +332,60 @@ public class PlatformOpenGL {
}
}
public static final void _wglDeleteProgram(IProgramGL obj) {
public static void _wglDeleteProgram(IProgramGL obj) {
ctx.deleteProgram(((OpenGLObjects.ProgramGL)obj).ptr);
}
public static final void _wglDeleteShader(IShaderGL obj) {
public static void _wglDeleteShader(IShaderGL obj) {
ctx.deleteShader(((OpenGLObjects.ShaderGL)obj).ptr);
}
public static final void _wglDeleteFramebuffer(IFramebufferGL obj) {
public static void _wglDeleteFramebuffer(IFramebufferGL obj) {
ctx.deleteFramebuffer(((OpenGLObjects.FramebufferGL)obj).ptr);
}
public static final void _wglDeleteRenderbuffer(IRenderbufferGL obj) {
public static void _wglDeleteRenderbuffer(IRenderbufferGL obj) {
ctx.deleteRenderbuffer(((OpenGLObjects.RenderbufferGL)obj).ptr);
}
public static final void _wglDeleteQueries(IQueryGL obj) {
public static void _wglDeleteQueries(IQueryGL obj) {
ctx.deleteQuery(((OpenGLObjects.QueryGL)obj).ptr);
}
public static final void _wglBindBuffer(int target, IBufferGL obj) {
public static void _wglBindBuffer(int target, IBufferGL obj) {
ctx.bindBuffer(target, obj != null ? ((OpenGLObjects.BufferGL)obj).ptr : null);
}
public static final void _wglBufferData(int target, ByteBuffer data, int usage) {
public static void _wglBufferData(int target, ByteBuffer data, int usage) {
ctx.bufferData(target, EaglerArrayBufferAllocator.getDataView8(data), usage);
}
public static final void _wglBufferData(int target, IntBuffer data, int usage) {
public static void _wglBufferData(int target, IntBuffer data, int usage) {
ctx.bufferData(target, EaglerArrayBufferAllocator.getDataView32(data), usage);
}
public static final void _wglBufferData(int target, FloatBuffer data, int usage) {
public static void _wglBufferData(int target, FloatBuffer data, int usage) {
ctx.bufferData(target, EaglerArrayBufferAllocator.getDataView32F(data), usage);
}
public static final void _wglBufferData(int target, int size, int usage) {
public static void _wglBufferData(int target, int size, int usage) {
ctx.bufferData(target, size, usage);
}
public static final void _wglBufferSubData(int target, int offset, ByteBuffer data) {
public static void _wglBufferSubData(int target, int offset, ByteBuffer data) {
ctx.bufferSubData(target, offset, EaglerArrayBufferAllocator.getDataView8(data));
}
public static final void _wglBufferSubData(int target, int offset, IntBuffer data) {
public static void _wglBufferSubData(int target, int offset, IntBuffer data) {
ctx.bufferSubData(target, offset, EaglerArrayBufferAllocator.getDataView32(data));
}
public static final void _wglBufferSubData(int target, int offset, FloatBuffer data) {
public static void _wglBufferSubData(int target, int offset, FloatBuffer data) {
ctx.bufferSubData(target, offset, EaglerArrayBufferAllocator.getDataView32F(data));
}
public static final void _wglBindVertexArray(IBufferArrayGL obj) {
WebGLVertexArray ptr = obj != null ? ((OpenGLObjects.BufferArrayGL)obj).ptr : null;
public static void _wglBindVertexArray(IVertexArrayGL obj) {
WebGLVertexArray ptr = obj != null ? ((OpenGLObjects.VertexArrayGL)obj).ptr : null;
switch(vertexArrayImpl) {
case VAO_IMPL_CORE:
ctx.bindVertexArray(ptr);
@ -398,20 +398,20 @@ public class PlatformOpenGL {
}
}
public static final void _wglEnableVertexAttribArray(int index) {
public static void _wglEnableVertexAttribArray(int index) {
ctx.enableVertexAttribArray(index);
}
public static final void _wglDisableVertexAttribArray(int index) {
public static void _wglDisableVertexAttribArray(int index) {
ctx.disableVertexAttribArray(index);
}
public static final void _wglVertexAttribPointer(int index, int size, int type,
public static void _wglVertexAttribPointer(int index, int size, int type,
boolean normalized, int stride, int offset) {
ctx.vertexAttribPointer(index, size, type, normalized, stride, offset);
}
public static final void _wglVertexAttribDivisor(int index, int divisor) {
public static void _wglVertexAttribDivisor(int index, int divisor) {
switch(instancingImpl) {
case INSTANCE_IMPL_CORE:
ctx.vertexAttribDivisor(index, divisor);
@ -424,153 +424,153 @@ public class PlatformOpenGL {
}
}
public static final void _wglActiveTexture(int texture) {
public static void _wglActiveTexture(int texture) {
ctx.activeTexture(texture);
}
public static final void _wglBindTexture(int target, ITextureGL obj) {
public static void _wglBindTexture(int target, ITextureGL obj) {
ctx.bindTexture(target, obj == null ? null : ((OpenGLObjects.TextureGL)obj).ptr);
}
public static final void _wglTexParameterf(int target, int param, float value) {
public static void _wglTexParameterf(int target, int param, float value) {
ctx.texParameterf(target, param, value);
}
public static final void _wglTexParameteri(int target, int param, int value) {
public static void _wglTexParameteri(int target, int param, int value) {
ctx.texParameteri(target, param, value);
}
public static final void _wglTexImage3D(int target, int level, int internalFormat, int width, int height, int depth,
public static void _wglTexImage3D(int target, int level, int internalFormat, int width, int height, int depth,
int border, int format, int type, ByteBuffer data) {
ctx.texImage3D(target, level, internalFormat, width, height, depth, border, format, type,
data == null ? null : EaglerArrayBufferAllocator.getDataView8Unsigned(data));
}
public static final void _wglTexImage2D(int target, int level, int internalFormat, int width,
public static void _wglTexImage2D(int target, int level, int internalFormat, int width,
int height, int border, int format, int type, ByteBuffer data) {
ctx.texImage2D(target, level, internalFormat, width, height, border, format, type,
data == null ? null : EaglerArrayBufferAllocator.getDataView8Unsigned(data));
}
public static final void _wglTexImage2Du16(int target, int level, int internalFormat, int width,
public static void _wglTexImage2Du16(int target, int level, int internalFormat, int width,
int height, int border, int format, int type, ByteBuffer data) {
ctx.texImage2D(target, level, internalFormat, width, height, border, format, type,
data == null ? null : EaglerArrayBufferAllocator.getDataView16Unsigned(data));
}
public static final void _wglTexImage2Df32(int target, int level, int internalFormat, int width,
public static void _wglTexImage2Df32(int target, int level, int internalFormat, int width,
int height, int border, int format, int type, ByteBuffer data) {
ctx.texImage2D(target, level, internalFormat, width, height, border, format, type,
data == null ? null : EaglerArrayBufferAllocator.getDataView32F(data));
}
public static final void _wglTexImage2D(int target, int level, int internalFormat, int width,
public static void _wglTexImage2D(int target, int level, int internalFormat, int width,
int height, int border, int format, int type, IntBuffer data) {
ctx.texImage2D(target, level, internalFormat, width, height, border, format, type,
data == null ? null : EaglerArrayBufferAllocator.getDataView8Unsigned(data));
}
public static final void _wglTexImage2Df32(int target, int level, int internalFormat, int width,
public static void _wglTexImage2Df32(int target, int level, int internalFormat, int width,
int height, int border, int format, int type, FloatBuffer data) {
ctx.texImage2D(target, level, internalFormat, width, height, border, format, type,
data == null ? null : EaglerArrayBufferAllocator.getDataView32F(data));
}
public static final void _wglTexSubImage2D(int target, int level, int xoffset, int yoffset,
public static void _wglTexSubImage2D(int target, int level, int xoffset, int yoffset,
int width, int height, int format, int type, ByteBuffer data) {
ctx.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type,
data == null ? null : EaglerArrayBufferAllocator.getDataView8Unsigned(data));
}
public static final void _wglTexSubImage2Du16(int target, int level, int xoffset, int yoffset,
public static void _wglTexSubImage2Du16(int target, int level, int xoffset, int yoffset,
int width, int height, int format, int type, ByteBuffer data) {
ctx.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type,
data == null ? null : EaglerArrayBufferAllocator.getDataView16Unsigned(data));
}
public static final void _wglTexSubImage2D(int target, int level, int xoffset, int yoffset,
public static void _wglTexSubImage2D(int target, int level, int xoffset, int yoffset,
int width, int height, int format, int type, IntBuffer data) {
ctx.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type,
data == null ? null : EaglerArrayBufferAllocator.getDataView8Unsigned(data));
}
public static final void _wglTexSubImage2Df32(int target, int level, int xoffset, int yoffset,
public static void _wglTexSubImage2Df32(int target, int level, int xoffset, int yoffset,
int width, int height, int format, int type, FloatBuffer data) {
ctx.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type,
data == null ? null : EaglerArrayBufferAllocator.getDataView32F(data));
}
public static final void _wglCopyTexSubImage2D(int target, int level, int xoffset, int yoffset,
public static void _wglCopyTexSubImage2D(int target, int level, int xoffset, int yoffset,
int x, int y, int width, int height) {
ctx.copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
}
public static final void _wglTexStorage2D(int target, int levels, int internalFormat, int w, int h) {
public static void _wglTexStorage2D(int target, int levels, int internalFormat, int w, int h) {
ctx.texStorage2D(target, levels, internalFormat, w, h);
}
public static final void _wglPixelStorei(int pname, int value) {
public static void _wglPixelStorei(int pname, int value) {
ctx.pixelStorei(pname, value);
}
public static final void _wglGenerateMipmap(int target) {
public static void _wglGenerateMipmap(int target) {
ctx.generateMipmap(target);
}
public static final void _wglShaderSource(IShaderGL obj, String source) {
public static void _wglShaderSource(IShaderGL obj, String source) {
ctx.shaderSource(((OpenGLObjects.ShaderGL)obj).ptr, source);
}
public static final void _wglCompileShader(IShaderGL obj) {
public static void _wglCompileShader(IShaderGL obj) {
ctx.compileShader(((OpenGLObjects.ShaderGL)obj).ptr);
}
public static final int _wglGetShaderi(IShaderGL obj, int param) {
public static int _wglGetShaderi(IShaderGL obj, int param) {
return ctx.getShaderParameteri(((OpenGLObjects.ShaderGL)obj).ptr, param);
}
public static final String _wglGetShaderInfoLog(IShaderGL obj) {
public static String _wglGetShaderInfoLog(IShaderGL obj) {
return ctx.getShaderInfoLog(((OpenGLObjects.ShaderGL)obj).ptr);
}
public static final void _wglUseProgram(IProgramGL obj) {
public static void _wglUseProgram(IProgramGL obj) {
ctx.useProgram(obj == null ? null : ((OpenGLObjects.ProgramGL)obj).ptr);
}
public static final void _wglAttachShader(IProgramGL obj, IShaderGL shader) {
public static void _wglAttachShader(IProgramGL obj, IShaderGL shader) {
ctx.attachShader(((OpenGLObjects.ProgramGL)obj).ptr, ((OpenGLObjects.ShaderGL)shader).ptr);
}
public static final void _wglDetachShader(IProgramGL obj, IShaderGL shader) {
public static void _wglDetachShader(IProgramGL obj, IShaderGL shader) {
ctx.detachShader(((OpenGLObjects.ProgramGL)obj).ptr, ((OpenGLObjects.ShaderGL)shader).ptr);
}
public static final void _wglLinkProgram(IProgramGL obj) {
public static void _wglLinkProgram(IProgramGL obj) {
ctx.linkProgram(((OpenGLObjects.ProgramGL)obj).ptr);
}
public static final int _wglGetProgrami(IProgramGL obj, int param) {
public static int _wglGetProgrami(IProgramGL obj, int param) {
return ctx.getProgramParameteri(((OpenGLObjects.ProgramGL)obj).ptr, param);
}
public static final String _wglGetProgramInfoLog(IProgramGL obj) {
public static String _wglGetProgramInfoLog(IProgramGL obj) {
return ctx.getProgramInfoLog(((OpenGLObjects.ProgramGL)obj).ptr);
}
public static final void _wglBindAttribLocation(IProgramGL obj, int index, String name) {
public static void _wglBindAttribLocation(IProgramGL obj, int index, String name) {
ctx.bindAttribLocation(((OpenGLObjects.ProgramGL)obj).ptr, index, name);
}
public static final int _wglGetAttribLocation(IProgramGL obj, String name) {
public static int _wglGetAttribLocation(IProgramGL obj, String name) {
return ctx.getAttribLocation(((OpenGLObjects.ProgramGL)obj).ptr, name);
}
public static final void _wglDrawArrays(int mode, int first, int count) {
public static void _wglDrawArrays(int mode, int first, int count) {
ctx.drawArrays(mode, first, count);
//checkErr("_wglDrawArrays(" + mode + ", " + first + ", " + count + ");");
}
public static final void _wglDrawArraysInstanced(int mode, int first, int count, int instances) {
public static void _wglDrawArraysInstanced(int mode, int first, int count, int instances) {
switch(instancingImpl) {
case INSTANCE_IMPL_CORE:
ctx.drawArraysInstanced(mode, first, count, instances);
@ -584,12 +584,12 @@ public class PlatformOpenGL {
//checkErr("_wglDrawArraysInstanced(" + mode + ", " + first + ", " + count + ", " + instanced + ");");
}
public static final void _wglDrawElements(int mode, int count, int type, int offset) {
public static void _wglDrawElements(int mode, int count, int type, int offset) {
ctx.drawElements(mode, count, type, offset);
//checkErr("_wglDrawElements(" + mode + ", " + count + ", " + type + ", " + offset + ");");
}
public static final void _wglDrawElementsInstanced(int mode, int count, int type, int offset, int instances) {
public static void _wglDrawElementsInstanced(int mode, int count, int type, int offset, int instances) {
switch(instancingImpl) {
case INSTANCE_IMPL_CORE:
ctx.drawElementsInstanced(mode, count, type, offset, instances);
@ -603,7 +603,7 @@ public class PlatformOpenGL {
//checkErr("_wglDrawElementsInstanced(" + mode + ", " + count + ", " + type + ", " + offset + ", " + instanced + ");");
}
public static final IUniformGL _wglGetUniformLocation(IProgramGL obj, String name) {
public static IUniformGL _wglGetUniformLocation(IProgramGL obj, String name) {
WebGLUniformLocation loc = ctx.getUniformLocation(((OpenGLObjects.ProgramGL)obj).ptr, name);
if(loc != null) {
return new OpenGLObjects.UniformGL(loc);
@ -612,7 +612,7 @@ public class PlatformOpenGL {
}
}
public static final int _wglGetUniformBlockIndex(IProgramGL obj, String name) {
public static int _wglGetUniformBlockIndex(IProgramGL obj, String name) {
int i = ctx.getUniformBlockIndex(((OpenGLObjects.ProgramGL)obj).ptr, name);
if(i > 2147483647) {
i = -1;
@ -620,77 +620,77 @@ public class PlatformOpenGL {
return i;
}
public static final void _wglBindBufferRange(int target, int index, IBufferGL buffer, int offset, int size) {
public static void _wglBindBufferRange(int target, int index, IBufferGL buffer, int offset, int size) {
ctx.bindBufferRange(target, index, ((OpenGLObjects.BufferGL)buffer).ptr, offset, size);
}
public static final void _wglUniformBlockBinding(IProgramGL obj, int blockIndex, int bufferIndex) {
public static void _wglUniformBlockBinding(IProgramGL obj, int blockIndex, int bufferIndex) {
ctx.uniformBlockBinding(((OpenGLObjects.ProgramGL)obj).ptr, blockIndex, bufferIndex);
}
public static final void _wglUniform1f(IUniformGL obj, float x) {
public static void _wglUniform1f(IUniformGL obj, float x) {
if(obj != null) ctx.uniform1f(((OpenGLObjects.UniformGL)obj).ptr, x);
}
public static final void _wglUniform2f(IUniformGL obj, float x, float y) {
public static void _wglUniform2f(IUniformGL obj, float x, float y) {
if(obj != null) ctx.uniform2f(((OpenGLObjects.UniformGL)obj).ptr, x, y);
}
public static final void _wglUniform3f(IUniformGL obj, float x, float y, float z) {
public static void _wglUniform3f(IUniformGL obj, float x, float y, float z) {
if(obj != null) ctx.uniform3f(((OpenGLObjects.UniformGL)obj).ptr, x, y, z);
}
public static final void _wglUniform4f(IUniformGL obj, float x, float y, float z, float w) {
public static void _wglUniform4f(IUniformGL obj, float x, float y, float z, float w) {
if(obj != null) ctx.uniform4f(((OpenGLObjects.UniformGL)obj).ptr, x, y, z, w);
}
public static final void _wglUniform1i(IUniformGL obj, int x) {
public static void _wglUniform1i(IUniformGL obj, int x) {
if(obj != null) ctx.uniform1i(((OpenGLObjects.UniformGL)obj).ptr, x);
}
public static final void _wglUniform2i(IUniformGL obj, int x, int y) {
public static void _wglUniform2i(IUniformGL obj, int x, int y) {
if(obj != null) ctx.uniform2i(((OpenGLObjects.UniformGL)obj).ptr, x, y);
}
public static final void _wglUniform3i(IUniformGL obj, int x, int y, int z) {
public static void _wglUniform3i(IUniformGL obj, int x, int y, int z) {
if(obj != null) ctx.uniform3i(((OpenGLObjects.UniformGL)obj).ptr, x, y, z);
}
public static final void _wglUniform4i(IUniformGL obj, int x, int y, int z, int w) {
public static void _wglUniform4i(IUniformGL obj, int x, int y, int z, int w) {
if(obj != null) ctx.uniform4i(((OpenGLObjects.UniformGL)obj).ptr, x, y, z, w);
}
public static final void _wglUniformMatrix2fv(IUniformGL obj, boolean transpose, FloatBuffer mat) {
public static void _wglUniformMatrix2fv(IUniformGL obj, boolean transpose, FloatBuffer mat) {
if(obj != null) ctx.uniformMatrix2fv(((OpenGLObjects.UniformGL)obj).ptr, transpose,
mat == null ? null : EaglerArrayBufferAllocator.getDataView32F(mat));
}
public static final void _wglUniformMatrix3fv(IUniformGL obj, boolean transpose, FloatBuffer mat) {
public static void _wglUniformMatrix3fv(IUniformGL obj, boolean transpose, FloatBuffer mat) {
if(obj != null) ctx.uniformMatrix3fv(((OpenGLObjects.UniformGL)obj).ptr, transpose,
mat == null ? null : EaglerArrayBufferAllocator.getDataView32F(mat));
}
public static final void _wglUniformMatrix3x2fv(IUniformGL obj, boolean transpose, FloatBuffer mat) {
public static void _wglUniformMatrix3x2fv(IUniformGL obj, boolean transpose, FloatBuffer mat) {
if(obj != null) ctx.uniformMatrix3x2fv(((OpenGLObjects.UniformGL)obj).ptr, transpose,
mat == null ? null : EaglerArrayBufferAllocator.getDataView32F(mat));
}
public static final void _wglUniformMatrix4fv(IUniformGL obj, boolean transpose, FloatBuffer mat) {
public static void _wglUniformMatrix4fv(IUniformGL obj, boolean transpose, FloatBuffer mat) {
if(obj != null) ctx.uniformMatrix4fv(((OpenGLObjects.UniformGL)obj).ptr, transpose,
mat == null ? null : EaglerArrayBufferAllocator.getDataView32F(mat));
}
public static final void _wglUniformMatrix4x2fv(IUniformGL obj, boolean transpose, FloatBuffer mat) {
public static void _wglUniformMatrix4x2fv(IUniformGL obj, boolean transpose, FloatBuffer mat) {
if(obj != null) ctx.uniformMatrix4x2fv(((OpenGLObjects.UniformGL)obj).ptr, transpose,
mat == null ? null : EaglerArrayBufferAllocator.getDataView32F(mat));
}
public static final void _wglUniformMatrix4x3fv(IUniformGL obj, boolean transpose, FloatBuffer mat) {
public static void _wglUniformMatrix4x3fv(IUniformGL obj, boolean transpose, FloatBuffer mat) {
if(obj != null) ctx.uniformMatrix4x3fv(((OpenGLObjects.UniformGL)obj).ptr, transpose,
mat == null ? null : EaglerArrayBufferAllocator.getDataView32F(mat));
}
public static final void _wglBindFramebuffer(int target, IFramebufferGL framebuffer) {
public static void _wglBindFramebuffer(int target, IFramebufferGL framebuffer) {
if(framebuffer == null) {
ctx.bindFramebuffer(target, PlatformRuntime.mainFramebuffer);
if(glesVers != 200) {
@ -701,41 +701,41 @@ public class PlatformOpenGL {
}
}
public static final int _wglCheckFramebufferStatus(int target) {
public static int _wglCheckFramebufferStatus(int target) {
return ctx.checkFramebufferStatus(target);
}
public static final void _wglFramebufferTexture2D(int target, int attachment, int texTarget,
public static void _wglFramebufferTexture2D(int target, int attachment, int texTarget,
ITextureGL texture, int level) {
ctx.framebufferTexture2D(target, attachment, texTarget, ((OpenGLObjects.TextureGL)texture).ptr, level);
}
public static final void _wglFramebufferTextureLayer(int target, int attachment, ITextureGL texture, int level, int layer) {
public static void _wglFramebufferTextureLayer(int target, int attachment, ITextureGL texture, int level, int layer) {
ctx.framebufferTextureLayer(target, attachment, ((OpenGLObjects.TextureGL) texture).ptr, level, layer);
}
public static final void _wglBlitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1,
public static void _wglBlitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1,
int dstX0, int dstY0, int dstX1, int dstY1, int bits, int filter) {
ctx.blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, bits, filter);
}
public static final void _wglBindRenderbuffer(int target, IRenderbufferGL renderbuffer) {
public static void _wglBindRenderbuffer(int target, IRenderbufferGL renderbuffer) {
ctx.bindRenderbuffer(target,
renderbuffer == null ? null : ((OpenGLObjects.RenderbufferGL)renderbuffer).ptr);
}
public static final void _wglRenderbufferStorage(int target, int internalformat,
public static void _wglRenderbufferStorage(int target, int internalformat,
int width, int height) {
ctx.renderbufferStorage(target, internalformat, width, height);
}
public static final void _wglFramebufferRenderbuffer(int target, int attachment,
public static void _wglFramebufferRenderbuffer(int target, int attachment,
int renderbufferTarget, IRenderbufferGL renderbuffer) {
ctx.framebufferRenderbuffer(target, attachment, renderbufferTarget,
((OpenGLObjects.RenderbufferGL)renderbuffer).ptr);
}
public static final String _wglGetString(int param) {
public static String _wglGetString(int param) {
if(hasWEBGLDebugRendererInfo) {
String s;
switch(param) {
@ -759,47 +759,47 @@ public class PlatformOpenGL {
}
}
public static final int _wglGetInteger(int param) {
public static int _wglGetInteger(int param) {
return ctx.getParameteri(param);
}
public static final int _wglGetError() {
public static int _wglGetError() {
return ctx.getError();
}
public static final int checkOpenGLESVersion() {
public static int checkOpenGLESVersion() {
return glesVers;
}
public static final boolean checkEXTGPUShader5Capable() {
public static boolean checkEXTGPUShader5Capable() {
return false;
}
public static final boolean checkOESGPUShader5Capable() {
public static boolean checkOESGPUShader5Capable() {
return false;
}
public static final boolean checkFBORenderMipmapCapable() {
public static boolean checkFBORenderMipmapCapable() {
return glesVers >= 300 || hasOESFBORenderMipmap;
}
public static final boolean checkVAOCapable() {
public static boolean checkVAOCapable() {
return vertexArrayImpl != VAO_IMPL_NONE;
}
public static final boolean checkInstancingCapable() {
public static boolean checkInstancingCapable() {
return instancingImpl != INSTANCE_IMPL_NONE;
}
public static final boolean checkTexStorageCapable() {
public static boolean checkTexStorageCapable() {
return glesVers >= 300;
}
public static final boolean checkTextureLODCapable() {
public static boolean checkTextureLODCapable() {
return glesVers >= 300 || hasEXTShaderTextureLOD;
}
public static final boolean checkHDRFramebufferSupport(int bits) {
public static boolean checkHDRFramebufferSupport(int bits) {
switch(bits) {
case 16:
return hasFBO16FSupport;
@ -810,7 +810,7 @@ public class PlatformOpenGL {
}
}
public static final boolean checkLinearHDRFilteringSupport(int bits) {
public static boolean checkLinearHDRFilteringSupport(int bits) {
switch(bits) {
case 16:
return hasLinearHDR16FSupport;
@ -822,19 +822,19 @@ public class PlatformOpenGL {
}
// legacy
public static final boolean checkLinearHDR32FSupport() {
public static boolean checkLinearHDR32FSupport() {
return hasLinearHDR32FSupport;
}
public static final boolean checkAnisotropicFilteringSupport() {
public static boolean checkAnisotropicFilteringSupport() {
return hasEXTTextureFilterAnisotropic;
}
public static final boolean checkNPOTCapable() {
public static boolean checkNPOTCapable() {
return glesVers >= 300;
}
private static final void checkErr(String name) {
private static void checkErr(String name) {
int i = ctx.getError();
if(i != 0) {
logger.error("########## GL ERROR ##########");
@ -851,11 +851,11 @@ public class PlatformOpenGL {
}
}
public static final String[] getAllExtensions() {
public static String[] getAllExtensions() {
return ctx.getSupportedExtensionArray();
}
public static final void enterVAOEmulationHook() {
public static void enterVAOEmulationHook() {
WebGLBackBuffer.enterVAOEmulationPhase();
}

View File

@ -16,7 +16,7 @@
package net.lax1dude.eaglercraft.v1_8.internal.teavm;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IVertexArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
import net.lax1dude.eaglercraft.v1_8.internal.IProgramGL;
import net.lax1dude.eaglercraft.v1_8.internal.IShaderGL;
@ -184,7 +184,7 @@ public class EarlyLoadScreen {
_wglUseProgram(program);
_wglUniform2f(_wglGetUniformLocation(program, "aspect"), x, y);
IBufferArrayGL vao = null;
IVertexArrayGL vao = null;
if(vaos) {
vao = _wglGenVertexArrays();
_wglBindVertexArray(vao);
@ -250,7 +250,7 @@ public class EarlyLoadScreen {
_wglUniform2f(_wglGetUniformLocation(program, "aspect"), x, y);
IBufferArrayGL vao = null;
IVertexArrayGL vao = null;
if(vaos) {
vao = _wglGenVertexArrays();
_wglBindVertexArray(vao);
@ -324,11 +324,11 @@ public class EarlyLoadScreen {
_wglUniform2f(_wglGetUniformLocation(program, "aspect"), x, y);
IBufferArrayGL vao = null;
IVertexArrayGL vao = null;
if(vaos) {
if(softVAOs) {
vao = EaglercraftGPU.createGLBufferArray();
EaglercraftGPU.bindGLBufferArray(vao);
vao = EaglercraftGPU.createGLVertexArray();
EaglercraftGPU.bindGLVertexArray(vao);
}else {
vao = _wglGenVertexArrays();
_wglBindVertexArray(vao);
@ -338,7 +338,7 @@ public class EarlyLoadScreen {
EaglercraftGPU.bindVAOGLArrayBuffer(vbo);
EaglercraftGPU.enableVertexAttribArray(0);
EaglercraftGPU.vertexAttribPointer(0, 2, GL_FLOAT, false, 8, 0);
EaglercraftGPU.doDrawArrays(GL_TRIANGLES, 0, 6);
EaglercraftGPU.drawArrays(GL_TRIANGLES, 0, 6);
}else {
_wglBindBuffer(GL_ARRAY_BUFFER, vbo);
_wglEnableVertexAttribArray(0);
@ -367,7 +367,7 @@ public class EarlyLoadScreen {
}
if(vaos) {
if(softVAOs) {
EaglercraftGPU.destroyGLBufferArray(vao);
EaglercraftGPU.destroyGLVertexArray(vao);
}else {
_wglDeleteVertexArrays(vao);
}

View File

@ -21,7 +21,7 @@ import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import org.teavm.jso.webgl.WebGLFramebuffer;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IVertexArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
import net.lax1dude.eaglercraft.v1_8.internal.IFramebufferGL;
import net.lax1dude.eaglercraft.v1_8.internal.IProgramGL;
@ -51,7 +51,7 @@ public class WebGLBackBuffer {
private static ITextureGL gles2ColorTexture;
private static IRenderbufferGL gles2DepthRenderbuffer;
private static IProgramGL gles2BlitProgram;
private static IBufferArrayGL gles2BlitVAO;
private static IVertexArrayGL gles2BlitVAO;
private static IBufferGL gles2BlitVBO;
private static boolean isVAOCapable = false;
@ -61,8 +61,9 @@ public class WebGLBackBuffer {
private static final int _GL_RENDERBUFFER = 0x8D41;
private static final int _GL_COLOR_ATTACHMENT0 = 0x8CE0;
private static final int _GL_DEPTH_ATTACHMENT = 0x8D00;
private static final int _GL_DEPTH_COMPONENT16 = 0x81A5;
private static final int _GL_DEPTH_STENCIL_ATTACHMENT = 0x821A;
private static final int _GL_DEPTH_COMPONENT32F = 0x8CAC;
private static final int _GL_DEPTH_STENCIL = 0x84F9;
private static final int _GL_READ_FRAMEBUFFER = 0x8CA8;
private static final int _GL_DRAW_FRAMEBUFFER = 0x8CA9;
@ -98,8 +99,8 @@ public class WebGLBackBuffer {
_wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, sw, sh, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer)null);
_wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gles2ColorTexture, 0);
_wglBindRenderbuffer(_GL_RENDERBUFFER, gles2DepthRenderbuffer);
_wglRenderbufferStorage(_GL_RENDERBUFFER, _GL_DEPTH_COMPONENT16, sw, sh);
_wglFramebufferRenderbuffer(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, _GL_RENDERBUFFER, gles2DepthRenderbuffer);
_wglRenderbufferStorage(_GL_RENDERBUFFER, _GL_DEPTH_STENCIL, sw, sh);
_wglFramebufferRenderbuffer(_GL_FRAMEBUFFER, _GL_DEPTH_STENCIL_ATTACHMENT, _GL_RENDERBUFFER, gles2DepthRenderbuffer);
ByteBuffer upload = PlatformRuntime.allocateByteBuffer(48);
upload.putFloat(0.0f); upload.putFloat(0.0f);
@ -160,8 +161,8 @@ public class WebGLBackBuffer {
if(isVAOCapable) {
_wglDeleteVertexArrays(gles2BlitVAO);
}
gles2BlitVAO = EaglercraftGPU.createGLBufferArray();
EaglercraftGPU.bindGLBufferArray(gles2BlitVAO);
gles2BlitVAO = EaglercraftGPU.createGLVertexArray();
EaglercraftGPU.bindGLVertexArray(gles2BlitVAO);
EaglercraftGPU.bindVAOGLArrayBuffer(gles2BlitVBO);
EaglercraftGPU.enableVertexAttribArray(0);
EaglercraftGPU.vertexAttribPointer(0, 2, GL_FLOAT, false, 8, 0);
@ -172,8 +173,8 @@ public class WebGLBackBuffer {
private static void drawBlitQuad() {
if(isEmulatedVAOPhase) {
EaglercraftGPU.bindGLBufferArray(gles2BlitVAO);
EaglercraftGPU.doDrawArrays(GL_TRIANGLES, 0, 6);
EaglercraftGPU.bindGLVertexArray(gles2BlitVAO);
EaglercraftGPU.drawArrays(GL_TRIANGLES, 0, 6);
}else {
if(isVAOCapable) {
_wglBindVertexArray(gles2BlitVAO);
@ -237,7 +238,7 @@ public class WebGLBackBuffer {
_wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, windowWidth, windowHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer)null);
_wglBindRenderbuffer(_GL_RENDERBUFFER, gles2DepthRenderbuffer);
_wglRenderbufferStorage(_GL_RENDERBUFFER, _GL_DEPTH_COMPONENT16, windowWidth, windowHeight);
_wglRenderbufferStorage(_GL_RENDERBUFFER, _GL_DEPTH_STENCIL, windowWidth, windowHeight);
}
if(isEmulatedVAOPhase) {
@ -281,7 +282,7 @@ public class WebGLBackBuffer {
}
if(gles2BlitVAO != null) {
if(isEmulatedVAOPhase) {
EaglercraftGPU.destroyGLBufferArray(gles2BlitVAO);
EaglercraftGPU.destroyGLVertexArray(gles2BlitVAO);
}else if(isVAOCapable) {
_wglDeleteVertexArrays(gles2BlitVAO);
}