java - Trying to load and initialize a shader using jogl -
trying initialize shaders in jogl
.
any ideas why error empty? check size of it, , looks larger 0 since "unknown"
not printed.
vertexshaderprogram = gl.glcreateshader(gl2.gl_vertex_shader); fragmentshaderprogram = gl.glcreateshader(gl2.gl_fragment_shader); gl.glshadersource(vertexshaderprogram, 1, vsrc, null, 0); gl.glcompileshader(vertexshaderprogram); gl.glshadersource(fragmentshaderprogram, 1, fsrc, null, 0); gl.glcompileshader(fragmentshaderprogram); shaderprogram = gl.glcreateprogram(); gl.glattachshader(shaderprogram, vertexshaderprogram); gl.glattachshader(shaderprogram, fragmentshaderprogram); gl.gllinkprogram(shaderprogram); gl.glvalidateprogram(shaderprogram); intbuffer intbuffer = intbuffer.allocate(1); gl.glgetprogramiv(shaderprogram, gl2.gl_link_status, intbuffer); system.out.println("got link status"); if (intbuffer.get(0) != 1) { gl.glgetprogramiv(shaderprogram, gl2.gl_info_log_length, intbuffer); int size = intbuffer.get(0); system.err.println("program link error: "); if (size > 0) { bytebuffer bytebuffer = bytebuffer.allocate(size); gl.glgetprograminfolog(shaderprogram, size, intbuffer, bytebuffer); (byte b: bytebuffer.array()) { system.err.print((char) b); } } else { system.out.println("unknown"); } system.exit(1); }
i error on console, contains no data ..
got link status program link error:
this fragment shader ..
< file :: fragmentshader.txt > uniform sampler2d fish_y_offset; uniform float alphavalue; void main() { gl_fragcolor = texture2d(fish_y_offset, gl_texcoord[0].st); gl_fragcolor.a=alphavalue; }
and vertex shader ..
< file :: vertextshader.txt > uniform float wavetime; uniform float wavewidth; uniform float waveheight; void main(void) { vec4 v = vec4(gl_vertex); v.y = 11 + sin(wavewidth * v.x + wavetime) * cos(wavewidth * v.z + wavetime) * waveheight; gl_position = gl_modelviewprojectionmatrix * v; gl_texcoord[0] = gl_multitexcoord0; }
check shader logs after each shader compilation.
https://www.khronos.org/opengles/sdk/docs/man/xhtml/glgetshaderinfolog.xml
Comments
Post a Comment