MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / CopyVertices

Method CopyVertices

engine/PoseidonGL33/EngineGL33_VertexBuffer.cpp:72–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72void VertexBufferGL33::CopyVertices(const Shape& src)
73{
74 if (_vertexCount <= 0)
75 return;
76
77 glBindBuffer(GL_ARRAY_BUFFER, _vbo);
78 // The map-flag combination is selected by the named helper. There
79 // is no API exposed by `Poseidon::render::buf` that maps a static buffer with
80 // INVALIDATE (B-028) or a dynamic buffer without it — picking the
81 // wrong helper is the only way to land in the bug class, and the
82 // helper name makes the mistake glaring. See
83 // `engine/Poseidon/Graphics/Core/GLBufferMap.hpp`.
84 void* mapped = _dynamic ? Poseidon::render::buf::MapDynamicWriteInvalidate(GL_ARRAY_BUFFER, 0, _vertexCount * sizeof(SVertex))
85 : Poseidon::render::buf::MapStaticWriteOnce(GL_ARRAY_BUFFER);
86 SVertex* sData = static_cast<SVertex*>(mapped);
87 if (!sData)
88 {
89 LOG_ERROR(Graphics, "GL33: VBO map failed");
90 return;
91 }
92
93 const UVPair* uv = &src.UV(0);
94 const Vector3* pos = &src.Pos(0);
95 const Vector3* norm = &src.Norm(0);
96 for (int i = src.NVertex(); --i >= 0;)
97 {
98 sData->pos = Vector3P(pos->X(), pos->Y(), pos->Z());
99 // Normals are negated (matches D3D11 convention)
100 sData->norm = Vector3P(-norm->X(), -norm->Y(), -norm->Z());
101 pos++;
102 norm++;
103 sData->t0 = *uv;
104 uv++;
105 sData++;
106 }
107
108 glUnmapBuffer(GL_ARRAY_BUFFER);
109}
110
111bool VertexBufferGL33::Init(const Shape& src, VBType type)
112{

Callers

nothing calls this directly

Calls 9

MapStaticWriteOnceFunction · 0.85
Vector3PClass · 0.85
PosMethod · 0.80
NormMethod · 0.80
NVertexMethod · 0.45
XMethod · 0.45
YMethod · 0.45
ZMethod · 0.45

Tested by

no test coverage detected