make shader work tm
This commit is contained in:
parent
9a3ecc06aa
commit
f46ee19838
|
@ -9,7 +9,7 @@ uniform float g_FadeClock;
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
gl_Position = m_Position;
|
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; //m_Position;
|
||||||
v_Color = vec4(1.0, 0.0, 0.0, 1.0);
|
v_Color = vec4(1.0, 0.0, 0.0, g_FadeClock);
|
||||||
v_TexCoord = m_TexCoord;
|
v_TexCoord = m_TexCoord;
|
||||||
}
|
}
|
|
@ -9,5 +9,5 @@ uniform sampler2D m_Sampler;
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);//v_Color * texture2D(m_Sampler, v_TexCoord);
|
gl_FragColor = v_Color * texture2D(m_Sampler, v_TexCoord);
|
||||||
}
|
}
|
|
@ -24,7 +24,7 @@ public class Shader {
|
||||||
public static List<Shader> loadedShaders = new ArrayList<>();
|
public static List<Shader> loadedShaders = new ArrayList<>();
|
||||||
public static int currentShader = 0;
|
public static int currentShader = 0;
|
||||||
|
|
||||||
private HashMap<String, Integer> attribLoc = new HashMap<>();
|
public HashMap<String, Integer> attribLoc = new HashMap<>();
|
||||||
private static final String[] attribs = new String[] {
|
private static final String[] attribs = new String[] {
|
||||||
"m_Position",
|
"m_Position",
|
||||||
"m_Color",
|
"m_Color",
|
||||||
|
@ -184,6 +184,11 @@ public class Shader {
|
||||||
this.previousShader = currentShader;
|
this.previousShader = currentShader;
|
||||||
currentShader = this.programId;
|
currentShader = this.programId;
|
||||||
|
|
||||||
|
GL20.glEnableVertexAttribArray(this.attribLoc.get("m_Position"));
|
||||||
|
GL20.glEnableVertexAttribArray(this.attribLoc.get("m_TexCoord"));
|
||||||
|
|
||||||
|
//this.Properties.set("m_Sampler", 0);
|
||||||
|
|
||||||
this.started = true;
|
this.started = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,6 +196,10 @@ public class Shader {
|
||||||
if (!this.started)
|
if (!this.started)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
GL11.glFlush();
|
||||||
|
GL20.glDisableVertexAttribArray(this.attribLoc.get("m_TexCoord"));
|
||||||
|
GL20.glDisableVertexAttribArray(this.attribLoc.get("m_Position"));
|
||||||
|
|
||||||
GL20.glUseProgram(this.previousShader);
|
GL20.glUseProgram(this.previousShader);
|
||||||
currentShader = this.previousShader;
|
currentShader = this.previousShader;
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class ShaderProperty {
|
||||||
GL20.glUniform1(this.Location, IntBuffer.wrap( new int[]{ (int)Value } ));
|
GL20.glUniform1(this.Location, IntBuffer.wrap( new int[]{ (int)Value } ));
|
||||||
break;
|
break;
|
||||||
case Float:
|
case Float:
|
||||||
GL20.glUniform1(this.Location, FloatBuffer.wrap( new float[]{ (float)Value } ));
|
GL20.glUniform1f(this.Location, (float)Value);
|
||||||
break;
|
break;
|
||||||
case BoolVec2:
|
case BoolVec2:
|
||||||
GL20.glUniform2(this.Location, IntBuffer.wrap( boolArrayToIntArray( (boolean[])Value ) ));
|
GL20.glUniform2(this.Location, IntBuffer.wrap( boolArrayToIntArray( (boolean[])Value ) ));
|
||||||
|
@ -43,7 +43,8 @@ public class ShaderProperty {
|
||||||
GL20.glUniform2(this.Location, IntBuffer.wrap( (int[])Value ));
|
GL20.glUniform2(this.Location, IntBuffer.wrap( (int[])Value ));
|
||||||
break;
|
break;
|
||||||
case FloatVec2:
|
case FloatVec2:
|
||||||
GL20.glUniform2(this.Location, FloatBuffer.wrap( (float[])Value ));
|
float[] value = (float[])Value;
|
||||||
|
GL20.glUniform2f(this.Location, value[0], value[1]);
|
||||||
break;
|
break;
|
||||||
case FloatMat2:
|
case FloatMat2:
|
||||||
GL20.glUniformMatrix2(this.Location, false, FloatBuffer.wrap( (float[])Value ));
|
GL20.glUniformMatrix2(this.Location, false, FloatBuffer.wrap( (float[])Value ));
|
||||||
|
@ -73,7 +74,7 @@ public class ShaderProperty {
|
||||||
GL20.glUniformMatrix4(this.Location, false, FloatBuffer.wrap( (float[])Value ));
|
GL20.glUniformMatrix4(this.Location, false, FloatBuffer.wrap( (float[])Value ));
|
||||||
break;
|
break;
|
||||||
case Sampler2D:
|
case Sampler2D:
|
||||||
GL20.glUniform1(this.Location, BufferUtils.createIntBuffer(1).put((int) Value));
|
GL20.glUniform1i(this.Location, (int) Value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,7 @@ import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import org.lwjgl.BufferUtils;
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.opengl.EXTFramebufferObject;
|
import org.lwjgl.opengl.*;
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
import org.lwjgl.opengl.GL13;
|
|
||||||
import org.lwjgl.opengl.GL14;
|
|
||||||
import org.newdawn.slick.*;
|
import org.newdawn.slick.*;
|
||||||
import org.newdawn.slick.opengl.Texture;
|
import org.newdawn.slick.opengl.Texture;
|
||||||
import org.newdawn.slick.opengl.TextureImpl;
|
import org.newdawn.slick.opengl.TextureImpl;
|
||||||
|
@ -203,6 +200,8 @@ public class Cursor {
|
||||||
float txtw = txt.getWidth();
|
float txtw = txt.getWidth();
|
||||||
float txth = txt.getHeight();
|
float txth = txt.getHeight();
|
||||||
|
|
||||||
|
//img.draw(0f,0f);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// stuff copied from CurveRenderState and stuff, I don't know what I'm doing
|
// stuff copied from CurveRenderState and stuff, I don't know what I'm doing
|
||||||
int oldFb = GL11.glGetInteger(EXTFramebufferObject.GL_FRAMEBUFFER_BINDING_EXT);
|
int oldFb = GL11.glGetInteger(EXTFramebufferObject.GL_FRAMEBUFFER_BINDING_EXT);
|
||||||
|
@ -214,34 +213,64 @@ public class Cursor {
|
||||||
GL11.glClearColor(0f, 0f, 0f, 0f);
|
GL11.glClearColor(0f, 0f, 0f, 0f);
|
||||||
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
|
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
|
||||||
*/
|
*/
|
||||||
//txt.bind();
|
//Color.white.bind();
|
||||||
Color.white.bind();
|
|
||||||
TextureImpl.unbind();
|
|
||||||
cursorTrailShader.Begin();
|
//GL20.glVertexAttrib4f(cursorTrailShader.attribLoc.get("m_Position"), 1f, 1f, 1f, 1f);
|
||||||
GL11.glBegin(GL11.GL_QUADS);
|
|
||||||
|
|
||||||
//GL11.glBindTexture(GL11.GL_TEXTURE_2D, );
|
//GL11.glBindTexture(GL11.GL_TEXTURE_2D, );
|
||||||
//cursorTrailShader.Properties.set("m_Sampler", txt.getTextureID());
|
//cursorTrailShader.Properties.set("m_Sampler", txt.getTextureID());
|
||||||
//cursorTrailShader.Properties.set("g_FadeClock", 0.4f);
|
|
||||||
|
//GL20.glUniform1i(cursorTrailShader.attribLoc.get("m_Sampler"), txt.getTextureID());
|
||||||
|
//IntBuffer buf = BufferUtils.createIntBuffer(1).put(txt.getTextureID());
|
||||||
|
|
||||||
|
cursorTrailShader.Begin();
|
||||||
|
GL13.glActiveTexture(GL13.GL_TEXTURE5);
|
||||||
|
//GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||||
|
//GL11.glGenTextures();
|
||||||
|
|
||||||
|
|
||||||
|
//txt.bind();
|
||||||
|
//TextureImpl.unbind();
|
||||||
|
GL11.glBindTexture(GL11.GL_TEXTURE_2D, txt.getTextureID());
|
||||||
|
//GL33.glBindSampler(GL20.GL_SAMPLER_2D, txt.getTextureID());
|
||||||
|
//GL20.glUniform1i(cursorTrailShader.attribLoc.get("m_Sampler"), 0);
|
||||||
|
|
||||||
|
//cursorTrailShader.Properties.set("m_TexCoord", new float[] { txtw, txth });
|
||||||
|
int idd = GL20.glGetAttribLocation(cursorTrailShader.programId, "m_TexCoord");
|
||||||
|
|
||||||
|
cursorTrailShader.Properties.set("m_Sampler", 5);
|
||||||
|
//GL20.glUniform1i(cursorTrailShader.Properties.get("m_Sampler").Location, 5);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cursorTrailShader.Properties.set("g_FadeClock", 0.04f);
|
||||||
|
GL11.glBegin(GL11.GL_QUADS);
|
||||||
float alpha = 0f;
|
float alpha = 0f;
|
||||||
float alphaIncrease = .4f / trail.size;
|
float alphaIncrease = .4f / trail.size;
|
||||||
for (Trailpart p : trail) {
|
for (Trailpart p : trail) {
|
||||||
//alpha += alphaIncrease;
|
//alpha += alphaIncrease;
|
||||||
GL11.glColor4f(filter.r, filter.g, filter.b, alpha);
|
//GL11.glColor4f(filter.r, filter.g, filter.b, 1f);
|
||||||
//GL11.glTexCoord2f(0f, 0f);
|
GL11.glTexCoord2f(0f, 0f);
|
||||||
|
GL20.glVertexAttrib2f(idd, 0f, 0f);
|
||||||
GL11.glVertex3f(p.x - trailw2, p.y - trailh2, 0f);
|
GL11.glVertex3f(p.x - trailw2, p.y - trailh2, 0f);
|
||||||
//GL11.glTexCoord2f(txtw, 0);
|
GL11.glTexCoord2f(txtw, 0);
|
||||||
|
GL20.glVertexAttrib2f(idd, txtw, 0);
|
||||||
GL11.glVertex3f(p.x + trailw2, p.y - trailh2, 0f);
|
GL11.glVertex3f(p.x + trailw2, p.y - trailh2, 0f);
|
||||||
//GL11.glTexCoord2f(txtw, txth);
|
GL11.glTexCoord2f(txtw, txth);
|
||||||
|
GL20.glVertexAttrib2f(idd, txtw, txth);
|
||||||
GL11.glVertex3f(p.x + trailw2, p.y + trailh2, 0f);
|
GL11.glVertex3f(p.x + trailw2, p.y + trailh2, 0f);
|
||||||
//GL11.glTexCoord2f(0f, txth);
|
GL11.glTexCoord2f(0f, txth);
|
||||||
|
GL20.glVertexAttrib2f(idd, 0f, txth);
|
||||||
GL11.glVertex3f(p.x - trailw2, p.y + trailh2, 0f);
|
GL11.glVertex3f(p.x - trailw2, p.y + trailh2, 0f);
|
||||||
break;
|
//break;
|
||||||
}
|
}
|
||||||
//GL11.glEnd();
|
|
||||||
GL11.glEnd();
|
GL11.glEnd();
|
||||||
cursorTrailShader.End();
|
cursorTrailShader.End();
|
||||||
|
|
||||||
|
GL13.glActiveTexture(GL13.GL_TEXTURE0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, oldTex);
|
GL11.glBindTexture(GL11.GL_TEXTURE_2D, oldTex);
|
||||||
EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, oldFb);
|
EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, oldFb);
|
||||||
|
@ -264,8 +293,8 @@ public class Cursor {
|
||||||
GL11.glEnd();
|
GL11.glEnd();
|
||||||
GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
*/
|
*/
|
||||||
//CURSOR.getScaledImage(OPTION_CURSOR_SIZE.val / 100f).drawCentered(lastPosition.x, lastPosition.y, filter);
|
CURSOR.getScaledImage(OPTION_CURSOR_SIZE.val / 100f).drawCentered(lastPosition.x, lastPosition.y, filter);
|
||||||
//CURSOR_MIDDLE.getScaledImage(OPTION_CURSOR_SIZE.val / 100f).drawCentered(lastPosition.x, lastPosition.y, filter);
|
CURSOR_MIDDLE.getScaledImage(OPTION_CURSOR_SIZE.val / 100f).drawCentered(lastPosition.x, lastPosition.y, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user