
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

. So I cannot help but go exploring!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| private void useShaderWiggle(GL gli) { int v = gli.glCreateShader(GL.GL_VERTEX_SHADER); int t = 6; 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] = "}"; String tmp; for(int i = 0; i < t;i++){ tmp = fsrc[i]; lengths[i] = tmp.length(); } gli.glShaderSource(v, t, fsrc, lengths, (int)0); gli.glCompileShader(v);
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
1 2 3 4 5
| gl.glUseProgram(wiggleShader); gl.glUniform1fARB(wiggleLoc, 1.00f);
gl.glUseProgram(0); |
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?