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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// OpenCSG - library for image-based CSG rendering for OpenGL
// Copyright (C) 2010-2026, Florian Kirsch
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110 - 1301 USA.
//
// context.h
//
// OpenCSG context management
//
#ifndef __OpenCSG__context_h__
#define __OpenCSG__context_h__
#include "opencsgConfig.h"
#include <opencsg.h>
#include "openglExt.h"
namespace OpenCSG {
/// redeclared from opencsg.h
void setContext(int context);
/// redeclared from opencsg.h
int getContext();
/// redeclared from opencsg.h
void freeResources();
namespace OpenGL {
class OffscreenBuffer;
/// Retrieves the OpenGL function pointers, including the
/// functions pointers of OpenGL extensions, from the
/// OpenGL extension library (such as GLEW or glad).
void ensureFunctionPointers();
/// Checks the OpenGL-extensions resp. the current settings
/// and returns a concrete offscreen buffer, for the currently
/// active context in OpenCSG.
OffscreenBuffer* getOffscreenBuffer(OffscreenType type);
/// Given a constant(!) ARB vertex program string and its length,
/// returns a ARB vertex program object, for the currently
/// active context in OpenCSG.
GLuint getARBVertexProgram(const char* prog, int len);
/// Given a constant(!) ARB fragment program string and its length,
/// returns a ARB fragment program object, for the currently
/// active context in OpenCSG.
GLuint getARBFragmentProgram(const char* prog, int len);
GLuint getGLSLVertexShader(const char* prog);
GLuint getGLSLFragmentShader(const char* prog);
/// Given a constant(!), null-terminated vertex and fragment
/// program strings, returns a GLSL program object, for the
/// currently active context in OpenCSG.
GLuint getGLSLProgram(const char* programId, const char* vertexShader, const char* fragmentShader);
/// Frees all resources (offscreen buffers, fragment programs...)
/// allocated for the currently active context in OpenCSG.
void freeResources();
} // namespace OpenGL
} // namespace OpenCSG
#endif // __OpenCSG__context_h__