diff options
Diffstat (limited to 'graphics/asymptote/glrender.cc')
-rw-r--r-- | graphics/asymptote/glrender.cc | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/graphics/asymptote/glrender.cc b/graphics/asymptote/glrender.cc index 0220398138..e0194e436c 100644 --- a/graphics/asymptote/glrender.cc +++ b/graphics/asymptote/glrender.cc @@ -397,9 +397,17 @@ bool Step; #ifdef HAVE_GL +stopWatch spinTimer; + +void idleFunc(void (*f)()) +{ + spinTimer.reset(); + glutIdleFunc(f); +} + void idle() { - glutIdleFunc(NULL); + idleFunc(NULL); Xspin=Yspin=Zspin=Animate=Step=false; } #endif @@ -435,7 +443,6 @@ double T[16]; #ifdef HAVE_GL #ifdef HAVE_LIBGLUT -timeval lasttime; int oldWidth,oldHeight; bool queueScreen=false; @@ -777,7 +784,7 @@ void deleteShaders() glDeleteProgram(camp::pixelShader); } -void resizeBlendShader(uint maxsize) +void resizeBlendShader(GLuint maxsize) { gl::maxSize=ceilpow2(maxsize); gl::deleteBlendShader(); @@ -1165,11 +1172,6 @@ void togglefitscreen() fitscreen(); } -void idleFunc(void (*f)()) -{ - glutIdleFunc(f); -} - void screen() { if(glthread && !interact::interactive) @@ -1579,13 +1581,7 @@ void mouse(int button, int state, int x, int y) double spinstep() { - timeval tv; - gettimeofday(&tv,NULL); - double step=getSetting<double>("spinstep")* - (tv.tv_sec-lasttime.tv_sec+ - ((double) tv.tv_usec-lasttime.tv_usec)/1000000.0); - lasttime=tv; - return step; + return getSetting<double>("spinstep")*spinTimer.seconds(true); } void xspin() @@ -1892,14 +1888,19 @@ void init_osmesa() #endif // HAVE_LIBOSMESA } -#endif /* HAVE_GL */ - bool NVIDIA() { - char *GLSL_VERSION=(char *) glGetString(GL_SHADING_LANGUAGE_VERSION); +#ifdef GL_SHADING_LANGUAGE_VERSION + const char *GLSL_VERSION=(const char *) + glGetString(GL_SHADING_LANGUAGE_VERSION); +#else + const char *GLSL_VERSION=""; +#endif return string(GLSL_VERSION).find("NVIDIA") != string::npos; } +#endif /* HAVE_GL */ + // angle=0 means orthographic. void glrender(const string& prefix, const picture *pic, const string& format, double width, double height, double angle, double zoom, @@ -1908,7 +1909,6 @@ void glrender(const string& prefix, const picture *pic, const string& format, double *background, size_t nlightsin, triple *lights, double *diffuse, double *specular, bool view, int oldpid) { - gettimeofday(&lasttime,NULL); Iconify=getSetting<bool>("iconify"); if(zoom == 0.0) zoom=1.0; @@ -2180,7 +2180,8 @@ void glrender(const string& prefix, const picture *pic, const string& format, if(glinitialize) { glinitialize=false; - char *GLSL_VERSION=(char *) glGetString(GL_SHADING_LANGUAGE_VERSION); + const char *GLSL_VERSION=(const char *) + glGetString(GL_SHADING_LANGUAGE_VERSION); GLSLversion=(int) (100*atof(GLSL_VERSION)+0.5); if(GLSLversion < 130) { @@ -2424,19 +2425,19 @@ void refreshBuffers() glBindBufferBase(GL_SHADER_STORAGE_BUFFER,2,camp::countBuffer); if(GPUcompress) { - glBindBuffer(GL_SHADER_STORAGE_BUFFER,camp::indexBuffer); - glBufferData(GL_SHADER_STORAGE_BUFFER,gl::pixels*sizeof(GLuint), - NULL,GL_DYNAMIC_DRAW); - glBindBufferBase(GL_SHADER_STORAGE_BUFFER,1,camp::indexBuffer); - GLuint one=1; glBindBuffer(GL_ATOMIC_COUNTER_BUFFER,camp::elementsBuffer); glBufferData(GL_ATOMIC_COUNTER_BUFFER,sizeof(GLuint),&one, GL_DYNAMIC_DRAW); glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER,0,camp::elementsBuffer); - } else - glClearBufferData(GL_SHADER_STORAGE_BUFFER,GL_R8UI,GL_RED_INTEGER, - GL_UNSIGNED_BYTE,&zero); // Clear the count buffer + + glBindBuffer(GL_SHADER_STORAGE_BUFFER,camp::indexBuffer); + glBufferData(GL_SHADER_STORAGE_BUFFER,gl::pixels*sizeof(GLuint), + NULL,GL_DYNAMIC_DRAW); + glBindBufferBase(GL_SHADER_STORAGE_BUFFER,1,camp::indexBuffer); + } + glClearBufferData(GL_SHADER_STORAGE_BUFFER,GL_R32UI,GL_RED_INTEGER, + GL_UNSIGNED_INT,&zero); // Clear count or index buffer glBindBuffer(GL_SHADER_STORAGE_BUFFER,camp::opaqueBuffer); glBufferData(GL_SHADER_STORAGE_BUFFER,gl::pixels*sizeof(glm::vec4),NULL, @@ -2464,8 +2465,8 @@ void refreshBuffers() if(gl::exporting && GPUindexing && !GPUcompress) { glBindBuffer(GL_SHADER_STORAGE_BUFFER,camp::countBuffer); - glClearBufferData(GL_SHADER_STORAGE_BUFFER,GL_R8UI,GL_RED_INTEGER, - GL_UNSIGNED_BYTE,&zero); + glClearBufferData(GL_SHADER_STORAGE_BUFFER,GL_R32UI,GL_RED_INTEGER, + GL_UNSIGNED_INT,&zero); glBindBuffer(GL_SHADER_STORAGE_BUFFER,camp::feedbackBuffer); } |