-
Notifications
You must be signed in to change notification settings - Fork 141
/
Copy pathopengl.hpp
84 lines (73 loc) · 2.06 KB
/
opengl.hpp
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
83
84
#if defined(DISPLAY_XORG)
#include <GL/gl.h>
#include <GL/glx.h>
#ifndef glGetProcAddress
#define glGetProcAddress(name) (*glXGetProcAddress)((const GLubyte*)(name))
#endif
#elif defined(DISPLAY_QUARTZ)
#include <OpenGL/gl3.h>
#elif defined(DISPLAY_WINDOWS)
#include <GL/gl.h>
#include <GL/glext.h>
#ifndef glGetProcAddress
#define glGetProcAddress(name) wglGetProcAddress(name)
#endif
#else
#error "ruby::OpenGL3: unsupported platform"
#endif
#include "bind.hpp"
#include "utility.hpp"
#if !defined(NO_LIBRASHADER)
#include "librashader_ld.h"
#endif
struct OpenGL;
struct OpenGLTexture {
auto getFormat() const -> GLuint;
auto getType() const -> GLuint;
GLuint texture = 0;
u32 width = 0;
u32 height = 0;
GLuint format = GL_RGBA8;
GLuint filter = GL_LINEAR;
GLuint wrap = GL_CLAMP_TO_BORDER;
};
struct OpenGLSurface : OpenGLTexture {
auto size(u32 width, u32 height) -> void;
auto release() -> void;
auto render(u32 sourceWidth, u32 sourceHeight, u32 targetX, u32 targetY, u32 targetWidth, u32 targetHeight) -> void;
GLuint framebuffer = 0;
GLuint framebufferTexture = 0;
GLuint framebufferFormat = 0;
GLuint framebufferWidth = 0;
GLuint framebufferHeight = 0;
u32* buffer = nullptr;
#if !defined(NO_LIBRASHADER)
libra_instance_t _libra;
libra_shader_preset_t _preset = NULL;
libra_gl_filter_chain_t _chain = NULL;
auto has_shader() { return _chain != NULL; };
#else
auto has_shader() const { return false; };
#endif
u32 frameCount = 0;
};
struct OpenGL : OpenGLSurface {
auto setShader(const string& pathname) -> void;
auto clear() -> void;
auto lock(u32*& data, u32& pitch) -> bool;
auto output() -> void;
auto initialize(const string& shader) -> bool;
auto terminate() -> void;
static auto resolveSymbol(const char* name) -> const void*;
GLuint inputFormat = GL_RGBA8;
u32 absoluteWidth = 0;
u32 absoluteHeight = 0;
u32 outputX = 0;
u32 outputY = 0;
u32 outputWidth = 0;
u32 outputHeight = 0;
bool initialized = false;
};
#include "texture.hpp"
#include "surface.hpp"
#include "main.hpp"