Skip to content

Commit

Permalink
Rewrote shaders for GLSL 110 (openGL2.0).
Browse files Browse the repository at this point in the history
  • Loading branch information
Szunti committed Aug 24, 2015
1 parent 5efb61d commit a3625ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/itdelatrisu/opsu/objects/curves/Curve.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ public static void init(int width, int height, float circleSize, Color borderCol
Curve.borderColor = borderColor;

ContextCapabilities capabilities = GLContext.getCapabilities();
mmsliderSupported = capabilities.GL_EXT_framebuffer_object && capabilities.OpenGL30;
mmsliderSupported = capabilities.GL_EXT_framebuffer_object;
if (mmsliderSupported)
CurveRenderState.init(width, height, circleSize);
else {
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.");
}
}

Expand Down
20 changes: 9 additions & 11 deletions src/itdelatrisu/opsu/render/CurveRenderState.java
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public void initGradient() {
buff.flip();
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);
GL30.glGenerateMipmap(GL11.GL_TEXTURE_1D);
EXTFramebufferObject.glGenerateMipmapEXT(GL11.GL_TEXTURE_1D);
}
}

Expand All @@ -409,12 +409,12 @@ public void initShaderProgram() {
program = GL20.glCreateProgram();
int vtxShdr = GL20.glCreateShader(GL20.GL_VERTEX_SHADER);
int frgShdr = GL20.glCreateShader(GL20.GL_FRAGMENT_SHADER);
GL20.glShaderSource(vtxShdr, "#version 130\n"
GL20.glShaderSource(vtxShdr, "#version 110\n"
+ "\n"
+ "in vec4 in_position;\n"
+ "in vec2 in_tex_coord;\n"
+ "attribute vec4 in_position;\n"
+ "attribute vec2 in_tex_coord;\n"
+ "\n"
+ "out vec2 tex_coord;\n"
+ "varying vec2 tex_coord;\n"
+ "void main()\n"
+ "{\n"
+ " gl_Position = in_position;\n"
Expand All @@ -426,22 +426,21 @@ public void initShaderProgram() {
String error = GL20.glGetShaderInfoLog(vtxShdr, 1024);
Log.error("Vertex Shader compilation failed.", new Exception(error));
}
GL20.glShaderSource(frgShdr, "#version 130\n"
GL20.glShaderSource(frgShdr, "#version 110\n"
+ "\n"
+ "uniform sampler1D tex;\n"
+ "uniform vec2 tex_size;\n"
+ "uniform vec3 col_tint;\n"
+ "uniform vec4 col_border;\n"
+ "\n"
+ "in vec2 tex_coord;\n"
+ "out vec4 out_colour;\n"
+ "varying vec2 tex_coord;\n"
+ "\n"
+ "void main()\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"
+ " 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);
res = GL20.glGetShaderi(frgShdr, GL20.GL_COMPILE_STATUS);
Expand All @@ -451,7 +450,6 @@ public void initShaderProgram() {
}
GL20.glAttachShader(program, vtxShdr);
GL20.glAttachShader(program, frgShdr);
GL30.glBindFragDataLocation(program, 0, "out_colour");
GL20.glLinkProgram(program);
res = GL20.glGetProgrami(program, GL20.GL_LINK_STATUS);
if (res != GL11.GL_TRUE) {
Expand Down

0 comments on commit a3625ed

Please sign in to comment.