summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordon bright <hugh.m.bright@gmail.com>2013-01-26 06:09:37 (GMT)
committerdon bright <hugh.m.bright@gmail.com>2013-01-26 06:09:37 (GMT)
commitaf4333a669eacc2cafc8274e23f58415e634477b (patch)
tree67d54465e838a224e16e262ebe8a5dfc0fde95f1 /src
parent544a8e5b799f5dd0a35d650c00db10074104650a (diff)
refactor to reduce duplicate code. enable ostream save from OffscreenView
Diffstat (limited to 'src')
-rw-r--r--src/OffscreenContextGLX.cc15
-rw-r--r--src/OffscreenContextWGL.cc16
-rw-r--r--src/OffscreenView.cc5
-rw-r--r--src/export_png.cc5
4 files changed, 8 insertions, 33 deletions
diff --git a/src/OffscreenContextGLX.cc b/src/OffscreenContextGLX.cc
index 574fbb5..ef26ce7 100644
--- a/src/OffscreenContextGLX.cc
+++ b/src/OffscreenContextGLX.cc
@@ -269,20 +269,7 @@ OffscreenContext *create_offscreen_context(int w, int h)
return NULL;
}
- // glewInit must come after Context creation and before FBO calls.
- GLenum err = glewInit();
- if (GLEW_OK != err) {
- cerr << "Unable to init GLEW: " << glewGetErrorString(err) << endl;
- return NULL;
- }
-
- ctx->fbo = fbo_new();
- if (!fbo_init(ctx->fbo, w, h)) {
- cerr << "GL Framebuffer Object init failed; dumping GLEW info" << endl;
- return NULL;
- }
-
- return ctx;
+ return create_offscreen_context_common( ctx );
}
bool teardown_offscreen_context(OffscreenContext *ctx)
diff --git a/src/OffscreenContextWGL.cc b/src/OffscreenContextWGL.cc
index b892c24..71d07e3 100644
--- a/src/OffscreenContextWGL.cc
+++ b/src/OffscreenContextWGL.cc
@@ -186,19 +186,7 @@ OffscreenContext *create_offscreen_context(int w, int h)
return NULL;
}
- GLenum err = glewInit(); // must come after Context creation and before FBO calls.
- if (GLEW_OK != err) {
- cerr << "Unable to init GLEW: " << glewGetErrorString(err) << "\n";
- return NULL;
- }
- //cerr << glew_dump(0);
-
- ctx->fbo = fbo_new();
- if (!fbo_init(ctx->fbo, w, h)) {
- return NULL;
- }
-
- return ctx;
+ return create_offscreen_context_common( ctx );
}
bool teardown_offscreen_context(OffscreenContext *ctx)
@@ -206,11 +194,9 @@ bool teardown_offscreen_context(OffscreenContext *ctx)
if (ctx) {
fbo_unbind(ctx->fbo);
fbo_delete(ctx->fbo);
-
wglMakeCurrent( NULL, NULL );
wglDeleteContext( ctx->openGLContext );
ReleaseDC( ctx->window, ctx->dev_context );
-
return true;
}
return false;
diff --git a/src/OffscreenView.cc b/src/OffscreenView.cc
index 61d5818..12ebf3a 100644
--- a/src/OffscreenView.cc
+++ b/src/OffscreenView.cc
@@ -142,6 +142,11 @@ bool OffscreenView::save(const char *filename)
return save_framebuffer(this->ctx, filename);
}
+bool OffscreenView::save(std::ostream &output)
+{
+ return save_framebuffer(this->ctx, output);
+}
+
std::string OffscreenView::getInfo()
{
std::stringstream out;
diff --git a/src/export_png.cc b/src/export_png.cc
index d983bc1..fb31917 100644
--- a/src/export_png.cc
+++ b/src/export_png.cc
@@ -43,10 +43,7 @@ void export_png_with_cgal(CGAL_Nef_polyhedron *root_N, std::ostream &output)
csgInfo.glview->setCamera(camerapos, center);
csgInfo.glview->setRenderer(&cgalRenderer);
csgInfo.glview->paintGL();
- csgInfo.glview->save("test.png");
-
- output << "solid OpenSCAD_Model\n";
- output << "endsolid OpenSCAD_Model\n";
+ csgInfo.glview->save(output);
}
void export_png_with_opencsg(CGAL_Nef_polyhedron *root_N, std::ostream &output)
contact: Jan Huwald // Impressum