Jump to content
  • Advertisement
Sign in to follow this  
levjs

OpenGL GLSL gl_LightSource[] Won't Accept Parameters Bigger Than 0

This topic is 4054 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have been messing around with GLSL for the first time recently, I am not new to OpenGL, and I have implemented Per-Pixel-Lighting and such for one light. Now I want to implement it for more than one light. The only problem is that gl_LightSource[x].variable with x greater than 0 crashes the program...but this is weird...only when I shut down the window, specifically, when I try to delete the window context. What is going on here. Am I somehow corrupting the windows memory? Thanks for any help you can give. Thanks, Levi [Edited by - levjs on August 14, 2007 4:58:02 PM]

Share this post


Link to post
Share on other sites
Advertisement
No, I don't believe you need to enable the lights when you are shading.

Actually, the program breaks when I try to delete the program(I have detached the shaders and all that). If I don't try to delete the program, then it breaks when I try to destroy the window context.

I have no idea what's going on. I may have to just use uniform variables to transfer the lighting information if I can't figure this out.

Levi

Share this post


Link to post
Share on other sites
You don't need to enable lights. Same for textures : glEnable(GL_TEXTURE_2D is ignored.

Do you have gl_LightSource[x].variable in yuor code or gl_LightSource[1].variable. It's possible the previous is not supported on your card.
Also, I recommend that you don't use gl_LightSource[x] or any other built in variables. Just upload those things as uniform.
I say this because some drivers have bugs.

Share this post


Link to post
Share on other sites
I use the gl_LightSource[1] in my code. Also, I am trying to use uniform variables; I've created a struct for the lighting variables. The thing is, I'm not sure how to pass structures as uniforms. Do I just pass the individual variables, and then declare the struct in my shader as well??

Thanks for all your help.
Levi

Share this post


Link to post
Share on other sites
Quote:
Original post by levjs
Do I just pass the individual variables, and then declare the struct in my shader as well??


Yes.

struct thing
{
float value;
vec4 value2;
};

thing zing; //this is an instance of thing

You need to get location of zing.value and zing.value2 and update values using glUniform1f and glUniform4f

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!