uniform GLSL uniform vec 3 positions1000 C std


![Обычные uniform-переменные //GLSL uniform vec 3 positions[1000]; //C++ std: : vector<glm: : vec 3> Обычные uniform-переменные //GLSL uniform vec 3 positions[1000]; //C++ std: : vector<glm: : vec 3>](https://slidetodoc.com/presentation_image_h/11e91ea11979649e5f04661b2186323f/image-3.jpg)

![Uniform Buffer Object //GLSL layout(std 140) uniform Positions { vec 3 positions[4000]; }; //C++ Uniform Buffer Object //GLSL layout(std 140) uniform Positions { vec 3 positions[4000]; }; //C++](https://slidetodoc.com/presentation_image_h/11e91ea11979649e5f04661b2186323f/image-5.jpg)
![Shader Storage Buffer Object //GLSL layout(std 430) buffer Positions { vec 3 positions[]; }; Shader Storage Buffer Object //GLSL layout(std 430) buffer Positions { vec 3 positions[]; };](https://slidetodoc.com/presentation_image_h/11e91ea11979649e5f04661b2186323f/image-6.jpg)







- Slides: 13


![Обычные uniformпеременные GLSL uniform vec 3 positions1000 C std vectorglm vec 3 Обычные uniform-переменные //GLSL uniform vec 3 positions[1000]; //C++ std: : vector<glm: : vec 3>](https://slidetodoc.com/presentation_image_h/11e91ea11979649e5f04661b2186323f/image-3.jpg)
Обычные uniform-переменные //GLSL uniform vec 3 positions[1000]; //C++ std: : vector<glm: : vec 3> positions; GLint uniform. Loc = gl. Get. Uniform. Location(_program. Id, “positions”); gl. Uniform 3 fv(uniform. Loc, positions. size(), positions. data());

Uniform Buffer Object Группировка обычных юниформ-переменных для удобства struct Light. Info { vec 3 pos; vec 3 La; vec 3 Ld; vec 3 Ls; float a 0; float a 1; float a 2; }; uniform Light. Info light; Юниформ-блок layout(std 140) uniform Light. Info { vec 3 pos; vec 3 La; vec 3 Ld; vec 3 Ls; float a 0; float a 1; float a 2; } light;
![Uniform Buffer Object GLSL layoutstd 140 uniform Positions vec 3 positions4000 C Uniform Buffer Object //GLSL layout(std 140) uniform Positions { vec 3 positions[4000]; }; //C++](https://slidetodoc.com/presentation_image_h/11e91ea11979649e5f04661b2186323f/image-5.jpg)
Uniform Buffer Object //GLSL layout(std 140) uniform Positions { vec 3 positions[4000]; }; //C++ std: : vector<glm: : vec 3> positions; Gluint ubo; gl. Gen. Buffers(1, & ubo); gl. Bind. Buffer(GL_UNIFORM_BUFFER, ubo); gl. Buffer. Data(GL_UNIFORM_BUFFER, размер, указатель, GL_DYNAMIC_DRAW); gl. Bind. Buffer. Base(GL_UNIFORM_BUFFER, 0, ubo); unsigned int ubo. Index = gl. Get. Uniform. Block. Index(_program. Id, "Positions"); gl. Uniform. Block. Binding(_program. Id, ubo. Index, 0); //0 я точка привязки
![Shader Storage Buffer Object GLSL layoutstd 430 buffer Positions vec 3 positions Shader Storage Buffer Object //GLSL layout(std 430) buffer Positions { vec 3 positions[]; };](https://slidetodoc.com/presentation_image_h/11e91ea11979649e5f04661b2186323f/image-6.jpg)
Shader Storage Buffer Object //GLSL layout(std 430) buffer Positions { vec 3 positions[]; }; //C++ std: : vector<glm: : vec 3> positions; Gluint ssbo; gl. Gen. Buffers(1, & ssbo); gl. Bind. Buffer(GL_SHADER_STORAGE_BUFFER, ssbo); gl. Buffer. Data(GL_SHADER_STORAGE_BUFFER, размер, указатель, GL_DYNAMIC_DRAW); gl. Bind. Buffer. Base(GL_SHADER_STORAGE_BUFFER, 0, ssbo); unsigned int ssbo. Index = gl. Get. Program. Resource. Index(_program. Id, GL_SHADER_STORAGE_BLOCK, "Positions"); gl. Shader. Storage. Block. Binding(_program. Id, ssbo. Index, 0); //0 я точка привязки

Texture Buffer //GLSL uniform sampler. Buffer tex. Buf; //C++ std: : vector<glm: : vec 3> positions; Gluint tbo; gl. Gen. Buffers(1, & tbo); gl. Bind. Buffer(GL_TEXTURE_BUFFER, tbo); gl. Buffer. Data(GL_TEXTURE_BUFFER, размер, указатель, GL_DYNAMIC_DRAW); Gluint tex. Id; gl. Gen. Textures(1, &tex. Id); gl. Bind. Texture(GL_TEXTURE_BUFFER, tex. Id) gl. Tex. Buffer(GL_TEXTURE_BUFFER, GL_RGB 32 F_ARB, tbo);

Vertex Attribute Divisor //GLSL layout(location = 3) in vec 3 model. Pos; //C++ std: : vector<glm: : vec 3> positions; Gluint vbo; gl. Gen. Buffers(1, & vbo); gl. Bind. Buffer(GL_ARRAY_BUFFER, vbo); gl. Buffer. Data(GL_ARRAY_BUFFER, размер, указатель, GL_DYNAMIC_DRAW); gl. Bind. Vertex. Array(_vao); gl. Enable. Vertex. Attrib. Array(3); gl. Vertex. Attrib. Pointer(3, 3, GL_FLOAT, GL_FALSE, 0, 0); gl. Vertex. Attrib. Divisor(3, 1);




