Rev 8063 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8063 | Rev 8069 | ||
---|---|---|---|
1 | ; fill triangle profile |
1 | ; fill triangle profile |
2 | ; #define PROFILE |
2 | ; #define PROFILE |
3 | 3 | ||
4 | CLIP_XMIN equ (1<<0) |
4 | CLIP_XMIN equ (1<<0) |
5 | CLIP_XMAX equ (1<<1) |
5 | CLIP_XMAX equ (1<<1) |
6 | CLIP_YMIN equ (1<<2) |
6 | CLIP_YMIN equ (1<<2) |
7 | CLIP_YMAX equ (1<<3) |
7 | CLIP_YMAX equ (1<<3) |
8 | CLIP_ZMIN equ (1<<4) |
8 | CLIP_ZMIN equ (1<<4) |
9 | CLIP_ZMAX equ (1<<5) |
9 | CLIP_ZMAX equ (1<<5) |
10 | 10 | ||
11 | align 16 |
11 | align 16 |
12 | proc gl_transform_to_viewport uses eax ebx ecx, context:dword,v:dword |
12 | proc gl_transform_to_viewport uses eax ebx ecx, context:dword,v:dword |
13 | mov eax,[context] |
13 | mov eax,[context] |
14 | mov ebx,[v] |
14 | mov ebx,[v] |
15 | 15 | ||
16 | ; coordinates |
16 | ; coordinates |
17 | fld1 |
17 | fld1 |
18 | fdiv dword[ebx+GLVertex.pc+offs_W] ;st0 = 1/v.pc.W |
18 | fdiv dword[ebx+GLVertex.pc+offs_W] ;st0 = 1/v.pc.W |
19 | 19 | ||
20 | fld dword[ebx+GLVertex.pc+offs_X] ;st0 = v.pc.X |
20 | fld dword[ebx+GLVertex.pc+offs_X] ;st0 = v.pc.X |
21 | fmul st0,st1 |
21 | fmul st0,st1 |
22 | fmul dword[eax+GLContext.viewport+offs_vpor_scale+offs_X] |
22 | fmul dword[eax+GLContext.viewport+GLViewport.scale+offs_X] |
23 | fadd dword[eax+GLContext.viewport+offs_vpor_trans+offs_X] |
23 | fadd dword[eax+GLContext.viewport+GLViewport.trans+offs_X] |
24 | fistp dword[ebx+GLVertex.zp] ;v.zp.x = st0, st0 = st1 |
24 | fistp dword[ebx+GLVertex.zp] ;v.zp.x = st0, st0 = st1 |
25 | 25 | ||
26 | fld dword[ebx+GLVertex.pc+offs_Y] ;st0 = v.pc.Y |
26 | fld dword[ebx+GLVertex.pc+offs_Y] ;st0 = v.pc.Y |
27 | fmul st0,st1 |
27 | fmul st0,st1 |
28 | fmul dword[eax+GLContext.viewport+offs_vpor_scale+offs_Y] |
28 | fmul dword[eax+GLContext.viewport+GLViewport.scale+offs_Y] |
29 | fadd dword[eax+GLContext.viewport+offs_vpor_trans+offs_Y] |
29 | fadd dword[eax+GLContext.viewport+GLViewport.trans+offs_Y] |
30 | fistp dword[ebx+GLVertex.zp+offs_zbup_y] ;v.zp.y = st0, st0 = st1 |
30 | fistp dword[ebx+GLVertex.zp+ZBufferPoint.y] ;v.zp.y = st0, st0 = st1 |
31 | 31 | ||
32 | fld dword[ebx+GLVertex.pc+offs_Z] ;st0 = v.pc.Z |
32 | fld dword[ebx+GLVertex.pc+offs_Z] ;st0 = v.pc.Z |
33 | fmulp |
33 | fmulp |
34 | fmul dword[eax+GLContext.viewport+offs_vpor_scale+offs_Z] |
34 | fmul dword[eax+GLContext.viewport+GLViewport.scale+offs_Z] |
35 | fadd dword[eax+GLContext.viewport+offs_vpor_trans+offs_Z] |
35 | fadd dword[eax+GLContext.viewport+GLViewport.trans+offs_Z] |
36 | fistp dword[ebx+GLVertex.zp+offs_zbup_z] ;v.zp.z = st0, st0 = st1 |
36 | fistp dword[ebx+GLVertex.zp+ZBufferPoint.z] ;v.zp.z = st0, st0 = st1 |
37 | 37 | ||
38 | ; color |
38 | ; color |
39 | cmp dword[eax+GLContext.lighting_enabled],0 ;if (context.lighting_enabled) |
39 | cmp dword[eax+GLContext.lighting_enabled],0 ;if (context.lighting_enabled) |
40 | je @f |
40 | je @f |
41 | lea ecx,[ebx+GLVertex.zp+offs_zbup_b] |
41 | lea ecx,[ebx+GLVertex.zp+ZBufferPoint.b] |
42 | push ecx |
42 | push ecx |
43 | add ecx,offs_zbup_g-offs_zbup_b |
43 | add ecx,ZBufferPoint.g-ZBufferPoint.b |
44 | push ecx |
44 | push ecx |
45 | add ecx,offs_zbup_r-offs_zbup_g |
45 | add ecx,ZBufferPoint.r-ZBufferPoint.g |
46 | push ecx |
46 | push ecx |
47 | stdcall RGBFtoRGBI, dword[ebx+GLVertex.color],dword[ebx+GLVertex.color+4],dword[ebx+GLVertex.color+8] |
47 | stdcall RGBFtoRGBI, dword[ebx+GLVertex.color],dword[ebx+GLVertex.color+4],dword[ebx+GLVertex.color+8] |
48 | jmp .end_if |
48 | jmp .end_if |
49 | align 4 |
49 | align 4 |
50 | @@: |
50 | @@: |
51 | ; no need to convert to integer if no lighting : take current color |
51 | ; no need to convert to integer if no lighting : take current color |
52 | mov ecx,[eax+GLContext.longcurrent_color] |
52 | mov ecx,[eax+GLContext.longcurrent_color] |
53 | mov dword[ebx+GLVertex.zp+offs_zbup_r],ecx |
53 | mov dword[ebx+GLVertex.zp+ZBufferPoint.r],ecx |
54 | mov ecx,[eax+GLContext.longcurrent_color+4] |
54 | mov ecx,[eax+GLContext.longcurrent_color+4] |
55 | mov dword[ebx+GLVertex.zp+offs_zbup_g],ecx |
55 | mov dword[ebx+GLVertex.zp+ZBufferPoint.g],ecx |
56 | mov ecx,[eax+GLContext.longcurrent_color+8] |
56 | mov ecx,[eax+GLContext.longcurrent_color+8] |
57 | mov dword[ebx+GLVertex.zp+offs_zbup_b],ecx |
57 | mov dword[ebx+GLVertex.zp+ZBufferPoint.b],ecx |
58 | .end_if: |
58 | .end_if: |
59 | 59 | ||
60 | ; texture |
60 | ; texture |
61 | cmp dword[eax+GLContext.texture_2d_enabled],0 |
61 | cmp dword[eax+GLContext.texture_2d_enabled],0 |
62 | je @f |
62 | je @f |
63 | mov eax,[eax+GLContext.current_texture] ;eax = &context.current_texture |
63 | mov eax,[eax+GLContext.current_texture] ;eax = &context.current_texture |
64 | mov eax,[eax] ;eax = context.current_texture |
64 | mov eax,[eax] ;eax = context.current_texture |
65 | ;[eax+offs_text_images] = im = &context.current_texture.images[0] |
65 | ;[eax+offs_text_images] = im = &context.current_texture.images[0] |
66 | 66 | ||
67 | fild dword[eax+offs_text_images+offs_imag_s_bound] |
67 | fild dword[eax+offs_text_images+offs_imag_s_bound] |
68 | fmul dword[ebx+GLVertex.tex_coord+offs_X] |
68 | fmul dword[ebx+GLVertex.tex_coord+offs_X] |
69 | fistp dword[ebx+GLVertex.zp+offs_zbup_s] |
69 | fistp dword[ebx+GLVertex.zp+ZBufferPoint.s] |
70 | ;v.zp.s=(int)(v.tex_coord.X * im.s_bound) |
70 | ;v.zp.s=(int)(v.tex_coord.X * im.s_bound) |
71 | 71 | ||
72 | fild dword[eax+offs_text_images+offs_imag_t_bound] |
72 | fild dword[eax+offs_text_images+offs_imag_t_bound] |
73 | fmul dword[ebx+GLVertex.tex_coord+offs_Y] |
73 | fmul dword[ebx+GLVertex.tex_coord+offs_Y] |
74 | fistp dword[ebx+GLVertex.zp+offs_zbup_t] |
74 | fistp dword[ebx+GLVertex.zp+ZBufferPoint.t] |
75 | ;v.zp.t=(int)(v.tex_coord.Y * im.t_bound) |
75 | ;v.zp.t=(int)(v.tex_coord.Y * im.t_bound) |
76 | @@: |
76 | @@: |
77 | ret |
77 | ret |
78 | endp |
78 | endp |
79 | 79 | ||
80 | align 16 |
80 | align 16 |
81 | proc gl_add_select1 uses eax ebx ecx, context:dword, z1:dword,z2:dword,z3:dword |
81 | proc gl_add_select1 uses eax ebx ecx, context:dword, z1:dword,z2:dword,z3:dword |
82 | mov eax,[z1] |
82 | mov eax,[z1] |
83 | mov ebx,eax |
83 | mov ebx,eax |
84 | cmp [z2],eax |
84 | cmp [z2],eax |
85 | jge @f |
85 | jge @f |
86 | mov eax,[z2] |
86 | mov eax,[z2] |
87 | @@: |
87 | @@: |
88 | cmp [z3],eax |
88 | cmp [z3],eax |
89 | jge @f |
89 | jge @f |
90 | mov eax,[z3] |
90 | mov eax,[z3] |
91 | @@: |
91 | @@: |
92 | cmp [z2],ebx |
92 | cmp [z2],ebx |
93 | jle @f |
93 | jle @f |
94 | mov ebx,[z2] |
94 | mov ebx,[z2] |
95 | @@: |
95 | @@: |
96 | cmp [z3],ebx |
96 | cmp [z3],ebx |
97 | jle @f |
97 | jle @f |
98 | mov ebx,[z3] |
98 | mov ebx,[z3] |
99 | @@: |
99 | @@: |
100 | mov ecx,0xffffffff |
100 | mov ecx,0xffffffff |
101 | sub ecx,ebx |
101 | sub ecx,ebx |
102 | push ecx |
102 | push ecx |
103 | mov ecx,0xffffffff |
103 | mov ecx,0xffffffff |
104 | sub ecx,eax |
104 | sub ecx,eax |
105 | push ecx |
105 | push ecx |
106 | stdcall gl_add_select, [context] ;,0xffffffff-eax,0xffffffff-ebx |
106 | stdcall gl_add_select, [context] ;,0xffffffff-eax,0xffffffff-ebx |
107 | ret |
107 | ret |
108 | endp |
108 | endp |
109 | 109 | ||
110 | ; point |
110 | ; point |
111 | 111 | ||
112 | align 16 |
112 | align 16 |
113 | proc gl_draw_point uses eax ebx, context:dword, p0:dword |
113 | proc gl_draw_point uses eax ebx, context:dword, p0:dword |
114 | mov ebx,[p0] |
114 | mov ebx,[p0] |
115 | cmp dword[ebx+GLVertex.clip_code],0 ;if (p0.clip_code == 0) |
115 | cmp dword[ebx+GLVertex.clip_code],0 ;if (p0.clip_code == 0) |
116 | jne @f |
116 | jne @f |
117 | mov eax,[context] |
117 | mov eax,[context] |
118 | cmp dword[eax+GLContext.render_mode],GL_SELECT |
118 | cmp dword[eax+GLContext.render_mode],GL_SELECT |
119 | jne .els |
119 | jne .els |
120 | stdcall gl_add_select, eax,dword[ebx+GLVertex.zp+offs_zbup_z],dword[ebx+GLVertex.zp+offs_zbup_z] ;p0.zp.z,p0.zp.z |
120 | stdcall gl_add_select, eax,dword[ebx+GLVertex.zp+ZBufferPoint.z],dword[ebx+GLVertex.zp+ZBufferPoint.z] ;p0.zp.z,p0.zp.z |
121 | jmp @f |
121 | jmp @f |
122 | align 4 |
122 | align 4 |
123 | .els: |
123 | .els: |
124 | add ebx,GLVertex.zp |
124 | add ebx,GLVertex.zp |
125 | stdcall ZB_plot, dword[eax+GLContext.zb],ebx |
125 | stdcall ZB_plot, dword[eax+GLContext.zb],ebx |
126 | @@: |
126 | @@: |
127 | ret |
127 | ret |
128 | endp |
128 | endp |
129 | 129 | ||
130 | ; line |
130 | ; line |
131 | 131 | ||
132 | ;input: |
132 | ;input: |
133 | ;q - регистр с адресом вершины для интерполяции |
133 | ;q - регистр с адресом вершины для интерполяции |
134 | ;p0 - регистр с адресом 1-й вершины |
134 | ;p0 - регистр с адресом 1-й вершины |
135 | ;p1 - регистр с адресом 2-й вершины |
135 | ;p1 - регистр с адресом 2-й вершины |
136 | ;t - float |
136 | ;t - float |
137 | macro interpolate q, p0, p1, t |
137 | macro interpolate q, p0, p1, t |
138 | { |
138 | { |
139 | fld dword[t] |
139 | fld dword[t] |
140 | 140 | ||
141 | ; интерполяция по координатам |
141 | ; интерполяция по координатам |
142 | fld dword[p1+GLVertex.pc] |
142 | fld dword[p1+GLVertex.pc] |
143 | fsub dword[p0+GLVertex.pc] |
143 | fsub dword[p0+GLVertex.pc] |
144 | fmul st0,st1 |
144 | fmul st0,st1 |
145 | fadd dword[p0+GLVertex.pc] |
145 | fadd dword[p0+GLVertex.pc] |
146 | fstp dword[q+GLVertex.pc] ;q.pc.X = p0.pc.X + (p1.pc.X - p0.pc.X) * t |
146 | fstp dword[q+GLVertex.pc] ;q.pc.X = p0.pc.X + (p1.pc.X - p0.pc.X) * t |
147 | 147 | ||
148 | fld dword[p1+GLVertex.pc+offs_Y] |
148 | fld dword[p1+GLVertex.pc+offs_Y] |
149 | fsub dword[p0+GLVertex.pc+offs_Y] |
149 | fsub dword[p0+GLVertex.pc+offs_Y] |
150 | fmul st0,st1 |
150 | fmul st0,st1 |
151 | fadd dword[p0+GLVertex.pc+offs_Y] |
151 | fadd dword[p0+GLVertex.pc+offs_Y] |
152 | fstp dword[q+GLVertex.pc+offs_Y] |
152 | fstp dword[q+GLVertex.pc+offs_Y] |
153 | 153 | ||
154 | fld dword[p1+GLVertex.pc+offs_Z] |
154 | fld dword[p1+GLVertex.pc+offs_Z] |
155 | fsub dword[p0+GLVertex.pc+offs_Z] |
155 | fsub dword[p0+GLVertex.pc+offs_Z] |
156 | fmul st0,st1 |
156 | fmul st0,st1 |
157 | fadd dword[p0+GLVertex.pc+offs_Z] |
157 | fadd dword[p0+GLVertex.pc+offs_Z] |
158 | fstp dword[q+GLVertex.pc+offs_Z] |
158 | fstp dword[q+GLVertex.pc+offs_Z] |
159 | 159 | ||
160 | fld dword[p1+GLVertex.pc+offs_W] |
160 | fld dword[p1+GLVertex.pc+offs_W] |
161 | fsub dword[p0+GLVertex.pc+offs_W] |
161 | fsub dword[p0+GLVertex.pc+offs_W] |
162 | fmul st0,st1 |
162 | fmul st0,st1 |
163 | fadd dword[p0+GLVertex.pc+offs_W] |
163 | fadd dword[p0+GLVertex.pc+offs_W] |
164 | fstp dword[q+GLVertex.pc+offs_W] |
164 | fstp dword[q+GLVertex.pc+offs_W] |
165 | 165 | ||
166 | ; интерполяция по цвету |
166 | ; интерполяция по цвету |
167 | fld dword[p1+GLVertex.color] |
167 | fld dword[p1+GLVertex.color] |
168 | fsub dword[p0+GLVertex.color] |
168 | fsub dword[p0+GLVertex.color] |
169 | fmul st0,st1 |
169 | fmul st0,st1 |
170 | fadd dword[p0+GLVertex.color] |
170 | fadd dword[p0+GLVertex.color] |
171 | fstp dword[q+GLVertex.color] |
171 | fstp dword[q+GLVertex.color] |
172 | 172 | ||
173 | fld dword[p1+GLVertex.color+4] |
173 | fld dword[p1+GLVertex.color+4] |
174 | fsub dword[p0+GLVertex.color+4] |
174 | fsub dword[p0+GLVertex.color+4] |
175 | fmul st0,st1 |
175 | fmul st0,st1 |
176 | fadd dword[p0+GLVertex.color+4] |
176 | fadd dword[p0+GLVertex.color+4] |
177 | fstp dword[q+GLVertex.color+4] |
177 | fstp dword[q+GLVertex.color+4] |
178 | 178 | ||
179 | fld dword[p1+GLVertex.color+8] |
179 | fld dword[p1+GLVertex.color+8] |
180 | fsub dword[p0+GLVertex.color+8] |
180 | fsub dword[p0+GLVertex.color+8] |
181 | fmulp |
181 | fmulp |
182 | fadd dword[p0+GLVertex.color+8] |
182 | fadd dword[p0+GLVertex.color+8] |
183 | fstp dword[q+GLVertex.color+8] |
183 | fstp dword[q+GLVertex.color+8] |
184 | } |
184 | } |
185 | 185 | ||
186 | ; |
186 | ; |
187 | ; Line Clipping |
187 | ; Line Clipping |
188 | ; |
188 | ; |
189 | 189 | ||
190 | ; Line Clipping algorithm from 'Computer Graphics', Principles and |
190 | ; Line Clipping algorithm from 'Computer Graphics', Principles and |
191 | ; Practice |
191 | ; Practice |
192 | ; tmin,tmax -> &float |
192 | ; tmin,tmax -> &float |
193 | align 16 |
193 | align 16 |
194 | proc ClipLine1 uses ebx, denom:dword,num:dword,tmin:dword,tmax:dword |
194 | proc ClipLine1 uses ebx, denom:dword,num:dword,tmin:dword,tmax:dword |
195 | fld dword[denom] |
195 | fld dword[denom] |
196 | ftst |
196 | ftst |
197 | fstsw ax |
197 | fstsw ax |
198 | sahf |
198 | sahf |
199 | jbe .els_0 ;if (denom>0) |
199 | jbe .els_0 ;if (denom>0) |
200 | fld dword[num] |
200 | fld dword[num] |
201 | fxch st1 |
201 | fxch st1 |
202 | fdivp ;t=num/denom |
202 | fdivp ;t=num/denom |
203 | mov ebx,[tmax] |
203 | mov ebx,[tmax] |
204 | fcom dword[ebx] |
204 | fcom dword[ebx] |
205 | fstsw ax |
205 | fstsw ax |
206 | sahf |
206 | sahf |
207 | ja .r0_f1 ;if (t>*tmax) return 0 |
207 | ja .r0_f1 ;if (t>*tmax) return 0 |
208 | mov ebx,[tmin] |
208 | mov ebx,[tmin] |
209 | fcom dword[ebx] |
209 | fcom dword[ebx] |
210 | fstsw ax |
210 | fstsw ax |
211 | sahf |
211 | sahf |
212 | jbe .r1_f1 ;if (t>*tmin) *tmin=t |
212 | jbe .r1_f1 ;if (t>*tmin) *tmin=t |
213 | fstp dword[ebx] |
213 | fstp dword[ebx] |
214 | jmp .r1 |
214 | jmp .r1 |
215 | align 4 |
215 | align 4 |
216 | .els_0: ;else if (denom<0) |
216 | .els_0: ;else if (denom<0) |
217 | jae .els_1 |
217 | jae .els_1 |
218 | fld dword[num] |
218 | fld dword[num] |
219 | fxch st1 |
219 | fxch st1 |
220 | fdivp ;t=num/denom |
220 | fdivp ;t=num/denom |
221 | mov ebx,[tmin] |
221 | mov ebx,[tmin] |
222 | fcom dword[ebx] |
222 | fcom dword[ebx] |
223 | fstsw ax |
223 | fstsw ax |
224 | sahf |
224 | sahf |
225 | jb .r0_f1 ;if (t<*tmin) return 0 |
225 | jb .r0_f1 ;if (t<*tmin) return 0 |
226 | mov ebx,[tmax] |
226 | mov ebx,[tmax] |
227 | fcom dword[ebx] |
227 | fcom dword[ebx] |
228 | fstsw ax |
228 | fstsw ax |
229 | sahf |
229 | sahf |
230 | jae .r1_f1 |
230 | jae .r1_f1 |
231 | fstp dword[ebx] ;if (t<*tmin) *tmax=t |
231 | fstp dword[ebx] ;if (t<*tmin) *tmax=t |
232 | jmp .r1 |
232 | jmp .r1 |
233 | align 4 |
233 | align 4 |
234 | .els_1: ;else if (num>0) |
234 | .els_1: ;else if (num>0) |
235 | ffree st0 ;denom |
235 | ffree st0 ;denom |
236 | fincstp |
236 | fincstp |
237 | fld dword[num] |
237 | fld dword[num] |
238 | ftst |
238 | ftst |
239 | fstsw ax |
239 | fstsw ax |
240 | sahf |
240 | sahf |
241 | ja .r0_f1 ;if (num>0) return 0 |
241 | ja .r0_f1 ;if (num>0) return 0 |
242 | jmp .r1_f1 |
242 | jmp .r1_f1 |
243 | align 4 |
243 | align 4 |
244 | .r0_f1: ;return 0 & free st0 |
244 | .r0_f1: ;return 0 & free st0 |
245 | ffree st0 |
245 | ffree st0 |
246 | fincstp |
246 | fincstp |
247 | .r0: ;return 0 |
247 | .r0: ;return 0 |
248 | xor eax,eax |
248 | xor eax,eax |
249 | jmp .end_f |
249 | jmp .end_f |
250 | align 4 |
250 | align 4 |
251 | .r1_f1: ;return 1 & free st0 |
251 | .r1_f1: ;return 1 & free st0 |
252 | ffree st0 |
252 | ffree st0 |
253 | fincstp |
253 | fincstp |
254 | .r1: ;return 1 |
254 | .r1: ;return 1 |
255 | xor eax,eax |
255 | xor eax,eax |
256 | inc eax |
256 | inc eax |
257 | .end_f: |
257 | .end_f: |
258 | ret |
258 | ret |
259 | endp |
259 | endp |
260 | 260 | ||
261 | align 16 |
261 | align 16 |
262 | proc gl_draw_line, context:dword, p1:dword, p2:dword |
262 | proc gl_draw_line, context:dword, p1:dword, p2:dword |
263 | locals |
263 | locals |
264 | d_x dd ? |
264 | d_x dd ? |
265 | d_y dd ? |
265 | d_y dd ? |
266 | d_z dd ? |
266 | d_z dd ? |
267 | d_w dd ? |
267 | d_w dd ? |
268 | x1 dd ? |
268 | x1 dd ? |
269 | y1 dd ? |
269 | y1 dd ? |
270 | z1 dd ? |
270 | z1 dd ? |
271 | w1 dd ? |
271 | w1 dd ? |
272 | q1 GLVertex ? |
272 | q1 GLVertex ? |
273 | q2 GLVertex ? |
273 | q2 GLVertex ? |
274 | tmin dd ? ;ebp-8 |
274 | tmin dd ? ;ebp-8 |
275 | tmax dd ? ;ebp-4 |
275 | tmax dd ? ;ebp-4 |
276 | endl |
276 | endl |
277 | pushad |
277 | pushad |
278 | mov edx,[context] |
278 | mov edx,[context] |
279 | mov edi,[p1] |
279 | mov edi,[p1] |
280 | mov esi,[p2] |
280 | mov esi,[p2] |
281 | 281 | ||
282 | cmp dword[edi+GLVertex.clip_code],0 |
282 | cmp dword[edi+GLVertex.clip_code],0 |
283 | jne .els_i |
283 | jne .els_i |
284 | cmp dword[esi+GLVertex.clip_code],0 |
284 | cmp dword[esi+GLVertex.clip_code],0 |
285 | jne .els_i |
285 | jne .els_i |
286 | ;if ( (p1.clip_code | p2.clip_code) == 0) |
286 | ;if ( (p1.clip_code | p2.clip_code) == 0) |
287 | cmp dword[edx+GLContext.render_mode],GL_SELECT ;if (context.render_mode == GL_SELECT) |
287 | cmp dword[edx+GLContext.render_mode],GL_SELECT ;if (context.render_mode == GL_SELECT) |
288 | jne .els_1 |
288 | jne .els_1 |
289 | stdcall gl_add_select1, edx,dword[edi+GLVertex.zp+offs_zbup_z],\ |
289 | stdcall gl_add_select1, edx,dword[edi+GLVertex.zp+ZBufferPoint.z],\ |
290 | dword[esi+GLVertex.zp+offs_zbup_z],dword[esi+GLVertex.zp+offs_zbup_z] |
290 | dword[esi+GLVertex.zp+ZBufferPoint.z],dword[esi+GLVertex.zp+ZBufferPoint.z] |
291 | jmp .end_f |
291 | jmp .end_f |
292 | align 4 |
292 | align 4 |
293 | .els_1: |
293 | .els_1: |
294 | add edi,GLVertex.zp |
294 | add edi,GLVertex.zp |
295 | add esi,GLVertex.zp |
295 | add esi,GLVertex.zp |
296 | push esi |
296 | push esi |
297 | push edi |
297 | push edi |
298 | push dword[edx+GLContext.zb] |
298 | push dword[edx+GLContext.zb] |
299 | cmp dword[edx+GLContext.depth_test],0 |
299 | cmp dword[edx+GLContext.depth_test],0 |
300 | je .els_2 |
300 | je .els_2 |
301 | ;if (context.depth_test) |
301 | ;if (context.depth_test) |
302 | call ZB_line_z ;, dword[edx+GLContext.zb],edi,esi |
302 | call ZB_line_z ;, dword[edx+GLContext.zb],edi,esi |
303 | jmp .end_f |
303 | jmp .end_f |
304 | align 4 |
304 | align 4 |
305 | .els_2: |
305 | .els_2: |
306 | call ZB_line ;, dword[edx+GLContext.zb],edi,esi |
306 | call ZB_line ;, dword[edx+GLContext.zb],edi,esi |
307 | jmp .end_f |
307 | jmp .end_f |
308 | align 4 |
308 | align 4 |
309 | .els_i: |
309 | .els_i: |
310 | ;else if ( (p1.clip_code & p2.clip_code) != 0 ) |
310 | ;else if ( (p1.clip_code & p2.clip_code) != 0 ) |
311 | mov eax,[edi+GLVertex.clip_code] |
311 | mov eax,[edi+GLVertex.clip_code] |
312 | and eax,[esi+GLVertex.clip_code] |
312 | and eax,[esi+GLVertex.clip_code] |
313 | or eax,eax |
313 | or eax,eax |
314 | jnz .end_f |
314 | jnz .end_f |
315 | .els_0: |
315 | .els_0: |
316 | 316 | ||
317 | fld dword[esi+GLVertex.pc+offs_X] |
317 | fld dword[esi+GLVertex.pc+offs_X] |
318 | fsub dword[edi+GLVertex.pc+offs_X] |
318 | fsub dword[edi+GLVertex.pc+offs_X] |
319 | fstp dword[d_x] ;d_x = p2.pc.X - p1.pc.X |
319 | fstp dword[d_x] ;d_x = p2.pc.X - p1.pc.X |
320 | fld dword[esi+GLVertex.pc+offs_Y] |
320 | fld dword[esi+GLVertex.pc+offs_Y] |
321 | fsub dword[edi+GLVertex.pc+offs_Y] |
321 | fsub dword[edi+GLVertex.pc+offs_Y] |
322 | fstp dword[d_y] ;d_y = p2.pc.Y - p1.pc.Y |
322 | fstp dword[d_y] ;d_y = p2.pc.Y - p1.pc.Y |
323 | fld dword[esi+GLVertex.pc+offs_Z] |
323 | fld dword[esi+GLVertex.pc+offs_Z] |
324 | fsub dword[edi+GLVertex.pc+offs_Z] |
324 | fsub dword[edi+GLVertex.pc+offs_Z] |
325 | fstp dword[d_z] ;d_z = p2.pc.Z - p1.pc.Z |
325 | fstp dword[d_z] ;d_z = p2.pc.Z - p1.pc.Z |
326 | fld dword[esi+GLVertex.pc+offs_W] |
326 | fld dword[esi+GLVertex.pc+offs_W] |
327 | fsub dword[edi+GLVertex.pc+offs_W] |
327 | fsub dword[edi+GLVertex.pc+offs_W] |
328 | fstp dword[d_w] ;d_w = p2.pc.W - p1.pc.W |
328 | fstp dword[d_w] ;d_w = p2.pc.W - p1.pc.W |
329 | 329 | ||
330 | mov eax,[edi+GLVertex.pc+offs_X] |
330 | mov eax,[edi+GLVertex.pc+offs_X] |
331 | mov [x1],eax ;x1 = p1.pc.X |
331 | mov [x1],eax ;x1 = p1.pc.X |
332 | mov eax,[edi+GLVertex.pc+offs_Y] |
332 | mov eax,[edi+GLVertex.pc+offs_Y] |
333 | mov [y1],eax ;y1 = p1.pc.Y |
333 | mov [y1],eax ;y1 = p1.pc.Y |
334 | mov eax,[edi+GLVertex.pc+offs_Z] |
334 | mov eax,[edi+GLVertex.pc+offs_Z] |
335 | mov [z1],eax ;z1 = p1.pc.Z |
335 | mov [z1],eax ;z1 = p1.pc.Z |
336 | mov eax,[edi+GLVertex.pc+offs_W] |
336 | mov eax,[edi+GLVertex.pc+offs_W] |
337 | mov [w1],eax ;w1 = p1.pc.W |
337 | mov [w1],eax ;w1 = p1.pc.W |
338 | 338 | ||
339 | mov dword[tmin],0.0 |
339 | mov dword[tmin],0.0 |
340 | mov dword[tmax],1.0 |
340 | mov dword[tmax],1.0 |
341 | 341 | ||
342 | lea eax,[ebp-4] |
342 | lea eax,[ebp-4] |
343 | push eax ;толкаем в стек адрес &tmax |
343 | push eax ;толкаем в стек адрес &tmax |
344 | sub eax,4 |
344 | sub eax,4 |
345 | push eax ;толкаем в стек адрес &tmin |
345 | push eax ;толкаем в стек адрес &tmin |
346 | fld dword[x1] |
346 | fld dword[x1] |
347 | fadd dword[w1] |
347 | fadd dword[w1] |
348 | fchs |
348 | fchs |
349 | fstp dword[esp-4] |
349 | fstp dword[esp-4] |
350 | fld dword[d_x] |
350 | fld dword[d_x] |
351 | fadd dword[d_w] |
351 | fadd dword[d_w] |
352 | fstp dword[esp-8] |
352 | fstp dword[esp-8] |
353 | sub esp,8 |
353 | sub esp,8 |
354 | call ClipLine1 ;d_x+d_w,-x1-w1,&tmin,&tmax |
354 | call ClipLine1 ;d_x+d_w,-x1-w1,&tmin,&tmax |
355 | bt eax,0 |
355 | bt eax,0 |
356 | jnc .end_f |
356 | jnc .end_f |
357 | 357 | ||
358 | sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax |
358 | sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax |
359 | fld dword[x1] |
359 | fld dword[x1] |
360 | fsub dword[w1] |
360 | fsub dword[w1] |
361 | fstp dword[esp-4] |
361 | fstp dword[esp-4] |
362 | fld dword[d_w] |
362 | fld dword[d_w] |
363 | fsub dword[d_x] |
363 | fsub dword[d_x] |
364 | fstp dword[esp-8] |
364 | fstp dword[esp-8] |
365 | sub esp,8 |
365 | sub esp,8 |
366 | call ClipLine1 ;-d_x+d_w,x1-w1,&tmin,&tmax |
366 | call ClipLine1 ;-d_x+d_w,x1-w1,&tmin,&tmax |
367 | bt eax,0 |
367 | bt eax,0 |
368 | jnc .end_f |
368 | jnc .end_f |
369 | 369 | ||
370 | sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax |
370 | sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax |
371 | fld dword[y1] |
371 | fld dword[y1] |
372 | fadd dword[w1] |
372 | fadd dword[w1] |
373 | fchs |
373 | fchs |
374 | fstp dword[esp-4] |
374 | fstp dword[esp-4] |
375 | fld dword[d_y] |
375 | fld dword[d_y] |
376 | fadd dword[d_w] |
376 | fadd dword[d_w] |
377 | fstp dword[esp-8] |
377 | fstp dword[esp-8] |
378 | sub esp,8 |
378 | sub esp,8 |
379 | call ClipLine1 ;d_y+d_w,-y1-w1,&tmin,&tmax |
379 | call ClipLine1 ;d_y+d_w,-y1-w1,&tmin,&tmax |
380 | bt eax,0 |
380 | bt eax,0 |
381 | jnc .end_f |
381 | jnc .end_f |
382 | 382 | ||
383 | sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax |
383 | sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax |
384 | fld dword[y1] |
384 | fld dword[y1] |
385 | fsub dword[w1] |
385 | fsub dword[w1] |
386 | fstp dword[esp-4] |
386 | fstp dword[esp-4] |
387 | fld dword[d_w] |
387 | fld dword[d_w] |
388 | fsub dword[d_y] |
388 | fsub dword[d_y] |
389 | fstp dword[esp-8] |
389 | fstp dword[esp-8] |
390 | sub esp,8 |
390 | sub esp,8 |
391 | call ClipLine1 ;-d_y+d_w,y1-w1,&tmin,&tmax |
391 | call ClipLine1 ;-d_y+d_w,y1-w1,&tmin,&tmax |
392 | bt eax,0 |
392 | bt eax,0 |
393 | jnc .end_f |
393 | jnc .end_f |
394 | 394 | ||
395 | sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax |
395 | sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax |
396 | fld dword[z1] |
396 | fld dword[z1] |
397 | fadd dword[w1] |
397 | fadd dword[w1] |
398 | fchs |
398 | fchs |
399 | fstp dword[esp-4] |
399 | fstp dword[esp-4] |
400 | fld dword[d_z] |
400 | fld dword[d_z] |
401 | fadd dword[d_w] |
401 | fadd dword[d_w] |
402 | fstp dword[esp-8] |
402 | fstp dword[esp-8] |
403 | sub esp,8 |
403 | sub esp,8 |
404 | call ClipLine1 ;d_z+d_w,-z1-w1,&tmin,&tmax |
404 | call ClipLine1 ;d_z+d_w,-z1-w1,&tmin,&tmax |
405 | bt eax,0 |
405 | bt eax,0 |
406 | jnc .end_f |
406 | jnc .end_f |
407 | 407 | ||
408 | sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax |
408 | sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax |
409 | fld dword[z1] |
409 | fld dword[z1] |
410 | fsub dword[w1] |
410 | fsub dword[w1] |
411 | fstp dword[esp-4] |
411 | fstp dword[esp-4] |
412 | fld dword[d_w] |
412 | fld dword[d_w] |
413 | fsub dword[d_z] |
413 | fsub dword[d_z] |
414 | fstp dword[esp-8] |
414 | fstp dword[esp-8] |
415 | sub esp,8 |
415 | sub esp,8 |
416 | call ClipLine1 ;-d_z+d_w,z1-w1,&tmin,&tmax |
416 | call ClipLine1 ;-d_z+d_w,z1-w1,&tmin,&tmax |
417 | bt eax,0 |
417 | bt eax,0 |
418 | jnc .end_f |
418 | jnc .end_f |
419 | 419 | ||
420 | lea eax,[ebp-8-2*sizeof.GLVertex] ;eax = &q1 |
420 | lea eax,[ebp-8-2*sizeof.GLVertex] ;eax = &q1 |
421 | interpolate eax,edi,esi,tmin |
421 | interpolate eax,edi,esi,tmin |
422 | stdcall gl_transform_to_viewport, edx,eax |
422 | stdcall gl_transform_to_viewport, edx,eax |
423 | add eax,sizeof.GLVertex ;eax = &q2 |
423 | add eax,sizeof.GLVertex ;eax = &q2 |
424 | interpolate eax,edi,esi,tmax |
424 | interpolate eax,edi,esi,tmax |
425 | stdcall gl_transform_to_viewport, edx,eax |
425 | stdcall gl_transform_to_viewport, edx,eax |
426 | 426 | ||
427 | sub eax,sizeof.GLVertex ;eax = &q1 |
427 | sub eax,sizeof.GLVertex ;eax = &q1 |
428 | lea ebx,[eax+GLVertex.zp+offs_zbup_b] |
428 | lea ebx,[eax+GLVertex.zp+ZBufferPoint.b] |
429 | push ebx |
429 | push ebx |
430 | add ebx,offs_zbup_g-offs_zbup_b |
430 | add ebx,ZBufferPoint.g-ZBufferPoint.b |
431 | push ebx |
431 | push ebx |
432 | add ebx,offs_zbup_r-offs_zbup_g |
432 | add ebx,ZBufferPoint.r-ZBufferPoint.g |
433 | push ebx |
433 | push ebx |
434 | stdcall RGBFtoRGBI, dword[eax+GLVertex.color],dword[eax+GLVertex.color+4],dword[eax+GLVertex.color+8] |
434 | stdcall RGBFtoRGBI, dword[eax+GLVertex.color],dword[eax+GLVertex.color+4],dword[eax+GLVertex.color+8] |
435 | 435 | ||
436 | add eax,sizeof.GLVertex ;eax = &q2 |
436 | add eax,sizeof.GLVertex ;eax = &q2 |
437 | lea ebx,[eax+GLVertex.zp+offs_zbup_b] |
437 | lea ebx,[eax+GLVertex.zp+ZBufferPoint.b] |
438 | push ebx |
438 | push ebx |
439 | add ebx,offs_zbup_g-offs_zbup_b |
439 | add ebx,ZBufferPoint.g-ZBufferPoint.b |
440 | push ebx |
440 | push ebx |
441 | add ebx,offs_zbup_r-offs_zbup_g |
441 | add ebx,ZBufferPoint.r-ZBufferPoint.g |
442 | push ebx |
442 | push ebx |
443 | stdcall RGBFtoRGBI, dword[eax+GLVertex.color],dword[eax+GLVertex.color+4],dword[eax+GLVertex.color+8] |
443 | stdcall RGBFtoRGBI, dword[eax+GLVertex.color],dword[eax+GLVertex.color+4],dword[eax+GLVertex.color+8] |
444 | 444 | ||
445 | add eax,GLVertex.zp ;eax = &q2.zp |
445 | add eax,GLVertex.zp ;eax = &q2.zp |
446 | push eax |
446 | push eax |
447 | sub eax,sizeof.GLVertex ;eax = &q1.zp |
447 | sub eax,sizeof.GLVertex ;eax = &q1.zp |
448 | push eax |
448 | push eax |
449 | push dword[edx+GLContext.zb] |
449 | push dword[edx+GLContext.zb] |
450 | cmp dword[edx+GLContext.depth_test],0 |
450 | cmp dword[edx+GLContext.depth_test],0 |
451 | je .els_3 |
451 | je .els_3 |
452 | call ZB_line_z ;(context.zb,&q1.zp,&q2.zp) |
452 | call ZB_line_z ;(context.zb,&q1.zp,&q2.zp) |
453 | jmp .end_f |
453 | jmp .end_f |
454 | align 4 |
454 | align 4 |
455 | .els_3: |
455 | .els_3: |
456 | call ZB_line ;(context.zb,&q1.zp,&q2.zp) |
456 | call ZB_line ;(context.zb,&q1.zp,&q2.zp) |
457 | .end_f: |
457 | .end_f: |
458 | popad |
458 | popad |
459 | ret |
459 | ret |
460 | endp |
460 | endp |
461 | 461 | ||
462 | ; triangle |
462 | ; triangle |
463 | 463 | ||
464 | ; |
464 | ; |
465 | ; Clipping |
465 | ; Clipping |
466 | ; |
466 | ; |
467 | 467 | ||
468 | ; We clip the segment [a,b] against the 6 planes of the normal volume. |
468 | ; We clip the segment [a,b] against the 6 planes of the normal volume. |
469 | ; We compute the point 'c' of intersection and the value of the parameter 't' |
469 | ; We compute the point 'c' of intersection and the value of the parameter 't' |
470 | ; of the intersection if x=a+t(b-a). |
470 | ; of the intersection if x=a+t(b-a). |
471 | ; |
471 | ; |
472 | ; sign: 0 -> '-', 1 -> '+' |
472 | ; sign: 0 -> '-', 1 -> '+' |
473 | macro clip_func sign,dir,dir1,dir2 |
473 | macro clip_func sign,dir,dir1,dir2 |
474 | { |
474 | { |
475 | locals |
475 | locals |
476 | t dd ? |
476 | t dd ? |
477 | d_X dd ? |
477 | d_X dd ? |
478 | d_Y dd ? |
478 | d_Y dd ? |
479 | d_Z dd ? |
479 | d_Z dd ? |
480 | d_W dd ? |
480 | d_W dd ? |
481 | endl |
481 | endl |
482 | mov edx,[a] |
482 | mov edx,[a] |
483 | mov ebx,[b] |
483 | mov ebx,[b] |
484 | mov ecx,[c] |
484 | mov ecx,[c] |
485 | fld dword[ebx+offs_X] |
485 | fld dword[ebx+offs_X] |
486 | fsub dword[edx+offs_X] |
486 | fsub dword[edx+offs_X] |
487 | fstp dword[d_X] ;d_X = (b.X - a.X) |
487 | fstp dword[d_X] ;d_X = (b.X - a.X) |
488 | fld dword[ebx+offs_Y] |
488 | fld dword[ebx+offs_Y] |
489 | fsub dword[edx+offs_Y] |
489 | fsub dword[edx+offs_Y] |
490 | fstp dword[d_Y] ;d_Y = (b.Y - a.Y) |
490 | fstp dword[d_Y] ;d_Y = (b.Y - a.Y) |
491 | fld dword[ebx+offs_Z] |
491 | fld dword[ebx+offs_Z] |
492 | fsub dword[edx+offs_Z] |
492 | fsub dword[edx+offs_Z] |
493 | fstp dword[d_Z] ;d_Z = (b.Z - a.Z) |
493 | fstp dword[d_Z] ;d_Z = (b.Z - a.Z) |
494 | fld dword[ebx+offs_W] |
494 | fld dword[ebx+offs_W] |
495 | fsub dword[edx+offs_W] |
495 | fsub dword[edx+offs_W] |
496 | fst dword[d_W] ;d_W = (b.W - a.W) |
496 | fst dword[d_W] ;d_W = (b.W - a.W) |
497 | if sign eq 0 |
497 | if sign eq 0 |
498 | fadd dword[d#dir] |
498 | fadd dword[d#dir] |
499 | else |
499 | else |
500 | fsub dword[d#dir] |
500 | fsub dword[d#dir] |
501 | end if |
501 | end if |
502 | 502 | ||
503 | ftst |
503 | ftst |
504 | fstsw ax |
504 | fstsw ax |
505 | sahf |
505 | sahf |
506 | jne @f |
506 | jne @f |
507 | fldz |
507 | fldz |
508 | fst dword[t] ;t=0 |
508 | fst dword[t] ;t=0 |
509 | jmp .e_zero |
509 | jmp .e_zero |
510 | align 4 |
510 | align 4 |
511 | @@: ;else |
511 | @@: ;else |
512 | fld dword[edx+offs#dir] |
512 | fld dword[edx+offs#dir] |
513 | if sign eq 0 |
513 | if sign eq 0 |
514 | fchs |
514 | fchs |
515 | end if |
515 | end if |
516 | fsub dword[edx+offs_W] |
516 | fsub dword[edx+offs_W] |
517 | fdiv st0,st1 |
517 | fdiv st0,st1 |
518 | fst dword[t] ;t = ( sign a.dir - a.W) / den |
518 | fst dword[t] ;t = ( sign a.dir - a.W) / den |
519 | .e_zero: |
519 | .e_zero: |
520 | 520 | ||
521 | fmul dword[d#dir1] ;st0 = t * d.dir1 |
521 | fmul dword[d#dir1] ;st0 = t * d.dir1 |
522 | fadd dword[edx+offs#dir1] |
522 | fadd dword[edx+offs#dir1] |
523 | fstp dword[ecx+offs#dir1] ;c.dir1 = a.dir1 + t * d.dir1 |
523 | fstp dword[ecx+offs#dir1] ;c.dir1 = a.dir1 + t * d.dir1 |
524 | 524 | ||
525 | ffree st0 |
525 | ffree st0 |
526 | fincstp |
526 | fincstp |
527 | 527 | ||
528 | fld dword[t] |
528 | fld dword[t] |
529 | fmul dword[d#dir2] ;st0 = t * d.dir2 |
529 | fmul dword[d#dir2] ;st0 = t * d.dir2 |
530 | fadd dword[edx+offs#dir2] |
530 | fadd dword[edx+offs#dir2] |
531 | fstp dword[ecx+offs#dir2] ;c.dir2 = a.dir2 + t * d.dir2 |
531 | fstp dword[ecx+offs#dir2] ;c.dir2 = a.dir2 + t * d.dir2 |
532 | 532 | ||
533 | fld dword[t] |
533 | fld dword[t] |
534 | fmul dword[d_W] |
534 | fmul dword[d_W] |
535 | fadd dword[edx+offs_W] |
535 | fadd dword[edx+offs_W] |
536 | fst dword[ecx+offs_W] ;c.W = a.W + t * d_W |
536 | fst dword[ecx+offs_W] ;c.W = a.W + t * d_W |
537 | 537 | ||
538 | if sign eq 0 |
538 | if sign eq 0 |
539 | fchs |
539 | fchs |
540 | end if |
540 | end if |
541 | fstp dword[ecx+offs#dir] ;c.dir = sign c.W |
541 | fstp dword[ecx+offs#dir] ;c.dir = sign c.W |
542 | mov eax,[t] |
542 | mov eax,[t] |
543 | } |
543 | } |
544 | 544 | ||
545 | align 16 |
545 | align 16 |
546 | proc clip_xmin uses ebx ecx edx, c:dword, a:dword, b:dword |
546 | proc clip_xmin uses ebx ecx edx, c:dword, a:dword, b:dword |
547 | clip_func 0,_X,_Y,_Z |
547 | clip_func 0,_X,_Y,_Z |
548 | ret |
548 | ret |
549 | endp |
549 | endp |
550 | 550 | ||
551 | align 16 |
551 | align 16 |
552 | proc clip_xmax uses ebx ecx edx, c:dword, a:dword, b:dword |
552 | proc clip_xmax uses ebx ecx edx, c:dword, a:dword, b:dword |
553 | clip_func 1,_X,_Y,_Z |
553 | clip_func 1,_X,_Y,_Z |
554 | ret |
554 | ret |
555 | endp |
555 | endp |
556 | 556 | ||
557 | align 16 |
557 | align 16 |
558 | proc clip_ymin uses ebx ecx edx, c:dword, a:dword, b:dword |
558 | proc clip_ymin uses ebx ecx edx, c:dword, a:dword, b:dword |
559 | clip_func 0,_Y,_X,_Z |
559 | clip_func 0,_Y,_X,_Z |
560 | ret |
560 | ret |
561 | endp |
561 | endp |
562 | 562 | ||
563 | align 16 |
563 | align 16 |
564 | proc clip_ymax uses ebx ecx edx, c:dword, a:dword, b:dword |
564 | proc clip_ymax uses ebx ecx edx, c:dword, a:dword, b:dword |
565 | clip_func 1,_Y,_X,_Z |
565 | clip_func 1,_Y,_X,_Z |
566 | ret |
566 | ret |
567 | endp |
567 | endp |
568 | 568 | ||
569 | align 16 |
569 | align 16 |
570 | proc clip_zmin uses ebx ecx edx, c:dword, a:dword, b:dword |
570 | proc clip_zmin uses ebx ecx edx, c:dword, a:dword, b:dword |
571 | clip_func 0,_Z,_X,_Y |
571 | clip_func 0,_Z,_X,_Y |
572 | ret |
572 | ret |
573 | endp |
573 | endp |
574 | 574 | ||
575 | align 16 |
575 | align 16 |
576 | proc clip_zmax uses ebx ecx edx, c:dword, a:dword, b:dword |
576 | proc clip_zmax uses ebx ecx edx, c:dword, a:dword, b:dword |
577 | clip_func 1,_Z,_X,_Y |
577 | clip_func 1,_Z,_X,_Y |
578 | ret |
578 | ret |
579 | endp |
579 | endp |
580 | 580 | ||
581 | align 4 |
581 | align 4 |
582 | clip_proc dd clip_xmin,clip_xmax, clip_ymin,clip_ymax, clip_zmin,clip_zmax |
582 | clip_proc dd clip_xmin,clip_xmax, clip_ymin,clip_ymax, clip_zmin,clip_zmax |
583 | 583 | ||
584 | ;input: |
584 | ;input: |
585 | ;edi - q |
585 | ;edi - q |
586 | align 16 |
586 | align 16 |
587 | proc updateTmp uses eax ecx edx, context:dword, p0:dword, p1:dword, t:dword |
587 | proc updateTmp uses eax ecx edx, context:dword, p0:dword, p1:dword, t:dword |
588 | mov edx,[context] |
588 | mov edx,[context] |
589 | mov eax,[p0] |
589 | mov eax,[p0] |
590 | cmp dword[edx+GLContext.current_shade_model],GL_SMOOTH ;if (context.current_shade_model == GL_SMOOTH) |
590 | cmp dword[edx+GLContext.current_shade_model],GL_SMOOTH ;if (context.current_shade_model == GL_SMOOTH) |
591 | jne .els_0 |
591 | jne .els_0 |
592 | mov ecx,[p1] |
592 | mov ecx,[p1] |
593 | fld dword[ecx+GLVertex.color] |
593 | fld dword[ecx+GLVertex.color] |
594 | fsub dword[eax+GLVertex.color] |
594 | fsub dword[eax+GLVertex.color] |
595 | fmul dword[t] |
595 | fmul dword[t] |
596 | fadd dword[eax+GLVertex.color] |
596 | fadd dword[eax+GLVertex.color] |
597 | fstp dword[edi+GLVertex.color] ;q.color.v[0]=p0.color.v[0] + (p1.color.v[0]-p0.color.v[0])*t |
597 | fstp dword[edi+GLVertex.color] ;q.color.v[0]=p0.color.v[0] + (p1.color.v[0]-p0.color.v[0])*t |
598 | fld dword[ecx+GLVertex.color+4] |
598 | fld dword[ecx+GLVertex.color+4] |
599 | fsub dword[eax+GLVertex.color+4] |
599 | fsub dword[eax+GLVertex.color+4] |
600 | fmul dword[t] |
600 | fmul dword[t] |
601 | fadd dword[eax+GLVertex.color+4] |
601 | fadd dword[eax+GLVertex.color+4] |
602 | fstp dword[edi+GLVertex.color+4] ;q.color.v[1]=p0.color.v[1] + (p1.color.v[1]-p0.color.v[1])*t |
602 | fstp dword[edi+GLVertex.color+4] ;q.color.v[1]=p0.color.v[1] + (p1.color.v[1]-p0.color.v[1])*t |
603 | fld dword[ecx+GLVertex.color+8] |
603 | fld dword[ecx+GLVertex.color+8] |
604 | fsub dword[eax+GLVertex.color+8] |
604 | fsub dword[eax+GLVertex.color+8] |
605 | fmul dword[t] |
605 | fmul dword[t] |
606 | fadd dword[eax+GLVertex.color+8] |
606 | fadd dword[eax+GLVertex.color+8] |
607 | fstp dword[edi+GLVertex.color+8] ;q.color.v[2]=p0.color.v[2] + (p1.color.v[2]-p0.color.v[2])*t |
607 | fstp dword[edi+GLVertex.color+8] ;q.color.v[2]=p0.color.v[2] + (p1.color.v[2]-p0.color.v[2])*t |
608 | jmp @f |
608 | jmp @f |
609 | align 4 |
609 | align 4 |
610 | .els_0: |
610 | .els_0: |
611 | mov ecx,[eax+GLVertex.color] |
611 | mov ecx,[eax+GLVertex.color] |
612 | mov [edi+GLVertex.color],ecx ;q.color.v[0]=p0.color.v[0] |
612 | mov [edi+GLVertex.color],ecx ;q.color.v[0]=p0.color.v[0] |
613 | mov ecx,[eax+GLVertex.color+4] |
613 | mov ecx,[eax+GLVertex.color+4] |
614 | mov [edi+GLVertex.color+4],ecx ;q.color.v[1]=p0.color.v[1] |
614 | mov [edi+GLVertex.color+4],ecx ;q.color.v[1]=p0.color.v[1] |
615 | mov ecx,[eax+GLVertex.color+8] |
615 | mov ecx,[eax+GLVertex.color+8] |
616 | mov [edi+GLVertex.color+8],ecx ;q.color.v[2]=p0.color.v[2] |
616 | mov [edi+GLVertex.color+8],ecx ;q.color.v[2]=p0.color.v[2] |
617 | @@: |
617 | @@: |
618 | 618 | ||
619 | cmp dword[edx+GLContext.texture_2d_enabled],0 ;if (context.texture_2d_enabled) |
619 | cmp dword[edx+GLContext.texture_2d_enabled],0 ;if (context.texture_2d_enabled) |
620 | je @f |
620 | je @f |
621 | mov ecx,[p1] |
621 | mov ecx,[p1] |
622 | fld dword[ecx+GLVertex.tex_coord+offs_X] |
622 | fld dword[ecx+GLVertex.tex_coord+offs_X] |
623 | fsub dword[eax+GLVertex.tex_coord+offs_X] |
623 | fsub dword[eax+GLVertex.tex_coord+offs_X] |
624 | fmul dword[t] |
624 | fmul dword[t] |
625 | fadd dword[eax+GLVertex.tex_coord+offs_X] |
625 | fadd dword[eax+GLVertex.tex_coord+offs_X] |
626 | fstp dword[edi+GLVertex.tex_coord+offs_X] ;q.tex_coord.X=p0.tex_coord.X + (p1.tex_coord.X-p0.tex_coord.X)*t |
626 | fstp dword[edi+GLVertex.tex_coord+offs_X] ;q.tex_coord.X=p0.tex_coord.X + (p1.tex_coord.X-p0.tex_coord.X)*t |
627 | fld dword[ecx+GLVertex.tex_coord+offs_Y] |
627 | fld dword[ecx+GLVertex.tex_coord+offs_Y] |
628 | fsub dword[eax+GLVertex.tex_coord+offs_Y] |
628 | fsub dword[eax+GLVertex.tex_coord+offs_Y] |
629 | fmul dword[t] |
629 | fmul dword[t] |
630 | fadd dword[eax+GLVertex.tex_coord+offs_Y] |
630 | fadd dword[eax+GLVertex.tex_coord+offs_Y] |
631 | fstp dword[edi+GLVertex.tex_coord+offs_Y] ;q.tex_coord.Y=p0.tex_coord.Y + (p1.tex_coord.Y-p0.tex_coord.Y)*t |
631 | fstp dword[edi+GLVertex.tex_coord+offs_Y] ;q.tex_coord.Y=p0.tex_coord.Y + (p1.tex_coord.Y-p0.tex_coord.Y)*t |
632 | @@: |
632 | @@: |
633 | 633 | ||
634 | stdcall gl_clipcode, [edi+GLVertex.pc+offs_X],[edi+GLVertex.pc+offs_Y],\ |
634 | stdcall gl_clipcode, [edi+GLVertex.pc+offs_X],[edi+GLVertex.pc+offs_Y],\ |
635 | [edi+GLVertex.pc+offs_Z],[edi+GLVertex.pc+offs_W] |
635 | [edi+GLVertex.pc+offs_Z],[edi+GLVertex.pc+offs_W] |
636 | mov dword[edi+GLVertex.clip_code],eax |
636 | mov dword[edi+GLVertex.clip_code],eax |
637 | or eax,eax ;if (q.clip_code==0) |
637 | or eax,eax ;if (q.clip_code==0) |
638 | jnz @f |
638 | jnz @f |
639 | stdcall gl_transform_to_viewport,[context],edi |
639 | stdcall gl_transform_to_viewport,[context],edi |
640 | lea eax,[edi+GLVertex.zp+offs_zbup_b] |
640 | lea eax,[edi+GLVertex.zp+ZBufferPoint.b] |
641 | push eax |
641 | push eax |
642 | add eax,offs_zbup_g-offs_zbup_b |
642 | add eax,ZBufferPoint.g-ZBufferPoint.b |
643 | push eax |
643 | push eax |
644 | add eax,offs_zbup_r-offs_zbup_g |
644 | add eax,ZBufferPoint.r-ZBufferPoint.g |
645 | push eax |
645 | push eax |
646 | stdcall RGBFtoRGBI, dword[edi+GLVertex.color],dword[edi+GLVertex.color+4],dword[edi+GLVertex.color+8] |
646 | stdcall RGBFtoRGBI, dword[edi+GLVertex.color],dword[edi+GLVertex.color+4],dword[edi+GLVertex.color+8] |
647 | @@: |
647 | @@: |
648 | ret |
648 | ret |
649 | endp |
649 | endp |
650 | 650 | ||
651 | align 16 |
651 | align 16 |
652 | proc gl_draw_triangle, context:dword, p0:dword, p1:dword, p2:dword |
652 | proc gl_draw_triangle, context:dword, p0:dword, p1:dword, p2:dword |
653 | locals |
653 | locals |
654 | cc rd 3 |
654 | cc rd 3 |
655 | front dd ? |
655 | front dd ? |
656 | norm dd ? ;float |
656 | norm dd ? ;float |
657 | endl |
657 | endl |
658 | pushad |
658 | pushad |
659 | mov ebx,[p0] |
659 | mov ebx,[p0] |
660 | mov ecx,[p1] |
660 | mov ecx,[p1] |
661 | mov edx,[p2] |
661 | mov edx,[p2] |
662 | mov edi,[ebx+GLVertex.clip_code] |
662 | mov edi,[ebx+GLVertex.clip_code] |
663 | mov dword[cc],edi |
663 | mov dword[cc],edi |
664 | mov eax,[ecx+GLVertex.clip_code] |
664 | mov eax,[ecx+GLVertex.clip_code] |
665 | mov dword[cc+4],eax |
665 | mov dword[cc+4],eax |
666 | or edi,eax |
666 | or edi,eax |
667 | mov eax,[edx+GLVertex.clip_code] |
667 | mov eax,[edx+GLVertex.clip_code] |
668 | mov dword[cc+8],eax |
668 | mov dword[cc+8],eax |
669 | or edi,eax ;co = cc[0] | cc[1] | cc[2] |
669 | or edi,eax ;co = cc[0] | cc[1] | cc[2] |
670 | 670 | ||
671 | ; we handle the non clipped case here to go faster |
671 | ; we handle the non clipped case here to go faster |
672 | ;or edi,___ - было выше |
672 | ;or edi,___ - было выше |
673 | jnz .els_0 |
673 | jnz .els_0 |
674 | ;if (co==0) |
674 | ;if (co==0) |
675 | mov edi,dword[edx+GLVertex.zp+offs_zbup_x] |
675 | mov edi,dword[edx+GLVertex.zp+ZBufferPoint.x] |
676 | sub edi,dword[ebx+GLVertex.zp+offs_zbup_x] |
676 | sub edi,dword[ebx+GLVertex.zp+ZBufferPoint.x] |
677 | mov dword[norm],edi ;p2.x-p0.x |
677 | mov dword[norm],edi ;p2.x-p0.x |
678 | fild dword[norm] |
678 | fild dword[norm] |
679 | mov edi,dword[ecx+GLVertex.zp+offs_zbup_y] |
679 | mov edi,dword[ecx+GLVertex.zp+ZBufferPoint.y] |
680 | sub edi,dword[ebx+GLVertex.zp+offs_zbup_y] |
680 | sub edi,dword[ebx+GLVertex.zp+ZBufferPoint.y] |
681 | mov dword[norm],edi ;p1.y-p0.y |
681 | mov dword[norm],edi ;p1.y-p0.y |
682 | fimul dword[norm] |
682 | fimul dword[norm] |
683 | fchs |
683 | fchs |
684 | mov edi,dword[ecx+GLVertex.zp+offs_zbup_x] |
684 | mov edi,dword[ecx+GLVertex.zp+ZBufferPoint.x] |
685 | sub edi,dword[ebx+GLVertex.zp+offs_zbup_x] |
685 | sub edi,dword[ebx+GLVertex.zp+ZBufferPoint.x] |
686 | mov dword[norm],edi ;p1.x-p0.x |
686 | mov dword[norm],edi ;p1.x-p0.x |
687 | fild dword[norm] |
687 | fild dword[norm] |
688 | mov edi,dword[edx+GLVertex.zp+offs_zbup_y] |
688 | mov edi,dword[edx+GLVertex.zp+ZBufferPoint.y] |
689 | sub edi,dword[ebx+GLVertex.zp+offs_zbup_y] |
689 | sub edi,dword[ebx+GLVertex.zp+ZBufferPoint.y] |
690 | mov dword[norm],edi ;p2.y-p0.y |
690 | mov dword[norm],edi ;p2.y-p0.y |
691 | fimul dword[norm] |
691 | fimul dword[norm] |
692 | faddp |
692 | faddp |
693 | ;st0 = (p1.zp.x-p0.zp.x)*(p2.zp.y-p0.zp.y) - (p2.zp.x-p0.zp.x)*(p1.zp.y-p0.zp.y) |
693 | ;st0 = (p1.zp.x-p0.zp.x)*(p2.zp.y-p0.zp.y) - (p2.zp.x-p0.zp.x)*(p1.zp.y-p0.zp.y) |
694 | 694 | ||
695 | mov dword[front],0 |
695 | mov dword[front],0 |
696 | ftst |
696 | ftst |
697 | fstsw ax |
697 | fstsw ax |
698 | ffree st0 |
698 | ffree st0 |
699 | fincstp |
699 | fincstp |
700 | sahf |
700 | sahf |
701 | je .end_f |
701 | je .end_f |
702 | jae @f |
702 | jae @f |
703 | inc dword[front] ;front = norm < 0.0 |
703 | inc dword[front] ;front = norm < 0.0 |
704 | @@: |
704 | @@: |
705 | mov edi,[context] |
705 | mov edi,[context] |
706 | mov eax,dword[edi+GLContext.current_front_face] |
706 | mov eax,dword[edi+GLContext.current_front_face] |
707 | xor dword[front],eax ;front ^= context.current_front_face |
707 | xor dword[front],eax ;front ^= context.current_front_face |
708 | 708 | ||
709 | ; back face culling |
709 | ; back face culling |
710 | cmp dword[edi+GLContext.cull_face_enabled],0 |
710 | cmp dword[edi+GLContext.cull_face_enabled],0 |
711 | je .els_1 |
711 | je .els_1 |
712 | ; most used case first |
712 | ; most used case first |
713 | cmp dword[edi+GLContext.current_cull_face],GL_BACK |
713 | cmp dword[edi+GLContext.current_cull_face],GL_BACK |
714 | jne @f |
714 | jne @f |
715 | cmp dword[front],0 |
715 | cmp dword[front],0 |
716 | je .end_f |
716 | je .end_f |
717 | stdcall dword[edi+GLContext.draw_triangle_front], edi,ebx,ecx,edx |
717 | stdcall dword[edi+GLContext.draw_triangle_front], edi,ebx,ecx,edx |
718 | jmp .end_f |
718 | jmp .end_f |
719 | align 4 |
719 | align 4 |
720 | @@: |
720 | @@: |
721 | cmp dword[edi+GLContext.current_cull_face],GL_FRONT |
721 | cmp dword[edi+GLContext.current_cull_face],GL_FRONT |
722 | jne .end_f |
722 | jne .end_f |
723 | cmp dword[front],0 |
723 | cmp dword[front],0 |
724 | jne .end_f |
724 | jne .end_f |
725 | stdcall dword[edi+GLContext.draw_triangle_back], edi,ebx,ecx,edx |
725 | stdcall dword[edi+GLContext.draw_triangle_back], edi,ebx,ecx,edx |
726 | jmp .end_f |
726 | jmp .end_f |
727 | align 4 |
727 | align 4 |
728 | .els_1: |
728 | .els_1: |
729 | ; no culling |
729 | ; no culling |
730 | cmp dword[front],0 |
730 | cmp dword[front],0 |
731 | je @f |
731 | je @f |
732 | stdcall dword[edi+GLContext.draw_triangle_front], edi,ebx,ecx,edx |
732 | stdcall dword[edi+GLContext.draw_triangle_front], edi,ebx,ecx,edx |
733 | jmp .end_f |
733 | jmp .end_f |
734 | align 4 |
734 | align 4 |
735 | @@: |
735 | @@: |
736 | stdcall dword[edi+GLContext.draw_triangle_back], edi,ebx,ecx,edx |
736 | stdcall dword[edi+GLContext.draw_triangle_back], edi,ebx,ecx,edx |
737 | jmp .end_f |
737 | jmp .end_f |
738 | align 4 |
738 | align 4 |
739 | .els_0: |
739 | .els_0: |
740 | ;eax = cc[2] |
740 | ;eax = cc[2] |
741 | and eax,[cc] |
741 | and eax,[cc] |
742 | and eax,[cc+4] ;eax = c_and = cc[0] & cc[1] & cc[2] |
742 | and eax,[cc+4] ;eax = c_and = cc[0] & cc[1] & cc[2] |
743 | or eax,eax ;if (c_and==0) |
743 | or eax,eax ;if (c_and==0) |
744 | jnz .end_f |
744 | jnz .end_f |
745 | stdcall gl_draw_triangle_clip, [context],ebx,ecx,edx,0 |
745 | stdcall gl_draw_triangle_clip, [context],ebx,ecx,edx,0 |
746 | .end_f: |
746 | .end_f: |
747 | popad |
747 | popad |
748 | ret |
748 | ret |
749 | endp |
749 | endp |
750 | 750 | ||
751 | align 16 |
751 | align 16 |
752 | proc gl_draw_triangle_clip, context:dword, p0:dword, p1:dword, p2:dword, clip_bit:dword |
752 | proc gl_draw_triangle_clip, context:dword, p0:dword, p1:dword, p2:dword, clip_bit:dword |
753 | locals |
753 | locals |
754 | co dd ? |
754 | co dd ? |
755 | cc rd 3 |
755 | cc rd 3 |
756 | edge_flag_tmp dd ? |
756 | edge_flag_tmp dd ? |
757 | clip_mask dd ? |
757 | clip_mask dd ? |
758 | q rd 3 ;GLVertex* |
758 | q rd 3 ;GLVertex* |
759 | tmp1 GLVertex ? |
759 | tmp1 GLVertex ? |
760 | tmp2 GLVertex ? |
760 | tmp2 GLVertex ? |
761 | endl |
761 | endl |
762 | pushad |
762 | pushad |
763 | mov ebx,[p0] |
763 | mov ebx,[p0] |
764 | mov ecx,[p1] |
764 | mov ecx,[p1] |
765 | mov edx,[p2] |
765 | mov edx,[p2] |
766 | 766 | ||
767 | mov edi,[ebx+GLVertex.clip_code] |
767 | mov edi,[ebx+GLVertex.clip_code] |
768 | mov [cc],edi |
768 | mov [cc],edi |
769 | mov eax,[ecx+GLVertex.clip_code] |
769 | mov eax,[ecx+GLVertex.clip_code] |
770 | mov [cc+4],eax |
770 | mov [cc+4],eax |
771 | or edi,eax |
771 | or edi,eax |
772 | mov eax,[edx+GLVertex.clip_code] |
772 | mov eax,[edx+GLVertex.clip_code] |
773 | mov [cc+8],eax |
773 | mov [cc+8],eax |
774 | or edi,eax |
774 | or edi,eax |
775 | mov [co],edi ;co = cc[0] | cc[1] | cc[2] |
775 | mov [co],edi ;co = cc[0] | cc[1] | cc[2] |
776 | 776 | ||
777 | or edi,edi ;if (co == 0) |
777 | or edi,edi ;if (co == 0) |
778 | jnz .els_0 |
778 | jnz .els_0 |
779 | stdcall gl_draw_triangle, [context],ebx,ecx,edx |
779 | stdcall gl_draw_triangle, [context],ebx,ecx,edx |
780 | jmp .end_f |
780 | jmp .end_f |
781 | align 4 |
781 | align 4 |
782 | .els_0: |
782 | .els_0: |
783 | ;eax = cc[2] |
783 | ;eax = cc[2] |
784 | and eax,[cc] |
784 | and eax,[cc] |
785 | and eax,[cc+4] ;c_and = cc[0] & cc[1] & cc[2] |
785 | and eax,[cc+4] ;c_and = cc[0] & cc[1] & cc[2] |
786 | 786 | ||
787 | ; the triangle is completely outside |
787 | ; the triangle is completely outside |
788 | or eax,eax ;if (c_and!=0) return |
788 | or eax,eax ;if (c_and!=0) return |
789 | jnz .end_f |
789 | jnz .end_f |
790 | 790 | ||
791 | ; find the next direction to clip |
791 | ; find the next direction to clip |
792 | .cycle_0: ;while (clip_bit < 6 && (co & (1 << clip_bit)) == 0) |
792 | .cycle_0: ;while (clip_bit < 6 && (co & (1 << clip_bit)) == 0) |
793 | cmp dword[clip_bit],6 |
793 | cmp dword[clip_bit],6 |
794 | jge .cycle_0_end |
794 | jge .cycle_0_end |
795 | xor eax,eax |
795 | xor eax,eax |
796 | inc eax |
796 | inc eax |
797 | mov ecx,[clip_bit] |
797 | mov ecx,[clip_bit] |
798 | shl eax,cl |
798 | shl eax,cl |
799 | and eax,[co] |
799 | and eax,[co] |
800 | or eax,eax |
800 | or eax,eax |
801 | jnz .cycle_0_end |
801 | jnz .cycle_0_end |
802 | inc dword[clip_bit] |
802 | inc dword[clip_bit] |
803 | jmp .cycle_0 |
803 | jmp .cycle_0 |
804 | align 4 |
804 | align 4 |
805 | .cycle_0_end: |
805 | .cycle_0_end: |
806 | 806 | ||
807 | ; this test can be true only in case of rounding errors |
807 | ; this test can be true only in case of rounding errors |
808 | cmp dword[clip_bit],6 |
808 | cmp dword[clip_bit],6 |
809 | if 0 |
809 | if 0 |
810 | jne @f |
810 | jne @f |
811 | ; printf("Error:\n"); |
811 | ; printf("Error:\n"); |
812 | ; printf("%f %f %f %f\n",p0->pc.X,p0->pc.Y,p0->pc.Z,p0->pc.W); |
812 | ; printf("%f %f %f %f\n",p0->pc.X,p0->pc.Y,p0->pc.Z,p0->pc.W); |
813 | ; printf("%f %f %f %f\n",p1->pc.X,p1->pc.Y,p1->pc.Z,p1->pc.W); |
813 | ; printf("%f %f %f %f\n",p1->pc.X,p1->pc.Y,p1->pc.Z,p1->pc.W); |
814 | ; printf("%f %f %f %f\n",p2->pc.X,p2->pc.Y,p2->pc.Z,p2->pc.W); |
814 | ; printf("%f %f %f %f\n",p2->pc.X,p2->pc.Y,p2->pc.Z,p2->pc.W); |
815 | jmp .end_f |
815 | jmp .end_f |
816 | @@: |
816 | @@: |
817 | end if |
817 | end if |
818 | if 1 |
818 | if 1 |
819 | je .end_f |
819 | je .end_f |
820 | end if |
820 | end if |
821 | 821 | ||
822 | xor eax,eax |
822 | xor eax,eax |
823 | inc eax |
823 | inc eax |
824 | mov ecx,[clip_bit] |
824 | mov ecx,[clip_bit] |
825 | shl eax,cl |
825 | shl eax,cl |
826 | mov [clip_mask],eax ;1 << clip_bit |
826 | mov [clip_mask],eax ;1 << clip_bit |
827 | mov edi,[cc] |
827 | mov edi,[cc] |
828 | xor edi,[cc+4] |
828 | xor edi,[cc+4] |
829 | xor edi,[cc+8] |
829 | xor edi,[cc+8] |
830 | and eax,edi ;eax = co1 = (cc[0] ^ cc[1] ^ cc[2]) & clip_mask |
830 | and eax,edi ;eax = co1 = (cc[0] ^ cc[1] ^ cc[2]) & clip_mask |
831 | 831 | ||
832 | mov ecx,[p1] ;востанавливаем после shl ___,cl |
832 | mov ecx,[p1] ;востанавливаем после shl ___,cl |
833 | 833 | ||
834 | or eax,eax ;if (co1) |
834 | or eax,eax ;if (co1) |
835 | jz .els_1 |
835 | jz .els_1 |
836 | ; one point outside |
836 | ; one point outside |
837 | mov eax,[cc] |
837 | mov eax,[cc] |
838 | and eax,[clip_mask] |
838 | and eax,[clip_mask] |
839 | or eax,eax ;if (cc[0] & clip_mask) |
839 | or eax,eax ;if (cc[0] & clip_mask) |
840 | jz .els_2 |
840 | jz .els_2 |
841 | ;q[0]=p0 q[1]=p1 q[2]=p2 |
841 | ;q[0]=p0 q[1]=p1 q[2]=p2 |
842 | mov [q],ebx |
842 | mov [q],ebx |
843 | mov [q+4],ecx |
843 | mov [q+4],ecx |
844 | mov [q+8],edx |
844 | mov [q+8],edx |
845 | jmp .els_2_end |
845 | jmp .els_2_end |
846 | align 4 |
846 | align 4 |
847 | .els_2: |
847 | .els_2: |
848 | mov eax,[cc+4] |
848 | mov eax,[cc+4] |
849 | and eax,[clip_mask] |
849 | and eax,[clip_mask] |
850 | or eax,eax ;else if (cc[1] & clip_mask) |
850 | or eax,eax ;else if (cc[1] & clip_mask) |
851 | jz .els_3 |
851 | jz .els_3 |
852 | ;q[0]=p1 q[1]=p2 q[2]=p0 |
852 | ;q[0]=p1 q[1]=p2 q[2]=p0 |
853 | mov [q],ecx |
853 | mov [q],ecx |
854 | mov [q+4],edx |
854 | mov [q+4],edx |
855 | mov [q+8],ebx |
855 | mov [q+8],ebx |
856 | jmp .els_2_end |
856 | jmp .els_2_end |
857 | align 4 |
857 | align 4 |
858 | .els_3: |
858 | .els_3: |
859 | ;q[0]=p2 q[1]=p0 q[2]=p1 |
859 | ;q[0]=p2 q[1]=p0 q[2]=p1 |
860 | mov [q],edx |
860 | mov [q],edx |
861 | mov [q+4],ebx |
861 | mov [q+4],ebx |
862 | mov [q+8],ecx |
862 | mov [q+8],ecx |
863 | .els_2_end: |
863 | .els_2_end: |
864 | 864 | ||
865 | mov ebx,[q] |
865 | mov ebx,[q] |
866 | add ebx,GLVertex.pc |
866 | add ebx,GLVertex.pc |
867 | mov ecx,[q+4] |
867 | mov ecx,[q+4] |
868 | add ecx,GLVertex.pc |
868 | add ecx,GLVertex.pc |
869 | mov edx,[q+8] |
869 | mov edx,[q+8] |
870 | add edx,GLVertex.pc |
870 | add edx,GLVertex.pc |
871 | 871 | ||
872 | lea eax,[clip_proc] |
872 | lea eax,[clip_proc] |
873 | mov edi,[clip_bit] |
873 | mov edi,[clip_bit] |
874 | lea eax,[eax+4*edi] |
874 | lea eax,[eax+4*edi] |
875 | lea edi,[ebp-(2*sizeof.GLVertex)+GLVertex.pc] |
875 | lea edi,[ebp-(2*sizeof.GLVertex)+GLVertex.pc] |
876 | stdcall dword[eax],edi,ebx,ecx ;clip_proc[clip_bit](&tmp1.pc,&q[0].pc,&q[1].pc) |
876 | stdcall dword[eax],edi,ebx,ecx ;clip_proc[clip_bit](&tmp1.pc,&q[0].pc,&q[1].pc) |
877 | sub edi,GLVertex.pc |
877 | sub edi,GLVertex.pc |
878 | 878 | ||
879 | sub ebx,GLVertex.pc |
879 | sub ebx,GLVertex.pc |
880 | sub ecx,GLVertex.pc |
880 | sub ecx,GLVertex.pc |
881 | stdcall updateTmp,[context],ebx,ecx,eax ;(c,&tmp1,q[0],q[1],tt) |
881 | stdcall updateTmp,[context],ebx,ecx,eax ;(c,&tmp1,q[0],q[1],tt) |
882 | add ebx,GLVertex.pc |
882 | add ebx,GLVertex.pc |
883 | 883 | ||
884 | lea eax,[clip_proc] |
884 | lea eax,[clip_proc] |
885 | mov edi,[clip_bit] |
885 | mov edi,[clip_bit] |
886 | lea eax,[eax+4*edi] |
886 | lea eax,[eax+4*edi] |
887 | lea edi,[ebp-sizeof.GLVertex+GLVertex.pc] |
887 | lea edi,[ebp-sizeof.GLVertex+GLVertex.pc] |
888 | stdcall dword[eax],edi,ebx,edx ;clip_proc[clip_bit](&tmp2.pc,&q[0].pc,&q[2].pc) |
888 | stdcall dword[eax],edi,ebx,edx ;clip_proc[clip_bit](&tmp2.pc,&q[0].pc,&q[2].pc) |
889 | sub edi,GLVertex.pc |
889 | sub edi,GLVertex.pc |
890 | sub ebx,GLVertex.pc |
890 | sub ebx,GLVertex.pc |
891 | sub edx,GLVertex.pc |
891 | sub edx,GLVertex.pc |
892 | stdcall updateTmp,[context],ebx,edx,eax ;(c,&tmp2,q[0],q[2],tt) |
892 | stdcall updateTmp,[context],ebx,edx,eax ;(c,&tmp2,q[0],q[2],tt) |
893 | 893 | ||
894 | mov eax,[ebx+GLVertex.edge_flag] |
894 | mov eax,[ebx+GLVertex.edge_flag] |
895 | mov [tmp1.edge_flag],eax ;q[0].edge_flag |
895 | mov [tmp1.edge_flag],eax ;q[0].edge_flag |
896 | mov eax,[edx+GLVertex.edge_flag] |
896 | mov eax,[edx+GLVertex.edge_flag] |
897 | mov [edge_flag_tmp],eax ;q[2].edge_flag |
897 | mov [edge_flag_tmp],eax ;q[2].edge_flag |
898 | mov dword[edx+GLVertex.edge_flag],0 ;q[2].edge_flag=0 |
898 | mov dword[edx+GLVertex.edge_flag],0 ;q[2].edge_flag=0 |
899 | mov eax,[clip_bit] |
899 | mov eax,[clip_bit] |
900 | inc eax |
900 | inc eax |
901 | push eax ;для вызова нижней функции |
901 | push eax ;для вызова нижней функции |
902 | lea edi,[ebp-2*sizeof.GLVertex] |
902 | lea edi,[ebp-2*sizeof.GLVertex] |
903 | stdcall gl_draw_triangle_clip,[context],edi,ecx,edx,eax ;gl_draw_triangle_clip(c,&tmp1,q[1],q[2],clip_bit+1) |
903 | stdcall gl_draw_triangle_clip,[context],edi,ecx,edx,eax ;gl_draw_triangle_clip(c,&tmp1,q[1],q[2],clip_bit+1) |
904 | 904 | ||
905 | mov dword[tmp2.edge_flag],0 |
905 | mov dword[tmp2.edge_flag],0 |
906 | mov dword[tmp1.edge_flag],0 |
906 | mov dword[tmp1.edge_flag],0 |
907 | mov eax,[edge_flag_tmp] |
907 | mov eax,[edge_flag_tmp] |
908 | mov [edx+GLVertex.edge_flag],eax ;q[2].edge_flag=edge_flag_tmp |
908 | mov [edx+GLVertex.edge_flag],eax ;q[2].edge_flag=edge_flag_tmp |
909 | push edx |
909 | push edx |
910 | push edi |
910 | push edi |
911 | add edi,sizeof.GLVertex ;edi = &tmp2 |
911 | add edi,sizeof.GLVertex ;edi = &tmp2 |
912 | stdcall gl_draw_triangle_clip,[context],edi ;gl_draw_triangle_clip(c,&tmp2,&tmp1,q[2],clip_bit+1) |
912 | stdcall gl_draw_triangle_clip,[context],edi ;gl_draw_triangle_clip(c,&tmp2,&tmp1,q[2],clip_bit+1) |
913 | jmp .end_f |
913 | jmp .end_f |
914 | align 4 |
914 | align 4 |
915 | .els_1: |
915 | .els_1: |
916 | ; two points outside |
916 | ; two points outside |
917 | mov eax,[cc] |
917 | mov eax,[cc] |
918 | and eax,[clip_mask] |
918 | and eax,[clip_mask] |
919 | cmp eax,0 ;if (cc[0] & clip_mask)==0 |
919 | cmp eax,0 ;if (cc[0] & clip_mask)==0 |
920 | jne .els_4 |
920 | jne .els_4 |
921 | ;q[0]=p0 q[1]=p1 q[2]=p2 |
921 | ;q[0]=p0 q[1]=p1 q[2]=p2 |
922 | mov [q],ebx |
922 | mov [q],ebx |
923 | mov [q+4],ecx |
923 | mov [q+4],ecx |
924 | mov [q+8],edx |
924 | mov [q+8],edx |
925 | jmp .els_4_end |
925 | jmp .els_4_end |
926 | align 4 |
926 | align 4 |
927 | .els_4: |
927 | .els_4: |
928 | mov eax,[cc+4] |
928 | mov eax,[cc+4] |
929 | and eax,[clip_mask] |
929 | and eax,[clip_mask] |
930 | cmp eax,0 ;else if (cc[1] & clip_mask)==0 |
930 | cmp eax,0 ;else if (cc[1] & clip_mask)==0 |
931 | jne .els_5 |
931 | jne .els_5 |
932 | ;q[0]=p1 q[1]=p2 q[2]=p0 |
932 | ;q[0]=p1 q[1]=p2 q[2]=p0 |
933 | mov [q],ecx |
933 | mov [q],ecx |
934 | mov [q+4],edx |
934 | mov [q+4],edx |
935 | mov [q+8],ebx |
935 | mov [q+8],ebx |
936 | jmp .els_4_end |
936 | jmp .els_4_end |
937 | align 4 |
937 | align 4 |
938 | .els_5: |
938 | .els_5: |
939 | ;q[0]=p2 q[1]=p0 q[2]=p1 |
939 | ;q[0]=p2 q[1]=p0 q[2]=p1 |
940 | mov [q],edx |
940 | mov [q],edx |
941 | mov [q+4],ebx |
941 | mov [q+4],ebx |
942 | mov [q+8],ecx |
942 | mov [q+8],ecx |
943 | .els_4_end: |
943 | .els_4_end: |
944 | 944 | ||
945 | mov ebx,[q] |
945 | mov ebx,[q] |
946 | add ebx,GLVertex.pc |
946 | add ebx,GLVertex.pc |
947 | mov ecx,[q+4] |
947 | mov ecx,[q+4] |
948 | add ecx,GLVertex.pc |
948 | add ecx,GLVertex.pc |
949 | mov edx,[q+8] |
949 | mov edx,[q+8] |
950 | add edx,GLVertex.pc |
950 | add edx,GLVertex.pc |
951 | 951 | ||
952 | lea eax,[clip_proc] |
952 | lea eax,[clip_proc] |
953 | mov edi,[clip_bit] |
953 | mov edi,[clip_bit] |
954 | lea eax,[eax+4*edi] |
954 | lea eax,[eax+4*edi] |
955 | lea edi,[ebp-(2*sizeof.GLVertex)+GLVertex.pc] |
955 | lea edi,[ebp-(2*sizeof.GLVertex)+GLVertex.pc] |
956 | stdcall dword[eax],edi,ebx,ecx ;clip_proc[clip_bit](&tmp1.pc,&q[0].pc,&q[1].pc) |
956 | stdcall dword[eax],edi,ebx,ecx ;clip_proc[clip_bit](&tmp1.pc,&q[0].pc,&q[1].pc) |
957 | sub edi,GLVertex.pc |
957 | sub edi,GLVertex.pc |
958 | stdcall updateTmp,[context],[q],[q+4],eax |
958 | stdcall updateTmp,[context],[q],[q+4],eax |
959 | 959 | ||
960 | lea eax,[clip_proc] |
960 | lea eax,[clip_proc] |
961 | mov edi,[clip_bit] |
961 | mov edi,[clip_bit] |
962 | lea eax,[eax+4*edi] |
962 | lea eax,[eax+4*edi] |
963 | lea edi,[ebp-sizeof.GLVertex+GLVertex.pc] |
963 | lea edi,[ebp-sizeof.GLVertex+GLVertex.pc] |
964 | stdcall dword[eax],edi,ebx,edx ;clip_proc[clip_bit](&tmp2.pc,&q[0].pc,&q[2].pc) |
964 | stdcall dword[eax],edi,ebx,edx ;clip_proc[clip_bit](&tmp2.pc,&q[0].pc,&q[2].pc) |
965 | sub edi,GLVertex.pc |
965 | sub edi,GLVertex.pc |
966 | stdcall updateTmp,[context],[q],[q+8],eax |
966 | stdcall updateTmp,[context],[q],[q+8],eax |
967 | 967 | ||
968 | mov dword[tmp1.edge_flag],1 |
968 | mov dword[tmp1.edge_flag],1 |
969 | mov eax,[edx+GLVertex.edge_flag-GLVertex.pc] |
969 | mov eax,[edx+GLVertex.edge_flag-GLVertex.pc] |
970 | mov dword[tmp2.edge_flag],eax ;tmp2.edge_flag = q[2].edge_flag |
970 | mov dword[tmp2.edge_flag],eax ;tmp2.edge_flag = q[2].edge_flag |
971 | mov eax,[clip_bit] |
971 | mov eax,[clip_bit] |
972 | inc eax |
972 | inc eax |
973 | push eax |
973 | push eax |
974 | push edi |
974 | push edi |
975 | sub edi,sizeof.GLVertex |
975 | sub edi,sizeof.GLVertex |
976 | stdcall gl_draw_triangle_clip,[context],[q],edi ;gl_draw_triangle_clip(c,q[0],&tmp1,&tmp2,clip_bit+1) |
976 | stdcall gl_draw_triangle_clip,[context],[q],edi ;gl_draw_triangle_clip(c,q[0],&tmp1,&tmp2,clip_bit+1) |
977 | .end_f: |
977 | .end_f: |
978 | popad |
978 | popad |
979 | ret |
979 | ret |
980 | endp |
980 | endp |
981 | 981 | ||
982 | align 16 |
982 | align 16 |
983 | proc gl_draw_triangle_select uses eax, context:dword, p0:dword,p1:dword,p2:dword |
983 | proc gl_draw_triangle_select uses eax, context:dword, p0:dword,p1:dword,p2:dword |
984 | mov eax,[p2] |
984 | mov eax,[p2] |
985 | push dword[eax+GLVertex.zp+offs_Z] |
985 | push dword[eax+GLVertex.zp+offs_Z] |
986 | mov eax,[p1] |
986 | mov eax,[p1] |
987 | push dword[eax+GLVertex.zp+offs_Z] |
987 | push dword[eax+GLVertex.zp+offs_Z] |
988 | mov eax,[p0] |
988 | mov eax,[p0] |
989 | push dword[eax+GLVertex.zp+offs_Z] |
989 | push dword[eax+GLVertex.zp+offs_Z] |
990 | stdcall gl_add_select1, [context] ;,p0.zp.z, p1.zp.z, p2.zp.z |
990 | stdcall gl_add_select1, [context] ;,p0.zp.z, p1.zp.z, p2.zp.z |
991 | ret |
991 | ret |
992 | endp |
992 | endp |
993 | 993 | ||
994 | if PROFILE eq 1 |
994 | if PROFILE eq 1 |
995 | count_triangles dd ? |
995 | count_triangles dd ? |
996 | count_triangles_textured dd ? |
996 | count_triangles_textured dd ? |
997 | count_pixels dd ? |
997 | count_pixels dd ? |
998 | end if |
998 | end if |
999 | 999 | ||
1000 | align 16 |
1000 | align 16 |
1001 | proc gl_draw_triangle_fill, context:dword, p0:dword,p1:dword,p2:dword |
1001 | proc gl_draw_triangle_fill, context:dword, p0:dword,p1:dword,p2:dword |
1002 | pushad |
1002 | pushad |
1003 | if PROFILE eq 1 |
1003 | if PROFILE eq 1 |
1004 | ; int norm; |
1004 | ; int norm; |
1005 | ; assert(p0->zp.x >= 0 && p0->zp.x < c->zb->xsize); |
1005 | ; assert(p0->zp.x >= 0 && p0->zp.x < c->zb->xsize); |
1006 | ; assert(p0->zp.y >= 0 && p0->zp.y < c->zb->ysize); |
1006 | ; assert(p0->zp.y >= 0 && p0->zp.y < c->zb->ysize); |
1007 | ; assert(p1->zp.x >= 0 && p1->zp.x < c->zb->xsize); |
1007 | ; assert(p1->zp.x >= 0 && p1->zp.x < c->zb->xsize); |
1008 | ; assert(p1->zp.y >= 0 && p1->zp.y < c->zb->ysize); |
1008 | ; assert(p1->zp.y >= 0 && p1->zp.y < c->zb->ysize); |
1009 | ; assert(p2->zp.x >= 0 && p2->zp.x < c->zb->xsize); |
1009 | ; assert(p2->zp.x >= 0 && p2->zp.x < c->zb->xsize); |
1010 | ; assert(p2->zp.y >= 0 && p2->zp.y < c->zb->ysize); |
1010 | ; assert(p2->zp.y >= 0 && p2->zp.y < c->zb->ysize); |
1011 | 1011 | ||
1012 | ; norm=(p1->zp.x-p0->zp.x)*(p2->zp.y-p0->zp.y)- |
1012 | ; norm=(p1->zp.x-p0->zp.x)*(p2->zp.y-p0->zp.y)- |
1013 | ; (p2->zp.x-p0->zp.x)*(p1->zp.y-p0->zp.y); |
1013 | ; (p2->zp.x-p0->zp.x)*(p1->zp.y-p0->zp.y); |
1014 | ; count_pixels+=abs(norm)/2; |
1014 | ; count_pixels+=abs(norm)/2; |
1015 | inc dword[count_triangles] |
1015 | inc dword[count_triangles] |
1016 | end if |
1016 | end if |
1017 | 1017 | ||
1018 | mov ebx,[p1] |
1018 | mov ebx,[p1] |
1019 | add ebx,GLVertex.zp |
1019 | add ebx,GLVertex.zp |
1020 | mov ecx,[p2] |
1020 | mov ecx,[p2] |
1021 | add ecx,GLVertex.zp |
1021 | add ecx,GLVertex.zp |
1022 | mov edx,[context] |
1022 | mov edx,[context] |
1023 | cmp dword[edx+GLContext.texture_2d_enabled],0 |
1023 | cmp dword[edx+GLContext.texture_2d_enabled],0 |
1024 | je .els_i |
1024 | je .els_i |
1025 | ;if (context.texture_2d_enabled) |
1025 | ;if (context.texture_2d_enabled) |
1026 | if PROFILE eq 1 |
1026 | if PROFILE eq 1 |
1027 | inc dword[count_triangles_textured] |
1027 | inc dword[count_triangles_textured] |
1028 | end if |
1028 | end if |
1029 | mov eax,[edx+GLContext.current_texture] |
1029 | mov eax,[edx+GLContext.current_texture] |
1030 | mov eax,[eax] ;переход по указателю |
1030 | mov eax,[eax] ;переход по указателю |
1031 | ;так как offs_text_images+offs_imag_pixmap = 0 то context.current_texture.images[0].pixmap = [eax] |
1031 | ;так как offs_text_images+offs_imag_pixmap = 0 то context.current_texture.images[0].pixmap = [eax] |
1032 | stdcall ZB_setTexture, [edx+GLContext.zb], [eax],\ |
1032 | stdcall ZB_setTexture, [edx+GLContext.zb], [eax],\ |
1033 | [eax+offs_imag_s_bound],[eax+offs_imag_t_bound],[eax+offs_imag_xsize_log2] |
1033 | [eax+offs_imag_s_bound],[eax+offs_imag_t_bound],[eax+offs_imag_xsize_log2] |
1034 | mov eax,[p0] |
1034 | mov eax,[p0] |
1035 | add eax,GLVertex.zp |
1035 | add eax,GLVertex.zp |
1036 | push ecx |
1036 | push ecx |
1037 | push ebx |
1037 | push ebx |
1038 | push eax |
1038 | push eax |
1039 | push dword[edx+GLContext.zb] |
1039 | push dword[edx+GLContext.zb] |
1040 | cmp dword[edx+GLContext.matrix_model_projection_no_w_transform],0 |
1040 | cmp dword[edx+GLContext.matrix_model_projection_no_w_transform],0 |
1041 | je @f |
1041 | je @f |
1042 | call ZB_fillTriangleMappingPerspective |
1042 | call ZB_fillTriangleMappingPerspective |
1043 | jmp .end_f |
1043 | jmp .end_f |
1044 | align 4 |
1044 | align 4 |
1045 | @@: |
1045 | @@: |
1046 | call ZB_fillTriangleMapping |
1046 | call ZB_fillTriangleMapping |
1047 | jmp .end_f |
1047 | jmp .end_f |
1048 | align 4 |
1048 | align 4 |
1049 | .els_i: |
1049 | .els_i: |
1050 | mov eax,[p0] |
1050 | mov eax,[p0] |
1051 | add eax,GLVertex.zp |
1051 | add eax,GLVertex.zp |
1052 | cmp dword[edx+GLContext.current_shade_model],GL_SMOOTH |
1052 | cmp dword[edx+GLContext.current_shade_model],GL_SMOOTH |
1053 | jne .els |
1053 | jne .els |
1054 | ;else if (context.current_shade_model == GL_SMOOTH) |
1054 | ;else if (context.current_shade_model == GL_SMOOTH) |
1055 | stdcall ZB_fillTriangleSmooth, dword[edx+GLContext.zb],eax,ebx,ecx |
1055 | stdcall ZB_fillTriangleSmooth, dword[edx+GLContext.zb],eax,ebx,ecx |
1056 | jmp .end_f |
1056 | jmp .end_f |
1057 | align 4 |
1057 | align 4 |
1058 | .els: |
1058 | .els: |
1059 | stdcall ZB_fillTriangleFlat, dword[edx+GLContext.zb],eax,ebx,ecx |
1059 | stdcall ZB_fillTriangleFlat, dword[edx+GLContext.zb],eax,ebx,ecx |
1060 | .end_f: |
1060 | .end_f: |
1061 | popad |
1061 | popad |
1062 | ret |
1062 | ret |
1063 | endp |
1063 | endp |
1064 | 1064 | ||
1065 | ; Render a clipped triangle in line mode |
1065 | ; Render a clipped triangle in line mode |
1066 | 1066 | ||
1067 | align 16 |
1067 | align 16 |
1068 | proc gl_draw_triangle_line uses eax ebx ecx edx, context:dword, p0:dword,p1:dword,p2:dword |
1068 | proc gl_draw_triangle_line uses eax ebx ecx edx, context:dword, p0:dword,p1:dword,p2:dword |
1069 | mov edx,[context] |
1069 | mov edx,[context] |
1070 | cmp dword[edx+GLContext.depth_test],0 |
1070 | cmp dword[edx+GLContext.depth_test],0 |
1071 | je .els |
1071 | je .els |
1072 | lea ecx,[ZB_line_z] |
1072 | lea ecx,[ZB_line_z] |
1073 | jmp @f |
1073 | jmp @f |
1074 | align 4 |
1074 | align 4 |
1075 | .els: |
1075 | .els: |
1076 | lea ecx,[ZB_line] |
1076 | lea ecx,[ZB_line] |
1077 | @@: |
1077 | @@: |
1078 | 1078 | ||
1079 | ;if (p0.edge_flag) ZB_line_z(context.zb,&p0.zp,&p1.zp) |
1079 | ;if (p0.edge_flag) ZB_line_z(context.zb,&p0.zp,&p1.zp) |
1080 | mov eax,[p0] |
1080 | mov eax,[p0] |
1081 | cmp dword[eax+GLVertex.edge_flag],0 |
1081 | cmp dword[eax+GLVertex.edge_flag],0 |
1082 | je @f |
1082 | je @f |
1083 | lea ebx,[eax+GLVertex.zp] |
1083 | lea ebx,[eax+GLVertex.zp] |
1084 | mov eax,[p1] |
1084 | mov eax,[p1] |
1085 | add eax,GLVertex.zp |
1085 | add eax,GLVertex.zp |
1086 | stdcall ecx,dword[edx+GLContext.zb],ebx,eax |
1086 | stdcall ecx,dword[edx+GLContext.zb],ebx,eax |
1087 | @@: |
1087 | @@: |
1088 | ;if (p1.edge_flag) ZB_line_z(context.zb,&p1.zp,&p2.zp) |
1088 | ;if (p1.edge_flag) ZB_line_z(context.zb,&p1.zp,&p2.zp) |
1089 | mov eax,[p1] |
1089 | mov eax,[p1] |
1090 | cmp dword[eax+GLVertex.edge_flag],0 |
1090 | cmp dword[eax+GLVertex.edge_flag],0 |
1091 | je @f |
1091 | je @f |
1092 | lea ebx,[eax+GLVertex.zp] |
1092 | lea ebx,[eax+GLVertex.zp] |
1093 | mov eax,[p2] |
1093 | mov eax,[p2] |
1094 | add eax,GLVertex.zp |
1094 | add eax,GLVertex.zp |
1095 | stdcall ecx,dword[edx+GLContext.zb],ebx,eax |
1095 | stdcall ecx,dword[edx+GLContext.zb],ebx,eax |
1096 | @@: |
1096 | @@: |
1097 | ;if (p2.edge_flag) ZB_line_z(context.zb,&p2.zp,&p0.zp); |
1097 | ;if (p2.edge_flag) ZB_line_z(context.zb,&p2.zp,&p0.zp); |
1098 | mov eax,[p2] |
1098 | mov eax,[p2] |
1099 | cmp dword[eax+GLVertex.edge_flag],0 |
1099 | cmp dword[eax+GLVertex.edge_flag],0 |
1100 | je @f |
1100 | je @f |
1101 | lea ebx,[eax+GLVertex.zp] |
1101 | lea ebx,[eax+GLVertex.zp] |
1102 | mov eax,[p0] |
1102 | mov eax,[p0] |
1103 | add eax,GLVertex.zp |
1103 | add eax,GLVertex.zp |
1104 | stdcall ecx,dword[edx+GLContext.zb],ebx,eax |
1104 | stdcall ecx,dword[edx+GLContext.zb],ebx,eax |
1105 | @@: |
1105 | @@: |
1106 | 1106 | ||
1107 | ret |
1107 | ret |
1108 | endp |
1108 | endp |
1109 | 1109 | ||
1110 | ; Render a clipped triangle in point mode |
1110 | ; Render a clipped triangle in point mode |
1111 | align 16 |
1111 | align 16 |
1112 | proc gl_draw_triangle_point uses eax edx, context:dword, p0:dword,p1:dword,p2:dword |
1112 | proc gl_draw_triangle_point uses eax edx, context:dword, p0:dword,p1:dword,p2:dword |
1113 | mov edx,[context] |
1113 | mov edx,[context] |
1114 | mov eax,[p0] |
1114 | mov eax,[p0] |
1115 | cmp dword[eax+GLVertex.edge_flag],0 |
1115 | cmp dword[eax+GLVertex.edge_flag],0 |
1116 | je @f |
1116 | je @f |
1117 | lea eax,[eax+GLVertex.zp] |
1117 | lea eax,[eax+GLVertex.zp] |
1118 | stdcall ZB_plot,dword[edx+GLContext.zb],eax |
1118 | stdcall ZB_plot,dword[edx+GLContext.zb],eax |
1119 | @@: |
1119 | @@: |
1120 | mov eax,[p1] |
1120 | mov eax,[p1] |
1121 | cmp dword[eax+GLVertex.edge_flag],0 |
1121 | cmp dword[eax+GLVertex.edge_flag],0 |
1122 | je @f |
1122 | je @f |
1123 | lea eax,[eax+GLVertex.zp] |
1123 | lea eax,[eax+GLVertex.zp] |
1124 | stdcall ZB_plot,dword[edx+GLContext.zb],eax |
1124 | stdcall ZB_plot,dword[edx+GLContext.zb],eax |
1125 | @@: |
1125 | @@: |
1126 | mov eax,[p2] |
1126 | mov eax,[p2] |
1127 | cmp dword[eax+GLVertex.edge_flag],0 |
1127 | cmp dword[eax+GLVertex.edge_flag],0 |
1128 | je @f |
1128 | je @f |
1129 | lea eax,[eax+GLVertex.zp] |
1129 | lea eax,[eax+GLVertex.zp] |
1130 | stdcall ZB_plot,dword[edx+GLContext.zb],eax |
1130 | stdcall ZB_plot,dword[edx+GLContext.zb],eax |
1131 | @@: |
1131 | @@: |
1132 | ret |
1132 | ret |
1133 | endp>>>>>>><>><>>>*tmin)>*tmin)>0) |
1133 | endp>>>>>>><>><>>>*tmin)>*tmin)>0) |
1134 | >5) |
1134 | >5) |
1135 | 1135 | ||
1136 | align><5) |
1136 | align><5) |
1137 | 1137 | ||
1138 | align>4) |
1138 | align>4) |
1139 | CLIP_ZMAX><4) |
1139 | CLIP_ZMAX><4) |
1140 | CLIP_ZMAX>3) |
1140 | CLIP_ZMAX>3) |
1141 | CLIP_ZMIN><3) |
1141 | CLIP_ZMIN><3) |
1142 | CLIP_ZMIN>2) |
1142 | CLIP_ZMIN>2) |
1143 | CLIP_YMAX><2) |
1143 | CLIP_YMAX><2) |
1144 | CLIP_YMAX>1) |
1144 | CLIP_YMAX>1) |
1145 | CLIP_YMIN><1) |
1145 | CLIP_YMIN><1) |
1146 | CLIP_YMIN>0) |
1146 | CLIP_YMIN>0) |
1147 | CLIP_XMAX><0) |
1147 | CLIP_XMAX><0) |
1148 | CLIP_XMAX> |
1148 | CLIP_XMAX> |