-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
OffscreenView.cc
43 lines (37 loc) · 958 Bytes
/
OffscreenView.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "OffscreenView.h"
#include "system-gl.h"
#include <cmath>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <sstream>
#include "printutils.h"
OffscreenView::OffscreenView(int width, int height)
{
this->ctx = create_offscreen_context(width, height);
if (this->ctx == nullptr) throw -1;
GLView::initializeGL();
GLView::resizeGL(width, height);
}
OffscreenView::~OffscreenView()
{
teardown_offscreen_context(this->ctx);
}
#ifdef ENABLE_OPENCSG
void OffscreenView::display_opencsg_warning()
{
LOG(message_group::None, Location::NONE, "", "OpenSCAD recommended OpenGL version is 2.0.");
}
#endif
bool OffscreenView::save(const char *filename) const
{
return save_framebuffer(this->ctx, filename);
}
bool OffscreenView::save(std::ostream& output) const
{
return save_framebuffer(this->ctx, output);
}
std::string OffscreenView::getRendererInfo() const
{
return STR(gl_dump(), offscreen_context_getinfo(this->ctx));
}