remove obsolete shader GlUtils functions
This commit is contained in:
parent
c6f44e7bbf
commit
afea93be73
@ -142,88 +142,6 @@ public class GLUtils {
|
||||
GL20.GL_REPEAT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param shaderType
|
||||
* shader type
|
||||
* @param source
|
||||
* shader code
|
||||
* @return gl identifier
|
||||
*/
|
||||
public static int loadShader(int shaderType, String source) {
|
||||
|
||||
if (GLAdapter.GDX_DESKTOP_QUIRKS) {
|
||||
// Strip precision modifer
|
||||
int start = source.indexOf("precision");
|
||||
if (start >= 0) {
|
||||
int end = source.indexOf(';', start) + 1;
|
||||
if (start > 0)
|
||||
source = source.substring(0, start) + source.substring(end);
|
||||
else
|
||||
source = source.substring(end);
|
||||
}
|
||||
}
|
||||
|
||||
int shader = GL.glCreateShader(shaderType);
|
||||
if (shader != 0) {
|
||||
GL.glShaderSource(shader, source);
|
||||
GL.glCompileShader(shader);
|
||||
IntBuffer compiled = MapRenderer.getIntBuffer(1);
|
||||
|
||||
GL.glGetShaderiv(shader, GL20.GL_COMPILE_STATUS, compiled);
|
||||
compiled.position(0);
|
||||
if (compiled.get() == 0) {
|
||||
log.error("Could not compile shader " + shaderType + ":");
|
||||
log.error(GL.glGetShaderInfoLog(shader));
|
||||
GL.glDeleteShader(shader);
|
||||
shader = 0;
|
||||
}
|
||||
}
|
||||
return shader;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vertexSource
|
||||
* ...
|
||||
* @param fragmentSource
|
||||
* ...
|
||||
* @return gl identifier
|
||||
*/
|
||||
public static int createProgram(String vertexSource, String fragmentSource) {
|
||||
int vertexShader = loadShader(GL20.GL_VERTEX_SHADER, vertexSource);
|
||||
if (vertexShader == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pixelShader = loadShader(GL20.GL_FRAGMENT_SHADER, fragmentSource);
|
||||
if (pixelShader == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int program = GL.glCreateProgram();
|
||||
if (program != 0) {
|
||||
checkGlError("glCreateProgram");
|
||||
GL.glAttachShader(program, vertexShader);
|
||||
checkGlError("glAttachShader");
|
||||
GL.glAttachShader(program, pixelShader);
|
||||
checkGlError("glAttachShader");
|
||||
GL.glLinkProgram(program);
|
||||
IntBuffer linkStatus = MapRenderer.getIntBuffer(1);
|
||||
GL.glGetProgramiv(program, GL20.GL_LINK_STATUS, linkStatus);
|
||||
linkStatus.position(0);
|
||||
if (linkStatus.get() != GL20.GL_TRUE) {
|
||||
log.error("Could not link program: ");
|
||||
log.error(GL.glGetProgramInfoLog(program));
|
||||
GL.glDeleteProgram(program);
|
||||
program = 0;
|
||||
}
|
||||
}
|
||||
return program;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param op
|
||||
* ...
|
||||
*/
|
||||
public static void checkGlError(String op) {
|
||||
//GL = GLAdapter.get();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user