mirror of
https://github.com/love2d/love.git
synced 2026-08-17 11:00:31 +02:00
Change how Canvas is flipped and add Canvas::drawq
This commit is contained in:
@@ -177,10 +177,10 @@ namespace opengl
|
|||||||
vertices[3].x = w; vertices[3].y = 0;
|
vertices[3].x = w; vertices[3].y = 0;
|
||||||
|
|
||||||
// texture coordinates
|
// texture coordinates
|
||||||
vertices[0].s = 0; vertices[0].t = 1;
|
vertices[0].s = 0; vertices[0].t = 0;
|
||||||
vertices[1].s = 0; vertices[1].t = 0;
|
vertices[1].s = 0; vertices[1].t = 1;
|
||||||
vertices[2].s = 1; vertices[2].t = 0;
|
vertices[2].s = 1; vertices[2].t = 1;
|
||||||
vertices[3].s = 1; vertices[3].t = 1;
|
vertices[3].s = 1; vertices[3].t = 0;
|
||||||
|
|
||||||
loadStrategy();
|
loadStrategy();
|
||||||
|
|
||||||
@@ -228,8 +228,8 @@ namespace opengl
|
|||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
// Set up orthographic view (no depth)
|
// Set up upside-down orthographic view (no depth)
|
||||||
glOrtho(0.0, width, height, 0.0, -1.0, 1.0);
|
glOrtho(0.0, width, 0.0, height, -1.0, 1.0);
|
||||||
|
|
||||||
// Switch back to modelview matrix
|
// Switch back to modelview matrix
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
@@ -273,20 +273,16 @@ namespace opengl
|
|||||||
static Matrix t;
|
static Matrix t;
|
||||||
t.setTransformation(x, y, angle, sx, sy, ox, oy, kx, ky);
|
t.setTransformation(x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||||
|
|
||||||
glPushMatrix();
|
drawv(t, vertices);
|
||||||
glMultMatrixf((const GLfloat*)t.getElements());
|
}
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, img);
|
void Canvas::drawq(Quad * quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const
|
||||||
|
{
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
static Matrix t;
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
const vertex * v = quad->getVertices();
|
||||||
glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid*)&vertices[0].x);
|
|
||||||
glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid*)&vertices[0].s);
|
t.setTransformation(x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||||
glDrawArrays(GL_QUADS, 0, 4);
|
drawv(t, v);
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
|
||||||
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
love::image::ImageData * Canvas::getImageData(love::image::Image * image)
|
love::image::ImageData * Canvas::getImageData(love::image::Image * image)
|
||||||
@@ -399,6 +395,25 @@ namespace opengl
|
|||||||
{
|
{
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Canvas::drawv(const Matrix & t, const vertex * v) const
|
||||||
|
{
|
||||||
|
glPushMatrix();
|
||||||
|
|
||||||
|
glMultMatrixf((const GLfloat*)t.getElements());
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, img);
|
||||||
|
|
||||||
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid*)&v[0].x);
|
||||||
|
glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid*)&v[0].s);
|
||||||
|
glDrawArrays(GL_QUADS, 0, 4);
|
||||||
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
|
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
} // opengl
|
} // opengl
|
||||||
} // graphics
|
} // graphics
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
#include <image/Image.h>
|
#include <image/Image.h>
|
||||||
#include <image/ImageData.h>
|
#include <image/ImageData.h>
|
||||||
#include <common/math.h>
|
#include <common/math.h>
|
||||||
|
#include <common/Matrix.h>
|
||||||
#include "GLee.h"
|
#include "GLee.h"
|
||||||
|
#include "Quad.h"
|
||||||
|
|
||||||
namespace love
|
namespace love
|
||||||
{
|
{
|
||||||
@@ -35,6 +37,14 @@ namespace opengl
|
|||||||
void clear(const Color& c);
|
void clear(const Color& c);
|
||||||
|
|
||||||
virtual void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
|
virtual void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function draws a section of the canvas using a Quad object.
|
||||||
|
*
|
||||||
|
* @param quad Represents the region of the Canvas to draw.
|
||||||
|
**/
|
||||||
|
void drawq(Quad * quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
|
||||||
|
|
||||||
love::image::ImageData * getImageData(love::image::Image * image);
|
love::image::ImageData * getImageData(love::image::Image * image);
|
||||||
|
|
||||||
void setFilter(const Image::Filter &f);
|
void setFilter(const Image::Filter &f);
|
||||||
@@ -67,6 +77,8 @@ namespace opengl
|
|||||||
Image::Filter filter;
|
Image::Filter filter;
|
||||||
Image::Wrap wrap;
|
Image::Wrap wrap;
|
||||||
} settings;
|
} settings;
|
||||||
|
|
||||||
|
void drawv(const Matrix & t, const vertex * v) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // opengl
|
} // opengl
|
||||||
|
|||||||
Reference in New Issue
Block a user