PrevUpHomeNext

Vertex attributes

#include <oglplus/vertex_attrib.hpp>

Basic vertex attribute location operations

template <>
class ProgVarLocOps<tag::VertexAttrib>
{
public:
	static void BindLocation(
		ProgramName program,
		VertexAttribSlot location,
		StrCRef identifier
	); 1

	static GLint GetLocation(
		ProgramName program,
		StrCRef identifier,
		bool active_only
	); 2
	static VertexAttribSlot GetLocation(
		ProgramName program,
		StrCRef identifier
	); 3

	static bool QueryActiveLocation(
		ProgramName program,
		StrCRef identifier,
		VertexAttribSlot& location
	); 4

	static bool QueryCommonLocation(
		const Sequence<ProgramName>& programs,
		StrCRef identifier,
		VertexAttribSlot& location
	); 5

	static VertexAttribSlot GetCommonLocation(
		const Sequence<ProgramName>& programs,
		StrCRef identifier
	); 6
};

1

Binds the vertex attribute location. See glBindAttribLocation.

2

Finds the location of the input vertex attribute specified by identifier in a program. If active_only is true then throws if no such attribute exists or if it is not active. For a non-throwing version see QueryActiveLocation(). See glGetAttribLocation.

3

Equivalent to GetLocation(program, identifier, true).

4

Queries the vertex attribute location, returns false on failure. See glGetAttribLocation.

5

Allows to query the vertex attribute location in multiple programs This function returns a temporary object that allows to query the location of the specified identifier in several programs. The returned object has two functions called In and And which are equivalent and take a Program as the argument. Both these functions return in turn a new instance of the temporary which allows to check in another program, and so on. The temporary is also convertible to bool indicating whether a common location was found in all programs in the chain. See glGetAttribLocation.

[Note] Note

Never store the resulting object in a named variable nor use it after the call to this overload of QueryCommonLocation has finished. Doing this causes undefined behavior.

6

Returns vertex attribute location in multiple programs if it's consistent. Finds the location of the input vertex attribute specified by identifier in every program in programs. Throws Error if no such attribute exists or if it is not active in some of the programs or if the attribute has different locations in different programs. Otherwise returns the vertex attribute position. See glGetAttribLocation.

Common operations

template <>
class ProgVarCommonOps<tag::VertexAttrib> 1
 : public ProgVarLoc<tag::VertexAttrib>
{
public:
	void Bind(StrCRef identifier); 2

#if GL_VERSION_3_3
	void Divisor(GLuint divisor) const; 3
#endif
};

1

Indirectly inherits from ProgVarCommonOps

2

Binds the vertex attribute specified by identifier to this vertex attribute location. See glBindAttribLocation.

3

Sets the vertex attribute divisor See glVertexAttribDivisor.

Get/set operations

template <typename OpsTag, typename T>
class ProgVarGetSetOps<OpsTag, tag::VertexAttrib, T>
 : public ProgVarCommonOps<tag::VertexAttrib>
{
public:
	void Set(T value);
	void SetValue(T value); 1

	void TrySet(T value); 2
};

1

Sets the vertex attribute value. See glVertexAttrib.

2

Sets the vertex attribute value if it is active. See glVertexAttrib.

Definition

template <typename T>
using VertexAttrib = ProgVar<
	tag::ImplicitSel,
	tag::Uniform,
	tag::NoTypecheck,
	T
>; 1

1

VertexAttrib inherits indirectly from ProgVarCommonOps, ProgVarCommonOps and ProgVarGetSetOps.

Vertex array attributes

class VertexArrayAttrib
 : public ProgVarCommonOps<tag::VertexAttrib>
{
public:
	VertexArrayAttrib(VertexAttribSlot location);

	VertexArrayAttrib(ProgramName program, VertexAttribSlot location);

	VertexArrayAttrib(ProgramName program, StrCRef identifier);

	const VertexArrayAttrib& Setup(
		GLint values_per_vertex,
		DataType data_type
	) const;

	const VertexArrayAttrib& Setup(
		GLint values_per_vertex,
		DataType data_type
	) const; 1

	template <typename T>
	const VertexArrayAttrib& Setup(GLuint n = 1) const; 2

	const VertexArrayAttrib& Pointer(
		GLint values_per_vertex,
		DataType data_type,
		Boolean normalized,
		SizeType stride,
		const void* pointer
	) const; 3

	const VertexArrayAttrib& IPointer(
		GLuint values_per_vertex,
		DataType data_type,
		SizeType stride,
		const void* pointer
	) const; 4

#if GL_VERSION_4_2 || GL_ARB_vertex_attrib_64bit
	const VertexArrayAttrib& LPointer(
		GLuint values_per_vertex,
		DataType data_type,
		SizeType stride,
		const void* pointer
	) const; 5
#endif

#if GL_VERSION_4_3 || GL_ARB_vertex_attrib_binding
	const VertexArrayAttrib& Format(
		GLint values_per_vertex,
		DataType data_type,
		Boolean normalized,
		GLuint relative_offset
	) const; 6

	const VertexArrayAttrib& IFormat(
		GLint values_per_vertex,
		DataType data_type,
		GLuint relative_offset
	) const; 7

	const VertexArrayAttrib& LFormat(
		GLint values_per_vertex,
		DataType data_type,
		GLuint relative_offset
	) const; 8
#endif

	const VertexArrayAttrib& Enable(void) const; 9

	const VertexArrayAttrib& Disable(void) const; 10
};

template <std::size_t N>
VertexArrayAttrib operator | (
	ProgramName program,
	const GLchar (&identifier)[N]
);

VertexArrayAttrib operator | (
	ProgramName program,
	GLuint location
);

1

Sets up the properties of this vertex attribute array. See glVertexAttribPointer.

[Note] Note

Consider using the templated version of Setup(), because it is more portable.

2

Sets up the properties of this vertex attribute array. See glVertexAttribPointer.

3

See glVertexAttribPointer.

4

See glVertexAttribIPointer.

5

See glVertexAttribLPointer.

6

See glVertexAttribFormat.

7

See glVertexAttribIFormat.

8

See glVertexAttribLFormat.

9

Enables this vertex attribute array. See glEnableVertexArrayAttrib.

10

Disables this vertex attribute array. See glDisableVertexArrayAttrib.


PrevUpHomeNext