Jump to content
  • Advertisement
Sign in to follow this  
Android_s

OpenGL Urgent: GLSL and VertexAttrib problems (solved)

This topic is 5060 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 am trying to make a set of classes to handle shading programs and i'm asked to have support for "User Defined Vertex Attributes". I've read all that i can find but frankly i'm not getting any wiser... I add a attribute float fooBar; to my .vert shader, and set it with a function SetVertexAttrib1fARB(string name, float val);. This function looks like this inside:
void ShadingProgram::SetVertexAttribute1f(std::string name, float f)
{
	if(shaderProgram == NULL) return;

	glVertexAttrib1fARB(GetAttribLoc(name), f);
}
GetAttribLoc() looks like this:
int ShadingProgram::GetAttribLoc(std::string name)
{
	if(shaderProgram == NULL) return -1;

	int loc = glGetAttribLocationARB(shaderProgram, name.c_str());

	if (loc == -1)
	{
		std::ostringstream stream;
		stream << "No such attribute named \"" << name << "\"";
		ErrorLog(stream.str());
	}

	CheckOpenGLError();  // Check for OpenGL errors

    return loc;
}
Now when i run my test application it spams me with "No such attribute named fooBar", and i can't figure out why... Is there something i have forgotten or missunderstood regarding the VertexAttributes? [Edited by - Android_s on November 12, 2004 6:11:47 AM]

Share this post


Link to post
Share on other sites
Advertisement
Hmm, is that so..?
You are correct, the attribute isn't used in the program, it's just a test variable. I will make some use of it and then try.

Thank you for the help!

I have one more question i might aswell ask right now [smile]

When i want to set a mat2, mat3 or mat4, how am i supposed to go about then? Is it possible to use the GetAttribLoc() function and then do something like this:

// m is a [2][2] array
glVertexAttrib2fvARB(GetAttribLoc(name), m[0]);
glVertexAttrib2fvARB(GetAttribLoc(name) + 1, m[1]);


...or is there a better way?

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!