| 70 | } |
| 71 | |
| 72 | void 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 | |
| 111 | bool VertexBufferGL33::Init(const Shape& src, VBType type) |
| 112 | { |
nothing calls this directly
no test coverage detected