mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-11 22:10:07 -05:00
created a separate updateVertexAttributes function
This commit is contained in:
@@ -158,6 +158,8 @@ void RenderableSignals::initializeGL() {
|
||||
// We don't need an index buffer, so we keep it at the default value of 0
|
||||
glGenVertexArrays(1, &_lineRenderInformation._vaoID);
|
||||
glGenBuffers(1, &_lineRenderInformation._vBufferID);
|
||||
|
||||
updateVertexAttributes();
|
||||
}
|
||||
|
||||
void RenderableSignals::deinitializeGL() {
|
||||
@@ -184,6 +186,23 @@ inline void unbindGL() {
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
void RenderableSignals::updateVertexAttributes() {
|
||||
|
||||
// position attributes
|
||||
glVertexAttribPointer(_vaLocVer, _sizeThreeVal, GL_FLOAT, GL_FALSE, sizeof(ColorVBOLayout) + sizeof(PositionVBOLayout) + sizeof(DistanceVBOLayout) + sizeof(float), (void*)0);
|
||||
glEnableVertexAttribArray(_vaLocVer);
|
||||
// color attributes
|
||||
glVertexAttribPointer(_vaLocCol, _sizeFourVal, GL_FLOAT, GL_FALSE, sizeof(ColorVBOLayout) + sizeof(PositionVBOLayout) + sizeof(DistanceVBOLayout) + sizeof(float), (void*)(sizeof(PositionVBOLayout)));
|
||||
glEnableVertexAttribArray(_vaLocCol);
|
||||
// distance attributes
|
||||
glVertexAttribPointer(_vaLocDist, _sizeOneVal, GL_FLOAT, GL_FALSE, sizeof(ColorVBOLayout) + sizeof(PositionVBOLayout) + sizeof(DistanceVBOLayout) + sizeof(float), (void*)(sizeof(PositionVBOLayout) + sizeof(ColorVBOLayout)));
|
||||
glEnableVertexAttribArray(_vaLocDist);
|
||||
// time attribute
|
||||
glVertexAttribPointer(_vaLocTimeSinceStart, _sizeOneVal, GL_FLOAT, GL_FALSE, sizeof(ColorVBOLayout) + sizeof(PositionVBOLayout) + sizeof(DistanceVBOLayout) + sizeof(float), (void*)(sizeof(PositionVBOLayout) + sizeof(ColorVBOLayout) + sizeof(float)));
|
||||
glEnableVertexAttribArray(_vaLocTimeSinceStart);
|
||||
|
||||
};
|
||||
|
||||
void RenderableSignals::render(const RenderData& data, RendererTasks&) {
|
||||
_programObject->activate();
|
||||
|
||||
@@ -280,18 +299,7 @@ void RenderableSignals::update(const UpdateData& data) {
|
||||
GL_STATIC_DRAW
|
||||
);
|
||||
|
||||
// position attributes
|
||||
glVertexAttribPointer(_vaLocVer, _sizeThreeVal, GL_FLOAT, GL_FALSE, sizeof(ColorVBOLayout) + sizeof(PositionVBOLayout) + sizeof(DistanceVBOLayout) + sizeof(float), (void*)0);
|
||||
glEnableVertexAttribArray(_vaLocVer);
|
||||
// color attributes
|
||||
glVertexAttribPointer(_vaLocCol, _sizeFourVal, GL_FLOAT, GL_FALSE, sizeof(ColorVBOLayout) + sizeof(PositionVBOLayout) + sizeof(DistanceVBOLayout) + sizeof(float), (void*)(sizeof(PositionVBOLayout)));
|
||||
glEnableVertexAttribArray(_vaLocCol);
|
||||
// distance attributes
|
||||
glVertexAttribPointer(_vaLocDist, _sizeOneVal, GL_FLOAT, GL_FALSE, sizeof(ColorVBOLayout) + sizeof(PositionVBOLayout) + sizeof(DistanceVBOLayout) + sizeof(float), (void*)(sizeof(PositionVBOLayout) + sizeof(ColorVBOLayout)));
|
||||
glEnableVertexAttribArray(_vaLocDist);
|
||||
// time attribute
|
||||
glVertexAttribPointer(_vaLocTimeSinceStart, _sizeOneVal, GL_FLOAT, GL_FALSE, sizeof(ColorVBOLayout) + sizeof(PositionVBOLayout) + sizeof(DistanceVBOLayout) + sizeof(float), (void*)(sizeof(PositionVBOLayout) + sizeof(ColorVBOLayout)+ sizeof(float)));
|
||||
glEnableVertexAttribArray(_vaLocTimeSinceStart);
|
||||
updateVertexAttributes();
|
||||
|
||||
// Directly render the entire step
|
||||
_lineRenderInformation.first = 0;
|
||||
@@ -301,6 +309,7 @@ void RenderableSignals::update(const UpdateData& data) {
|
||||
unbindGL();
|
||||
}
|
||||
|
||||
|
||||
int RenderableSignals::findFileIndexForCurrentTime(double time, std::vector<double> vec) {
|
||||
// upper_bound has O(log n) for sorted vectors, more efficient than for loop
|
||||
auto iter = std::upper_bound(vec.begin(), vec.end(), time);
|
||||
|
||||
@@ -79,6 +79,7 @@ namespace openspace {
|
||||
*/
|
||||
void render(const RenderData& data, RendererTasks& rendererTask) override;
|
||||
|
||||
void updateVertexAttributes();
|
||||
bool isReady() const override;
|
||||
/* Returns an index for our filenames */
|
||||
static int findFileIndexForCurrentTime(double time, std::vector<double> vec);
|
||||
@@ -92,6 +93,7 @@ namespace openspace {
|
||||
glm::vec3 getPositionForGeocentricSceneGraphNode(const char* id);
|
||||
/* Returns a color based on what site the station is located to */
|
||||
glm::vec3 getStationColor(std::string dishidentifier);
|
||||
/* Returns a distance between two scenegraphnodes */
|
||||
float getDistance(std::string nodeIdA, std::string nodeIdB);
|
||||
|
||||
/* The VBO layout of the vertex position */
|
||||
|
||||
Reference in New Issue
Block a user