| 110 | } |
| 111 | |
| 112 | void EngineGL33::DrawLine(const Line2DAbs& line, PackedColor c0, PackedColor c1, const Rect2DAbs& clip) |
| 113 | { |
| 114 | float x0 = line.beg.x; |
| 115 | float y0 = line.beg.y; |
| 116 | float x1 = line.end.x; |
| 117 | float y1 = line.end.y; |
| 118 | // use line texture |
| 119 | Texture* tex = GPreloadedTextures.New(TextureLine); |
| 120 | const MipInfo& mip = TextBank()->UseMipmap(tex, 1, 1); |
| 121 | |
| 122 | // convert line to poly; |
| 123 | int specFlags = NoZBuf | IsAlpha | ClampU | ClampV | IsAlphaFog; |
| 124 | float dx = x1 - x0; |
| 125 | float dy = y1 - y0; |
| 126 | float dSize2 = dx * dx + dy * dy; |
| 127 | float invDSize = dSize2 > 0 ? InvSqrt(dSize2) : 1; |
| 128 | |
| 129 | // direction perpendicular dx, dy |
| 130 | // 2D line drawing |
| 131 | float pdx = +dy * invDSize, pdy = -dx * invDSize; |
| 132 | float w = 3.0f; |
| 133 | x0 -= pdx * (w * 0.5); |
| 134 | x1 -= pdx * (w * 0.5); |
| 135 | y0 -= pdy * (w * 0.5); |
| 136 | y1 -= pdy * (w * 0.5); |
| 137 | float x0Side = x0 + pdx * w, y0Side = y0 + pdy * w; |
| 138 | float x1Side = x1 + pdx * w, y1Side = y1 + pdy * w; |
| 139 | |
| 140 | Vertex2DAbs vertices[4]; |
| 141 | float off = 0; |
| 142 | vertices[0].x = x0 - off; |
| 143 | vertices[0].y = y0 - off; |
| 144 | vertices[0].u = 0; |
| 145 | vertices[0].v = 0.25; |
| 146 | vertices[0].color = c0; |
| 147 | |
| 148 | vertices[1].x = x0Side - off; |
| 149 | vertices[1].y = y0Side - off; |
| 150 | vertices[1].u = 0; |
| 151 | vertices[1].v = 1; |
| 152 | vertices[1].color = c0; |
| 153 | |
| 154 | vertices[3].x = x1 - off; |
| 155 | vertices[3].y = y1 - off; |
| 156 | vertices[3].u = 0.1; |
| 157 | vertices[3].v = 0.25; |
| 158 | vertices[3].color = c1; |
| 159 | |
| 160 | vertices[2].x = x1Side - off; |
| 161 | vertices[2].y = y1Side - off; |
| 162 | vertices[2].u = 0.1; |
| 163 | vertices[2].v = 1; |
| 164 | vertices[2].color = c1; |
| 165 | |
| 166 | DrawPoly(mip, vertices, 4, clip, specFlags); |
| 167 | } |
| 168 | |
| 169 | void EngineGL33::DrawPoly(const MipInfo& mip, const Vertex2DPixel* vertices, int n, const Rect2DPixel& clipRect, |