diff options
author | Marius Kintel <marius@kintel.net> | 2013-03-06 18:08:31 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2013-03-06 18:08:31 (GMT) |
commit | cfc67f928fc86310614940f126d9f6c76d4e9ea7 (patch) | |
tree | 162be7579d3acd0eeb5b7b509ef9a0b428d6831f /src/OffscreenView.cc | |
parent | fe44758f5096be0e98c82d2cb0d54bdeffc4403a (diff) | |
parent | 974abf13049d5e73227418e3990af8a9bbf9db09 (diff) |
Merge branch 'master' of github.com:openscad/openscad
Diffstat (limited to 'src/OffscreenView.cc')
-rw-r--r-- | src/OffscreenView.cc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/OffscreenView.cc b/src/OffscreenView.cc new file mode 100644 index 0000000..430d4ea --- /dev/null +++ b/src/OffscreenView.cc @@ -0,0 +1,48 @@ +#include <GL/glew.h> +#include "OffscreenView.h" +#include "system-gl.h" +#include <math.h> +#include <stdio.h> +#include <string.h> +#include <cstdlib> +#include <sstream> + +OffscreenView::OffscreenView(size_t width, size_t height) +{ + this->ctx = create_offscreen_context(width, height); + if ( this->ctx == NULL ) throw -1; + GLView::initializeGL(); + GLView::resizeGL(width, height); +} + +OffscreenView::~OffscreenView() +{ + teardown_offscreen_context(this->ctx); +} + +#ifdef ENABLE_OPENCSG +void OffscreenView::display_opencsg_warning() +{ + fprintf(stderr, "OpenSCAD recommended OpenGL version is 2.0. \n"); +} +#endif + +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::getRendererInfo() const +{ + std::stringstream out; + + out << glew_dump() + << offscreen_context_getinfo(this->ctx); + + return out.str(); +} |