Moved line and shape drawing code out of the opengl folder, since it no longer directly calls any OpenGL functions.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2016-12-27 23:21:25 -04:00
parent 70df473680
commit 603c3e43d5
8 changed files with 353 additions and 366 deletions
+2 -2
View File
@@ -472,6 +472,8 @@ set(LOVE_SRC_MODULE_GRAPHICS_ROOT
src/modules/graphics/Graphics.h
src/modules/graphics/ParticleSystem.cpp
src/modules/graphics/ParticleSystem.h
src/modules/graphics/Polyline.cpp
src/modules/graphics/Polyline.h
src/modules/graphics/Quad.cpp
src/modules/graphics/Quad.h
src/modules/graphics/StreamBuffer.cpp
@@ -505,8 +507,6 @@ set(LOVE_SRC_MODULE_GRAPHICS_OPENGL
src/modules/graphics/opengl/OpenGL.h
src/modules/graphics/opengl/ParticleSystem.cpp
src/modules/graphics/opengl/ParticleSystem.h
src/modules/graphics/opengl/Polyline.cpp
src/modules/graphics/opengl/Polyline.h
src/modules/graphics/opengl/Shader.cpp
src/modules/graphics/opengl/Shader.h
src/modules/graphics/opengl/SpriteBatch.cpp
@@ -2437,6 +2437,8 @@
FA0B7B8C1A95902C000E1D17 /* opengl */,
FAE272501C05A15B00A67640 /* ParticleSystem.cpp */,
FAE272511C05A15B00A67640 /* ParticleSystem.h */,
FA0B7B9B1A95902C000E1D17 /* Polyline.cpp */,
FA0B7B9C1A95902C000E1D17 /* Polyline.h */,
FA0B7BBC1A95902C000E1D17 /* Quad.cpp */,
FA0B7BBD1A95902C000E1D17 /* Quad.h */,
FA29C0041E12355B00268CD8 /* StreamBuffer.cpp */,
@@ -2474,8 +2476,6 @@
FA0B7B981A95902C000E1D17 /* OpenGL.h */,
FA0B7B991A95902C000E1D17 /* ParticleSystem.cpp */,
FA0B7B9A1A95902C000E1D17 /* ParticleSystem.h */,
FA0B7B9B1A95902C000E1D17 /* Polyline.cpp */,
FA0B7B9C1A95902C000E1D17 /* Polyline.h */,
FA0B7B9D1A95902C000E1D17 /* Shader.cpp */,
FA0B7B9E1A95902C000E1D17 /* Shader.h */,
FA0B7B9F1A95902C000E1D17 /* SpriteBatch.cpp */,
+259
View File
@@ -20,6 +20,7 @@
#include "Graphics.h"
#include "math/MathModule.h"
#include "Polyline.h"
namespace love
{
@@ -185,6 +186,264 @@ Graphics::StreamVertexData Graphics::requestStreamDraw(const StreamDrawRequest &
return d;
}
int Graphics::calculateEllipsePoints(float rx, float ry) const
{
int points = (int) sqrtf(((rx + ry) / 2.0f) * 20.0f * (float) pixelScaleStack.back());
return std::max(points, 8);
}
void Graphics::polyline(const float *coords, size_t count)
{
float halfwidth = getLineWidth() * 0.5f;
LineJoin linejoin = getLineJoin();
LineStyle linestyle = getLineStyle();
float pixelsize = 1.0f / std::max((float) pixelScaleStack.back(), 0.000001f);
if (linejoin == LINE_JOIN_NONE)
{
NoneJoinPolyline line;
line.render(coords, count, halfwidth, pixelsize, linestyle == LINE_SMOOTH);
line.draw(this);
}
else if (linejoin == LINE_JOIN_BEVEL)
{
BevelJoinPolyline line;
line.render(coords, count, halfwidth, pixelsize, linestyle == LINE_SMOOTH);
line.draw(this);
}
else if (linejoin == LINE_JOIN_MITER)
{
MiterJoinPolyline line;
line.render(coords, count, halfwidth, pixelsize, linestyle == LINE_SMOOTH);
line.draw(this);
}
}
void Graphics::rectangle(DrawMode mode, float x, float y, float w, float h)
{
float coords[] = {x,y, x,y+h, x+w,y+h, x+w,y, x,y};
polygon(mode, coords, 5 * 2);
}
void Graphics::rectangle(DrawMode mode, float x, float y, float w, float h, float rx, float ry, int points)
{
if (rx == 0 || ry == 0)
{
rectangle(mode, x, y, w, h);
return;
}
// Radius values that are more than half the rectangle's size aren't handled
// correctly (for now)...
if (w >= 0.02f)
rx = std::min(rx, w / 2.0f - 0.01f);
if (h >= 0.02f)
ry = std::min(ry, h / 2.0f - 0.01f);
points = std::max(points / 4, 1);
const float half_pi = static_cast<float>(LOVE_M_PI / 2);
float angle_shift = half_pi / ((float) points + 1.0f);
int num_coords = (points + 2) * 8;
float *coords = getScratchBuffer<float>(num_coords + 2);
float phi = .0f;
for (int i = 0; i <= points + 2; ++i, phi += angle_shift)
{
coords[2 * i + 0] = x + rx * (1 - cosf(phi));
coords[2 * i + 1] = y + ry * (1 - sinf(phi));
}
phi = half_pi;
for (int i = points + 2; i <= 2 * (points + 2); ++i, phi += angle_shift)
{
coords[2 * i + 0] = x + w - rx * (1 + cosf(phi));
coords[2 * i + 1] = y + ry * (1 - sinf(phi));
}
phi = 2 * half_pi;
for (int i = 2 * (points + 2); i <= 3 * (points + 2); ++i, phi += angle_shift)
{
coords[2 * i + 0] = x + w - rx * (1 + cosf(phi));
coords[2 * i + 1] = y + h - ry * (1 + sinf(phi));
}
phi = 3 * half_pi;
for (int i = 3 * (points + 2); i <= 4 * (points + 2); ++i, phi += angle_shift)
{
coords[2 * i + 0] = x + rx * (1 - cosf(phi));
coords[2 * i + 1] = y + h - ry * (1 + sinf(phi));
}
coords[num_coords + 0] = coords[0];
coords[num_coords + 1] = coords[1];
polygon(mode, coords, num_coords + 2);
}
void Graphics::rectangle(DrawMode mode, float x, float y, float w, float h, float rx, float ry)
{
rectangle(mode, x, y, w, h, rx, ry, calculateEllipsePoints(rx, ry));
}
void Graphics::circle(DrawMode mode, float x, float y, float radius, int points)
{
ellipse(mode, x, y, radius, radius, points);
}
void Graphics::circle(DrawMode mode, float x, float y, float radius)
{
ellipse(mode, x, y, radius, radius);
}
void Graphics::ellipse(DrawMode mode, float x, float y, float a, float b, int points)
{
float two_pi = (float) (LOVE_M_PI * 2);
if (points <= 0) points = 1;
float angle_shift = (two_pi / points);
float phi = .0f;
float *coords = getScratchBuffer<float>(2 * (points + 1));
for (int i = 0; i < points; ++i, phi += angle_shift)
{
coords[2*i+0] = x + a * cosf(phi);
coords[2*i+1] = y + b * sinf(phi);
}
coords[2*points+0] = coords[0];
coords[2*points+1] = coords[1];
polygon(mode, coords, (points + 1) * 2);
}
void Graphics::ellipse(DrawMode mode, float x, float y, float a, float b)
{
ellipse(mode, x, y, a, b, calculateEllipsePoints(a, b));
}
void Graphics::arc(DrawMode drawmode, ArcMode arcmode, float x, float y, float radius, float angle1, float angle2, int points)
{
// Nothing to display with no points or equal angles. (Or is there with line mode?)
if (points <= 0 || angle1 == angle2)
return;
// Oh, you want to draw a circle?
if (fabs(angle1 - angle2) >= 2.0f * (float) LOVE_M_PI)
{
circle(drawmode, x, y, radius, points);
return;
}
float angle_shift = (angle2 - angle1) / points;
// Bail on precision issues.
if (angle_shift == 0.0)
return;
// Prevent the connecting line from being drawn if a closed line arc has a
// small angle. Avoids some visual issues when connected lines are at sharp
// angles, due to the miter line join drawing code.
if (drawmode == DRAW_LINE && arcmode == ARC_CLOSED && fabsf(angle1 - angle2) < LOVE_TORAD(4))
arcmode = ARC_OPEN;
// Quick fix for the last part of a filled open arc not being drawn (because
// polygon(DRAW_FILL, ...) doesn't work without a closed loop of vertices.)
if (drawmode == DRAW_FILL && arcmode == ARC_OPEN)
arcmode = ARC_CLOSED;
float phi = angle1;
float *coords = nullptr;
int num_coords = 0;
const auto createPoints = [&](float *coordinates)
{
for (int i = 0; i <= points; ++i, phi += angle_shift)
{
coordinates[2 * i + 0] = x + radius * cosf(phi);
coordinates[2 * i + 1] = y + radius * sinf(phi);
}
};
if (arcmode == ARC_PIE)
{
num_coords = (points + 3) * 2;
coords = getScratchBuffer<float>(num_coords);
coords[0] = coords[num_coords - 2] = x;
coords[1] = coords[num_coords - 1] = y;
createPoints(coords + 2);
}
else if (arcmode == ARC_OPEN)
{
num_coords = (points + 1) * 2;
coords = getScratchBuffer<float>(num_coords);
createPoints(coords);
}
else // ARC_CLOSED
{
num_coords = (points + 2) * 2;
coords = getScratchBuffer<float>(num_coords);
createPoints(coords);
// Connect the ends of the arc.
coords[num_coords - 2] = coords[0];
coords[num_coords - 1] = coords[1];
}
polygon(drawmode, coords, num_coords);
}
void Graphics::arc(DrawMode drawmode, ArcMode arcmode, float x, float y, float radius, float angle1, float angle2)
{
float points = (float) calculateEllipsePoints(radius, radius);
// The amount of points is based on the fraction of the circle created by the arc.
float angle = fabsf(angle1 - angle2);
if (angle < 2.0f * (float) LOVE_M_PI)
points *= angle / (2.0f * (float) LOVE_M_PI);
arc(drawmode, arcmode, x, y, radius, angle1, angle2, (int) (points + 0.5f));
}
/// @param mode the draw mode
/// @param coords the coordinate array
/// @param count the number of coordinates/size of the array
void Graphics::polygon(DrawMode mode, const float *coords, size_t count)
{
// coords is an array of a closed loop of vertices, i.e.
// coords[count-2] = coords[0], coords[count-1] = coords[1]
if (mode == DRAW_LINE)
{
polyline(coords, count);
}
else
{
StreamDrawRequest req;
req.formats[0] = vertex::CommonFormat::XYf;
req.formats[1] = vertex::CommonFormat::RGBAub;
req.indexMode = vertex::TriangleIndexMode::FAN;
req.vertexCount = (int)count/2 - 1;
StreamVertexData data = requestStreamDraw(req);
const Matrix4 &t = getTransform();
t.transform((Vector *) data.stream[0], (const Vector *) coords, req.vertexCount);
Color c = toColor(getColor());
Color *colordata = (Color *) data.stream[1];
for (int i = 0; i < req.vertexCount; i++)
colordata[i] = c;
}
}
const Matrix4 &Graphics::getTransform() const
{
return transformStack.back();
+84
View File
@@ -317,6 +317,86 @@ public:
virtual Colorf getColor() const = 0;
virtual float getLineWidth() const = 0;
virtual LineStyle getLineStyle() const = 0;
virtual LineJoin getLineJoin() const = 0;
/**
* Draws a series of lines connecting the given vertices.
* @param coords Vertex components (x1, y1, ..., xn, yn). If x1,y1 == xn,yn the line will be drawn closed.
* @param count Number of items in the array, i.e. count = 2 * n
**/
void polyline(const float *coords, size_t count);
/**
* Draws a rectangle.
* @param x Position along x-axis for top-left corner.
* @param y Position along y-axis for top-left corner.
* @param w The width of the rectangle.
* @param h The height of the rectangle.
**/
void rectangle(DrawMode mode, float x, float y, float w, float h);
/**
* Variant of rectangle that draws a rounded rectangle.
* @param mode The mode of drawing (line/filled).
* @param x X-coordinate of top-left corner
* @param y Y-coordinate of top-left corner
* @param w The width of the rectangle.
* @param h The height of the rectangle.
* @param rx The radius of the corners on the x axis
* @param ry The radius of the corners on the y axis
* @param points The number of points to use per corner
**/
void rectangle(DrawMode mode, float x, float y, float w, float h, float rx, float ry, int points);
void rectangle(DrawMode mode, float x, float y, float w, float h, float rx, float ry);
/**
* Draws a circle using the specified arguments.
* @param mode The mode of drawing (line/filled).
* @param x X-coordinate.
* @param y Y-coordinate.
* @param radius Radius of the circle.
* @param points Number of points to use to draw the circle.
**/
void circle(DrawMode mode, float x, float y, float radius, int points);
void circle(DrawMode mode, float x, float y, float radius);
/**
* Draws an ellipse using the specified arguments.
* @param mode The mode of drawing (line/filled).
* @param x X-coordinate of center
* @param y Y-coordinate of center
* @param a Radius in x-direction
* @param b Radius in y-direction
* @param points Number of points to use to draw the circle.
**/
void ellipse(DrawMode mode, float x, float y, float a, float b, int points);
void ellipse(DrawMode mode, float x, float y, float a, float b);
/**
* Draws an arc using the specified arguments.
* @param drawmode The mode of drawing (line/filled).
* @param arcmode The type of arc.
* @param x X-coordinate.
* @param y Y-coordinate.
* @param radius Radius of the arc.
* @param angle1 The angle at which the arc begins.
* @param angle2 The angle at which the arc terminates.
* @param points Number of points to use to draw the arc.
**/
void arc(DrawMode drawmode, ArcMode arcmode, float x, float y, float radius, float angle1, float angle2, int points);
void arc(DrawMode drawmode, ArcMode arcmode, float x, float y, float radius, float angle1, float angle2);
/**
* Draws a polygon with an arbitrary number of vertices.
* @param mode The type of drawing (line/filled).
* @param coords Vertex components (x1, y1, x2, y2, etc.)
* @param count Coord array size
**/
void polygon(DrawMode mode, const float *coords, size_t count);
const Matrix4 &getTransform() const;
const Matrix4 &getProjection() const;
@@ -386,8 +466,12 @@ protected:
std::vector<Matrix4> transformStack;
Matrix4 projectionMatrix;
std::vector<double> pixelScaleStack;
private:
int calculateEllipsePoints(float rx, float ry) const;
std::vector<uint8> scratchBuffer;
static StringMap<DrawMode, DRAW_MAX_ENUM>::Entry drawModeEntries[];
@@ -32,8 +32,6 @@ namespace love
{
namespace graphics
{
namespace opengl
{
void Polyline::render(const float *coords, size_t count, size_t size_hint, float halfwidth, float pixel_size, bool draw_overdraw)
{
@@ -414,6 +412,5 @@ void NoneJoinPolyline::fill_color_array(Color constant_color, Color *colors)
}
}
} // opengl
} // graphics
} // love
@@ -18,8 +18,7 @@
* 3. This notice may not be removed or altered from any source distribution.
**/
#ifndef LOVE_GRAPHICS_OPENGL_POLYLINE_H
#define LOVE_GRAPHICS_OPENGL_POLYLINE_H
#pragma once
// LOVE
#include "common/config.h"
@@ -37,9 +36,6 @@ namespace graphics
class Graphics;
namespace opengl
{
/**
* Abstract base class for a chain of segments.
* @author Matthias Richter
@@ -188,8 +184,5 @@ protected:
}; // BevelJoinPolyline
} // opengl
} // graphics
} // love
#endif // LOVE_GRAPHICS_OPENGL_POLYLINE_H
+1 -256
View File
@@ -25,7 +25,7 @@
#include "Graphics.h"
#include "font/Font.h"
#include "Polyline.h"
#include "graphics/Polyline.h"
#include "math/MathModule.h"
#include "window/Window.h"
@@ -1793,261 +1793,6 @@ void Graphics::points(const float *coords, const Colorf *colors, size_t numpoint
}
}
void Graphics::polyline(const float *coords, size_t count)
{
const DisplayState &state = states.back();
float pixelsize = 1.0f / std::max((float) pixelScaleStack.back(), 0.000001f);
if (state.lineJoin == LINE_JOIN_NONE)
{
NoneJoinPolyline line;
line.render(coords, count, state.lineWidth * .5f, pixelsize, state.lineStyle == LINE_SMOOTH);
line.draw(this);
}
else if (state.lineJoin == LINE_JOIN_BEVEL)
{
BevelJoinPolyline line;
line.render(coords, count, state.lineWidth * .5f, pixelsize, state.lineStyle == LINE_SMOOTH);
line.draw(this);
}
else // LINE_JOIN_MITER
{
MiterJoinPolyline line;
line.render(coords, count, state.lineWidth * .5f, pixelsize, state.lineStyle == LINE_SMOOTH);
line.draw(this);
}
}
void Graphics::rectangle(DrawMode mode, float x, float y, float w, float h)
{
float coords[] = {x,y, x,y+h, x+w,y+h, x+w,y, x,y};
polygon(mode, coords, 5 * 2);
}
void Graphics::rectangle(DrawMode mode, float x, float y, float w, float h, float rx, float ry, int points)
{
if (rx == 0 || ry == 0)
{
rectangle(mode, x, y, w, h);
return;
}
// Radius values that are more than half the rectangle's size aren't handled
// correctly (for now)...
if (w >= 0.02f)
rx = std::min(rx, w / 2.0f - 0.01f);
if (h >= 0.02f)
ry = std::min(ry, h / 2.0f - 0.01f);
points = std::max(points / 4, 1);
const float half_pi = static_cast<float>(LOVE_M_PI / 2);
float angle_shift = half_pi / ((float) points + 1.0f);
int num_coords = (points + 2) * 8;
float *coords = getScratchBuffer<float>(num_coords + 2);
float phi = .0f;
for (int i = 0; i <= points + 2; ++i, phi += angle_shift)
{
coords[2 * i + 0] = x + rx * (1 - cosf(phi));
coords[2 * i + 1] = y + ry * (1 - sinf(phi));
}
phi = half_pi;
for (int i = points + 2; i <= 2 * (points + 2); ++i, phi += angle_shift)
{
coords[2 * i + 0] = x + w - rx * (1 + cosf(phi));
coords[2 * i + 1] = y + ry * (1 - sinf(phi));
}
phi = 2 * half_pi;
for (int i = 2 * (points + 2); i <= 3 * (points + 2); ++i, phi += angle_shift)
{
coords[2 * i + 0] = x + w - rx * (1 + cosf(phi));
coords[2 * i + 1] = y + h - ry * (1 + sinf(phi));
}
phi = 3 * half_pi;
for (int i = 3 * (points + 2); i <= 4 * (points + 2); ++i, phi += angle_shift)
{
coords[2 * i + 0] = x + rx * (1 - cosf(phi));
coords[2 * i + 1] = y + h - ry * (1 + sinf(phi));
}
coords[num_coords + 0] = coords[0];
coords[num_coords + 1] = coords[1];
polygon(mode, coords, num_coords + 2);
}
int Graphics::calculateEllipsePoints(float rx, float ry) const
{
int points = (int) sqrtf(((rx + ry) / 2.0f) * 20.0f * (float) pixelScaleStack.back());
return std::max(points, 8);
}
void Graphics::rectangle(DrawMode mode, float x, float y, float w, float h, float rx, float ry)
{
rectangle(mode, x, y, w, h, rx, ry, calculateEllipsePoints(rx, ry));
}
void Graphics::circle(DrawMode mode, float x, float y, float radius, int points)
{
ellipse(mode, x, y, radius, radius, points);
}
void Graphics::circle(DrawMode mode, float x, float y, float radius)
{
ellipse(mode, x, y, radius, radius);
}
void Graphics::ellipse(DrawMode mode, float x, float y, float a, float b, int points)
{
float two_pi = (float) (LOVE_M_PI * 2);
if (points <= 0) points = 1;
float angle_shift = (two_pi / points);
float phi = .0f;
float *coords = getScratchBuffer<float>(2 * (points + 1));
for (int i = 0; i < points; ++i, phi += angle_shift)
{
coords[2*i+0] = x + a * cosf(phi);
coords[2*i+1] = y + b * sinf(phi);
}
coords[2*points+0] = coords[0];
coords[2*points+1] = coords[1];
polygon(mode, coords, (points + 1) * 2);
}
void Graphics::ellipse(DrawMode mode, float x, float y, float a, float b)
{
ellipse(mode, x, y, a, b, calculateEllipsePoints(a, b));
}
void Graphics::arc(DrawMode drawmode, ArcMode arcmode, float x, float y, float radius, float angle1, float angle2, int points)
{
// Nothing to display with no points or equal angles. (Or is there with line mode?)
if (points <= 0 || angle1 == angle2)
return;
// Oh, you want to draw a circle?
if (fabs(angle1 - angle2) >= 2.0f * (float) LOVE_M_PI)
{
circle(drawmode, x, y, radius, points);
return;
}
float angle_shift = (angle2 - angle1) / points;
// Bail on precision issues.
if (angle_shift == 0.0)
return;
// Prevent the connecting line from being drawn if a closed line arc has a
// small angle. Avoids some visual issues when connected lines are at sharp
// angles, due to the miter line join drawing code.
if (drawmode == DRAW_LINE && arcmode == ARC_CLOSED && fabsf(angle1 - angle2) < LOVE_TORAD(4))
arcmode = ARC_OPEN;
// Quick fix for the last part of a filled open arc not being drawn (because
// polygon(DRAW_FILL, ...) doesn't work without a closed loop of vertices.)
if (drawmode == DRAW_FILL && arcmode == ARC_OPEN)
arcmode = ARC_CLOSED;
float phi = angle1;
float *coords = nullptr;
int num_coords = 0;
const auto createPoints = [&](float *coordinates)
{
for (int i = 0; i <= points; ++i, phi += angle_shift)
{
coordinates[2 * i + 0] = x + radius * cosf(phi);
coordinates[2 * i + 1] = y + radius * sinf(phi);
}
};
if (arcmode == ARC_PIE)
{
num_coords = (points + 3) * 2;
coords = getScratchBuffer<float>(num_coords);
coords[0] = coords[num_coords - 2] = x;
coords[1] = coords[num_coords - 1] = y;
createPoints(coords + 2);
}
else if (arcmode == ARC_OPEN)
{
num_coords = (points + 1) * 2;
coords = getScratchBuffer<float>(num_coords);
createPoints(coords);
}
else // ARC_CLOSED
{
num_coords = (points + 2) * 2;
coords = getScratchBuffer<float>(num_coords);
createPoints(coords);
// Connect the ends of the arc.
coords[num_coords - 2] = coords[0];
coords[num_coords - 1] = coords[1];
}
polygon(drawmode, coords, num_coords);
}
void Graphics::arc(DrawMode drawmode, ArcMode arcmode, float x, float y, float radius, float angle1, float angle2)
{
float points = (float) calculateEllipsePoints(radius, radius);
// The amount of points is based on the fraction of the circle created by the arc.
float angle = fabsf(angle1 - angle2);
if (angle < 2.0f * (float) LOVE_M_PI)
points *= angle / (2.0f * (float) LOVE_M_PI);
arc(drawmode, arcmode, x, y, radius, angle1, angle2, (int) (points + 0.5f));
}
/// @param mode the draw mode
/// @param coords the coordinate array
/// @param count the number of coordinates/size of the array
void Graphics::polygon(DrawMode mode, const float *coords, size_t count)
{
// coords is an array of a closed loop of vertices, i.e.
// coords[count-2] = coords[0], coords[count-1] = coords[1]
if (mode == DRAW_LINE)
{
polyline(coords, count);
}
else
{
StreamDrawRequest req;
req.formats[0] = vertex::CommonFormat::XYf;
req.formats[1] = vertex::CommonFormat::RGBAub;
req.indexMode = vertex::TriangleIndexMode::FAN;
req.vertexCount = (int)count/2 - 1;
StreamVertexData data = requestStreamDraw(req);
const Matrix4 &t = getTransform();
t.transform((Vector *) data.stream[0], (const Vector *) coords, req.vertexCount);
Color c = toColor(getColor());
Color *colordata = (Color *) data.stream[1];
for (int i = 0; i < req.vertexCount; i++)
colordata[i] = c;
}
}
Graphics::RendererInfo Graphics::getRendererInfo() const
{
RendererInfo info;
+4 -95
View File
@@ -279,25 +279,13 @@ public:
void setLineStyle(LineStyle style);
/**
* Sets the line style.
* @param style LINE_ROUGH or LINE_SMOOTH.
* Sets the line join mode.
**/
void setLineJoin(LineJoin style);
/**
* Gets the line width.
**/
float getLineWidth() const;
/**
* Gets the line style.
**/
LineStyle getLineStyle() const;
/**
* Gets the line style.
**/
LineJoin getLineJoin() const;
float getLineWidth() const override;
LineStyle getLineStyle() const override;
LineJoin getLineJoin() const override;
/**
* Sets the size of points.
@@ -342,81 +330,6 @@ public:
**/
void points(const float *coords, const Colorf *colors, size_t numpoints);
/**
* Draws a series of lines connecting the given vertices.
* @param coords Vertex components (x1, y1, ..., xn, yn). If x1,y1 == xn,yn the line will be drawn closed.
* @param count Number of items in the array, i.e. count = 2 * n
**/
void polyline(const float *coords, size_t count);
/**
* Draws a rectangle.
* @param x Position along x-axis for top-left corner.
* @param y Position along y-axis for top-left corner.
* @param w The width of the rectangle.
* @param h The height of the rectangle.
**/
void rectangle(DrawMode mode, float x, float y, float w, float h);
/**
* Variant of rectangle that draws a rounded rectangle.
* @param mode The mode of drawing (line/filled).
* @param x X-coordinate of top-left corner
* @param y Y-coordinate of top-left corner
* @param w The width of the rectangle.
* @param h The height of the rectangle.
* @param rx The radius of the corners on the x axis
* @param ry The radius of the corners on the y axis
* @param points The number of points to use per corner
**/
void rectangle(DrawMode mode, float x, float y, float w, float h, float rx, float ry, int points);
void rectangle(DrawMode mode, float x, float y, float w, float h, float rx, float ry);
/**
* Draws a circle using the specified arguments.
* @param mode The mode of drawing (line/filled).
* @param x X-coordinate.
* @param y Y-coordinate.
* @param radius Radius of the circle.
* @param points Number of points to use to draw the circle.
**/
void circle(DrawMode mode, float x, float y, float radius, int points);
void circle(DrawMode mode, float x, float y, float radius);
/**
* Draws an ellipse using the specified arguments.
* @param mode The mode of drawing (line/filled).
* @param x X-coordinate of center
* @param y Y-coordinate of center
* @param a Radius in x-direction
* @param b Radius in y-direction
* @param points Number of points to use to draw the circle.
**/
void ellipse(DrawMode mode, float x, float y, float a, float b, int points);
void ellipse(DrawMode mode, float x, float y, float a, float b);
/**
* Draws an arc using the specified arguments.
* @param drawmode The mode of drawing (line/filled).
* @param arcmode The type of arc.
* @param x X-coordinate.
* @param y Y-coordinate.
* @param radius Radius of the arc.
* @param angle1 The angle at which the arc begins.
* @param angle2 The angle at which the arc terminates.
* @param points Number of points to use to draw the arc.
**/
void arc(DrawMode drawmode, ArcMode arcmode, float x, float y, float radius, float angle1, float angle2, int points);
void arc(DrawMode drawmode, ArcMode arcmode, float x, float y, float radius, float angle1, float angle2);
/**
* Draws a polygon with an arbitrary number of vertices.
* @param mode The type of drawing (line/filled).
* @param coords Vertex components (x1, y1, x2, y2, etc.)
* @param count Coord array size
**/
void polygon(DrawMode mode, const float *coords, size_t count);
void captureScreenshot(const ScreenshotInfo &info);
/**
@@ -516,12 +429,8 @@ private:
void checkSetDefaultFont();
int calculateEllipsePoints(float rx, float ry) const;
StrongRef<Font> defaultFont;
std::vector<double> pixelScaleStack;
std::vector<ScreenshotInfo> pendingScreenshotCallbacks;
std::unordered_map<uint32, GLuint> framebufferObjects;