forked from openscad/openscad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOffscreenContextNULL.cc
66 lines (52 loc) · 1.3 KB
/
OffscreenContextNULL.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
Create an NULL OpenGL context that doesnt actually use any OpenGL code,
and can be compiled on a system without OpenGL.
*/
#include <vector>
#include "OffscreenContext.h"
#include "printutils.h"
#include "imageutils.h"
#include <map>
#include <string>
#include <sstream>
using namespace std;
struct OffscreenContext
{
int width;
int height;
};
void offscreen_context_init(OffscreenContext &ctx, int width, int height)
{
ctx.width = width;
ctx.height = height;
}
string offscreen_context_getinfo(OffscreenContext *ctx)
{
return string("NULLGL");
}
OffscreenContext *create_offscreen_context(int w, int h)
{
OffscreenContext *ctx = new OffscreenContext;
offscreen_context_init( *ctx, w, h );
}
bool teardown_offscreen_context(OffscreenContext *ctx)
{
return true;
}
bool save_framebuffer(OffscreenContext *ctx, char const * filename)
{
std::ofstream fstream(filename,std::ios::out|std::ios::binary);
if (!fstream.is_open()) {
std::cerr << "Can't open file " << filename << " for writing";
return false;
} else {
save_framebuffer(ctx, fstream);
fstream.close();
}
return true;
}
bool save_framebuffer(OffscreenContext *ctx, std::ostream &output)
{
output << "NULLGL framebuffer";
return true;
}