Skip to content

Commit 26886da

Browse files
feat(webgl): add vertexAttrib[1234]fv vector methods
- Added command buffer types for vector float vertex attributes - Implemented VertexAttrib[1234]fvCommandBufferRequest classes - Added API methods to WebGLContext - Implemented JavaScript bindings in WebGLRenderingContext - Added OpenGL ES renderer implementations - Registered command buffer handlers Co-authored-by: EndlessJour9527 <155411404+EndlessJour9527@users.noreply.github.com>
1 parent 7939dfd commit 26886da

24 files changed

+386
-18
lines changed

src/client/graphics/webgl_context.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,62 @@ namespace endor
943943
sendCommandBufferRequest(req);
944944
}
945945

946+
void WebGLContext::vertexAttrib1fv(const WebGLAttribLocation &index, const vector<float> values)
947+
{
948+
auto req = VertexAttrib1fvCommandBufferRequest(index.programId, index.name, values);
949+
if (index.index.has_value())
950+
req.setLoc(index.index.value());
951+
sendCommandBufferRequest(req);
952+
}
953+
954+
void WebGLContext::vertexAttrib1fv(int index, const vector<float> values)
955+
{
956+
auto req = VertexAttrib1fvCommandBufferRequest(0, index, values);
957+
sendCommandBufferRequest(req);
958+
}
959+
960+
void WebGLContext::vertexAttrib2fv(const WebGLAttribLocation &index, const vector<float> values)
961+
{
962+
auto req = VertexAttrib2fvCommandBufferRequest(index.programId, index.name, values);
963+
if (index.index.has_value())
964+
req.setLoc(index.index.value());
965+
sendCommandBufferRequest(req);
966+
}
967+
968+
void WebGLContext::vertexAttrib2fv(int index, const vector<float> values)
969+
{
970+
auto req = VertexAttrib2fvCommandBufferRequest(0, index, values);
971+
sendCommandBufferRequest(req);
972+
}
973+
974+
void WebGLContext::vertexAttrib3fv(const WebGLAttribLocation &index, const vector<float> values)
975+
{
976+
auto req = VertexAttrib3fvCommandBufferRequest(index.programId, index.name, values);
977+
if (index.index.has_value())
978+
req.setLoc(index.index.value());
979+
sendCommandBufferRequest(req);
980+
}
981+
982+
void WebGLContext::vertexAttrib3fv(int index, const vector<float> values)
983+
{
984+
auto req = VertexAttrib3fvCommandBufferRequest(0, index, values);
985+
sendCommandBufferRequest(req);
986+
}
987+
988+
void WebGLContext::vertexAttrib4fv(const WebGLAttribLocation &index, const vector<float> values)
989+
{
990+
auto req = VertexAttrib4fvCommandBufferRequest(index.programId, index.name, values);
991+
if (index.index.has_value())
992+
req.setLoc(index.index.value());
993+
sendCommandBufferRequest(req);
994+
}
995+
996+
void WebGLContext::vertexAttrib4fv(int index, const vector<float> values)
997+
{
998+
auto req = VertexAttrib4fvCommandBufferRequest(0, index, values);
999+
sendCommandBufferRequest(req);
1000+
}
1001+
9461002
optional<WebGLActiveInfo> WebGLContext::getActiveAttrib(shared_ptr<WebGLProgram> program, unsigned int index)
9471003
{
9481004
assert(program != nullptr && "Program is not null");

src/client/graphics/webgl_context.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,14 @@ namespace endor
439439
void vertexAttrib3f(int index, float v0, float v1, float v2);
440440
void vertexAttrib4f(const WebGLAttribLocation &, float v0, float v1, float v2, float v3);
441441
void vertexAttrib4f(int index, float v0, float v1, float v2, float v3);
442+
void vertexAttrib1fv(const WebGLAttribLocation &, const std::vector<float> values);
443+
void vertexAttrib1fv(int index, const std::vector<float> values);
444+
void vertexAttrib2fv(const WebGLAttribLocation &, const std::vector<float> values);
445+
void vertexAttrib2fv(int index, const std::vector<float> values);
446+
void vertexAttrib3fv(const WebGLAttribLocation &, const std::vector<float> values);
447+
void vertexAttrib3fv(int index, const std::vector<float> values);
448+
void vertexAttrib4fv(const WebGLAttribLocation &, const std::vector<float> values);
449+
void vertexAttrib4fv(int index, const std::vector<float> values);
442450
std::optional<WebGLActiveInfo> getActiveAttrib(std::shared_ptr<WebGLProgram> program, unsigned int index);
443451
std::optional<WebGLActiveInfo> getActiveUniform(std::shared_ptr<WebGLProgram> program, unsigned int index);
444452
std::optional<WebGLAttribLocation> getAttribLocation(std::shared_ptr<WebGLProgram> program, const std::string &name);

src/client/script_bindings/events/all_events.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ namespace endor
2424
DOM_EVENT_CLASSES_MAP(XX) \
2525
XR_EVENT_CLASSES_MAP(XX)
2626

27-
void Initialize(Isolate *isolate)
28-
{
27+
void Initialize(Isolate *isolate){
2928
#define XX(T) T::Initialize(isolate);
3029
ALL_EVENT_CLASSES_MAP(XX)
3130
#undef XX

src/client/script_bindings/webgl/active_info.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@ namespace endor
6060
}
6161

6262
} // namespace webgl
63-
} // namespace script_bindings
63+
} // namespace script_bindings
6464
} // namespace endor

src/client/script_bindings/webgl/active_info.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ namespace endor
3838
};
3939

4040
} // namespace webgl
41-
} // namespace script_bindings
41+
} // namespace script_bindings
4242
} // namespace endor

src/client/script_bindings/webgl/framebuffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ namespace endor
3131
{
3232
}
3333
} // namespace webgl
34-
} // namespace script_bindings
34+
} // namespace script_bindings
3535
} // namespace endor

src/client/script_bindings/webgl/framebuffer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ namespace endor
3737
};
3838

3939
} // namespace webgl
40-
} // namespace script_bindings
40+
} // namespace script_bindings
4141
} // namespace endor

src/client/script_bindings/webgl/object.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ namespace endor
2828
// WebGLObject is a base class, typically not instantiated directly
2929
}
3030
} // namespace webgl
31-
} // namespace script_bindings
31+
} // namespace script_bindings
3232
} // namespace endor

src/client/script_bindings/webgl/object.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ namespace endor
4545
};
4646

4747
} // namespace webgl
48-
} // namespace script_bindings
48+
} // namespace script_bindings
4949
} // namespace endor

src/client/script_bindings/webgl/program.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ namespace endor
2020
}
2121

2222
} // namespace webgl
23-
} // namespace script_bindings
23+
} // namespace script_bindings
2424
} // namespace endor

0 commit comments

Comments
 (0)