From acc30a5e60e9c691fb440ac85a054db408207ea1 Mon Sep 17 00:00:00 2001 From: pgovyadi Date: Wed, 21 Sep 2016 18:10:39 -0500 Subject: [PATCH] Added the ability for glObj to render with blended lines --- stim/visualization/glObj.h | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/stim/visualization/glObj.h b/stim/visualization/glObj.h index e0be584..2493d0a 100644 --- a/stim/visualization/glObj.h +++ b/stim/visualization/glObj.h @@ -43,7 +43,7 @@ private: } void - Create(GLenum mode, bool blend = false) + Create(GLenum mode, bool blend = false, float opacity = 1.0, stim::vec3 point = stim::vec(-10000.0, -10000.0, -10000.0)) { // GLuint selectBuf[2048]; // GLint hits; @@ -65,7 +65,15 @@ private: { glLoadName(i); } - glColor3f(0.0, 1.0, 0.05); + if(blend == false) + glColor3f(0.0, 1.0, 0.05); + + else if(blend && point[0] < -9999.9) + { + glColor4f(50.0/256.0,205.0/256.0, 50.0/256.0, opacity); ///Dark Green. + } else { +// ??????? + } //glColor3ub(rand()%255, rand()%255, rand()%255); glBegin(GL_LINE_STRIP); for(int j = 0; j < line.size(); j++){ @@ -90,11 +98,19 @@ public: } void - createFromSelf(GLenum mode = GL_RENDER, bool blend = false) + createFromSelf(GLenum mode = GL_RENDER, bool blend = false, float opacity = 1.0) + { + // glPopMatrix(); + init(); + Create(mode, blend, opacity); + // glPushMatrix(); + } + + createFromSelf(GLenum mode = GL_RENDER, bool blend = false, stim::vec3 point) { // glPopMatrix(); init(); - Create(mode, blend); + Create(mode, blend, 1.0, point); // glPushMatrix(); } @@ -111,9 +127,16 @@ public: void - Render() + Render(bool blend = false) { + if(blend) + { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } glCallList(dList); + if(blend) + glDisable(GL_BLEND); CHECK_OPENGL_ERROR } -- libgit2 0.21.4