openscad/src/OffscreenView.cc

49 lines
968 B
C++
Raw Normal View History

2013-01-24 07:02:31 +04:00
#include "OffscreenView.h"
#include "system-gl.h"
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <sstream>
2013-03-11 20:02:01 +04:00
#include "printutils.h"
2013-01-24 07:02:31 +04:00
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);
2013-01-24 07:02:31 +04:00
}
OffscreenView::~OffscreenView()
{
teardown_offscreen_context(this->ctx);
}
#ifdef ENABLE_OPENCSG
void OffscreenView::display_opencsg_warning()
{
PRINT("OpenSCAD recommended OpenGL version is 2.0.");
2013-01-24 07:02:31 +04:00
}
#endif
2013-01-24 07:02:31 +04:00
bool OffscreenView::save(const char *filename)
{
return save_framebuffer(this->ctx, filename);
2013-01-24 07:02:31 +04:00
}
bool OffscreenView::save(std::ostream &output)
{
return save_framebuffer(this->ctx, output);
}
std::string OffscreenView::getRendererInfo() const
2013-01-24 07:02:31 +04:00
{
std::stringstream out;
out << glew_dump()
<< offscreen_context_getinfo(this->ctx);
2013-01-24 07:02:31 +04:00
return out.str();
2013-01-24 07:02:31 +04:00
}