|
| 1 | +#include <command_buffers/shared.hpp> |
| 2 | +#include <command_buffers/webgl_constants.hpp> |
| 3 | +#include <renderer/context_webgl.hpp> |
| 4 | +#include <renderer/content_renderer.hpp> |
| 5 | + |
| 6 | +namespace renderer |
| 7 | +{ |
| 8 | + using namespace std; |
| 9 | + using namespace commandbuffers; |
| 10 | + |
| 11 | + void TrContextWebGL::glBindBuffer(WebGLenum target, WebGLuint buffer) |
| 12 | + { |
| 13 | + if (!glIsBuffer(buffer)) [[unlikely]] |
| 14 | + { |
| 15 | + last_error_ = WEBGL_INVALID_OPERATION; |
| 16 | + return; |
| 17 | + } |
| 18 | + |
| 19 | + for (auto &binding : buffer_bindings_) |
| 20 | + { |
| 21 | + if (binding.buffer == buffer) |
| 22 | + { |
| 23 | + binding.target = target; |
| 24 | + break; |
| 25 | + } |
| 26 | + } |
| 27 | + } |
| 28 | + |
| 29 | + void TrContextWebGL::glBindBufferBase(WebGLenum target, |
| 30 | + WebGLuint bindingPoint, |
| 31 | + WebGLuint buffer) |
| 32 | + { |
| 33 | + /* TODO(yorkie): implement */ |
| 34 | + } |
| 35 | + |
| 36 | + void TrContextWebGL::glBindBufferRange(WebGLenum target, |
| 37 | + WebGLuint bindingPoint, |
| 38 | + WebGLuint buffer, |
| 39 | + WebGLintptr offset, |
| 40 | + WebGLsizeiptr size) |
| 41 | + { |
| 42 | + /* TODO(yorkie): implement */ |
| 43 | + } |
| 44 | + |
| 45 | + void TrContextWebGL::glBufferData(WebGLenum target, |
| 46 | + WebGLsizeiptr size, |
| 47 | + const WebGLvoid *data, |
| 48 | + WebGLenum usage) |
| 49 | + { |
| 50 | + /* TODO(yorkie): implement */ |
| 51 | + } |
| 52 | + |
| 53 | + void TrContextWebGL::glBufferSubData(WebGLenum target, |
| 54 | + WebGLintptr offset, |
| 55 | + WebGLsizeiptr size, |
| 56 | + const WebGLvoid *data) |
| 57 | + { |
| 58 | + /* TODO(yorkie): implement */ |
| 59 | + } |
| 60 | + |
| 61 | + void TrContextWebGL::glCopyBufferSubData(WebGLenum readTarget, |
| 62 | + WebGLenum writeTarget, |
| 63 | + WebGLintptr readOffset, |
| 64 | + WebGLintptr writeOffset, |
| 65 | + WebGLsizeiptr size) |
| 66 | + { |
| 67 | + /* TODO(yorkie): implement */ |
| 68 | + } |
| 69 | + |
| 70 | + void TrContextWebGL::glDeleteBuffers(WebGLsizei count, const WebGLuint *buffers) |
| 71 | + { |
| 72 | + for (WebGLsizei i = 0; i < count; i++) |
| 73 | + { |
| 74 | + for (auto it = buffers_.begin(); it != buffers_.end(); ++it) |
| 75 | + { |
| 76 | + if (*it == buffers[i]) |
| 77 | + { |
| 78 | + buffers_.erase(it); |
| 79 | + break; |
| 80 | + } |
| 81 | + } |
| 82 | + } |
| 83 | + } |
| 84 | + |
| 85 | + void TrContextWebGL::glDisableVertexAttribArray(WebGLuint index) |
| 86 | + { |
| 87 | + /* TODO(yorkie): implement */ |
| 88 | + } |
| 89 | + |
| 90 | + void TrContextWebGL::glDrawArrays(WebGLenum mode, WebGLint first, WebGLsizei count) |
| 91 | + { |
| 92 | + /* TODO(yorkie): implement */ |
| 93 | + } |
| 94 | + |
| 95 | + void TrContextWebGL::glDrawArraysInstanced(WebGLenum mode, |
| 96 | + WebGLint first, |
| 97 | + WebGLsizei count, |
| 98 | + WebGLsizei instanceCount) |
| 99 | + { |
| 100 | + /* TODO(yorkie): implement */ |
| 101 | + } |
| 102 | + |
| 103 | + void TrContextWebGL::glDrawElements(WebGLenum mode, |
| 104 | + WebGLsizei count, |
| 105 | + WebGLenum type, |
| 106 | + const WebGLvoid *indices) |
| 107 | + { |
| 108 | + /* TODO(yorkie): implement */ |
| 109 | + } |
| 110 | + |
| 111 | + void TrContextWebGL::glDrawElementsInstanced(WebGLenum mode, WebGLsizei count, WebGLenum type, const WebGLvoid *indices, WebGLsizei instanceCount) |
| 112 | + { |
| 113 | + /* TODO(yorkie): implement */ |
| 114 | + } |
| 115 | + |
| 116 | + void TrContextWebGL::glDrawRangeElements(WebGLenum mode, WebGLuint start, WebGLuint end, WebGLsizei count, WebGLenum type, const WebGLvoid *indices) |
| 117 | + { |
| 118 | + /* TODO(yorkie): implement */ |
| 119 | + } |
| 120 | + |
| 121 | + void TrContextWebGL::glEnableVertexAttribArray(WebGLuint index) |
| 122 | + { |
| 123 | + /* TODO(yorkie): implement */ |
| 124 | + } |
| 125 | + |
| 126 | + void TrContextWebGL::glFlushMappedBufferRange(WebGLenum target, WebGLintptr offset, WebGLsizeiptr size) |
| 127 | + { |
| 128 | + /* TODO(yorkie): implement */ |
| 129 | + } |
| 130 | + |
| 131 | + void TrContextWebGL::glGenBuffers(WebGLsizei n, WebGLuint *buffers) |
| 132 | + { |
| 133 | + glGenObjects(buffers_, n, buffers); |
| 134 | + } |
| 135 | + |
| 136 | + void TrContextWebGL::glGetBufferParameter(WebGLenum target, WebGLenum pname, WebGLint *params) |
| 137 | + { |
| 138 | + /* TODO(yorkie): implement */ |
| 139 | + } |
| 140 | + |
| 141 | + void TrContextWebGL::glGetBufferParameteriv(WebGLenum target, WebGLenum pname, WebGLint *params) |
| 142 | + { |
| 143 | + /* TODO(yorkie): implement */ |
| 144 | + } |
| 145 | + |
| 146 | + void TrContextWebGL::glGetBufferPointerv(WebGLenum target, WebGLenum pname, WebGLvoid **params) |
| 147 | + { |
| 148 | + /* TODO(yorkie): implement */ |
| 149 | + } |
| 150 | + |
| 151 | + void TrContextWebGL::glGetVertexAttrib(WebGLuint index, WebGLenum pname, WebGLint *params) |
| 152 | + { |
| 153 | + /* TODO(yorkie): implement */ |
| 154 | + } |
| 155 | + |
| 156 | + void TrContextWebGL::glGetVertexAttribPointerv(WebGLuint index, WebGLenum pname, WebGLvoid **pointer) |
| 157 | + { |
| 158 | + /* TODO(yorkie): implement */ |
| 159 | + } |
| 160 | + |
| 161 | + WebGLboolean TrContextWebGL::glIsBuffer(WebGLuint buffer) |
| 162 | + { |
| 163 | + for (const auto &binding : buffer_bindings_) |
| 164 | + { |
| 165 | + if (binding.buffer == buffer) |
| 166 | + { |
| 167 | + return true; |
| 168 | + } |
| 169 | + } |
| 170 | + return false; |
| 171 | + } |
| 172 | + |
| 173 | + void TrContextWebGL::glMapBufferRange(WebGLenum target, WebGLintptr offset, WebGLsizeiptr length, WebGLbitfield access) |
| 174 | + { /* TODO(yorkie): implement */ |
| 175 | + } |
| 176 | + |
| 177 | + void TrContextWebGL::glUnmapBuffer(WebGLenum target) |
| 178 | + { |
| 179 | + /* TODO(yorkie): implement */ |
| 180 | + } |
| 181 | + |
| 182 | + void TrContextWebGL::glVertexAttrib1f(WebGLuint index, WebGLfloat x) |
| 183 | + { |
| 184 | + /* TODO(yorkie): implement */ |
| 185 | + } |
| 186 | + |
| 187 | + void TrContextWebGL::glVertexAttrib2f(WebGLuint index, WebGLfloat x, WebGLfloat y) |
| 188 | + { |
| 189 | + /* TODO(yorkie): implement */ |
| 190 | + } |
| 191 | + |
| 192 | + void TrContextWebGL::glVertexAttrib3f(WebGLuint index, WebGLfloat x, WebGLfloat y, WebGLfloat z) |
| 193 | + { |
| 194 | + /* TODO(yorkie): implement */ |
| 195 | + } |
| 196 | + |
| 197 | + void TrContextWebGL::glVertexAttrib4f(WebGLuint index, WebGLfloat x, WebGLfloat y, WebGLfloat z, WebGLfloat w) |
| 198 | + { |
| 199 | + /* TODO(yorkie): implement */ |
| 200 | + } |
| 201 | + |
| 202 | + void TrContextWebGL::glVertexAttrib1fv(WebGLuint index, const WebGLfloat *v) |
| 203 | + { |
| 204 | + /* TODO(yorkie): implement */ |
| 205 | + } |
| 206 | + |
| 207 | + void TrContextWebGL::glVertexAttrib2fv(WebGLuint index, const WebGLfloat *v) |
| 208 | + { |
| 209 | + /* TODO(yorkie): implement */ |
| 210 | + } |
| 211 | + |
| 212 | + void TrContextWebGL::glVertexAttrib3fv(WebGLuint index, const WebGLfloat *v) |
| 213 | + { |
| 214 | + /* TODO(yorkie): implement */ |
| 215 | + } |
| 216 | + |
| 217 | + void TrContextWebGL::glVertexAttrib4fv(WebGLuint index, const WebGLfloat *v) |
| 218 | + { |
| 219 | + /* TODO(yorkie): implement */ |
| 220 | + } |
| 221 | + |
| 222 | + void TrContextWebGL::glVertexAttribDivisor(WebGLuint index, WebGLuint divisor) |
| 223 | + { |
| 224 | + /* TODO(yorkie): implement */ |
| 225 | + } |
| 226 | + |
| 227 | + void TrContextWebGL::glVertexAttribPointer(WebGLuint index, |
| 228 | + WebGLint size, |
| 229 | + WebGLenum type, |
| 230 | + WebGLboolean normalized, |
| 231 | + WebGLsizei stride, |
| 232 | + WebGLintptr offset) |
| 233 | + { |
| 234 | + /* TODO(yorkie): implement */ |
| 235 | + } |
| 236 | + |
| 237 | + void TrContextWebGL::glVertexAttribIPointer(WebGLuint index, |
| 238 | + WebGLint size, |
| 239 | + WebGLenum type, |
| 240 | + WebGLsizei stride, |
| 241 | + WebGLintptr offset) |
| 242 | + { |
| 243 | + /* TODO(yorkie): implement */ |
| 244 | + } |
| 245 | +} |
0 commit comments