File: GLUniform.h

package info (click to toggle)
jazz2-native 3.5.0-2
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 16,912 kB
  • sloc: cpp: 172,557; xml: 113; python: 36; makefile: 5; sh: 2
file content (65 lines) | stat: -rw-r--r-- 1,379 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#pragma once

#ifndef DOXYGEN_GENERATING_OUTPUT
#define NCINE_INCLUDE_OPENGL
#include "../../CommonHeaders.h"
#endif

#include "../../../Main.h"

namespace nCine
{
	/// Stores information about an active OpenGL shader uniform
	/*! Its only purpose is to initialize a `GLUniformCache` class. */
	class GLUniform
	{
		friend class GLUniformBlock;

	public:
		static constexpr std::uint32_t MaxNameLength = 48;

		GLUniform();
		GLUniform(GLuint program, GLuint index);

		inline GLuint GetIndex() const {
			return index_;
		}
		inline GLint GetBlockIndex() const {
			return blockIndex_;
		}
		inline GLint GetLocation() const {
			return location_;
		}
		inline GLint GetSize() const {
			return size_;
		}
		inline GLenum GetType() const {
			return type_;
		}
		inline GLint GetOffset() const {
			return offset_;
		}
		inline const char* GetName() const {
			return name_;
		}
		GLenum GetBasicType() const;
		std::uint32_t GetComponentCount() const;
		inline std::uint32_t GetMemorySize() const {
			return GetSize() * GetComponentCount() * sizeof(GetBasicType());
		}

		/// Returns true if the uniform name starts with `gl_`
		bool HasReservedPrefix() const;

	private:
		GLuint index_;
		/// Active uniforms not in a block have a block index of -1
		GLint blockIndex_;
		GLint location_;
		GLint size_;
		GLenum type_;
		GLint offset_;
		char name_[MaxNameLength];
	};

}