MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / drawLine

Function drawLine

engine/Poseidon/Graphics/Textures/ModelRenderer.cpp:65–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65static void drawLine(std::vector<uint8_t>& buf, int w, int h, int x0, int y0, int x1, int y1, uint8_t r, uint8_t g,
66 uint8_t b)
67{
68 int dx = std::abs(x1 - x0), sx = x0 < x1 ? 1 : -1;
69 int dy = -std::abs(y1 - y0), sy = y0 < y1 ? 1 : -1;
70 int err = dx + dy;
71 for (;;)
72 {
73 if (x0 >= 0 && x0 < w && y0 >= 0 && y0 < h)
74 {
75 int idx = (y0 * w + x0) * 3;
76 buf[idx] = r;
77 buf[idx + 1] = g;
78 buf[idx + 2] = b;
79 }
80 if (x0 == x1 && y0 == y1)
81 break;
82 int e2 = 2 * err;
83 if (e2 >= dy)
84 {
85 err += dy;
86 x0 += sx;
87 }
88 if (e2 <= dx)
89 {
90 err += dx;
91 y0 += sy;
92 }
93 }
94}
95
96// Vertex accessor for Shape* (used by RenderModelWireframe)
97struct ShapeVA

Callers 3

renderOrthoTFunction · 0.85
renderPerspTFunction · 0.85
DrawTestPatternMethod · 0.85

Calls 1

absFunction · 0.85

Tested by

no test coverage detected