Added high-dpi / retina support to the no-game screen; additional minor tweaks and cleanup.

This commit is contained in:
Alex Szpakowski
2015-11-11 19:35:45 -04:00
parent 3cd18bae20
commit 7043b5314d
10 changed files with 2025 additions and 106 deletions
+14 -14
View File
@@ -29,7 +29,7 @@ namespace love
namespace graphics
{
Quad::Quad(const Quad::Viewport &v, float sw, float sh)
Quad::Quad(const Quad::Viewport &v, double sw, double sh)
: sw(sw)
, sh(sh)
{
@@ -41,7 +41,7 @@ Quad::~Quad()
{
}
void Quad::refresh(const Quad::Viewport &v, float sw, float sh)
void Quad::refresh(const Quad::Viewport &v, double sw, double sh)
{
viewport = v;
@@ -53,20 +53,20 @@ void Quad::refresh(const Quad::Viewport &v, float sw, float sh)
vertices[0].x = 0.0f;
vertices[0].y = 0.0f;
vertices[1].x = 0.0f;
vertices[1].y = v.h;
vertices[2].x = v.w;
vertices[1].y = (float) v.h;
vertices[2].x = (float) v.w;
vertices[2].y = 0.0f;
vertices[3].x = v.w;
vertices[3].y = v.h;
vertices[3].x = (float) v.w;
vertices[3].y = (float) v.h;
vertices[0].s = v.x/sw;
vertices[0].t = v.y/sh;
vertices[1].s = v.x/sw;
vertices[1].t = (v.y+v.h)/sh;
vertices[2].s = (v.x+v.w)/sw;
vertices[2].t = v.y/sh;
vertices[3].s = (v.x+v.w)/sw;
vertices[3].t = (v.y+v.h)/sh;
vertices[0].s = (float) (v.x/sw);
vertices[0].t = (float) (v.y/sh);
vertices[1].s = (float) (v.x/sw);
vertices[1].t = (float) ((v.y+v.h)/sh);
vertices[2].s = (float) ((v.x+v.w)/sw);
vertices[2].t = (float) (v.y/sh);
vertices[3].s = (float) ((v.x+v.w)/sw);
vertices[3].t = (float) ((v.y+v.h)/sh);
}
void Quad::setViewport(const Quad::Viewport &v)
+6 -6
View File
@@ -36,14 +36,14 @@ public:
struct Viewport
{
float x, y;
float w, h;
double x, y;
double w, h;
};
Quad(const Viewport &v, float sw, float sh);
Quad(const Viewport &v, double sw, double sh);
virtual ~Quad();
void refresh(const Viewport &v, float sw, float sh);
void refresh(const Viewport &v, double sw, double sh);
void setViewport(const Viewport &v);
Viewport getViewport() const;
@@ -54,8 +54,8 @@ private:
Vertex vertices[4];
Viewport viewport;
float sw;
float sh;
double sw;
double sh;
}; // Quad
-2
View File
@@ -164,11 +164,9 @@ void GLBuffer::setMappedRangeModified(size_t offset, size_t modifiedsize)
// a and b are marked as modified.
size_t old_range_end = modified_offset + modified_size;
modified_offset = std::min(modified_offset, offset);
size_t new_range_end = std::max(offset + modifiedsize, old_range_end);
modified_size = new_range_end - modified_offset;
}
+1 -1
View File
@@ -708,7 +708,7 @@ Image *Graphics::newImage(const std::vector<love::image::CompressedImageData *>
return new Image(cdata, flags);
}
Quad *Graphics::newQuad(Quad::Viewport v, float sw, float sh)
Quad *Graphics::newQuad(Quad::Viewport v, double sw, double sh)
{
return new Quad(v, sw, sh);
}
+1 -1
View File
@@ -162,7 +162,7 @@ public:
Image *newImage(const std::vector<love::image::ImageData *> &data, const Image::Flags &flags);
Image *newImage(const std::vector<love::image::CompressedImageData *> &cdata, const Image::Flags &flags);
Quad *newQuad(Quad::Viewport v, float sw, float sh);
Quad *newQuad(Quad::Viewport v, double sw, double sh);
/**
* Creates a Font object.
@@ -368,13 +368,13 @@ int w_newImage(lua_State *L)
int w_newQuad(lua_State *L)
{
Quad::Viewport v;
v.x = (float) luaL_checknumber(L, 1);
v.y = (float) luaL_checknumber(L, 2);
v.w = (float) luaL_checknumber(L, 3);
v.h = (float) luaL_checknumber(L, 4);
v.x = luaL_checknumber(L, 1);
v.y = luaL_checknumber(L, 2);
v.w = luaL_checknumber(L, 3);
v.h = luaL_checknumber(L, 4);
float sw = (float) luaL_checknumber(L, 5);
float sh = (float) luaL_checknumber(L, 6);
double sw = luaL_checknumber(L, 5);
double sh = luaL_checknumber(L, 6);
Quad *quad = instance()->newQuad(v, sw, sh);
luax_pushtype(L, GRAPHICS_QUAD_ID, quad);
@@ -159,7 +159,7 @@ precision mediump float;
#endif
varying mediump vec4 VaryingTexCoord;
varying lowp vec4 VaryingColor;
varying mediump vec4 VaryingColor;
#define love_Canvases gl_FragData
@@ -307,7 +307,7 @@ vec4 position(mat4 transform_proj, vec4 vertpos) {
return transform_proj * vertpos;
}]],
pixel = [[
vec4 effect(lowp vec4 vcolor, Image tex, vec2 texcoord, vec2 pixcoord) {
vec4 effect(mediump vec4 vcolor, Image tex, vec2 texcoord, vec2 pixcoord) {
return Texel(tex, texcoord) * vcolor;
}]]
}
+6 -6
View File
@@ -36,17 +36,17 @@ int w_Quad_setViewport(lua_State *L)
Quad *quad = luax_checkquad(L, 1);
Quad::Viewport v;
v.x = (float) luaL_checknumber(L, 2);
v.y = (float) luaL_checknumber(L, 3);
v.w = (float) luaL_checknumber(L, 4);
v.h = (float) luaL_checknumber(L, 5);
v.x = luaL_checknumber(L, 2);
v.y = luaL_checknumber(L, 3);
v.w = luaL_checknumber(L, 4);
v.h = luaL_checknumber(L, 5);
if (lua_isnoneornil(L, 6))
quad->setViewport(v);
else
{
float sw = (float) luaL_checknumber(L, 6);
float sh = (float) luaL_checknumber(L, 7);
double sw = luaL_checknumber(L, 6);
double sh = luaL_checknumber(L, 7);
quad->refresh(v, sw, sh);
}