Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

problem with GLSL

Started by bojkarPL Dec 24, 2004 at 4:21 AM 5 replies 1.1k views
Original Post
bojkarPL
bojkarPL
Hello I have function in my class: void CShader::sendToShader(char *varname,GLint v0) { int loc = glGetUniformLocationARB(my_program, varname); glUniform1iARB(loc, v0); } And i have fragment program: niform sampler2D basetex; uniform sampler2D bumptex; varying vec3 eyeVec; void main() { vec2 texUV, srcUV = gl_TexCoord[0].xy; float height = texture2D(bumptex, srcUV).r; float v = height * 0.04 - 0.02; vec3 eye = normalize(eyeVec); texUV = srcUV + (eye.xy * v); vec3 rgb = texture2D(basetex, texUV).rgb; gl_FragColor = vec4(vec3(rgb), 1.0); // gl_FragColor = vec4(vec3(rgb)*height, 1.0); } in my engin code: shader.start(); shader.sendToShader("bumptex",0); render_scene(); shader.stop(); And when i run this i have error "memory can't be read" What is wrong? merry christmas :)
nts
nts
where exactly is the memory read error occuring? Which line. This will be very helpful in solving the problem :)
bojkarPL
bojkarPL
Ok.

In this line:

glUniform1iARB(loc, v0);
nts
nts
Quote:
Original post by bojkarPL
Ok.

In this line:

glUniform1iARB(loc, v0);


Is loc valid? Check that it is not 0

bojkarPL
bojkarPL
loc value is ok
loc=1
bojkarPL
bojkarPL
ok i have error ;D
I forget about define this extanasion(glUniform1iARB sic!) :| Sorry and thanks!
nts
nts
Quote:
Original post by bojkarPL
loc value is ok
loc=1


very odd, is the crash happening in your application or is the crash in the video driver. Run in debug mode, when it crashes it should show you the stack trace, if the last thing on the stack is something like 'atiglxxx.dll' or an nvidia dll then i suggest updating the driver (and checking your shader loading, linking and binding). If the crash is in your app, hmm might want to check that those functions are linked correctly from the ogl extensions (if you aren't using glee or something). You might have a NULL pointer (what is the read error address).

HTH


EDIT: good to hear it works, didn't see above post when i posted this :p


[Edited by - nts on December 25, 2004 3:32:29 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.