Hi, I have two questions, I am implementing spherical harmonics lighting and trying to use GLSL for the real time part. I have an array consisting of 16 element with type of Color. Color is a class with R, G and B which are float. how should I pass this array to shader?
int sh_location = glGetUniformLocation(SHShader.GetID(), "vf3Light");
glUniform3fvARB(sh_location, 16, light_tex.m_shCoeffRead);
but I get the error!
My other question is that, for each vertex I have 16 coefficients which I’m reading them from a file and have to send them to my shader for calculating light, but I have no idea how to send them, I though about dividing them into 4 part and assign each part to a texture, but i don’t think it’s a good idea.
int sh_location = glGetUniformLocation(SHShader.GetID(), "vf3Light");
glUniform3fvARB(sh_location, 16, light_tex.m_shCoeffRead);
This mixes the ARB extension GLSL functions (from ARB_shader_objects) with core GLSL functions. That is never a good idea. Just use the core functionality, not the functions that end in ARB.
yeah that can be what i want! A 4*4 matrix can work too, but is there any other ways without using VBO? I’m don’t know about vertex buffers and try to not to use it.
Can you explain why it’s not a good idea to use ARB?
Because it is ancient. It was only ever a test run for GLSL. The interaction between GLSL versions 1.10 and above are not defined when using ARB_shader_objects.
You shouldn’t be using it at all.
In general, if something is in core, you should use it as a core feature. Only if it is only available as an extension (or you need to support some version of OpenGL in which it is not core) should you do it. And you should never mix the two.
yeah that can be what i want! A 4*4 matrix can work too, but is there any other ways without using VBO? I’m don’t know about vertex buffers and try to not to use it.
The previosly noted reference talks about other methods but the VBO is the recommended one. It is well worth the effort to learn about VBOs.