mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
moved Mesh:setWireframe to love.graphics.setWireframe (affects all draws until it's disabled.)
Wireframe mode should only be used for debugging: the wireframe lines behave differently than regular lines, their widths aren't affected by the graphics scale, and the mode isn't available on OpenGL ES.
This commit is contained in:
@@ -102,6 +102,8 @@ DisplayState Graphics::saveState()
|
|||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
s.colorMask[i] = colorMask[i];
|
s.colorMask[i] = colorMask[i];
|
||||||
|
|
||||||
|
wireframe = isWireframe();
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,6 +121,7 @@ void Graphics::restoreState(const DisplayState &s)
|
|||||||
else
|
else
|
||||||
setScissor();
|
setScissor();
|
||||||
setColorMask(s.colorMask[0], s.colorMask[1], s.colorMask[2], s.colorMask[3]);
|
setColorMask(s.colorMask[0], s.colorMask[1], s.colorMask[2], s.colorMask[3]);
|
||||||
|
setWireframe(s.wireframe);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::setViewportSize(int width, int height)
|
void Graphics::setViewportSize(int width, int height)
|
||||||
@@ -749,6 +752,17 @@ Graphics::PointStyle Graphics::getPointStyle() const
|
|||||||
return POINT_ROUGH;
|
return POINT_ROUGH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Graphics::setWireframe(bool enable)
|
||||||
|
{
|
||||||
|
wireframe = enable;
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, enable ? GL_LINE : GL_FILL);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Graphics::isWireframe() const
|
||||||
|
{
|
||||||
|
return wireframe;
|
||||||
|
}
|
||||||
|
|
||||||
void Graphics::print(const std::string &str, float x, float y , float angle, float sx, float sy, float ox, float oy, float kx, float ky)
|
void Graphics::print(const std::string &str, float x, float y , float angle, float sx, float sy, float ox, float oy, float kx, float ky)
|
||||||
{
|
{
|
||||||
if (currentFont != nullptr)
|
if (currentFont != nullptr)
|
||||||
|
|||||||
@@ -81,6 +81,8 @@ struct DisplayState
|
|||||||
// Color mask.
|
// Color mask.
|
||||||
bool colorMask[4];
|
bool colorMask[4];
|
||||||
|
|
||||||
|
bool wireframe;
|
||||||
|
|
||||||
// Default values.
|
// Default values.
|
||||||
DisplayState()
|
DisplayState()
|
||||||
{
|
{
|
||||||
@@ -93,6 +95,7 @@ struct DisplayState
|
|||||||
pointStyle = Graphics::POINT_SMOOTH;
|
pointStyle = Graphics::POINT_SMOOTH;
|
||||||
scissor = false;
|
scissor = false;
|
||||||
colorMask[0] = colorMask[1] = colorMask[2] = colorMask[3] = true;
|
colorMask[0] = colorMask[1] = colorMask[2] = colorMask[3] = true;
|
||||||
|
wireframe = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -334,6 +337,19 @@ public:
|
|||||||
**/
|
**/
|
||||||
PointStyle getPointStyle() const;
|
PointStyle getPointStyle() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether graphics will be drawn as wireframe lines instead of filled
|
||||||
|
* triangles (has no effect for drawn points.)
|
||||||
|
* This should only be used as a debugging tool. The wireframe lines do not
|
||||||
|
* behave the same as regular love.graphics lines.
|
||||||
|
**/
|
||||||
|
void setWireframe(bool enable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether wireframe drawing mode is enabled.
|
||||||
|
**/
|
||||||
|
bool isWireframe() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws text at the specified coordinates, with rotation and
|
* Draws text at the specified coordinates, with rotation and
|
||||||
* scaling along both axes.
|
* scaling along both axes.
|
||||||
@@ -460,6 +476,7 @@ private:
|
|||||||
GLint matrixLimit;
|
GLint matrixLimit;
|
||||||
GLint userMatrices;
|
GLint userMatrices;
|
||||||
bool colorMask[4];
|
bool colorMask[4];
|
||||||
|
bool wireframe;
|
||||||
|
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ Mesh::Mesh(const std::vector<Vertex> &verts, Mesh::DrawMode mode)
|
|||||||
, range_max(-1)
|
, range_max(-1)
|
||||||
, texture(nullptr)
|
, texture(nullptr)
|
||||||
, colors_enabled(false)
|
, colors_enabled(false)
|
||||||
, wireframe(false)
|
|
||||||
{
|
{
|
||||||
setVertices(verts);
|
setVertices(verts);
|
||||||
}
|
}
|
||||||
@@ -59,7 +58,6 @@ Mesh::Mesh(int vertexcount, Mesh::DrawMode mode)
|
|||||||
, range_max(-1)
|
, range_max(-1)
|
||||||
, texture(nullptr)
|
, texture(nullptr)
|
||||||
, colors_enabled(false)
|
, colors_enabled(false)
|
||||||
, wireframe(false)
|
|
||||||
{
|
{
|
||||||
if (vertexcount < 1)
|
if (vertexcount < 1)
|
||||||
throw love::Exception("Invalid number of vertices.");
|
throw love::Exception("Invalid number of vertices.");
|
||||||
@@ -278,16 +276,6 @@ bool Mesh::hasVertexColors() const
|
|||||||
return colors_enabled;
|
return colors_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mesh::setWireframe(bool enable)
|
|
||||||
{
|
|
||||||
wireframe = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Mesh::isWireframe() const
|
|
||||||
{
|
|
||||||
return wireframe;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mesh::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
|
void Mesh::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
|
||||||
{
|
{
|
||||||
const size_t pos_offset = offsetof(Vertex, x);
|
const size_t pos_offset = offsetof(Vertex, x);
|
||||||
@@ -326,9 +314,6 @@ void Mesh::draw(float x, float y, float angle, float sx, float sy, float ox, flo
|
|||||||
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), vbo->getPointer(color_offset));
|
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), vbo->getPointer(color_offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wireframe)
|
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
|
||||||
|
|
||||||
GLenum mode = getGLDrawMode(draw_mode);
|
GLenum mode = getGLDrawMode(draw_mode);
|
||||||
|
|
||||||
gl.prepareDraw();
|
gl.prepareDraw();
|
||||||
@@ -374,9 +359,6 @@ void Mesh::draw(float x, float y, float angle, float sx, float sy, float ox, flo
|
|||||||
glDrawArrays(mode, min, max - min + 1);
|
glDrawArrays(mode, min, max - min + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wireframe)
|
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
|
||||||
|
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
|
||||||
|
|||||||
@@ -162,15 +162,6 @@ public:
|
|||||||
void setVertexColors(bool enable);
|
void setVertexColors(bool enable);
|
||||||
bool hasVertexColors() const;
|
bool hasVertexColors() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets whether the Mesh will be drawn as wireframe lines instead of filled
|
|
||||||
* triangles (has no effect for DRAW_MODE_POINTS.)
|
|
||||||
* This should only be used as a debugging tool. The wireframe lines do not
|
|
||||||
* behave the same as regular love.graphics lines.
|
|
||||||
**/
|
|
||||||
void setWireframe(bool enable);
|
|
||||||
bool isWireframe() const;
|
|
||||||
|
|
||||||
// Implements Drawable.
|
// Implements Drawable.
|
||||||
void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
|
void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
|
||||||
|
|
||||||
@@ -201,8 +192,6 @@ private:
|
|||||||
// Whether the per-vertex colors are used when drawing.
|
// Whether the per-vertex colors are used when drawing.
|
||||||
bool colors_enabled;
|
bool colors_enabled;
|
||||||
|
|
||||||
bool wireframe;
|
|
||||||
|
|
||||||
static StringMap<DrawMode, DRAW_MODE_MAX_ENUM>::Entry drawModeEntries[];
|
static StringMap<DrawMode, DRAW_MODE_MAX_ENUM>::Entry drawModeEntries[];
|
||||||
static StringMap<DrawMode, DRAW_MODE_MAX_ENUM> drawModes;
|
static StringMap<DrawMode, DRAW_MODE_MAX_ENUM> drawModes;
|
||||||
|
|
||||||
|
|||||||
@@ -844,6 +844,18 @@ int w_getMaxPointSize(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int w_setWireframe(lua_State *L)
|
||||||
|
{
|
||||||
|
instance->setWireframe(luax_toboolean(L, 1));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int w_isWireframe(lua_State *L)
|
||||||
|
{
|
||||||
|
luax_pushboolean(L, instance->isWireframe());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int w_newScreenshot(lua_State *L)
|
int w_newScreenshot(lua_State *L)
|
||||||
{
|
{
|
||||||
love::image::Image *image = luax_getmodule<love::image::Image>(L, "image", MODULE_IMAGE_T);
|
love::image::Image *image = luax_getmodule<love::image::Image>(L, "image", MODULE_IMAGE_T);
|
||||||
@@ -1388,6 +1400,8 @@ static const luaL_Reg functions[] =
|
|||||||
{ "setPointStyle", w_setPointStyle },
|
{ "setPointStyle", w_setPointStyle },
|
||||||
{ "getPointSize", w_getPointSize },
|
{ "getPointSize", w_getPointSize },
|
||||||
{ "getPointStyle", w_getPointStyle },
|
{ "getPointStyle", w_getPointStyle },
|
||||||
|
{ "setWireframe", w_setWireframe },
|
||||||
|
{ "isWireframe", w_isWireframe },
|
||||||
{ "newScreenshot", w_newScreenshot },
|
{ "newScreenshot", w_newScreenshot },
|
||||||
{ "setCanvas", w_setCanvas },
|
{ "setCanvas", w_setCanvas },
|
||||||
{ "getCanvas", w_getCanvas },
|
{ "getCanvas", w_getCanvas },
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ int w_setPointStyle(lua_State *L);
|
|||||||
int w_getPointSize(lua_State *L);
|
int w_getPointSize(lua_State *L);
|
||||||
int w_getPointStyle(lua_State *L);
|
int w_getPointStyle(lua_State *L);
|
||||||
int w_getMaxPointSize(lua_State *L);
|
int w_getMaxPointSize(lua_State *L);
|
||||||
|
int w_setWireframe(lua_State *L);
|
||||||
|
int w_isWireframe(lua_State *L);
|
||||||
int w_newScreenshot(lua_State *L);
|
int w_newScreenshot(lua_State *L);
|
||||||
int w_setCanvas(lua_State *L);
|
int w_setCanvas(lua_State *L);
|
||||||
int w_getCanvas(lua_State *L);
|
int w_getCanvas(lua_State *L);
|
||||||
|
|||||||
@@ -361,20 +361,6 @@ int w_Mesh_hasVertexColors(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_Mesh_setWireframe(lua_State *L)
|
|
||||||
{
|
|
||||||
Mesh *t = luax_checkmesh(L, 1);
|
|
||||||
t->setWireframe(luax_toboolean(L, 2));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int w_Mesh_isWireframe(lua_State *L)
|
|
||||||
{
|
|
||||||
Mesh *t = luax_checkmesh(L, 1);
|
|
||||||
luax_pushboolean(L, t->isWireframe());
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const luaL_Reg functions[] =
|
static const luaL_Reg functions[] =
|
||||||
{
|
{
|
||||||
{ "setVertex", w_Mesh_setVertex },
|
{ "setVertex", w_Mesh_setVertex },
|
||||||
@@ -394,8 +380,6 @@ static const luaL_Reg functions[] =
|
|||||||
{ "getDrawRange", w_Mesh_getDrawRange },
|
{ "getDrawRange", w_Mesh_getDrawRange },
|
||||||
{ "setVertexColors", w_Mesh_setVertexColors },
|
{ "setVertexColors", w_Mesh_setVertexColors },
|
||||||
{ "hasVertexColors", w_Mesh_hasVertexColors },
|
{ "hasVertexColors", w_Mesh_hasVertexColors },
|
||||||
{ "setWireframe", w_Mesh_setWireframe },
|
|
||||||
{ "isWireframe", w_Mesh_isWireframe },
|
|
||||||
|
|
||||||
// Deprecated since 0.9.1.
|
// Deprecated since 0.9.1.
|
||||||
{ "setImage", w_Mesh_setTexture },
|
{ "setImage", w_Mesh_setTexture },
|
||||||
|
|||||||
@@ -51,8 +51,6 @@ int w_Mesh_setDrawRange(lua_State *L);
|
|||||||
int w_Mesh_getDrawRange(lua_State *L);
|
int w_Mesh_getDrawRange(lua_State *L);
|
||||||
int w_Mesh_setVertexColors(lua_State *L);
|
int w_Mesh_setVertexColors(lua_State *L);
|
||||||
int w_Mesh_hasVertexColors(lua_State *L);
|
int w_Mesh_hasVertexColors(lua_State *L);
|
||||||
int w_Mesh_setWireframe(lua_State *L);
|
|
||||||
int w_Mesh_isWireframe(lua_State *L);
|
|
||||||
|
|
||||||
extern "C" int luaopen_mesh(lua_State *L);
|
extern "C" int luaopen_mesh(lua_State *L);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user