-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwebgl_rendering_context.hpp
More file actions
200 lines (173 loc) · 10.8 KB
/
webgl_rendering_context.hpp
File metadata and controls
200 lines (173 loc) · 10.8 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#pragma once
#include <memory>
#include <client/canvas/image_source.hpp>
#include <client/graphics/webgl_context.hpp>
#include <client/scripting_base/v8_object_wrap.hpp>
namespace endor
{
namespace script_bindings
{
namespace webgl_bindings
{
class WebGLRenderingContext;
using WebGLRenderingContextBase = scripting_base::ObjectWrap<WebGLRenderingContext, client_graphics::WebGLContext>;
class WebGLRenderingContext : public WebGLRenderingContextBase
{
using WebGLRenderingContextBase::ObjectWrap;
public:
static std::string Name()
{
return "WebGLRenderingContext";
}
static void SetupConstants(v8::Isolate *isolate, v8::Local<v8::FunctionTemplate> tpl);
static void ConfigureFunctionTemplate(v8::Isolate *isolate, v8::Local<v8::FunctionTemplate> tpl);
private:
// Canvas properties
void CanvasGetter(const v8::PropertyCallbackInfo<v8::Value> &info);
void DrawingBufferWidthGetter(const v8::PropertyCallbackInfo<v8::Value> &info);
void DrawingBufferHeightGetter(const v8::PropertyCallbackInfo<v8::Value> &info);
// Basic methods
void GetContextAttributes(const v8::FunctionCallbackInfo<v8::Value> &info);
void IsContextLost(const v8::FunctionCallbackInfo<v8::Value> &info);
void MakeXRCompatible(const v8::FunctionCallbackInfo<v8::Value> &info);
void SetDefaultCoordHandedness(const v8::FunctionCallbackInfo<v8::Value> &info);
// State management
void Hint(const v8::FunctionCallbackInfo<v8::Value> &info);
void LineWidth(const v8::FunctionCallbackInfo<v8::Value> &info);
void PixelStorei(const v8::FunctionCallbackInfo<v8::Value> &info);
void PolygonOffset(const v8::FunctionCallbackInfo<v8::Value> &info);
void CullFace(const v8::FunctionCallbackInfo<v8::Value> &info);
void FrontFace(const v8::FunctionCallbackInfo<v8::Value> &info);
void ActiveTexture(const v8::FunctionCallbackInfo<v8::Value> &info);
void AttachShader(const v8::FunctionCallbackInfo<v8::Value> &info);
void DetachShader(const v8::FunctionCallbackInfo<v8::Value> &info);
void BindAttribLocation(const v8::FunctionCallbackInfo<v8::Value> &info);
void BindBuffer(const v8::FunctionCallbackInfo<v8::Value> &info);
void BindFramebuffer(const v8::FunctionCallbackInfo<v8::Value> &info);
void BindRenderbuffer(const v8::FunctionCallbackInfo<v8::Value> &info);
void BindTexture(const v8::FunctionCallbackInfo<v8::Value> &info);
// Buffer operations
void BufferData(const v8::FunctionCallbackInfo<v8::Value> &info);
void BufferSubData(const v8::FunctionCallbackInfo<v8::Value> &info);
// Framebuffer operations
void FramebufferRenderbuffer(const v8::FunctionCallbackInfo<v8::Value> &info);
void FramebufferTexture2D(const v8::FunctionCallbackInfo<v8::Value> &info);
void CheckFramebufferStatus(const v8::FunctionCallbackInfo<v8::Value> &info);
void Clear(const v8::FunctionCallbackInfo<v8::Value> &info);
void ClearColor(const v8::FunctionCallbackInfo<v8::Value> &info);
void ClearDepth(const v8::FunctionCallbackInfo<v8::Value> &info);
void ClearStencil(const v8::FunctionCallbackInfo<v8::Value> &info);
void ColorMask(const v8::FunctionCallbackInfo<v8::Value> &info);
void DepthMask(const v8::FunctionCallbackInfo<v8::Value> &info);
void DepthFunc(const v8::FunctionCallbackInfo<v8::Value> &info);
void DepthRange(const v8::FunctionCallbackInfo<v8::Value> &info);
void StencilFunc(const v8::FunctionCallbackInfo<v8::Value> &info);
void StencilFuncSeparate(const v8::FunctionCallbackInfo<v8::Value> &info);
void StencilMask(const v8::FunctionCallbackInfo<v8::Value> &info);
void StencilMaskSeparate(const v8::FunctionCallbackInfo<v8::Value> &info);
void StencilOp(const v8::FunctionCallbackInfo<v8::Value> &info);
void StencilOpSeparate(const v8::FunctionCallbackInfo<v8::Value> &info);
void BlendColor(const v8::FunctionCallbackInfo<v8::Value> &info);
void BlendEquation(const v8::FunctionCallbackInfo<v8::Value> &info);
void BlendEquationSeparate(const v8::FunctionCallbackInfo<v8::Value> &info);
void BlendFunc(const v8::FunctionCallbackInfo<v8::Value> &info);
void BlendFuncSeparate(const v8::FunctionCallbackInfo<v8::Value> &info);
// Renderbuffer operations
void RenderbufferStorage(const v8::FunctionCallbackInfo<v8::Value> &info);
// Shader operations
void CompileShader(const v8::FunctionCallbackInfo<v8::Value> &info);
void CreateProgram(const v8::FunctionCallbackInfo<v8::Value> &info);
void CreateShader(const v8::FunctionCallbackInfo<v8::Value> &info);
// Resource creation
void CreateBuffer(const v8::FunctionCallbackInfo<v8::Value> &info);
void CreateFramebuffer(const v8::FunctionCallbackInfo<v8::Value> &info);
void CreateRenderbuffer(const v8::FunctionCallbackInfo<v8::Value> &info);
void CreateTexture(const v8::FunctionCallbackInfo<v8::Value> &info);
// Resource deletion
void DeleteBuffer(const v8::FunctionCallbackInfo<v8::Value> &info);
void DeleteFramebuffer(const v8::FunctionCallbackInfo<v8::Value> &info);
void DeleteProgram(const v8::FunctionCallbackInfo<v8::Value> &info);
void DeleteRenderbuffer(const v8::FunctionCallbackInfo<v8::Value> &info);
void DeleteShader(const v8::FunctionCallbackInfo<v8::Value> &info);
void DeleteTexture(const v8::FunctionCallbackInfo<v8::Value> &info);
// Drawing operations
void DrawArrays(const v8::FunctionCallbackInfo<v8::Value> &info);
void DrawElements(const v8::FunctionCallbackInfo<v8::Value> &info);
// Enable/disable state
void Enable(const v8::FunctionCallbackInfo<v8::Value> &info);
void Disable(const v8::FunctionCallbackInfo<v8::Value> &info);
// Vertex attributes
void EnableVertexAttribArray(const v8::FunctionCallbackInfo<v8::Value> &info);
void DisableVertexAttribArray(const v8::FunctionCallbackInfo<v8::Value> &info);
// Program operations
void GetActiveAttrib(const v8::FunctionCallbackInfo<v8::Value> &info);
void GetActiveUniform(const v8::FunctionCallbackInfo<v8::Value> &info);
void GetAttribLocation(const v8::FunctionCallbackInfo<v8::Value> &info);
void GetUniformLocation(const v8::FunctionCallbackInfo<v8::Value> &info);
void LinkProgram(const v8::FunctionCallbackInfo<v8::Value> &info);
void UseProgram(const v8::FunctionCallbackInfo<v8::Value> &info);
void ValidateProgram(const v8::FunctionCallbackInfo<v8::Value> &info);
// Shader source
void ShaderSource(const v8::FunctionCallbackInfo<v8::Value> &info);
void GetShaderSource(const v8::FunctionCallbackInfo<v8::Value> &info);
// Texture operations
void TexImage2D(const v8::FunctionCallbackInfo<v8::Value> &info);
void TexSubImage2D(const v8::FunctionCallbackInfo<v8::Value> &info);
void TexParameterf(const v8::FunctionCallbackInfo<v8::Value> &info);
void TexParameteri(const v8::FunctionCallbackInfo<v8::Value> &info);
void CopyTexImage2D(const v8::FunctionCallbackInfo<v8::Value> &info);
void CopyTexSubImage2D(const v8::FunctionCallbackInfo<v8::Value> &info);
void GenerateMipmap(const v8::FunctionCallbackInfo<v8::Value> &info);
// Uniform operations
void Uniform1f(const v8::FunctionCallbackInfo<v8::Value> &info);
void Uniform1i(const v8::FunctionCallbackInfo<v8::Value> &info);
void Uniform2f(const v8::FunctionCallbackInfo<v8::Value> &info);
void Uniform2i(const v8::FunctionCallbackInfo<v8::Value> &info);
void Uniform3f(const v8::FunctionCallbackInfo<v8::Value> &info);
void Uniform3i(const v8::FunctionCallbackInfo<v8::Value> &info);
void Uniform4f(const v8::FunctionCallbackInfo<v8::Value> &info);
void Uniform4i(const v8::FunctionCallbackInfo<v8::Value> &info);
void Uniform1fv(const v8::FunctionCallbackInfo<v8::Value> &info);
void Uniform1iv(const v8::FunctionCallbackInfo<v8::Value> &info);
void Uniform2fv(const v8::FunctionCallbackInfo<v8::Value> &info);
void Uniform2iv(const v8::FunctionCallbackInfo<v8::Value> &info);
void Uniform3fv(const v8::FunctionCallbackInfo<v8::Value> &info);
void Uniform3iv(const v8::FunctionCallbackInfo<v8::Value> &info);
void Uniform4fv(const v8::FunctionCallbackInfo<v8::Value> &info);
void Uniform4iv(const v8::FunctionCallbackInfo<v8::Value> &info);
void UniformMatrix2fv(const v8::FunctionCallbackInfo<v8::Value> &info);
void UniformMatrix3fv(const v8::FunctionCallbackInfo<v8::Value> &info);
void UniformMatrix4fv(const v8::FunctionCallbackInfo<v8::Value> &info);
// Vertex attribute operations
void VertexAttrib1f(const v8::FunctionCallbackInfo<v8::Value> &info);
void VertexAttrib2f(const v8::FunctionCallbackInfo<v8::Value> &info);
void VertexAttrib3f(const v8::FunctionCallbackInfo<v8::Value> &info);
void VertexAttrib4f(const v8::FunctionCallbackInfo<v8::Value> &info);
void VertexAttrib1fv(const v8::FunctionCallbackInfo<v8::Value> &info);
void VertexAttrib2fv(const v8::FunctionCallbackInfo<v8::Value> &info);
void VertexAttrib3fv(const v8::FunctionCallbackInfo<v8::Value> &info);
void VertexAttrib4fv(const v8::FunctionCallbackInfo<v8::Value> &info);
void VertexAttribPointer(const v8::FunctionCallbackInfo<v8::Value> &info);
// Viewport & scissor
void Viewport(const v8::FunctionCallbackInfo<v8::Value> &info);
void Scissor(const v8::FunctionCallbackInfo<v8::Value> &info);
// Error checking
void GetError(const v8::FunctionCallbackInfo<v8::Value> &info);
// Parameter queries
void GetParameter(const v8::FunctionCallbackInfo<v8::Value> &info);
void GetProgramParameter(const v8::FunctionCallbackInfo<v8::Value> &info);
void GetShaderParameter(const v8::FunctionCallbackInfo<v8::Value> &info);
void GetShaderPrecisionFormat(const v8::FunctionCallbackInfo<v8::Value> &info);
// Info logs
void GetProgramInfoLog(const v8::FunctionCallbackInfo<v8::Value> &info);
void GetShaderInfoLog(const v8::FunctionCallbackInfo<v8::Value> &info);
// Extensions
void GetExtension(const v8::FunctionCallbackInfo<v8::Value> &info);
void GetSupportedExtensions(const v8::FunctionCallbackInfo<v8::Value> &info);
private:
static std::vector<float> GetFloatValuesFromValue(v8::Isolate *isolate, v8::Local<v8::Value> value);
static std::vector<int> GetIntValuesFromValue(v8::Isolate *isolate, v8::Local<v8::Value> value);
};
}
}
} // namespace endor