aboutsummaryrefslogtreecommitdiffstats
path: root/src/common.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.cpp')
-rw-r--r--src/common.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/common.cpp b/src/common.cpp
index 45ab5b6..060da00 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -34,6 +34,50 @@ std::vector<std::string> StringTokenizer(const std::string& str, char delim)
return tokens;
}
+static GLuint *Gshader;
+static GLint *tex_uni;
+static GLint *coord_attrib;
+static GLint *tex_attrib;
+
+void useShader(GLuint *sh, GLint *tu, GLint *ca, GLint *ta)
+{
+ Gshader = sh;
+ tex_uni = tu;
+ coord_attrib = ca;
+ tex_attrib = ta;
+}
+
+void drawRect(vec2 ll, vec2 ur)
+{
+ GLfloat verts[] = {ll.x, ll.y, 1.0,
+ ur.x, ll.y, 1.0,
+ ur.x, ur.y, 1.0,
+
+ ur.x, ur.y, 1.0,
+ ll.x, ur.y, 1.0,
+ ll.x, ll.y, 1.0};
+
+ GLfloat tex[] = {0.0, 1.0,
+ 1.0, 1.0,
+ 1.0, 0.0,
+
+ 1.0, 0.0,
+ 0.0, 0.0,
+ 0.0, 1.0};
+
+ glUniform1i(*tex_uni, 0);
+
+ glEnableVertexAttribArray(*coord_attrib);
+ glEnableVertexAttribArray(*tex_attrib);
+
+ glVertexAttribPointer(*coord_attrib, 3, GL_FLOAT, GL_FALSE, 0, verts);
+ glVertexAttribPointer(*tex_attrib, 2, GL_FLOAT, GL_FALSE, 0, tex);
+ glDrawArrays(GL_TRIANGLES, 0, 6);
+
+ glDisableVertexAttribArray(*tex_attrib);
+ glDisableVertexAttribArray(*coord_attrib);
+}
+
void DEBUG_prints(const char* file, int line, const char *s,...)
{
va_list args;