le3d - LightEngine 3D
A straightforward C++ 3D software engine for real-time graphics
flattexzc.h
Go to the documentation of this file.
1 
33 inline void LeRasterizer::fillFlatTexZC(int y, float x1, float x2, float w1, float w2, float u1, float u2, float v1, float v2)
34 {
35  uint8_t * c = (uint8_t *) &curTriangle->solidColor;
36 
37  float d = x2 - x1;
38  if (d == 0.0f) return;
39 
40  float au = (u2 - u1) / d;
41  float av = (v2 - v1) / d;
42  float aw = (w2 - w1) / d;
43 
44  int xb = (int) (x1);
45  int xe = (int) (x2 + 1.9999f);
46  if (xe > frame.tx) xe = frame.tx;
47 
48  uint8_t * p = (uint8_t *) (xb + ((int) y) * frame.tx + pixels);
49 
50  for (int x = xb; x < xe; x++) {
51  float z = 1.0f / w1;
52  uint32_t tu = ((int32_t) (u1 * z)) & texMaskU;
53  uint32_t tv = ((int32_t) (v1 * z)) & texMaskV;
54  uint8_t * t = (uint8_t *) &texDiffusePixels[tu + (tv << texSizeU)];
55 
56  p[0] = (t[0] * c[0]) >> 8;
57  p[1] = (t[1] * c[1]) >> 8;
58  p[2] = (t[2] * c[2]) >> 8;
59  p += 4;
60 
61  u1 += au;
62  v1 += av;
63  w1 += aw;
64  }
65 }
LeColor solidColor
Definition: trilist.h:83
int tx
Definition: bitmap.h:81
LeBitmap frame
Definition: rasterizer_float.h:61