50 # include <OpenGL/gl.h> 71 GLfloat *feedbackBuffer = NULL ;
83 vparams.
progress(0.0, QGLViewer::tr(
"Rendering...")) ;
87 if(feedbackBuffer != NULL)
88 delete[] feedbackBuffer ;
90 feedbackBuffer =
new GLfloat[vparams.
size()] ;
92 if(feedbackBuffer == NULL)
93 throw std::runtime_error(
"Out of memory during feedback buffer allocation.") ;
95 glFeedbackBuffer(vparams.
size(), GL_3D_COLOR, feedbackBuffer);
96 glRenderMode(GL_FEEDBACK);
97 render_callback(callback_params);
98 returned = glRenderMode(GL_RENDER);
103 vparams.
size() *= 2 ;
110 glGetIntegerv(GL_DEPTH_BITS, &depth_bits) ;
116 if (returned > vparams.
size())
117 vparams.
size() = returned;
118 #ifdef _VRENDER_DEBUG 119 cout <<
"Size = " << vparams.
size() <<
", returned=" << returned << endl ;
125 vector<PtrPrimitive> primitive_tab ;
130 if(feedbackBuffer != NULL)
132 delete[] feedbackBuffer ;
133 feedbackBuffer = NULL ;
139 bfopt.
optimize(primitive_tab,vparams) ;
160 throw std::runtime_error(
"Unknown sorting method.") ;
170 vopt.
optimize(primitive_tab,vparams) ;
174 if(vparams.
isEnabled(VRenderParams::OptimizePrimitiveSplit))
195 throw std::runtime_error(
"Sorry, this output format is not handled now. Only EPS and PS are currently supported.") ;
200 GLfloat viewport[4],clearColor[4],lineWidth,pointSize ;
202 glGetFloatv(GL_COLOR_CLEAR_VALUE, clearColor);
203 glGetFloatv(GL_LINE_WIDTH, &lineWidth);
204 glGetFloatv(GL_POINT_SIZE, &pointSize);
205 glGetFloatv(GL_VIEWPORT, viewport);
207 lineWidth /= (float)max(viewport[2] - viewport[0],viewport[3]-viewport[1]) ;
214 exporter->
setBoundingBox(viewport[0],viewport[1],viewport[0]+viewport[2],viewport[1]+viewport[3]) ;
218 exporter->
setClearColor(clearColor[0],clearColor[1],clearColor[2]) ;
224 for(
unsigned int i=0;i<primitive_tab.size();++i)
225 delete primitive_tab[i] ;
227 if(exporter != NULL)
delete exporter ;
228 if(sort_method != NULL)
delete sort_method ;
232 cout <<
"Render aborted: " << e.what() << endl ;
234 if(exporter != NULL)
delete exporter ;
235 if(sort_method != NULL)
delete sort_method ;
236 if(feedbackBuffer != NULL)
delete[] feedbackBuffer ;
247 _progress_function = NULL ;
248 _sortMethod = BSPSort ;
257 _progress_function(f,progress_string) ;
262 _filename = filename;
275 return (_options & opt) > 0 ;
void setClearColor(float r, float g, float b)
void setOption(VRenderOption, bool)
virtual void optimize(std::vector< PtrPrimitive > &, VRenderParams &)
void setClearBackground(bool b)
void setBoundingBox(float xmin, float ymin, float xmax, float ymax)
void setBlackAndWhite(bool b)
void progress(float, const QString &)
void setBreakCycles(bool b)
virtual void optimize(std::vector< PtrPrimitive > &, VRenderParams &)
void parseFeedbackBuffer(GLfloat *, int size, std::vector< PtrPrimitive > &primitive_tab, VRenderParams &vparams)
void VectorialRender(RenderCB DrawFunc, void *callback_params, VRenderParams &render_params)
virtual void sortPrimitives(std::vector< PtrPrimitive > &, VRenderParams &)=0
void setFilename(const QString &filename)
virtual void exportToFile(const QString &filename, const std::vector< PtrPrimitive > &, VRenderParams &)
bool isEnabled(VRenderOption)
virtual void optimize(std::vector< PtrPrimitive > &, VRenderParams &)