Download src/Mod/CAM/PathSimulator/AppGL/MillPathLine.cpp from AbdulElahGwaith/FreeCAD: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/AbdulElahGwaith/FreeCAD/resolve/main/src/Mod/CAM/PathSimulator/AppGL/MillPathLine.cpp
- Command line
-
hf download hf://AbdulElahGwaith/FreeCAD/src/Mod/CAM/PathSimulator/AppGL/MillPathLine.cpp
-
curl -L -o MillPathLine.cpp https://huggingface.co/AbdulElahGwaith/FreeCAD/resolve/main/src/Mod/CAM/PathSimulator/AppGL/MillPathLine.cpp
1.45 kB
| // SPDX-License-Identifier: LGPL-2.1-or-later | |
| namespace MillSim | |
| { | |
| MillPathLine::MillPathLine() | |
| { | |
| mVao = mVbo = 0; | |
| } | |
| void MillPathLine::GenerateModel() | |
| { | |
| mNumVerts = MillPathPointsBuffer.size(); | |
| void* vbuffer = MillPathPointsBuffer.data(); | |
| // vertex array | |
| glGenVertexArrays(1, &mVao); | |
| glBindVertexArray(mVao); | |
| // vertex buffer | |
| glGenBuffers(1, &mVbo); | |
| glBindBuffer(GL_ARRAY_BUFFER, mVbo); | |
| glBufferData(GL_ARRAY_BUFFER, mNumVerts * sizeof(MillPathPosition), vbuffer, GL_STATIC_DRAW); | |
| // vertex attribs | |
| glEnableVertexAttribArray(0); | |
| glVertexAttribPointer( | |
| 0, | |
| 3, | |
| GL_FLOAT, | |
| GL_FALSE, | |
| sizeof(MillPathPosition), | |
| (void*)offsetof(MillPathPosition, X) | |
| ); | |
| glEnableVertexAttribArray(1); | |
| glVertexAttribIPointer( | |
| 1, | |
| 1, | |
| GL_INT, | |
| sizeof(MillPathPosition), | |
| (void*)offsetof(MillPathPosition, SegmentId) | |
| ); | |
| // unbind and free | |
| glBindVertexArray(0); | |
| MillPathPointsBuffer.clear(); | |
| } | |
| void MillPathLine::Clear() | |
| { | |
| MillPathPointsBuffer.clear(); | |
| glBindBuffer(GL_ARRAY_BUFFER, 0); | |
| glBindVertexArray(0); | |
| GLDELETE_BUFFER(mVbo); | |
| GLDELETE_VERTEXARRAY(mVao); | |
| } | |
| void MillPathLine::Render() | |
| { | |
| glBindVertexArray(mVao); | |
| glDrawArrays(GL_LINE_STRIP, 0, mNumVerts); | |
| } | |
| } // namespace MillSim | |