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)
|
|
|
|
{
|
2013-02-24 21:21:45 +04:00
|
|
|
this->ctx = create_offscreen_context(width, height);
|
|
|
|
if ( this->ctx == NULL ) throw -1;
|
2013-02-25 00:31:03 +04:00
|
|
|
GLView::initializeGL();
|
2013-02-24 21:21:45 +04:00
|
|
|
GLView::resizeGL(width, height);
|
2013-01-24 07:02:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
OffscreenView::~OffscreenView()
|
|
|
|
{
|
2013-02-24 21:21:45 +04:00
|
|
|
teardown_offscreen_context(this->ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ENABLE_OPENCSG
|
|
|
|
void OffscreenView::display_opencsg_warning()
|
|
|
|
{
|
2013-03-11 19:59:52 +04:00
|
|
|
PRINT("OpenSCAD recommended OpenGL version is 2.0.");
|
2013-01-24 07:02:31 +04:00
|
|
|
}
|
2013-02-24 21:21:45 +04:00
|
|
|
#endif
|
2013-02-24 06:54:13 +04:00
|
|
|
|
2013-01-24 07:02:31 +04:00
|
|
|
bool OffscreenView::save(const char *filename)
|
|
|
|
{
|
2013-02-24 21:21:45 +04:00
|
|
|
return save_framebuffer(this->ctx, filename);
|
2013-01-24 07:02:31 +04:00
|
|
|
}
|
|
|
|
|
2013-01-26 10:09:37 +04:00
|
|
|
bool OffscreenView::save(std::ostream &output)
|
|
|
|
{
|
2013-02-24 21:21:45 +04:00
|
|
|
return save_framebuffer(this->ctx, output);
|
2013-01-26 10:09:37 +04:00
|
|
|
}
|
|
|
|
|
2013-02-24 05:19:33 +04:00
|
|
|
std::string OffscreenView::getRendererInfo() const
|
2013-01-24 07:02:31 +04:00
|
|
|
{
|
2013-02-24 21:21:45 +04:00
|
|
|
std::stringstream out;
|
2013-02-21 09:02:44 +04:00
|
|
|
|
2013-02-24 21:21:45 +04:00
|
|
|
out << glew_dump()
|
|
|
|
<< offscreen_context_getinfo(this->ctx);
|
2013-01-24 07:02:31 +04:00
|
|
|
|
2013-02-24 21:21:45 +04:00
|
|
|
return out.str();
|
2013-01-24 07:02:31 +04:00
|
|
|
}
|