Rewrote shaders for GLSL 110 (openGL2.0).
This commit is contained in:
parent
5efb61d3bb
commit
017150233b
|
@ -87,12 +87,12 @@ public abstract class Curve {
|
||||||
Curve.borderColor = borderColor;
|
Curve.borderColor = borderColor;
|
||||||
|
|
||||||
ContextCapabilities capabilities = GLContext.getCapabilities();
|
ContextCapabilities capabilities = GLContext.getCapabilities();
|
||||||
mmsliderSupported = capabilities.GL_EXT_framebuffer_object && capabilities.OpenGL30;
|
mmsliderSupported = capabilities.GL_EXT_framebuffer_object;
|
||||||
if (mmsliderSupported)
|
if (mmsliderSupported)
|
||||||
CurveRenderState.init(width, height, circleSize);
|
CurveRenderState.init(width, height, circleSize);
|
||||||
else {
|
else {
|
||||||
if (Options.getSkin().getSliderStyle() != Skin.STYLE_PEPPYSLIDER)
|
if (Options.getSkin().getSliderStyle() != Skin.STYLE_PEPPYSLIDER)
|
||||||
Log.warn("New slider style requires FBO support and OpenGL 3.0.");
|
Log.warn("New slider style requires FBO support.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@ import org.lwjgl.opengl.GL13;
|
||||||
import org.lwjgl.opengl.GL14;
|
import org.lwjgl.opengl.GL14;
|
||||||
import org.lwjgl.opengl.GL15;
|
import org.lwjgl.opengl.GL15;
|
||||||
import org.lwjgl.opengl.GL20;
|
import org.lwjgl.opengl.GL20;
|
||||||
import org.lwjgl.opengl.GL30;
|
|
||||||
import org.newdawn.slick.Color;
|
import org.newdawn.slick.Color;
|
||||||
import org.newdawn.slick.Image;
|
import org.newdawn.slick.Image;
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
|
@ -396,7 +395,7 @@ public class CurveRenderState {
|
||||||
buff.flip();
|
buff.flip();
|
||||||
GL11.glBindTexture(GL11.GL_TEXTURE_1D, gradientTexture);
|
GL11.glBindTexture(GL11.GL_TEXTURE_1D, gradientTexture);
|
||||||
GL11.glTexImage1D(GL11.GL_TEXTURE_1D, 0, GL11.GL_RGBA, slider.getWidth(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buff);
|
GL11.glTexImage1D(GL11.GL_TEXTURE_1D, 0, GL11.GL_RGBA, slider.getWidth(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buff);
|
||||||
GL30.glGenerateMipmap(GL11.GL_TEXTURE_1D);
|
EXTFramebufferObject.glGenerateMipmapEXT(GL11.GL_TEXTURE_1D);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,12 +408,12 @@ public class CurveRenderState {
|
||||||
program = GL20.glCreateProgram();
|
program = GL20.glCreateProgram();
|
||||||
int vtxShdr = GL20.glCreateShader(GL20.GL_VERTEX_SHADER);
|
int vtxShdr = GL20.glCreateShader(GL20.GL_VERTEX_SHADER);
|
||||||
int frgShdr = GL20.glCreateShader(GL20.GL_FRAGMENT_SHADER);
|
int frgShdr = GL20.glCreateShader(GL20.GL_FRAGMENT_SHADER);
|
||||||
GL20.glShaderSource(vtxShdr, "#version 130\n"
|
GL20.glShaderSource(vtxShdr, "#version 110\n"
|
||||||
+ "\n"
|
+ "\n"
|
||||||
+ "in vec4 in_position;\n"
|
+ "attribute vec4 in_position;\n"
|
||||||
+ "in vec2 in_tex_coord;\n"
|
+ "attribute vec2 in_tex_coord;\n"
|
||||||
+ "\n"
|
+ "\n"
|
||||||
+ "out vec2 tex_coord;\n"
|
+ "varying vec2 tex_coord;\n"
|
||||||
+ "void main()\n"
|
+ "void main()\n"
|
||||||
+ "{\n"
|
+ "{\n"
|
||||||
+ " gl_Position = in_position;\n"
|
+ " gl_Position = in_position;\n"
|
||||||
|
@ -426,22 +425,21 @@ public class CurveRenderState {
|
||||||
String error = GL20.glGetShaderInfoLog(vtxShdr, 1024);
|
String error = GL20.glGetShaderInfoLog(vtxShdr, 1024);
|
||||||
Log.error("Vertex Shader compilation failed.", new Exception(error));
|
Log.error("Vertex Shader compilation failed.", new Exception(error));
|
||||||
}
|
}
|
||||||
GL20.glShaderSource(frgShdr, "#version 130\n"
|
GL20.glShaderSource(frgShdr, "#version 110\n"
|
||||||
+ "\n"
|
+ "\n"
|
||||||
+ "uniform sampler1D tex;\n"
|
+ "uniform sampler1D tex;\n"
|
||||||
+ "uniform vec2 tex_size;\n"
|
+ "uniform vec2 tex_size;\n"
|
||||||
+ "uniform vec3 col_tint;\n"
|
+ "uniform vec3 col_tint;\n"
|
||||||
+ "uniform vec4 col_border;\n"
|
+ "uniform vec4 col_border;\n"
|
||||||
+ "\n"
|
+ "\n"
|
||||||
+ "in vec2 tex_coord;\n"
|
+ "varying vec2 tex_coord;\n"
|
||||||
+ "out vec4 out_colour;\n"
|
|
||||||
+ "\n"
|
+ "\n"
|
||||||
+ "void main()\n"
|
+ "void main()\n"
|
||||||
+ "{\n"
|
+ "{\n"
|
||||||
+ " vec4 in_color = texture(tex, tex_coord.x);\n"
|
+ " vec4 in_color = texture1D(tex, tex_coord.x);\n"
|
||||||
+ " float blend_factor = in_color.r-in_color.b;\n"
|
+ " float blend_factor = in_color.r-in_color.b;\n"
|
||||||
+ " vec4 new_color = vec4(mix(in_color.xyz*col_border.xyz,col_tint,blend_factor),in_color.w);\n"
|
+ " vec4 new_color = vec4(mix(in_color.xyz*col_border.xyz,col_tint,blend_factor),in_color.w);\n"
|
||||||
+ " out_colour = new_color;\n"
|
+ " gl_FragColor = new_color;\n"
|
||||||
+ "}");
|
+ "}");
|
||||||
GL20.glCompileShader(frgShdr);
|
GL20.glCompileShader(frgShdr);
|
||||||
res = GL20.glGetShaderi(frgShdr, GL20.GL_COMPILE_STATUS);
|
res = GL20.glGetShaderi(frgShdr, GL20.GL_COMPILE_STATUS);
|
||||||
|
@ -451,7 +449,6 @@ public class CurveRenderState {
|
||||||
}
|
}
|
||||||
GL20.glAttachShader(program, vtxShdr);
|
GL20.glAttachShader(program, vtxShdr);
|
||||||
GL20.glAttachShader(program, frgShdr);
|
GL20.glAttachShader(program, frgShdr);
|
||||||
GL30.glBindFragDataLocation(program, 0, "out_colour");
|
|
||||||
GL20.glLinkProgram(program);
|
GL20.glLinkProgram(program);
|
||||||
res = GL20.glGetProgrami(program, GL20.GL_LINK_STATUS);
|
res = GL20.glGetProgrami(program, GL20.GL_LINK_STATUS);
|
||||||
if (res != GL11.GL_TRUE) {
|
if (res != GL11.GL_TRUE) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user