Skip to content

Instantly share code, notes, and snippets.

@xoppa
Last active May 31, 2017
Embed
What would you like to do?
adreno gl20
package com.xoppa.gdx.graphics.utils;
import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
public class GL20Adreno20X implements GL20 {
public static void enable () {
Gdx.gl20 = new GL20Adreno20X(Gdx.gl20);
Gdx.gl = Gdx.gl20;
}
public static void disable () {
Gdx.gl20 = ((GL20Adreno20X)Gdx.gl).gl20;
Gdx.gl = Gdx.gl20;
}
public GL20 gl20;
public int currentProgram;
public GL20Adreno20X (GL20 gl20) {
this.gl20 = gl20;
}
@Override
public void glActiveTexture (int texture) {
gl20.glActiveTexture(texture);
}
@Override
public void glBindTexture (int target, int texture) {
gl20.glUseProgram(0);
gl20.glUseProgram(currentProgram);
gl20.glBindTexture(target, texture);
}
@Override
public void glBlendFunc (int sfactor, int dfactor) {
gl20.glBlendFunc(sfactor, dfactor);
}
@Override
public void glClear (int mask) {
gl20.glClear(mask);
}
@Override
public void glClearColor (float red, float green, float blue, float alpha) {
gl20.glClearColor(red, green, blue, alpha);
}
@Override
public void glClearDepthf (float depth) {
gl20.glClearDepthf(depth);
}
@Override
public void glClearStencil (int s) {
gl20.glClearStencil(s);
}
@Override
public void glColorMask (boolean red, boolean green, boolean blue, boolean alpha) {
gl20.glColorMask(red, green, blue, alpha);
}
@Override
public void glCompressedTexImage2D (int target, int level, int internalformat, int width, int height, int border,
int imageSize, Buffer data) {
gl20.glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
}
@Override
public void glCompressedTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format,
int imageSize, Buffer data) {
gl20.glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
}
@Override
public void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) {
gl20.glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
}
@Override
public void glCopyTexSubImage2D (int target, int level, int xoffset, int yoffset, int x, int y, int width, int height) {
gl20.glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
}
@Override
public void glCullFace (int mode) {
gl20.glCullFace(mode);
}
@Override
public void glDeleteTextures (int n, IntBuffer textures) {
gl20.glDeleteTextures(n, textures);
}
@Override
public void glDepthFunc (int func) {
gl20.glDepthFunc(func);
}
@Override
public void glDepthMask (boolean flag) {
gl20.glDepthMask(flag);
}
@Override
public void glDepthRangef (float zNear, float zFar) {
gl20.glDepthRangef(zNear, zFar);
}
@Override
public void glDisable (int cap) {
gl20.glDisable(cap);
}
@Override
public void glDrawArrays (int mode, int first, int count) {
gl20.glDrawArrays(mode, first, count);
}
@Override
public void glDrawElements (int mode, int count, int type, Buffer indices) {
gl20.glDrawElements(mode, count, type, indices);
}
@Override
public void glEnable (int cap) {
gl20.glEnable(cap);
}
@Override
public void glFinish () {
gl20.glFinish();
}
@Override
public void glFlush () {
gl20.glFlush();
}
@Override
public void glFrontFace (int mode) {
gl20.glFrontFace(mode);
}
@Override
public void glGenTextures (int n, IntBuffer textures) {
gl20.glGenTextures(n, textures);
}
@Override
public int glGetError () {
return gl20.glGetError();
}
@Override
public void glGetIntegerv (int pname, IntBuffer params) {
gl20.glGetIntegerv(pname, params);
}
@Override
public String glGetString (int name) {
return gl20.glGetString(name);
}
@Override
public void glHint (int target, int mode) {
gl20.glHint(target, mode);
}
@Override
public void glLineWidth (float width) {
gl20.glLineWidth(width);
}
@Override
public void glPixelStorei (int pname, int param) {
gl20.glPixelStorei(pname, param);
}
@Override
public void glPolygonOffset (float factor, float units) {
gl20.glPolygonOffset(factor, units);
}
@Override
public void glReadPixels (int x, int y, int width, int height, int format, int type, Buffer pixels) {
gl20.glReadPixels(x, y, width, height, format, type, pixels);
}
@Override
public void glScissor (int x, int y, int width, int height) {
gl20.glScissor(x, y, width, height);
}
@Override
public void glStencilFunc (int func, int ref, int mask) {
gl20.glStencilFunc(func, ref, mask);
}
@Override
public void glStencilMask (int mask) {
gl20.glStencilMask(mask);
}
@Override
public void glStencilOp (int fail, int zfail, int zpass) {
gl20.glStencilOp(fail, zfail, zpass);
}
@Override
public void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type,
Buffer pixels) {
gl20.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
}
@Override
public void glTexParameterf (int target, int pname, float param) {
gl20.glTexParameterf(target, pname, param);
}
@Override
public void glTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format, int type,
Buffer pixels) {
gl20.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
}
@Override
public void glViewport (int x, int y, int width, int height) {
gl20.glViewport(x, y, width, height);
}
@Override
public void glAttachShader (int program, int shader) {
gl20.glAttachShader(program, shader);
}
@Override
public void glBindAttribLocation (int program, int index, String name) {
gl20.glBindAttribLocation(program, index, name);
}
@Override
public void glBindBuffer (int target, int buffer) {
gl20.glBindBuffer(target, buffer);
}
@Override
public void glBindFramebuffer (int target, int framebuffer) {
gl20.glBindFramebuffer(target, framebuffer);
}
@Override
public void glBindRenderbuffer (int target, int renderbuffer) {
gl20.glBindRenderbuffer(target, renderbuffer);
}
@Override
public void glBlendColor (float red, float green, float blue, float alpha) {
gl20.glBlendColor(red, green, blue, alpha);
}
@Override
public void glBlendEquation (int mode) {
gl20.glBlendEquation(mode);
}
@Override
public void glBlendEquationSeparate (int modeRGB, int modeAlpha) {
gl20.glBlendEquationSeparate(modeRGB, modeAlpha);
}
@Override
public void glBlendFuncSeparate (int srcRGB, int dstRGB, int srcAlpha, int dstAlpha) {
gl20.glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
}
@Override
public void glBufferData (int target, int size, Buffer data, int usage) {
gl20.glBufferData(target, size, data, usage);
}
@Override
public void glBufferSubData (int target, int offset, int size, Buffer data) {
gl20.glBufferSubData(target, offset, size, data);
}
@Override
public int glCheckFramebufferStatus (int target) {
return gl20.glCheckFramebufferStatus(target);
}
@Override
public void glCompileShader (int shader) {
gl20.glCompileShader(shader);
}
@Override
public int glCreateProgram () {
return gl20.glCreateProgram();
}
@Override
public int glCreateShader (int type) {
return gl20.glCreateShader(type);
}
@Override
public void glDeleteBuffers (int n, IntBuffer buffers) {
gl20.glDeleteBuffers(n, buffers);
}
@Override
public void glDeleteFramebuffers (int n, IntBuffer framebuffers) {
gl20.glDeleteFramebuffers(n, framebuffers);
}
@Override
public void glDeleteProgram (int program) {
gl20.glDeleteProgram(program);
}
@Override
public void glDeleteRenderbuffers (int n, IntBuffer renderbuffers) {
gl20.glDeleteRenderbuffers(n, renderbuffers);
}
@Override
public void glDeleteShader (int shader) {
gl20.glDeleteShader(shader);
}
@Override
public void glDetachShader (int program, int shader) {
gl20.glDetachShader(program, shader);
}
@Override
public void glDisableVertexAttribArray (int index) {
gl20.glDisableVertexAttribArray(index);
}
@Override
public void glDrawElements (int mode, int count, int type, int indices) {
gl20.glDrawElements(mode, count, type, indices);
}
@Override
public void glEnableVertexAttribArray (int index) {
gl20.glEnableVertexAttribArray(index);
}
@Override
public void glFramebufferRenderbuffer (int target, int attachment, int renderbuffertarget, int renderbuffer) {
gl20.glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
}
@Override
public void glFramebufferTexture2D (int target, int attachment, int textarget, int texture, int level) {
gl20.glFramebufferTexture2D(target, attachment, textarget, texture, level);
}
@Override
public void glGenBuffers (int n, IntBuffer buffers) {
gl20.glGenBuffers(n, buffers);
}
@Override
public void glGenerateMipmap (int target) {
gl20.glGenerateMipmap(target);
}
@Override
public void glGenFramebuffers (int n, IntBuffer framebuffers) {
gl20.glGenFramebuffers(n, framebuffers);
}
@Override
public void glGenRenderbuffers (int n, IntBuffer renderbuffers) {
gl20.glGenRenderbuffers(n, renderbuffers);
}
@Override
public String glGetActiveAttrib (int program, int index, IntBuffer size, Buffer type) {
return gl20.glGetActiveAttrib(program, index, size, type);
}
@Override
public String glGetActiveUniform (int program, int index, IntBuffer size, Buffer type) {
return gl20.glGetActiveUniform(program, index, size, type);
}
@Override
public void glGetAttachedShaders (int program, int maxcount, Buffer count, IntBuffer shaders) {
gl20.glGetAttachedShaders(program, maxcount, count, shaders);
}
@Override
public int glGetAttribLocation (int program, String name) {
return gl20.glGetAttribLocation(program, name);
}
@Override
public void glGetBooleanv (int pname, Buffer params) {
gl20.glGetBooleanv(pname, params);
}
@Override
public void glGetBufferParameteriv (int target, int pname, IntBuffer params) {
gl20.glGetBufferParameteriv(target, pname, params);
}
@Override
public void glGetFloatv (int pname, FloatBuffer params) {
gl20.glGetFloatv(pname, params);
}
@Override
public void glGetFramebufferAttachmentParameteriv (int target, int attachment, int pname, IntBuffer params) {
gl20.glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
}
@Override
public void glGetProgramiv (int program, int pname, IntBuffer params) {
gl20.glGetProgramiv(program, pname, params);
}
@Override
public String glGetProgramInfoLog (int program) {
return gl20.glGetProgramInfoLog(program);
}
@Override
public void glGetRenderbufferParameteriv (int target, int pname, IntBuffer params) {
gl20.glGetRenderbufferParameteriv(target, pname, params);
}
@Override
public void glGetShaderiv (int shader, int pname, IntBuffer params) {
gl20.glGetShaderiv(shader, pname, params);
}
@Override
public String glGetShaderInfoLog (int shader) {
return gl20.glGetShaderInfoLog(shader);
}
@Override
public void glGetShaderPrecisionFormat (int shadertype, int precisiontype, IntBuffer range, IntBuffer precision) {
gl20.glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
}
@Override
public void glGetTexParameterfv (int target, int pname, FloatBuffer params) {
gl20.glGetTexParameterfv(target, pname, params);
}
@Override
public void glGetTexParameteriv (int target, int pname, IntBuffer params) {
gl20.glGetTexParameteriv(target, pname, params);
}
@Override
public void glGetUniformfv (int program, int location, FloatBuffer params) {
gl20.glGetUniformfv(program, location, params);
}
@Override
public void glGetUniformiv (int program, int location, IntBuffer params) {
gl20.glGetUniformiv(program, location, params);
}
@Override
public int glGetUniformLocation (int program, String name) {
return gl20.glGetUniformLocation(program, name);
}
@Override
public void glGetVertexAttribfv (int index, int pname, FloatBuffer params) {
gl20.glGetVertexAttribfv(index, pname, params);
}
@Override
public void glGetVertexAttribiv (int index, int pname, IntBuffer params) {
gl20.glGetVertexAttribiv(index, pname, params);
}
@Override
public void glGetVertexAttribPointerv (int index, int pname, Buffer pointer) {
gl20.glGetVertexAttribPointerv(index, pname, pointer);
}
@Override
public boolean glIsBuffer (int buffer) {
return gl20.glIsBuffer(buffer);
}
@Override
public boolean glIsEnabled (int cap) {
return gl20.glIsEnabled(cap);
}
@Override
public boolean glIsFramebuffer (int framebuffer) {
return gl20.glIsFramebuffer(framebuffer);
}
@Override
public boolean glIsProgram (int program) {
return gl20.glIsProgram(program);
}
@Override
public boolean glIsRenderbuffer (int renderbuffer) {
return gl20.glIsRenderbuffer(renderbuffer);
}
@Override
public boolean glIsShader (int shader) {
return gl20.glIsShader(shader);
}
@Override
public boolean glIsTexture (int texture) {
return gl20.glIsTexture(texture);
}
@Override
public void glLinkProgram (int program) {
gl20.glLinkProgram(program);
}
@Override
public void glReleaseShaderCompiler () {
gl20.glReleaseShaderCompiler();
}
@Override
public void glRenderbufferStorage (int target, int internalformat, int width, int height) {
gl20.glRenderbufferStorage(target, internalformat, width, height);
}
@Override
public void glSampleCoverage (float value, boolean invert) {
gl20.glSampleCoverage(value, invert);
}
@Override
public void glShaderBinary (int n, IntBuffer shaders, int binaryformat, Buffer binary, int length) {
gl20.glShaderBinary(n, shaders, binaryformat, binary, length);
}
@Override
public void glShaderSource (int shader, String string) {
gl20.glShaderSource(shader, string);
}
@Override
public void glStencilFuncSeparate (int face, int func, int ref, int mask) {
gl20.glStencilFuncSeparate(face, func, ref, mask);
}
@Override
public void glStencilMaskSeparate (int face, int mask) {
gl20.glStencilMaskSeparate(face, mask);
}
@Override
public void glStencilOpSeparate (int face, int fail, int zfail, int zpass) {
gl20.glStencilOpSeparate(face, fail, zfail, zpass);
}
@Override
public void glTexParameterfv (int target, int pname, FloatBuffer params) {
gl20.glTexParameterfv(target, pname, params);
}
@Override
public void glTexParameteri (int target, int pname, int param) {
gl20.glTexParameteri(target, pname, param);
}
@Override
public void glTexParameteriv (int target, int pname, IntBuffer params) {
gl20.glTexParameteriv(target, pname, params);
}
@Override
public void glUniform1f (int location, float x) {
gl20.glUniform1f(location, x);
}
@Override
public void glUniform1fv (int location, int count, FloatBuffer v) {
gl20.glUniform1fv(location, count, v);
}
@Override
public void glUniform1i (int location, int x) {
gl20.glUniform1i(location, x);
}
@Override
public void glUniform1iv (int location, int count, IntBuffer v) {
gl20.glUniform1iv(location, count, v);
}
@Override
public void glUniform2f (int location, float x, float y) {
gl20.glUniform2f(location, x, y);
}
@Override
public void glUniform2fv (int location, int count, FloatBuffer v) {
gl20.glUniform2fv(location, count, v);
}
@Override
public void glUniform2i (int location, int x, int y) {
gl20.glUniform2i(location, x, y);
}
@Override
public void glUniform2iv (int location, int count, IntBuffer v) {
gl20.glUniform2iv(location, count, v);
}
@Override
public void glUniform3f (int location, float x, float y, float z) {
gl20.glUniform3f(location, x, y, z);
}
@Override
public void glUniform3fv (int location, int count, FloatBuffer v) {
gl20.glUniform3fv(location, count, v);
}
@Override
public void glUniform3i (int location, int x, int y, int z) {
gl20.glUniform3i(location, x, y, z);
}
@Override
public void glUniform3iv (int location, int count, IntBuffer v) {
gl20.glUniform3iv(location, count, v);
}
@Override
public void glUniform4f (int location, float x, float y, float z, float w) {
gl20.glUniform4f(location, x, y, z, w);
}
@Override
public void glUniform4fv (int location, int count, FloatBuffer v) {
gl20.glUniform4fv(location, count, v);
}
@Override
public void glUniform4i (int location, int x, int y, int z, int w) {
gl20.glUniform4i(location, x, y, z, w);
}
@Override
public void glUniform4iv (int location, int count, IntBuffer v) {
gl20.glUniform4iv(location, count, v);
}
@Override
public void glUniformMatrix2fv (int location, int count, boolean transpose, FloatBuffer value) {
gl20.glUniformMatrix2fv(location, count, transpose, value);
}
@Override
public void glUniformMatrix3fv (int location, int count, boolean transpose, FloatBuffer value) {
gl20.glUniformMatrix3fv(location, count, transpose, value);
}
@Override
public void glUniformMatrix4fv (int location, int count, boolean transpose, FloatBuffer value) {
gl20.glUniformMatrix4fv(location, count, transpose, value);
}
@Override
public void glUseProgram (int program) {
currentProgram = program;
gl20.glUseProgram(program);
}
@Override
public void glValidateProgram (int program) {
gl20.glValidateProgram(program);
}
@Override
public void glVertexAttrib1f (int indx, float x) {
gl20.glVertexAttrib1f(indx, x);
}
@Override
public void glVertexAttrib1fv (int indx, FloatBuffer values) {
gl20.glVertexAttrib1fv(indx, values);
}
@Override
public void glVertexAttrib2f (int indx, float x, float y) {
gl20.glVertexAttrib2f(indx, x, y);
}
@Override
public void glVertexAttrib2fv (int indx, FloatBuffer values) {
gl20.glVertexAttrib2fv(indx, values);
}
@Override
public void glVertexAttrib3f (int indx, float x, float y, float z) {
gl20.glVertexAttrib3f(indx, x, y, z);
}
@Override
public void glVertexAttrib3fv (int indx, FloatBuffer values) {
gl20.glVertexAttrib3fv(indx, values);
}
@Override
public void glVertexAttrib4f (int indx, float x, float y, float z, float w) {
gl20.glVertexAttrib4f(indx, x, y, z, w);
}
@Override
public void glVertexAttrib4fv (int indx, FloatBuffer values) {
gl20.glVertexAttrib4fv(indx, values);
}
@Override
public void glVertexAttribPointer (int indx, int size, int type, boolean normalized, int stride, Buffer ptr) {
gl20.glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
}
@Override
public void glVertexAttribPointer (int indx, int size, int type, boolean normalized, int stride, int ptr) {
gl20.glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
}
@Override
public void glDeleteTexture (int texture) {
gl20.glDeleteTexture(texture);
}
@Override
public int glGenTexture () {
return gl20.glGenTexture();
}
@Override
public void glDeleteBuffer (int buffer) {
gl20.glDeleteBuffer(buffer);
}
@Override
public void glDeleteFramebuffer (int framebuffer) {
gl20.glDeleteFramebuffer(framebuffer);
}
@Override
public void glDeleteRenderbuffer (int renderbuffer) {
gl20.glDeleteRenderbuffer(renderbuffer);
}
@Override
public int glGenBuffer () {
return gl20.glGenBuffer();
}
@Override
public int glGenFramebuffer () {
return gl20.glGenFramebuffer();
}
@Override
public int glGenRenderbuffer () {
return gl20.glGenRenderbuffer();
}
@Override
public void glUniform1fv (int location, int count, float[] v, int offset) {
gl20.glUniform1fv(location, count, v, offset);
}
@Override
public void glUniform1iv (int location, int count, int[] v, int offset) {
gl20.glUniform1iv(location, count, v, offset);
}
@Override
public void glUniform2fv (int location, int count, float[] v, int offset) {
gl20.glUniform2fv(location, count, v, offset);
}
@Override
public void glUniform2iv (int location, int count, int[] v, int offset) {
gl20.glUniform2iv(location, count, v, offset);
}
@Override
public void glUniform3fv (int location, int count, float[] v, int offset) {
gl20.glUniform3fv(location, count, v, offset);
}
@Override
public void glUniform3iv (int location, int count, int[] v, int offset) {
gl20.glUniform3iv(location, count, v, offset);
}
@Override
public void glUniform4fv (int location, int count, float[] v, int offset) {
gl20.glUniform4fv(location, count, v, offset);
}
@Override
public void glUniform4iv (int location, int count, int[] v, int offset) {
gl20.glUniform4iv(location, count, v, offset);
}
@Override
public void glUniformMatrix2fv (int location, int count, boolean transpose, float[] value, int offset) {
gl20.glUniformMatrix2fv(location, count, transpose, value, offset);
}
@Override
public void glUniformMatrix3fv (int location, int count, boolean transpose, float[] value, int offset) {
gl20.glUniformMatrix3fv(location, count, transpose, value, offset);
}
@Override
public void glUniformMatrix4fv (int location, int count, boolean transpose, float[] value, int offset) {
gl20.glUniformMatrix4fv(location, count, transpose, value, offset);
}
}
@ACrsm
Copy link

ACrsm commented May 31, 2017

first init currentProgram = Integer.MIN_VALUE

then
@OverRide
public void glBindTexture (int target, int texture) {
if(currentProgram != Integer.MIN_VALUE){
gl20.glUseProgram(0);
gl20.glUseProgram(currentProgram);
}
gl20.glBindTexture(target, texture);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment