92 U11, V11, U12, V12, U13, V13, \
93 U21, V21, U22, V22, U23, V23, \
94 VCOLOR) \
95 do { \
96 ADD_VERTEX_XYUVUVC(X1, Y1, U11, V11, U21, V21, VCOLOR); \
97 ADD_VERTEX_XYUVUVC(X2, Y2, U12, V12, U22, V22, VCOLOR); \
98 ADD_VERTEX_XYUVUVC(X3, Y3, U13, V13, U23, V23, VCOLOR); \
99 batches[currentBatch].pNum++; \
100 } while (0)
101
102 // These are fudge factors for rendering lines found by experimenting.
103 // They are used to tweak the geometry such that the rendering (mostly) matches
104 // our software rendering on most hardware. The main goal was to pick the
105 // numbers such that the beginning and ending pixels of lines match.
106 #define LINE_FUDGE
107 // fudge factors
108 #ifdef LINE_FUDGE
109
110 // Horiz/vertical
111 #define HV_FF1 ( 0.0f)
112 #define HV_FF2 ( 0.51f)
113 // For the record: value below (or larger) is required for Intel 855, but
114 // breaks Nvidia, ATI and Intel 965, and since the pipeline is disabled on
115 // 855 anyway we'll use 0.51f.
116 //#define HV_FF2 ( 0.5315f)
117 #define HV_FF3 (-0.2f)
118 // single pixel
119 #define SP_FF4 ( 0.3f)
120
121 // diagonal, down
122 #define DD_FX1 (-0.1f)
123 #define DD_FY1 (-0.25f)
124 #define DD_FX2 ( 0.2f)
125 #define DD_FY2 ( 0.304f)
126 // For the record: with this value diagonal-down lines with Texture paint
127 // are a bit off on all chipsets but Intel 965. So instead we'll use
128 // .304f which makes it better for the rest, but at a price of a bit
129 // of pixel/texel shifting on 965G
130 //#define DD_FY2 ( 0.4f)
131 // diagonal, up
132 #define DU_FX1 (-0.1f)
133 #define DU_FY1 ( 0.4f)
134 #define DU_FX2 ( 0.3f)
135 #define DU_FY2 (-0.3f)
136
137 #else
234 if (x1 > x2) {
235 fx1 = (float)x2+HV_FF3;
236 fx2 = (float)x1+HV_FF2;
237 } else if (x1 < x2) {
238 fx1 = (float)x1+HV_FF3;
239 fx2 = (float)x2+HV_FF2;
240 } else {
241 // single point, offset a little so that a single
242 // pixel is rendered
243 fx1 = (float)x1-SP_FF4;
244 fy1 = (float)y1-SP_FF4;
245 fx2 = (float)x2+SP_FF4;
246 fy2 = (float)y2+SP_FF4;
247 }
248 } else if (x1 == x2) {
249 // vertical
250 fx1 = (float)x1+HV_FF1;
251 fx2 = fx1;
252 if (y1 > y2) {
253 fy1 = (float)y2+HV_FF3;
254 fy2 = (float)y1+HV_FF2;
255 } else {
256 fy1 = (float)y1+HV_FF3;
257 fy2 = (float)y2+HV_FF2;
258 }
259 } else {
260 // diagonal
261 if (x1 > x2 && y1 > y2) {
262 // ^
263 // \ case -> inverse
264 fx1 = (float)x2;
265 fy1 = (float)y2;
266 fx2 = (float)x1;
267 fy2 = (float)y1;
268 } else if (x1 > x2 && y2 > y1) {
269 // /
270 // v case - inverse
271 fx1 = (float)x2;
272 fy1 = (float)y2;
273 fx2 = (float)x1;
274 fy2 = (float)y1;
275 } else {
276 // \ ^
277 // v or / - leave as is
430
431 HRESULT D3DVertexCacher::DrawRect(int x1, int y1, int x2, int y2)
432 {
433 HRESULT res;
434
435 if ((x2 - x1) < 2 || (y2 - y1) < 2) {
436 return FillRect(x1, y1, x2+1, y2+1);
437 }
438 if (SUCCEEDED(res = EnsureCapacity(D3DPT_LINELIST, 4*2))) {
439
440 float fx1 = (float)x1;
441 float fy1 = (float)y1;
442 float fx2 = (float)x2;
443 float fy2 = (float)y2;
444
445 // horiz: top left - top right
446 ADD_LINE_XYC(fx1+HV_FF3, fy1+HV_FF1, fx2-1.0f+HV_FF2, fy1+HV_FF1,color);
447 // horiz: bottom left - bottom right
448 ADD_LINE_XYC(fx1+1.0f+HV_FF3, fy2+HV_FF1, fx2+HV_FF2, fy2+HV_FF1,color);
449 // vert : top right - bottom right
450 ADD_LINE_XYC(fx2+HV_FF1, fy1+HV_FF3, fx2+HV_FF1, fy2-1.0f+HV_FF2,color);
451 // vert : top left - bottom left
452 ADD_LINE_XYC(fx1+HV_FF1, fy1+1.0f+HV_FF3, fx1+HV_FF1, fy2+HV_FF2,color);
453 }
454 return res;
455 }
456
457 HRESULT D3DVertexCacher::FillRect(int x1, int y1, int x2, int y2)
458 {
459 HRESULT res;
460 if (SUCCEEDED(res = EnsureCapacity(D3DPT_TRIANGLELIST, 2*3))) {
461 float fx1 = (float)x1;
462 float fy1 = (float)y1;
463 float fx2 = (float)x2;
464 float fy2 = (float)y2;
465 ADD_TRIANGLE_XYUVC(fx1, fy1, fx2, fy1, fx1, fy2,
466 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f,
467 color);
468 ADD_TRIANGLE_XYUVC(fx1, fy2, fx2, fy1, fx2, fy2,
469 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f,
470 color);
471 }
472 return res;
|
92 U11, V11, U12, V12, U13, V13, \
93 U21, V21, U22, V22, U23, V23, \
94 VCOLOR) \
95 do { \
96 ADD_VERTEX_XYUVUVC(X1, Y1, U11, V11, U21, V21, VCOLOR); \
97 ADD_VERTEX_XYUVUVC(X2, Y2, U12, V12, U22, V22, VCOLOR); \
98 ADD_VERTEX_XYUVUVC(X3, Y3, U13, V13, U23, V23, VCOLOR); \
99 batches[currentBatch].pNum++; \
100 } while (0)
101
102 // These are fudge factors for rendering lines found by experimenting.
103 // They are used to tweak the geometry such that the rendering (mostly) matches
104 // our software rendering on most hardware. The main goal was to pick the
105 // numbers such that the beginning and ending pixels of lines match.
106 #define LINE_FUDGE
107 // fudge factors
108 #ifdef LINE_FUDGE
109
110 // Horiz/vertical
111 #define HV_FF1 ( 0.0f)
112 #define HV_FF2 ( 0.501f)
113 // For the record: value below (or larger) is required for Intel 855, but
114 // breaks Nvidia, ATI and Intel 965, and since the pipeline is disabled on
115 // 855 anyway we'll use 0.51f.
116 //#define HV_FF2 ( 0.5315f)
117 #define HV_FF3 (-0.2f)
118 #define HV_FF4 ( 0.51f)
119 // single pixel
120 #define SP_FF4 ( 0.3f)
121
122 // diagonal, down
123 #define DD_FX1 (-0.1f)
124 #define DD_FY1 (-0.25f)
125 #define DD_FX2 ( 0.2f)
126 #define DD_FY2 ( 0.304f)
127 // For the record: with this value diagonal-down lines with Texture paint
128 // are a bit off on all chipsets but Intel 965. So instead we'll use
129 // .304f which makes it better for the rest, but at a price of a bit
130 // of pixel/texel shifting on 965G
131 //#define DD_FY2 ( 0.4f)
132 // diagonal, up
133 #define DU_FX1 (-0.1f)
134 #define DU_FY1 ( 0.4f)
135 #define DU_FX2 ( 0.3f)
136 #define DU_FY2 (-0.3f)
137
138 #else
235 if (x1 > x2) {
236 fx1 = (float)x2+HV_FF3;
237 fx2 = (float)x1+HV_FF2;
238 } else if (x1 < x2) {
239 fx1 = (float)x1+HV_FF3;
240 fx2 = (float)x2+HV_FF2;
241 } else {
242 // single point, offset a little so that a single
243 // pixel is rendered
244 fx1 = (float)x1-SP_FF4;
245 fy1 = (float)y1-SP_FF4;
246 fx2 = (float)x2+SP_FF4;
247 fy2 = (float)y2+SP_FF4;
248 }
249 } else if (x1 == x2) {
250 // vertical
251 fx1 = (float)x1+HV_FF1;
252 fx2 = fx1;
253 if (y1 > y2) {
254 fy1 = (float)y2+HV_FF3;
255 fy2 = (float)y1+HV_FF4;
256 } else {
257 fy1 = (float)y1+HV_FF3;
258 fy2 = (float)y2+HV_FF4;
259 }
260 } else {
261 // diagonal
262 if (x1 > x2 && y1 > y2) {
263 // ^
264 // \ case -> inverse
265 fx1 = (float)x2;
266 fy1 = (float)y2;
267 fx2 = (float)x1;
268 fy2 = (float)y1;
269 } else if (x1 > x2 && y2 > y1) {
270 // /
271 // v case - inverse
272 fx1 = (float)x2;
273 fy1 = (float)y2;
274 fx2 = (float)x1;
275 fy2 = (float)y1;
276 } else {
277 // \ ^
278 // v or / - leave as is
431
432 HRESULT D3DVertexCacher::DrawRect(int x1, int y1, int x2, int y2)
433 {
434 HRESULT res;
435
436 if ((x2 - x1) < 2 || (y2 - y1) < 2) {
437 return FillRect(x1, y1, x2+1, y2+1);
438 }
439 if (SUCCEEDED(res = EnsureCapacity(D3DPT_LINELIST, 4*2))) {
440
441 float fx1 = (float)x1;
442 float fy1 = (float)y1;
443 float fx2 = (float)x2;
444 float fy2 = (float)y2;
445
446 // horiz: top left - top right
447 ADD_LINE_XYC(fx1+HV_FF3, fy1+HV_FF1, fx2-1.0f+HV_FF2, fy1+HV_FF1,color);
448 // horiz: bottom left - bottom right
449 ADD_LINE_XYC(fx1+1.0f+HV_FF3, fy2+HV_FF1, fx2+HV_FF2, fy2+HV_FF1,color);
450 // vert : top right - bottom right
451 ADD_LINE_XYC(fx2+HV_FF1, fy1+HV_FF3, fx2+HV_FF1, fy2-1.0f+HV_FF4,color);
452 // vert : top left - bottom left
453 ADD_LINE_XYC(fx1+HV_FF1, fy1+1.0f+HV_FF3, fx1+HV_FF1, fy2+HV_FF4,color);
454 }
455 return res;
456 }
457
458 HRESULT D3DVertexCacher::FillRect(int x1, int y1, int x2, int y2)
459 {
460 HRESULT res;
461 if (SUCCEEDED(res = EnsureCapacity(D3DPT_TRIANGLELIST, 2*3))) {
462 float fx1 = (float)x1;
463 float fy1 = (float)y1;
464 float fx2 = (float)x2;
465 float fy2 = (float)y2;
466 ADD_TRIANGLE_XYUVC(fx1, fy1, fx2, fy1, fx1, fy2,
467 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f,
468 color);
469 ADD_TRIANGLE_XYUVC(fx1, fy2, fx2, fy1, fx2, fy2,
470 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f,
471 color);
472 }
473 return res;
|