本文整理汇总了C++中UniformBufferOffset函数的典型用法代码示例。如果您正苦于以下问题:C++ UniformBufferOffset函数的具体用法?C++ UniformBufferOffset怎么用?C++ UniformBufferOffset使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UniformBufferOffset函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initBuffer
bool initBuffer()
{
// Generate a buffer object
glGenBuffers(buffer::MAX, &BufferName[0]);
// Allocate and copy buffers memory
std::vector<glm::byte> Data(PositionSizeF32 + PositionSizeI8 + PositionSizeI32 + PositionSizeRGB10A2 + PositionSizeF16 + PositionSizeRG11FB10F);
std::size_t CurrentOffset = 0;
memcpy(&Data[0] + CurrentOffset, PositionDataF32, PositionSizeF32);
CurrentOffset += PositionSizeF32;
memcpy(&Data[0] + CurrentOffset, PositionDataI8, PositionSizeI8);
CurrentOffset += PositionSizeI8;
memcpy(&Data[0] + CurrentOffset, PositionDataI32, PositionSizeI32);
CurrentOffset += PositionSizeI32;
memcpy(&Data[0] + CurrentOffset, PositionDataRGB10A2, PositionSizeRGB10A2);
CurrentOffset += PositionSizeRGB10A2;
memcpy(&Data[0] + CurrentOffset, PositionDataF16, PositionSizeF16);
CurrentOffset += PositionSizeF16;
memcpy(&Data[0] + CurrentOffset, PositionDataRG11FB10F, PositionSizeRG11FB10F);
glBindBuffer(GL_ARRAY_BUFFER, BufferName[buffer::VERTEX]);
glBufferStorage(GL_ARRAY_BUFFER, GLsizeiptr(Data.size()), &Data[0], 0);
GLint UniformBufferOffset(0);
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &UniformBufferOffset);
GLint UniformBlockSize = glm::max(GLint(sizeof(glm::mat4)), UniformBufferOffset);
glBindBuffer(GL_UNIFORM_BUFFER, BufferName[buffer::TRANSFORM]);
glBufferStorage(GL_UNIFORM_BUFFER, UniformBlockSize, nullptr, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
return this->checkError("initBuffer");
}
示例2: initBuffer
bool initBuffer()
{
bool Validated(true);
glGenBuffers(buffer::MAX, BufferName);
glObjectLabel(GL_BUFFER, BufferName[buffer::ELEMENT], -1, "Element Array Buffer object");
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, BufferName[buffer::ELEMENT]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, ElementSize, ElementData, GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glObjectLabel(GL_BUFFER, BufferName[buffer::VERTEX], -1, "Array Buffer object");
glBindBuffer(GL_ARRAY_BUFFER, BufferName[buffer::VERTEX]);
glBufferData(GL_ARRAY_BUFFER, VertexSize, VertexData, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
GLint UniformBufferOffset(0);
glGetIntegerv(
GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT,
&UniformBufferOffset);
GLint UniformBlockSize = glm::max(GLint(sizeof(glm::mat4)), UniformBufferOffset);
glObjectLabel(GL_BUFFER, BufferName[buffer::TRANSFORM], -1, "Uniform Buffer object");
glBindBuffer(GL_UNIFORM_BUFFER, BufferName[buffer::TRANSFORM]);
glBufferData(GL_UNIFORM_BUFFER, UniformBlockSize, NULL, GL_DYNAMIC_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
return Validated;
}
示例3: initBuffer
bool initBuffer()
{
glGenBuffers(buffer::MAX, &BufferName[0]);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, BufferName[buffer::ELEMENT]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, ElementSize, ElementData, GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, BufferName[buffer::VERTEX]);
glBufferData(GL_ARRAY_BUFFER, VertexSize, VertexData, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
GLint UniformBufferOffset(0);
glGetIntegerv(
GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT,
&UniformBufferOffset);
GLint UniformBlockSize = glm::max(GLint(sizeof(glm::mat4)), UniformBufferOffset);
glBindBuffer(GL_UNIFORM_BUFFER, BufferName[buffer::TRANSFORM]);
glBufferData(GL_UNIFORM_BUFFER, UniformBlockSize, NULL, GL_DYNAMIC_COPY);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
return true;
}
示例4: initBuffer
bool initBuffer()
{
GLint UniformBufferOffset(0);
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &UniformBufferOffset);
glGenBuffers(buffer::MAX, &BufferName[0]);
glBindBuffer(GL_ARRAY_BUFFER, BufferName[buffer::VERTEX]);
glBufferData(GL_ARRAY_BUFFER, PositionSize, &PositionData[0][0], GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
GLint UniformTransformBlockSize = glm::max(GLint(sizeof(glm::mat4)), UniformBufferOffset);
glBindBuffer(GL_UNIFORM_BUFFER, BufferName[buffer::TRANSFORM]);
glBufferData(GL_UNIFORM_BUFFER, UniformTransformBlockSize, nullptr, GL_DYNAMIC_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
this->UniformMaterialOffset = glm::max(GLint(sizeof(glm::vec4)), UniformBufferOffset);
glBindBuffer(GL_UNIFORM_BUFFER, BufferName[buffer::MATERIAL]);
glBufferData(GL_UNIFORM_BUFFER, this->UniformMaterialOffset * 2, nullptr, GL_STATIC_DRAW);
glm::byte* Pointer = reinterpret_cast<glm::byte*>(
glMapBufferRange(GL_UNIFORM_BUFFER, 0, this->UniformMaterialOffset * 2, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT));
*reinterpret_cast<glm::vec4*>(Pointer + 0) = glm::vec4(0.0f, 0.5f, 1.0f, 1.0f);
*reinterpret_cast<glm::vec4*>(Pointer + this->UniformMaterialOffset) = glm::vec4(1.0f, 0.5f, 0.0f, 1.0f);
glUnmapBuffer(GL_UNIFORM_BUFFER);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
return this->checkError("initBuffer");
}
示例5: initBuffer
bool initBuffer()
{
std::size_t const Count(360);
float const Step(360.f / float(Count));
VertexData.resize(Count);
for(std::size_t i = 0; i < Count; ++i)
VertexData[i] = glm::vec2(glm::sin(glm::radians(Step * float(i))), glm::cos(glm::radians(Step * float(i))));
glGenBuffers(buffer::MAX, &BufferName[0]);
glBindBuffer(GL_ARRAY_BUFFER, BufferName[buffer::VERTEX]);
glBufferData(GL_ARRAY_BUFFER, VertexData.size() * sizeof(glm::vec2), &VertexData[0], GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
GLint UniformBufferOffset(0);
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &UniformBufferOffset);
GLint UniformBlockSize = glm::max(GLint(sizeof(glm::mat4)), UniformBufferOffset);
glBindBuffer(GL_UNIFORM_BUFFER, BufferName[buffer::TRANSFORM]);
glBufferData(GL_UNIFORM_BUFFER, UniformBlockSize, NULL, GL_DYNAMIC_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
return true;
}
示例6: initUniformBuffer
bool initUniformBuffer()
{
bool Validated(true);
GLint UniformBufferOffset(0);
glGetIntegerv(
GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT,
&UniformBufferOffset);
{
GLint UniformBlockSize = glm::max(GLint(sizeof(glm::mat4)), UniformBufferOffset);
glBindBuffer(GL_UNIFORM_BUFFER, BufferName[buffer::TRANSFORM]);
glBufferData(GL_UNIFORM_BUFFER, UniformBlockSize, NULL, GL_DYNAMIC_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
{
GLint UniformBlockSize = glm::max(GLint(sizeof(glm::uvec2)), UniformBufferOffset);
glBindBuffer(GL_UNIFORM_BUFFER, BufferName[buffer::MATERIAL]);
glBufferData(GL_UNIFORM_BUFFER, UniformBlockSize, NULL, GL_DYNAMIC_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
return Validated;
}
示例7: initBuffer
bool initBuffer()
{
glGenBuffers(buffer::MAX, &BufferName[0]);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, BufferName[buffer::ELEMENT]);
glBufferStorage(GL_ELEMENT_ARRAY_BUFFER, ElementSize, ElementData, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, BufferName[buffer::VERTEX]);
glBufferStorage(GL_ARRAY_BUFFER, VertexSize, VertexData, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
GLint UniformBufferOffset(0);
glGetIntegerv(
GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT,
&UniformBufferOffset);
GLint UniformBlockSize = glm::max(GLint(sizeof(glm::mat4)), UniformBufferOffset);
glBindBuffer(GL_UNIFORM_BUFFER, BufferName[buffer::TRANSFORM]);
glBufferStorage(GL_UNIFORM_BUFFER, UniformBlockSize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
return true;
}
示例8: initBuffer
bool initBuffer()
{
bool Validated(true);
glGenBuffers(buffer::MAX, &BufferName[0]);
GLint UniformBufferOffset(0);
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &UniformBufferOffset);
GLint UniformBlockSize = glm::max(GLint(sizeof(glm::mat4)), UniformBufferOffset);
glBindBuffer(GL_UNIFORM_BUFFER, BufferName[buffer::TRANSFORM]);
glBufferData(GL_UNIFORM_BUFFER, UniformBlockSize, nullptr, GL_DYNAMIC_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, BufferName[buffer::ELEMENT]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, ElementSize, ElementData, GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
void* Pointer = initMemoryBuffer();
glBindBuffer(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, BufferName[buffer::VERTEX]);
glBufferData(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, VertexSize, Pointer, GL_STREAM_COPY);
glBindBuffer(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, 0);
glBindBuffer(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, 0);
return Validated;
}
示例9: initBuffer
bool initBuffer()
{
GLint UniformBufferOffset(0);
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &UniformBufferOffset);
GLint UniformBlockSize = glm::max(GLint(sizeof(glm::mat4)), UniformBufferOffset);
glCreateBuffers(buffer::MAX, &BufferName[0]);
glNamedBufferStorage(BufferName[buffer::ELEMENT], ElementSize, ElementData, 0);
glNamedBufferStorage(BufferName[buffer::VERTEX], VertexSize, VertexData, 0);
glNamedBufferStorage(BufferName[buffer::TRANSFORM], UniformBlockSize, nullptr, GL_MAP_WRITE_BIT);
return true;
}
示例10: initBuffer
bool initBuffer()
{
GLint UniformBufferOffset(0);
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &UniformBufferOffset);
UniformBlockSize = glm::max(GLint(sizeof(glm::mat4)), UniformBufferOffset);
glGenBuffers(buffer::MAX, &BufferName[0]);
glNamedBufferDataEXT(BufferName[buffer::ELEMENT], ElementSize, ElementData, GL_STATIC_DRAW);
glNamedBufferDataEXT(BufferName[buffer::VERTEX], VertexSize, VertexData, GL_STATIC_DRAW);
glNamedBufferDataEXT(BufferName[buffer::TRANSFORM], UniformBlockSize, nullptr, GL_DYNAMIC_DRAW);
return true;
}
示例11: initBuffer
bool initBuffer()
{
GLint UniformBufferOffset(0);
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &UniformBufferOffset);
this->UniformBlockSize = glm::max(GLint(sizeof(glm::mat4)), UniformBufferOffset);
glCreateBuffers(buffer::MAX, &BufferName[0]);
glNamedBufferStorage(BufferName[buffer::ELEMENT], ElementSize, ElementData, 0);
glNamedBufferStorage(BufferName[buffer::VERTEX], VertexSize, VertexData, 0);
glNamedBufferStorage(BufferName[buffer::TRANSFORM], this->UniformBlockSize * 2, nullptr, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
this->UniformPointer = static_cast<glm::uint8*>(glMapNamedBufferRange(
BufferName[buffer::TRANSFORM], 0, this->UniformBlockSize * 2, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT | GL_MAP_INVALIDATE_BUFFER_BIT));
return true;
}
示例12: initBuffer
bool initBuffer()
{
glGenBuffers(buffer::MAX, BufferName);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, BufferName[buffer::ELEMENT]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, ElementSize, ElementData, GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, BufferName[buffer::POSITION_INPUT]);
glBufferData(GL_ARRAY_BUFFER, PositionSize * 2, NULL, GL_STATIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, PositionSize, PositionData);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, BufferName[buffer::TEXCOORD_INPUT]);
glBufferData(GL_ARRAY_BUFFER, TexcoordSize * 2, TexcoordData, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, BufferName[buffer::COLOR_INPUT]);
glBufferData(GL_ARRAY_BUFFER, ColorSize * 2, ColorData, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, BufferName[buffer::POSITION_OUTPUT]);
glBufferData(GL_ARRAY_BUFFER, PositionSize * 2, NULL, GL_STATIC_COPY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, BufferName[buffer::TEXCOORD_OUTPUT]);
glBufferData(GL_ARRAY_BUFFER, TexcoordSize * 2, NULL, GL_STATIC_COPY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, BufferName[buffer::COLOR_OUTPUT]);
glBufferData(GL_ARRAY_BUFFER, ColorSize * 2, NULL, GL_STATIC_COPY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
GLint UniformBufferOffset(0);
glGetIntegerv(
GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT,
&UniformBufferOffset);
GLint UniformBlockSize = glm::max(GLint(sizeof(glm::mat4)), UniformBufferOffset);
glBindBuffer(GL_UNIFORM_BUFFER, BufferName[buffer::TRANSFORM]);
glBufferData(GL_UNIFORM_BUFFER, UniformBlockSize, NULL, GL_DYNAMIC_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
return true;
}
示例13: initBuffer
bool initBuffer()
{
glGenBuffers(buffer::MAX, &BufferName[0]);
glBindBuffer(GL_ARRAY_BUFFER, BufferName[buffer::VERTEX]);
glBufferData(GL_ARRAY_BUFFER, PositionSize, &PositionData[0][0], GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
GLint UniformBufferOffset(0);
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &UniformBufferOffset);
GLint UniformBlockSize = glm::max(GLint(sizeof(glm::mat4)), UniformBufferOffset);
glBindBuffer(GL_UNIFORM_BUFFER, BufferName[buffer::TRANSFORM]);
glBufferData(GL_UNIFORM_BUFFER, UniformBlockSize, nullptr, GL_DYNAMIC_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
return true;
}
示例14: initBuffer
bool initBuffer()
{
glGenBuffers(buffer::MAX, &BufferName[0]);
glBindBuffer(GL_SHADER_STORAGE_BUFFER, BufferName[buffer::VERTEX]);
glBufferStorage(GL_SHADER_STORAGE_BUFFER, VertexSize, VertexData, 0);
glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
GLint UniformBufferOffset(0);
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &UniformBufferOffset);
GLint UniformBlockSize = glm::max(GLint(sizeof(transform)), UniformBufferOffset);
glBindBuffer(GL_UNIFORM_BUFFER, BufferName[buffer::TRANSFORM]);
glBufferStorage(GL_UNIFORM_BUFFER, UniformBlockSize, nullptr, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
return true;
}
示例15: initBuffer
bool initBuffer()
{
// Generate a buffer object
glGenBuffers(buffer::MAX, &BufferName[0]);
glBindBuffer(GL_ARRAY_BUFFER, BufferName[buffer::VERTEX]);
glBufferStorage(GL_ARRAY_BUFFER, VertexSize, VertexData, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
GLint UniformBufferOffset(0);
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &UniformBufferOffset);
GLint UniformBlockSize = glm::max(GLint(sizeof(glm::mat4)), UniformBufferOffset);
glBindBuffer(GL_UNIFORM_BUFFER, BufferName[buffer::TRANSFORM]);
glBufferStorage(GL_UNIFORM_BUFFER, UniformBlockSize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
return this->checkError("initBuffer");;
}