diff options
Diffstat (limited to 'cwd')
-rw-r--r-- | cwd/assets/altcraft/shaders/rml.json | 1 | ||||
-rw-r--r-- | cwd/assets/altcraft/shaders/rmltex.json | 1 | ||||
-rw-r--r-- | cwd/assets/altcraft/shaders/vert/rml.vs | 7 | ||||
-rw-r--r-- | cwd/test.rcss | 24 | ||||
-rw-r--r-- | cwd/test.rml | 20 |
5 files changed, 47 insertions, 6 deletions
diff --git a/cwd/assets/altcraft/shaders/rml.json b/cwd/assets/altcraft/shaders/rml.json index c62ff25..0cd85cc 100644 --- a/cwd/assets/altcraft/shaders/rml.json +++ b/cwd/assets/altcraft/shaders/rml.json @@ -2,6 +2,7 @@ "vert": "/altcraft/shaders/vert/rml", "frag": "/altcraft/shaders/frag/rml", "uniforms": [ + "translation", "viewportSize" ] }
\ No newline at end of file diff --git a/cwd/assets/altcraft/shaders/rmltex.json b/cwd/assets/altcraft/shaders/rmltex.json index 3fef969..a8a1323 100644 --- a/cwd/assets/altcraft/shaders/rmltex.json +++ b/cwd/assets/altcraft/shaders/rmltex.json @@ -2,6 +2,7 @@ "vert": "/altcraft/shaders/vert/rml", "frag": "/altcraft/shaders/frag/rmltex", "uniforms": [ + "translation", "viewportSize", "fontTexture" ] diff --git a/cwd/assets/altcraft/shaders/vert/rml.vs b/cwd/assets/altcraft/shaders/vert/rml.vs index bfc50fb..bdd3b71 100644 --- a/cwd/assets/altcraft/shaders/vert/rml.vs +++ b/cwd/assets/altcraft/shaders/vert/rml.vs @@ -1,6 +1,7 @@ #version 330 core uniform uvec2 viewportSize; +uniform vec2 translation; uniform mat4 rotationMat; layout (location = 0) in vec2 pos; @@ -13,9 +14,9 @@ out VS_OUT { } vs_out; void main() { - float x = (pos.x - viewportSize.x) / viewportSize.x; - float y = ((pos.y - viewportSize.y) / viewportSize.y) * -1; - gl_Position = vec4(x, y, -1.0f, 1.0f); + float x = ((pos.x + translation.x) / viewportSize.x) * 2.0f - 1.0f; + float y = ((pos.y + translation.y) / viewportSize.y) * 2.0f - 1.0f; + gl_Position = vec4(x, -y, -1.0f, 1.0f); vs_out.color = vec4(float(color.x) / 255.0f, float(color.y) / 255.0f, float(color.z) / 255.0f, float(color.w) / 255.0f); vs_out.tex_coord = tex_coord; } diff --git a/cwd/test.rcss b/cwd/test.rcss index 47441bb..f1e8cee 100644 --- a/cwd/test.rcss +++ b/cwd/test.rcss @@ -1,6 +1,28 @@ body { background-color: red; color: blue; - font-size: 100px; + font-size: 50px; font-family: "open sans"; + width: 100%; +} + +body:hover { + background-color: yellow; +} + +div { + background-color: green; +} + +div:hover { + background-color: white; +} + +button:active { + background-color: teal; +} + +.right-pos { + position: absolute; + right: 0px; } diff --git a/cwd/test.rml b/cwd/test.rml index ee72ece..4c7bfa6 100644 --- a/cwd/test.rml +++ b/cwd/test.rml @@ -1,10 +1,26 @@ <rml> <head> <link type="text/rcss" href="test.rcss" /> + <script> + redLvl = 0 + function Test(elem) + elem.style["background-color"] = "rgb(" .. redLvl .. ",255,255)" + print("New background-color: "..elem.style["background-color"]) + redLvl = redLvl + 50 + end + </script> </head> <body> - <div style="background-color:green;"> - Test RmlUi + Test RmlUi + <br /> + New line + <div> + Substring + </div> + <br /> + <button onclick="print('Button clicked!')" style="background-color:navy;">Clickable!</button> + <div class="right-pos" onclick="Test(element)"> + (Clickable) Right viewport border is here -> </div> </body> </rmL> |