Merge pull request #5158 from unknownbrackets/softgpu

Fix a bunch of issues in line drawing in softgpu
This commit is contained in:
Henrik Rydgård 2014-01-19 23:59:32 -08:00
commit 7d8b4b5cfe
2 changed files with 12 additions and 5 deletions

View File

@ -133,6 +133,12 @@ bool SymbolMap::LoadSymbolMap(const char *filename) {
void SymbolMap::SaveSymbolMap(const char *filename) const {
lock_guard guard(lock_);
// Don't bother writing a blank file.
if (!File::Exists(filename) && functions.empty() && data.empty()) {
return;
}
FILE *f = File::OpenCFile(filename, "w");
if (!f)
return;

View File

@ -1237,9 +1237,9 @@ void DrawLine(const VertexData &v0, const VertexData &v1)
int steps;
if (abs(dx) < abs(dy))
steps = dy;
steps = abs(dy) / 16;
else
steps = dx;
steps = abs(dx) / 16;
float xinc = (float)dx / steps;
float yinc = (float)dy / steps;
@ -1285,14 +1285,15 @@ void DrawLine(const VertexData &v0, const VertexData &v1)
float x = a.x;
float y = a.y;
float z = a.z;
const int steps1 = steps == 0 ? 1 : steps;
for (int i = 0; i <= steps; i++) {
if (x < scissorTL.x || y < scissorTL.y || x >= scissorBR.x || y >= scissorBR.y)
continue;
Vec4<int> c0 = (v0.color0 * (steps - i) + v1.color0 * i) / steps;
Vec3<int> sec_color = (v0.color1 * (steps - i) + v1.color1 * i) / steps;
Vec4<int> c0 = (v0.color0 * (steps - i) + v1.color0 * i) / steps1;
Vec3<int> sec_color = (v0.color1 * (steps - i) + v1.color1 * i) / steps1;
// TODO: UVGenMode?
Vec2<float> tc = (v0.texturecoords * (float)(steps - i) + v1.texturecoords * (float)i) / steps;
Vec2<float> tc = (v0.texturecoords * (float)(steps - i) + v1.texturecoords * (float)i) / steps1;
Vec3<int> prim_color_rgb = c0.rgb();
int prim_color_a = c0.a();
float s = tc.s();