Passing unifrom glm::vec3 array to shader

Hello guys,

I´m trying to pass an array with vec3 to a fragmentshader.
My code looks like this, but I think it`s wrong:


bool Shader::SetShaderVec3ArrayParameter(const char* pName, vec3 pValue[])
{
	int loc = glGetUniformLocation(m_shaderProgram, pName);
	if (loc >= 0)
	{
		glUniform3fv(loc, sizeof(pValue),(float*)pValue);

		return true;
	}

	return false;
}


can anyone tell me how to pass an array of vec3 to a shader as an uniform variable?!
Thanks in advance

What version of OpenGL are you using?

In OpenGL 4 I would maybe create a uniform buffer with glBufferStorage (if available to you) otherwiese glBufferData. I would then use glBindBufferBase with an explicit binding point, as to avoid any shader reflection.

ex:


layout(binding = 0, std140) uniform SomeBlock
{
    vec3 data[MAX_DATA_ARRAY_SIZE];
};


bool Shader::SetShaderVec3ArrayParameter(const char* pName, vec3 pValue[])
{
    ....
        glUniform3fv(loc, sizeof(pValue),(float*)pValue);
    ....
}

pValue is a pointer to a vec3. sizeof(pValue) is the size of a pointer as a multiple as the size of a char. Probably 8 or 4 or something.
What is your vec3 anyway? Does it really store exactely 3 float value with no padding whatsoever?

[QUOTE=Agent D;1258332]



What is your vec3 anyway? Does it really store exactely 3 float value with no padding whatsoever?[/QUOTE]

vec3 is a glm::vec3 from an OpenGl Mathematics library

glm.g-truc.net/0.9.5/index.html


I thought that it stores 3 float values as a vec3. When I pass just one vec3, everything works fine. Only the array isn`t working.

[QUOTE=Chris_F;1258329]What version of OpenGL are you using?

[/QUOTE]

I`m using OpenGL 4. I don`t think that I get your code right :o. Can you describe it more in detail?

http://www.opengl.org/sdk/docs/man/docbook4/xhtml/glBufferStorage.xml

https://www.opengl.org/sdk/docs/man/docbook4/xhtml/glBindBufferBase.xml

http://www.opengl.org/registry/specs/ARB/shading_language_420pack.txt

http://www.opengl.org/wiki/Interface_Block_(GLSL)#Uniform_blocks