aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics/Drawable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin/Graphics/Drawable.cpp')
-rw-r--r--src/libjin/Graphics/Drawable.cpp48
1 files changed, 22 insertions, 26 deletions
diff --git a/src/libjin/Graphics/Drawable.cpp b/src/libjin/Graphics/Drawable.cpp
index 675c54d..9f52f0a 100644
--- a/src/libjin/Graphics/Drawable.cpp
+++ b/src/libjin/Graphics/Drawable.cpp
@@ -1,6 +1,7 @@
-#include "../modules.h"
+#include "../jin_configuration.h"
#if LIBJIN_MODULES_RENDER
+#include "Shader.h"
#include "drawable.h"
#include "../math/matrix.h"
#include <stdlib.h>
@@ -15,6 +16,15 @@ namespace graphics
, size(w, h)
, anchor(0, 0)
{
+ vertex_coords[0] = 0; vertex_coords[1] = 0;
+ vertex_coords[2] = 0; vertex_coords[3] = h;
+ vertex_coords[4] = w; vertex_coords[5] = h;
+ vertex_coords[6] = w; vertex_coords[7] = 0;
+
+ texture_coords[0] = 0; texture_coords[1] = 0;
+ texture_coords[2] = 0; texture_coords[3] = 1;
+ texture_coords[4] = 1; texture_coords[5] = 1;
+ texture_coords[6] = 1; texture_coords[7] = 0;
}
Drawable::~Drawable()
@@ -30,31 +40,17 @@ namespace graphics
void Drawable::draw(int x, int y, float sx, float sy, float r)
{
- /* Must set textCoord and vertCoord before renderring */
- if (! textCoord||! vertCoord) return;
-
- static jin::math::Matrix t;
- t.setTransformation(x, y, r, sx, sy, anchor.x, anchor.y);
-
- glBindTexture(GL_TEXTURE_2D, texture);
-
- /* push modle matrix */
- glPushMatrix();
- glMultMatrixf((const GLfloat*)t.getElements());
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(2, GL_FLOAT, 0, textCoord);
- glVertexPointer(2, GL_FLOAT, 0, vertCoord);
- glDrawArrays(GL_QUADS, 0, 4);
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-
- /* pop the model matrix */
- glPopMatrix();
-
- /* bind texture to default screen */
- glBindTexture(GL_TEXTURE_2D, 0);
+ gl.ModelMatrix.setTransformation(x, y, r, sx, sy, anchor.x, anchor.y);
+
+ Shader* shader = Shader::getCurrentJSL();
+ shader->sendMatrix4(Shader::MODEL_MATRIX, &gl.ModelMatrix);
+ shader->sendMatrix4(Shader::PROJECTION_MATRIX, &gl.ProjectionMatrix);
+ shader->bindVertexPointer(2, GL_FLOAT, 0, vertex_coords);
+ shader->bindUVPointer(2, GL_FLOAT, 0, texture_coords);
+
+ gl.bindTexture(texture);
+ gl.drawArrays(GL_QUADS, 0, 4);
+ gl.bindTexture(0);
}
} // render