Replace line drawing via GL_LINE with custom line drawing (issue #153)

Allows for correctly scaleable lines, (very) big line widths. Corners in
rectangles/triangles/... join up nicely (issue #197).

--HG--
branch : minor
This commit is contained in:
vrld
2011-03-22 01:08:31 +01:00
parent 37560e36c3
commit 2a42c64a35
3 changed files with 209 additions and 370 deletions
+9 -36
View File
@@ -76,11 +76,7 @@ namespace opengl
Graphics::ColorMode colorMode;
// Line.
float lineWidth;
Graphics::LineStyle lineStyle;
bool stipple;
GLint stippleRepeat;
GLint stipplePattern;
// Point.
float pointSize;
@@ -107,9 +103,7 @@ namespace opengl
backgroundColor.a = 255;
blendMode = Graphics::BLEND_ALPHA;
colorMode = Graphics::COLOR_MODULATE;
lineWidth = 1.0f;
lineStyle = Graphics::LINE_SMOOTH;
stipple = false;
pointSize = 1.0f;
pointStyle = Graphics::POINT_SMOOTH;
scissor = false;
@@ -126,6 +120,8 @@ namespace opengl
Font * currentFont;
DisplayMode currentMode;
float lineWidth;
public:
Graphics();
@@ -335,16 +331,6 @@ namespace opengl
**/
void setLine(float width, LineStyle style);
/**
* Disables line stippling.
**/
void setLineStipple();
/**
* Sets a line stipple pattern.
**/
void setLineStipple(unsigned short pattern, int repeat = 1);
/**
* Gets the line width.
**/
@@ -355,13 +341,6 @@ namespace opengl
**/
LineStyle getLineStyle();
/**
* Gets the line stipple pattern and repeat factor.
* @return pattern The stipplie bit-pattern.
* @return repeat The reapeat factor.
**/
int getLineStipple(lua_State * L);
/**
* Sets the size of points.
**/
@@ -423,20 +402,13 @@ namespace opengl
**/
void point(float x, float y);
/**
* Draws a line from (x1,y1) to (x2,y2).
* @param x1 First x-coordinate.
* @param y1 First y-coordinate.
* @param x2 Second x-coordinate.
* @param y2 Second y-coordinate.
**/
void line(float x1, float y1, float x2, float y2);
/**
* Draws a series of lines connecting the given vertices.
* @param ... Vertex components (x1, y1, x2, y2, etc.)
* @param coords Vertex components (x1, y1, x2, y2, etc.)
* @param count Coord array size
* @param looping Wether the line is joining itself
**/
int polyline(lua_State * L);
void polyline(const float* coords, size_t count, bool looping = false);
/**
* Draws a triangle using the three coordinates passed.
@@ -488,9 +460,10 @@ namespace opengl
/**
* Draws a polygon with an arbitrary number of vertices.
* @param type The type of drawing (line/filled).
* @param ... Vertex components (x1, y1, x2, y2, etc).
* @param coords Vertex components (x1, y1, x2, y2, etc.)
* @param count Coord array size
**/
int polygon(lua_State * L);
void polygon(DrawMode mode, const float* coords, size_t count);
/**
* Creates a screenshot of the view and saves it to the default folder.