;D So I am back at the shading again. Thanks to everyone who helped me yesterday. I feel as if I discovered a secret OpenGL world ;D. So I cannot help but go exploring!
private void useShaderWiggle(GL gli) {
int v = gli.glCreateShader(GL.GL_VERTEX_SHADER);
int t = 6;//Total Number of lines in shader
String fsrc[] = new String[t];
int lengths[] = new int[t];
fsrc[0] = "uniform float time;";
fsrc[1] = "void main (void) {";
fsrc[2] = "vec4 v = vec4(gl_Vertex);";
fsrc[3] = "v.x = v.x + time;";
fsrc[4] = "gl_Position = v;";
fsrc[5] = "}";
//Load variables with shader code information
String tmp;
for(int i = 0; i < t;i++){
tmp = fsrc[i];
lengths[i] = tmp.length();
}
//Apply Shader Source
gli.glShaderSource(v, t, fsrc, lengths, (int)0);
gli.glCompileShader(v);//Compile
int shaderprogram = gli.glCreateProgram();
wiggleShader = shaderprogram;
gli.glAttachShader(shaderprogram, v);
gli.glLinkProgram(shaderprogram);
gli.glValidateProgram(shaderprogram);
wiggleLoc = gli.glGetUniformLocationARB(shaderprogram, "time");
}
then to use it - in my Display Method
gl.glUseProgram(wiggleShader);
gl.glUniform1fARB(wiggleLoc, 1.00f);//pass a value of 1.00f to shader
//render object
gl.glUseProgram(0); //Close shader
When I use this for some reason it just makes the objects I apply it to not display, rather then shift 1.0 floats over. I feel as if I am missing something here. Can anyone shed some light?
It seems like every Vertex Shader example I try isn’t working? Perhaps I am doing something wrong? Do you need a fragment shader, to get a vertex shader to work? Can there be only one GLProgram?