summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2022-01-22 13:30:35 -0500
committer AJR <ajrhacker@users.noreply.github.com>2022-01-22 13:39:58 -0500
commitdefa0f3262f30b2635baefc0700af646af8dfdc8 (patch)
tree6d95adba94431a08cb102418bdb99e545abae209 /src/osd/modules
parent6d2f9e1fda212a54d0b9c4f9615c354e4d5710f2 (diff)
rendutil.cpp: API cleanup + minor related OSD render cleanups
Diffstat (limited to 'src/osd/modules')
-rw-r--r--src/osd/modules/render/drawd3d.cpp18
-rw-r--r--src/osd/modules/render/drawogl.cpp25
2 files changed, 11 insertions, 32 deletions
diff --git a/src/osd/modules/render/drawd3d.cpp b/src/osd/modules/render/drawd3d.cpp
index 7fc1bcf53d6..cfc494a2be9 100644
--- a/src/osd/modules/render/drawd3d.cpp
+++ b/src/osd/modules/render/drawd3d.cpp
@@ -1523,15 +1523,10 @@ void renderer_d3d9::batch_vector(const render_primitive &prim)
}
// compute the effective width based on the direction of the line
- float effwidth = prim.width;
- if (effwidth < 2.0f)
- {
- effwidth = 2.0f;
- }
+ float effwidth = std::max(prim.width, 2.0f);
// determine the bounds of a quad to draw this line
- render_bounds b0, b1;
- render_line_to_quad(&prim.bounds, effwidth, effwidth, &b0, &b1);
+ auto [b0, b1] = render_line_to_quad(prim.bounds, effwidth, effwidth);
float lx = b1.x1 - b0.x1;
float ly = b1.y1 - b0.y1;
@@ -1630,15 +1625,10 @@ void renderer_d3d9::draw_line(const render_primitive &prim)
}
// compute the effective width based on the direction of the line
- float effwidth = prim.width;
- if (effwidth < 1.0f)
- {
- effwidth = 1.0f;
- }
+ float effwidth = std::max(prim.width, 1.0f);
// determine the bounds of a quad to draw this line
- render_bounds b0, b1;
- render_line_to_quad(&prim.bounds, effwidth, 0.0f, &b0, &b1);
+ auto [b0, b1] = render_line_to_quad(prim.bounds, effwidth, 0.0f);
vertex[0].x = b0.x0;
vertex[0].y = b0.y0;
diff --git a/src/osd/modules/render/drawogl.cpp b/src/osd/modules/render/drawogl.cpp
index 7cf99ccfb5f..9e200f3817c 100644
--- a/src/osd/modules/render/drawogl.cpp
+++ b/src/osd/modules/render/drawogl.cpp
@@ -1253,11 +1253,6 @@ int renderer_ogl::draw(const int update)
}
#else
{
- const line_aa_step *step = line_aa_4step;
- render_bounds b0, b1;
- float r, g, b, a;
- float effwidth;
-
// we're not gonna play fancy here. close anything pending and let's go.
if (pendingPrimitive!=GL_NO_PRIMITIVE && pendingPrimitive!=curPrimitive)
{
@@ -1268,12 +1263,10 @@ int renderer_ogl::draw(const int update)
set_blendmode(sdl, PRIMFLAG_GET_BLENDMODE(prim.flags));
// compute the effective width based on the direction of the line
- effwidth = prim.width();
- if (effwidth < 0.5f)
- effwidth = 0.5f;
+ float effwidth = std::max(prim.width(), 0.5f);
// determine the bounds of a quad to draw this line
- render_line_to_quad(&prim.bounds, effwidth, 0.0f, &b0, &b1);
+ auto [b0, b1] = render_line_to_quad(prim.bounds, effwidth, 0.0f);
// fix window position
b0.x0 += hofs;
@@ -1286,7 +1279,7 @@ int renderer_ogl::draw(const int update)
b1.y1 += vofs;
// iterate over AA steps
- for (step = PRIMFLAG_GET_ANTIALIAS(prim.flags) ? line_aa_4step : line_aa_1step; step->weight != 0; step++)
+ for (const line_aa_step *step = PRIMFLAG_GET_ANTIALIAS(prim.flags) ? line_aa_4step : line_aa_1step; step->weight != 0; step++)
{
glBegin(GL_TRIANGLE_STRIP);
@@ -1303,14 +1296,10 @@ int renderer_ogl::draw(const int update)
glVertex2f(b1.x1 + step->xoffs, b1.y1 + step->yoffs);
// determine the color of the line
- r = (prim.color.r * step->weight);
- g = (prim.color.g * step->weight);
- b = (prim.color.b * step->weight);
- a = (prim.color.a * 255.0f);
- if (r > 1.0) r = 1.0;
- if (g > 1.0) g = 1.0;
- if (b > 1.0) b = 1.0;
- if (a > 1.0) a = 1.0;
+ float r = std::min(prim.color.r * step->weight, 1.0f);
+ float g = std::min(prim.color.g * step->weight, 1.0f);
+ float b = std::min(prim.color.b * step->weight, 1.0f);
+ float a = std::min(prim.color.a * 255.0f, 1.0f);
glColor4f(r, g, b, a);
// texture = texture_update(window, &prim, 0);