From b17c035642cc33ee614046be011bf8ad9f9db95d Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 6 Jan 2016 16:52:03 +0100 Subject: OPENGL: Implement texture drawing in Pipeline instead of Surface. --- backends/graphics/opengl/pipeline.h | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'backends/graphics/opengl/pipeline.h') diff --git a/backends/graphics/opengl/pipeline.h b/backends/graphics/opengl/pipeline.h index d101a99d9b..5ec52f2f28 100644 --- a/backends/graphics/opengl/pipeline.h +++ b/backends/graphics/opengl/pipeline.h @@ -24,6 +24,7 @@ #define BACKENDS_GRAPHICS_OPENGL_PIEPLINE_H #include "backends/graphics/opengl/opengl-sys.h" +#include "backends/graphics/opengl/texture.h" namespace OpenGL { @@ -87,13 +88,22 @@ public: virtual void setColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a) = 0; /** - * Setup coordinates for drawing with glDrawArrays. + * Draw a texture rectangle to the currently active framebuffer. * - * @param vertices The list of vertices, 2 coordinates for each vertex. - * @param texCoords The list of texture coordinates, 2 coordinates for - * each vertex. + * @param texture Texture to use for drawing. + * @param coordinates x1, y1, x2, y2 coordinates where to draw the texture. */ - virtual void setDrawCoordinates(const GLfloat *vertices, const GLfloat *texCoords) = 0; + virtual void drawTexture(const GLTexture &texture, const GLfloat *coordinates) = 0; + + void drawTexture(const GLTexture &texture, GLfloat x, GLfloat y, GLfloat w, GLfloat h) { + const GLfloat coordinates[4*2] = { + x, y, + x + w, y, + x, y + h, + x + w, y + h + }; + drawTexture(texture, coordinates); + } /** * Set the projection matrix. @@ -113,7 +123,7 @@ public: virtual void setColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a); - virtual void setDrawCoordinates(const GLfloat *vertices, const GLfloat *texCoords); + virtual void drawTexture(const GLTexture &texture, const GLfloat *coordinates); virtual void setProjectionMatrix(const GLfloat *projectionMatrix); }; @@ -130,7 +140,7 @@ public: virtual void setColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a); - virtual void setDrawCoordinates(const GLfloat *vertices, const GLfloat *texCoords); + virtual void drawTexture(const GLTexture &texture, const GLfloat *coordinates); virtual void setProjectionMatrix(const GLfloat *projectionMatrix); -- cgit v1.2.3