summaryrefslogtreecommitdiff
path: root/chisel/backends/opengl/gfx.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chisel/backends/opengl/gfx.cpp')
-rw-r--r--chisel/backends/opengl/gfx.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/chisel/backends/opengl/gfx.cpp b/chisel/backends/opengl/gfx.cpp
new file mode 100644
index 0000000..be25413
--- /dev/null
+++ b/chisel/backends/opengl/gfx.cpp
@@ -0,0 +1,53 @@
+#include "gfx.h"
+
+const std::string standard_vs =
+ "#version 330\n"
+ "in vec2 pos;\n"
+ "void main() {\n"
+ "gl_Position = vec4(pos, 0.0, 1.0);\n"
+ "}\n";
+const std::string standard_fs =
+ "#version 330\n"
+ "out vec4 color;\n"
+ "void main() {\n"
+ "color = vec4(1.0, 1.0, 1.0, 1.0);\n"
+ "}\n";
+
+namespace gfx {
+ Shaders shaders;
+
+ Program* Shaders::standard() {
+ if (_standard)
+ return _standard;
+
+ _standard = new Program();
+ {
+ auto vs = Shader(standard_vs, VERTEX_SHADER);
+ auto fs = Shader(standard_fs, FRAGMENT_SHADER);
+
+ _standard->attach(vs);
+ _standard->attach(fs);
+ _standard->link();
+ }
+
+ return _standard;
+ }
+
+
+
+ namespace state {
+ GLuint current_program_id = 0;
+ float width = 0.0;
+ float height = 0.0;
+ }
+
+ void viewport(int w, int h) {
+ state::width = (float)w;
+ state::height = (float)h;
+ glViewport(0, 0, w, h);
+ }
+
+ void draw(Drawable& object) {
+ object.draw();
+ }
+} \ No newline at end of file