diff options
Diffstat (limited to 'Build/source/utils/asymptote/glrender.cc')
-rw-r--r-- | Build/source/utils/asymptote/glrender.cc | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/Build/source/utils/asymptote/glrender.cc b/Build/source/utils/asymptote/glrender.cc index 727376a2d84..8cbfe2e7cb2 100644 --- a/Build/source/utils/asymptote/glrender.cc +++ b/Build/source/utils/asymptote/glrender.cc @@ -25,6 +25,12 @@ #include "drawimage.h" #include "interact.h" +namespace gl { +#ifdef HAVE_PTHREAD +pthread_t mainthread; +#endif +} + #ifdef HAVE_GL #include "tr.h" @@ -60,13 +66,12 @@ namespace camp { Billboard BB; GLint pixelShader; -GLint noNormalShader; GLint materialShader; GLint colorShader; GLint transparentShader; -vertexBuffer material0Data; -vertexBuffer material1Data; +vertexBuffer material0Data(GL_POINTS); +vertexBuffer material1Data(GL_LINES); vertexBuffer materialData; vertexBuffer colorData; vertexBuffer transparentData; @@ -397,7 +402,6 @@ unsigned char *osmesa_buffer; #endif #ifdef HAVE_PTHREAD -pthread_t mainthread; pthread_cond_t initSignal=PTHREAD_COND_INITIALIZER; pthread_mutex_t initLock=PTHREAD_MUTEX_INITIALIZER; @@ -452,8 +456,7 @@ void initShaders() camp::pixelShader=compileAndLinkShader(shaders,Nlights,Nmaterials, shaderParams); shaderParams.pop_back(); - camp::noNormalShader=compileAndLinkShader(shaders,Nlights,Nmaterials, - shaderParams); + shaderParams.push_back("NORMAL"); camp::materialShader=compileAndLinkShader(shaders,Nlights,Nmaterials, shaderParams); @@ -471,7 +474,6 @@ void deleteShaders() glDeleteProgram(camp::colorShader); glDeleteProgram(camp::materialShader); glDeleteProgram(camp::pixelShader); - glDeleteProgram(camp::noNormalShader); } void setBuffers() @@ -485,7 +487,6 @@ void setBuffers() glBindVertexArray(vao); camp::material0Data.reserve0(); - camp::material1Data.reserve1(); camp::materialData.reserve(); camp::colorData.Reserve(); camp::triangleData.Reserve(); @@ -523,7 +524,7 @@ void drawscene(int Width, int Height) Picture->render(size2,m,M,perspective,remesh); - remesh=false; + if(!outlinemode) remesh=false; } // Return x divided by y rounded up to the nearest integer. @@ -1841,7 +1842,7 @@ void registerBuffer(const std::vector<T>& buffervector, GLuint bufferIndex, void setUniforms(const vertexBuffer& data, GLint shader) { - bool normal=shader != pixelShader && shader != noNormalShader; + bool normal=shader != pixelShader; if(shader != gl::lastshader) { glUseProgram(shader); @@ -1885,7 +1886,6 @@ void setUniforms(const vertexBuffer& data, GLint shader) glUniformMatrix4fv(glGetUniformLocation(shader,"viewMat"),1,GL_FALSE, value_ptr(gl::viewMat)); - if(normal) glUniformMatrix3fv(glGetUniformLocation(shader,"normMat"),1,GL_FALSE, value_ptr(gl::normMat)); @@ -1895,20 +1895,17 @@ void drawBuffer(vertexBuffer& data, GLint shader) { if(data.indices.empty()) return; - bool pixel=shader == pixelShader; - bool normal=shader != noNormalShader && !pixel; + bool normal=shader != pixelShader; bool color=shader == colorShader || shader == transparentShader; const size_t size=sizeof(GLfloat); const size_t intsize=sizeof(GLint); const size_t bytestride=color ? sizeof(VertexData) : - (normal ? sizeof(vertexData) : - (pixel ? sizeof(vertexData0) : sizeof(vertexData1))); + (normal ? sizeof(vertexData) : sizeof(vertexData0)); if(color) registerBuffer(data.Vertices,attributeBuffer); else if(normal) registerBuffer(data.vertices,attributeBuffer); - else if(pixel) registerBuffer(data.vertices0,attributeBuffer); - else registerBuffer(data.vertices1,attributeBuffer); + else registerBuffer(data.vertices0,attributeBuffer); registerBuffer(data.indices,indicesBuffer,GL_ELEMENT_ARRAY_BUFFER); @@ -1925,14 +1922,14 @@ void drawBuffer(vertexBuffer& data, GLint shader) glVertexAttribPointer(normalAttrib,3,GL_FLOAT,GL_FALSE,bytestride, (void *) (3*size)); glEnableVertexAttribArray(normalAttrib); - } else if(pixel) { + } else if(!normal) { glVertexAttribPointer(widthAttrib,1,GL_FLOAT,GL_FALSE,bytestride, (void *) (3*size)); glEnableVertexAttribArray(widthAttrib); } glVertexAttribIPointer(materialAttrib,1,GL_INT,bytestride, - (void *) ((normal ? 6 : (pixel ? 4 : 3))*size)); + (void *) ((normal ? 6 : 4)*size)); glEnableVertexAttribArray(materialAttrib); if(color) { @@ -1941,13 +1938,12 @@ void drawBuffer(vertexBuffer& data, GLint shader) glEnableVertexAttribArray(colorAttrib); } - glDrawElements(normal ? GL_TRIANGLES : (pixel ? GL_POINTS : GL_LINES), - data.indices.size(),GL_UNSIGNED_INT,(void *) 0); + glDrawElements(data.type,data.indices.size(),GL_UNSIGNED_INT,(void *) 0); glDisableVertexAttribArray(positionAttrib); if(normal && gl::Nlights > 0) glDisableVertexAttribArray(normalAttrib); - if(pixel) + if(!normal) glDisableVertexAttribArray(widthAttrib); glDisableVertexAttribArray(materialAttrib); if(color) @@ -1967,7 +1963,7 @@ void drawMaterial0() void drawMaterial1() { - drawBuffer(material1Data,noNormalShader); + drawBuffer(material1Data,materialShader); material1Data.clear(); } |