summaryrefslogtreecommitdiff
path: root/themes/src/Renderer2d.cpp
diff options
context:
space:
mode:
authormattkae <mattkae@protonmail.com>2023-07-31 07:31:52 -0400
committermattkae <mattkae@protonmail.com>2023-07-31 07:31:52 -0400
commitb6a666e96ffd04bd6d52be8fd9899faf27b751db (patch)
treeddc56ec77d0fa6a35a581ea49bcd1b4c3cac3756 /themes/src/Renderer2d.cpp
parentffa1ada2b7f65e0b3afe561b3291219394df21f3 (diff)
Some initial shader loading work
Diffstat (limited to 'themes/src/Renderer2d.cpp')
-rw-r--r--themes/src/Renderer2d.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/themes/src/Renderer2d.cpp b/themes/src/Renderer2d.cpp
index c303e83..06f0838 100644
--- a/themes/src/Renderer2d.cpp
+++ b/themes/src/Renderer2d.cpp
@@ -6,7 +6,7 @@
// Note: In the 'transform' attribute, the transform.x is the scale,
// transform.y is the rotation, and transform.zw is the translation.
-const char* Vertex2DShader =
+const char* DEFAULT_VERTEX_SHADER =
"attribute vec2 position; \n"
"attribute vec4 color; \n"
"attribute mat4 vMatrix; \n"
@@ -19,16 +19,18 @@ const char* Vertex2DShader =
" VertexColor = color; \n"
"}";
-const char* renderer2dFragmentShader =
+const char* DEFAULT_FRAGMENT_SHADER =
"varying lowp vec4 VertexColor; \n"
"void main() { \n"
" gl_FragColor = VertexColor; \n"
"}";
-void Renderer2d::load(WebglContext* inContext) {
+void Renderer2d::load(WebglContext* inContext, const char* inVertexShader, const char* inFragmentShader) {
+ auto vertexShader = inVertexShader ? inVertexShader : DEFAULT_VERTEX_SHADER;
+ auto fragmentShader = inFragmentShader ? inFragmentShader : DEFAULT_FRAGMENT_SHADER;
context = inContext;
printf("Compiling Renderer2d shader...\n");
- shader = loadShader(Vertex2DShader, renderer2dFragmentShader);
+ shader = loadShader(vertexShader, fragmentShader);
useShader(shader);
attributes.position = getShaderAttribute(shader, "position");