flopoloco's picture

How to get all attributes of a shader program?

Just as the title says, is there any way to do this?


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

Link the program, then use GL.GetProgram to query the attribute count and loop with GL.GetActiveAttrib() to retrieve their details. See here for example code: https://stackoverflow.com/questions/440144/in-opengl-is-there-a-way-to-g...

Edit: the OpenGL wiki is always worth searching, see https://www.opengl.org/wiki/Program_Introspection

flopoloco's picture

Wow it worked, thanks for pointing me what do look for.

			int attributes;
			GL.GetProgramInterface(shader.ID, ProgramInterface.ProgramInput,
				ProgramInterfaceParameter.ActiveResources, out attributes);
			for (var i = 0; i < attributes; i++) {
				var sb = new System.Text.StringBuilder();
				int length = 0;
				GL.GetProgramResourceName(shader.ID, ProgramInterface.ProgramInput, i, 256, out length, sb);