Rev 5213 | Rev 5256 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5153 | IgorA | 1 | |
2 | proc glopNormal uses ecx esi edi, context:dword, p:dword |
||
3 | mov esi,[p] |
||
4 | add esi,4 |
||
5 | mov edi,[context] |
||
6 | add edi,offs_cont_current_normal |
||
7 | mov ecx,3 |
||
5218 | IgorA | 8 | rep movsd |
5153 | IgorA | 9 | mov dword[edi],0.0 ;context.current_normal.W = 0.0 |
5218 | IgorA | 10 | ret |
5153 | IgorA | 11 | endp |
12 | |||
13 | |||
14 | proc glopTexCoord uses ecx esi edi, context:dword, p:dword |
||
15 | mov esi,[p] |
||
16 | add esi,4 |
||
17 | mov edi,[context] |
||
18 | add edi,offs_cont_current_tex_coord |
||
19 | mov ecx,4 |
||
20 | rep movsd |
||
21 | ret |
||
22 | endp |
||
23 | |||
24 | |||
25 | proc glopEdgeFlag uses eax ebx, context:dword, p:dword |
||
26 | mov eax,[context] |
||
27 | mov ebx,[p] |
||
28 | mov ebx,[ebx+4] ;ebx = p[1] |
||
29 | mov dword[eax+offs_cont_current_edge_flag],ebx |
||
30 | ret |
||
31 | endp |
||
32 | |||
33 | |||
34 | proc glopColor uses eax ecx esi edi, context:dword, p:dword |
||
35 | locals |
||
36 | q rd 7 |
||
37 | endl |
||
38 | ;current_color[3] = p[1-4] |
||
39 | ;longcurrent_color[2] = p[5-7] |
||
40 | mov esi,[p] |
||
41 | add esi,4 |
||
42 | mov edi,[context] |
||
43 | add edi,offs_cont_current_color |
||
44 | mov ecx,7 |
||
45 | rep movsd |
||
46 | |||
47 | |||
48 | cmp dword[eax+offs_cont_color_material_enabled],0 |
||
5213 | IgorA | 49 | je @f |
50 | mov dword[q],OP_Material |
||
5153 | IgorA | 51 | mov ecx,[eax+offs_cont_current_color_material_mode] |
52 | mov dword[q+4],ecx |
||
53 | mov ecx,[eax+offs_cont_current_color_material_type] |
||
54 | mov dword[q+8],ecx |
||
55 | mov esi,[p] |
||
56 | add esi,4 |
||
57 | mov edi,ebp |
||
5213 | IgorA | 58 | sub edi,16 ;edi = &q[3] |
59 | mov ecx,4 |
||
5153 | IgorA | 60 | rep movsd |
61 | stdcall glopMaterial, eax,[q] |
||
62 | @@: |
||
63 | ret |
||
64 | endp |
||
65 | |||
66 | |||
67 | proc gl_eval_viewport uses eax, context:dword |
||
68 | locals |
||
69 | zsize dd ? ;float |
||
70 | endl |
||
71 | mov eax,[context] |
||
72 | add eax,offs_cont_viewport ;eax = (GLViewport*) v |
||
73 | |||
74 | |||
75 | fild dword[zsize] |
||
76 | fstp dword[zsize] |
||
77 | |||
78 | |||
79 | fld1 |
||
80 | fadd st1,st0 ;st1 = 2.0 |
||
81 | fdiv st0,st1 ;st0 = 0.5 |
||
82 | |||
83 | |||
84 | fsub st0,st1 |
||
85 | fdiv st0,st2 |
||
86 | fst dword[eax+offs_vpor_scale+offs_X] |
||
87 | fiadd dword[eax+offs_vpor_xmin] |
||
88 | fstp dword[eax+offs_vpor_trans+offs_X] |
||
89 | |||
90 | |||
91 | fsub st0,st1 |
||
92 | fdiv st0,st2 |
||
93 | fchs |
||
94 | fst dword[eax+offs_vpor_scale+offs_Y] |
||
95 | fchs |
||
96 | fiadd dword[eax+offs_vpor_ymin] |
||
97 | fstp dword[eax+offs_vpor_trans+offs_Y] |
||
98 | |||
99 | |||
100 | fsub st0,st1 |
||
101 | fdiv st0,st2 |
||
102 | fchs |
||
103 | fst dword[eax+offs_vpor_scale+offs_Z] |
||
104 | fchs |
||
105 | mov dword[zsize],(1 shl ZB_POINT_Z_FRAC_BITS) / 2 |
||
106 | fiadd dword[zsize] |
||
107 | fstp dword[eax+offs_vpor_trans+offs_Z] |
||
108 | if DEBUG ;gl_eval_viewport |
||
109 | stdcall dbg_print,f_ev,txt_nl |
||
110 | add eax,offs_vpor_scale |
||
111 | stdcall gl_print_matrix,eax,1 |
||
112 | add eax,8 |
||
113 | stdcall gl_print_matrix,eax,1 |
||
114 | end if |
||
115 | ret |
||
116 | endp |
||
117 | |||
118 | |||
119 | |||
120 | proc glopBegin uses eax ebx ecx edx, context:dword, p:dword |
||
121 | locals |
||
122 | tmp M4 |
||
123 | endl |
||
124 | ; assert(c->in_begin == 0); |
||
125 | |||
126 | |||
127 | mov ebx,[p] |
||
128 | mov ebx,[ebx+4] ;ebx = p[1] |
||
129 | mov [edx+offs_cont_begin_type],ebx |
||
130 | mov dword[edx+offs_cont_in_begin],1 |
||
131 | mov dword[edx+offs_cont_vertex_n],0 |
||
132 | mov dword[edx+offs_cont_vertex_cnt],0 |
||
133 | |||
134 | |||
135 | jnc .end_mmpu |
||
136 | |||
137 | |||
138 | je @f |
||
139 | ; precompute inverse modelview |
||
140 | mov ebx,ebp |
||
141 | sub ebx,64 |
||
142 | stdcall gl_M4_Inv, ebx, edx+offs_cont_matrix_stack_ptr |
||
143 | stdcall gl_M4_Transpose, edx+offs_cont_matrix_model_view_inv, ebx |
||
144 | jmp .end_if_0 |
||
145 | @@: |
||
146 | mov ecx,edx |
||
147 | add ecx,offs_cont_matrix_model_projection |
||
148 | ; precompute projection matrix |
||
149 | stdcall gl_M4_Mul, ecx,dword[edx+offs_cont_matrix_stack_ptr+4],dword[edx+offs_cont_matrix_stack_ptr] |
||
150 | |||
5213 | IgorA | 151 | |
5153 | IgorA | 152 | mov dword[edx+offs_cont_matrix_model_projection_no_w_transform],0 |
153 | fldz |
||
154 | fld dword[ecx+12*4] |
||
155 | fcomp st1 |
||
156 | fstsw ax |
||
157 | sahf |
||
158 | jne .end_if_0 |
||
159 | fld dword[ecx+13*4] |
||
160 | fcomp st1 |
||
161 | fstsw ax |
||
162 | sahf |
||
163 | jne .end_if_0 |
||
164 | fld dword[ecx+14*4] |
||
165 | fcomp st1 |
||
166 | fstsw ax |
||
167 | sahf |
||
168 | jne .end_if_0 |
||
169 | mov dword[edx+offs_cont_matrix_model_projection_no_w_transform],1 |
||
170 | .end_if_0: |
||
171 | |||
172 | |||
173 | mov eax,edx |
||
5218 | IgorA | 174 | add eax,offs_cont_matrix_stack_ptr+8 |
175 | stdcall gl_M4_IsId,eax |
||
176 | xor eax,1 |
||
177 | mov dword[edx+offs_cont_apply_texture_matrix],eax |
||
178 | |||
5153 | IgorA | 179 | |
180 | .end_mmpu: |
||
181 | |||
182 | |||
183 | cmp dword[edx+offs_cont_viewport+offs_vpor_updated],0 ;if (context.viewport.updated) |
||
184 | je @f |
||
185 | stdcall gl_eval_viewport,edx |
||
186 | mov dword[edx+offs_cont_viewport+offs_vpor_updated],0 |
||
187 | @@: |
||
188 | ; triangle drawing functions |
||
189 | cmp dword[edx+offs_cont_render_mode],GL_SELECT |
||
190 | jne @f |
||
191 | mov dword[edx+offs_cont_draw_triangle_front],gl_draw_triangle_select |
||
192 | mov dword[edx+offs_cont_draw_triangle_back],gl_draw_triangle_select |
||
193 | jmp .end_if_2 |
||
194 | @@: |
||
195 | |||
196 | |||
197 | jne @f |
||
198 | mov dword[edx+offs_cont_draw_triangle_front],gl_draw_triangle_point |
||
199 | jmp .end_if_1 |
||
200 | @@: |
||
201 | cmp dword[edx+offs_cont_polygon_mode_front],GL_LINE |
||
202 | jne @f |
||
203 | mov dword[edx+offs_cont_draw_triangle_front],gl_draw_triangle_line |
||
204 | jmp .end_if_1 |
||
205 | @@: ;default: |
||
206 | mov dword[edx+offs_cont_draw_triangle_front],gl_draw_triangle_fill |
||
207 | .end_if_1: |
||
208 | |||
209 | |||
210 | jne @f |
||
211 | mov dword[edx+offs_cont_draw_triangle_back],gl_draw_triangle_point |
||
212 | jmp .end_if_2 |
||
213 | @@: |
||
214 | cmp dword[edx+offs_cont_polygon_mode_back],GL_LINE |
||
215 | jne @f |
||
216 | mov dword[edx+offs_cont_draw_triangle_back],gl_draw_triangle_line |
||
217 | jmp .end_if_2 |
||
218 | @@: ;default: |
||
219 | mov dword[edx+offs_cont_draw_triangle_back],gl_draw_triangle_fill |
||
220 | .end_if_2: |
||
221 | ret |
||
222 | endp |
||
223 | |||
224 | |||
225 | ; TODO : handle all cases |
||
226 | align 4 |
||
227 | proc gl_vertex_transform, context:dword, v:dword |
||
228 | pushad |
||
229 | mov eax,[context] |
||
230 | mov edx,[v] |
||
231 | cmp dword[eax+offs_cont_lighting_enabled],0 ;if (context.lighting_enabled) |
||
232 | je .els_0 |
||
233 | ; eye coordinates needed for lighting |
||
234 | mov ebx,dword[eax+offs_cont_matrix_stack_ptr] |
||
235 | finit |
||
236 | fld dword[edx+offs_vert_coord+offs_X] |
||
237 | fld dword[edx+offs_vert_coord+offs_Y] |
||
238 | fld dword[edx+offs_vert_coord+offs_Z] |
||
239 | |||
240 | |||
241 | .cycle_0: |
||
242 | fld dword[ebx] ;st0 = m[0] |
||
243 | fmul st0,st3 ;st0 *= v.coord.X |
||
244 | fld dword[ebx+4] ;st0 = m[1] |
||
245 | fmul st0,st3 ;st0 *= v.coord.Y |
||
246 | fld dword[ebx+8] ;st0 = m[2] |
||
247 | fmul st0,st3 ;st0 *= v.coord.Z |
||
248 | fadd dword[ebx+12] ;st0 += m[3] |
||
249 | faddp ;st0 += v.coord.Z * m[2] |
||
5175 | IgorA | 250 | faddp ;st0 += v.coord.Y * m[1] |
251 | fstp dword[edx+offs_vert_ec] ;v.ec.X = v.coord.X * m[0] + v.coord.Y * m[1] + v.coord.Z * m[2] + m[3] |
||
5153 | IgorA | 252 | add ebx,16 ;следущая строка матрицы |
253 | add edx,4 ;следущая координата вектора |
||
254 | loop .cycle_0 |
||
255 | ffree st0 |
||
5218 | IgorA | 256 | fincstp |
257 | ffree st0 |
||
258 | fincstp |
||
259 | ffree st0 |
||
260 | fincstp |
||
261 | |||
5153 | IgorA | 262 | |
263 | mov ebx,dword[eax+offs_cont_matrix_stack_ptr+4] |
||
264 | mov edx,[v] |
||
265 | |||
5218 | IgorA | 266 | |
5153 | IgorA | 267 | fld dword[edx+offs_vert_ec+offs_Y] |
268 | fld dword[edx+offs_vert_ec+offs_Z] |
||
269 | |||
270 | |||
271 | .cycle_1: |
||
272 | fld dword[ebx] ;st0 = m[0] |
||
273 | fmul st0,st3 ;st0 *= v.ec.X |
||
274 | fld dword[ebx+4] ;st0 = m[1] |
||
275 | fmul st0,st3 ;st0 *= v.ec.Y |
||
276 | fld dword[ebx+8] ;st0 = m[2] |
||
277 | fmul st0,st3 ;st0 *= v.ec.Z |
||
278 | fadd dword[ebx+12] ;st0 += m[3] |
||
279 | faddp ;st0 += v.ec.Z * m[2] |
||
5175 | IgorA | 280 | faddp ;st0 += v.ec.Y * m[1] |
281 | fstp dword[edx+offs_vert_pc] ;v.pc.X = v.ec.X * m[0] + v.ec.Y * m[1] + v.ec.Z * m[2] + m[3] |
||
5153 | IgorA | 282 | add ebx,16 ;следущая строка матрицы |
283 | add edx,4 ;следущая координата вектора |
||
284 | loop .cycle_1 |
||
285 | ffree st0 |
||
5218 | IgorA | 286 | fincstp |
287 | ffree st0 |
||
288 | fincstp |
||
289 | ffree st0 |
||
290 | fincstp |
||
291 | |||
5153 | IgorA | 292 | |
293 | add ebx,offs_cont_matrix_model_view_inv |
||
294 | mov edi,eax |
||
295 | add edi,offs_cont_current_normal |
||
296 | mov edx,[v] |
||
297 | |||
5218 | IgorA | 298 | |
5153 | IgorA | 299 | fld dword[edi+offs_Y] |
300 | fld dword[edi+offs_Z] |
||
301 | |||
302 | |||
303 | .cycle_2: |
||
304 | fld dword[ebx] ;st0 = m[0] |
||
5218 | IgorA | 305 | fmul st0,st3 ;st0 *= n.X |
306 | fld dword[ebx+4] ;st0 = m[1] |
||
307 | fmul st0,st3 ;st0 *= n.Y |
||
308 | fld dword[ebx+8] ;st0 = m[2] |
||
309 | fmul st0,st3 ;st0 *= n.Z |
||
310 | faddp ;st0 += n.Z * m[2] |
||
311 | faddp ;st0 += n.Y * m[1] |
||
312 | fstp dword[edx+offs_vert_normal] ;v.normal.X = n.X * m[0] + n.Y * m[1] + n.Z * m[2] |
||
5153 | IgorA | 313 | add ebx,16 ;следущая строка матрицы |
314 | add edx,4 ;следущая координата вектора |
||
315 | loop .cycle_2 |
||
316 | |||
317 | |||
318 | je .end_els |
||
319 | mov edx,[v] |
||
5218 | IgorA | 320 | add edx,offs_vert_normal |
321 | stdcall gl_V3_Norm,edx |
||
322 | jmp .end_els |
||
5153 | IgorA | 323 | .els_0: |
324 | ; no eye coordinates needed, no normal |
||
325 | ; NOTE: W = 1 is assumed |
||
326 | mov ebx,eax |
||
327 | add ebx,offs_cont_matrix_model_projection |
||
328 | |||
329 | |||
330 | fld dword[edx+offs_vert_coord+offs_X] |
||
331 | fld dword[edx+offs_vert_coord+offs_Y] |
||
332 | fld dword[edx+offs_vert_coord+offs_Z] |
||
333 | |||
334 | |||
335 | add esi,offs_vert_pc |
||
336 | |||
337 | |||
338 | fmul st0,st3 ;st0 *= v.coord.X |
||
339 | fld dword[ebx+4] ;st0 = m[1] |
||
340 | fmul st0,st3 ;st0 *= v.coord.Y |
||
341 | fld dword[ebx+8] ;st0 = m[2] |
||
342 | fmul st0,st3 ;st0 *= v.coord.Z |
||
343 | fadd dword[ebx+12] ;st0 += m[3] |
||
344 | faddp ;st0 += v.coord.Z * m[2] |
||
5175 | IgorA | 345 | faddp ;st0 += v.coord.Y * m[1] |
346 | fstp dword[esi] ;v.pc.X = v.coord.X * m[0] + v.coord.Y * m[1] + v.coord.Z * m[2] + m[3] |
||
5153 | IgorA | 347 | |
5175 | IgorA | 348 | |
5153 | IgorA | 349 | fmul st0,st3 ;st0 *= v.coord.X |
350 | fld dword[ebx+20] ;st0 = m[5] |
||
351 | fmul st0,st3 ;st0 *= v.coord.Y |
||
352 | fld dword[ebx+24] ;st0 = m[6] |
||
353 | fmul st0,st3 ;st0 *= v.coord.Z |
||
354 | fadd dword[ebx+28] ;st0 += m[7] |
||
355 | faddp ;st0 += v.coord.Z * m[6] |
||
5175 | IgorA | 356 | faddp ;st0 += v.coord.Y * m[5] |
357 | fstp dword[esi+4] ;v.pc.X = v.coord.X * m[4] + v.coord.Y * m[5] + v.coord.Z * m[6] + m[7] |
||
5153 | IgorA | 358 | |
5175 | IgorA | 359 | |
5153 | IgorA | 360 | fmul st0,st3 ;st0 *= v.coord.X |
361 | fld dword[ebx+36] ;st0 = m[9] |
||
362 | fmul st0,st3 ;st0 *= v.coord.Y |
||
363 | fld dword[ebx+40] ;st0 = m[10] |
||
364 | fmul st0,st3 ;st0 *= v.coord.Z |
||
365 | fadd dword[ebx+44] ;st0 += m[11] |
||
366 | faddp ;st0 += v.coord.Z * m[10] |
||
5175 | IgorA | 367 | faddp ;st0 += v.coord.Y * m[9] |
368 | fstp dword[esi+8] ;v.pc.X = v.coord.X * m[8] + v.coord.Y * m[9] + v.coord.Z * m[10] + m[11] |
||
5153 | IgorA | 369 | |
370 | |||
371 | je .els_1 |
||
372 | ;if (context.matrix_model_projection_no_w_transform) |
||
373 | mov ebx,dword[ebx+60] ;ebx = m[15] |
||
374 | mov dword[esi+12],ebx ;v.pc.W = m[15] |
||
375 | jmp .end_els |
||
376 | .els_1: |
||
377 | fld dword[ebx+48] ;st0 = m[12] |
||
378 | fmul st0,st3 ;st0 *= v.coord.X |
||
379 | fld dword[ebx+52] ;st0 = m[13] |
||
380 | fmul st0,st3 ;st0 *= v.coord.Y |
||
381 | fld dword[ebx+56] ;st0 = m[14] |
||
382 | fmul st0,st3 ;st0 *= v.coord.Z |
||
383 | fadd dword[ebx+60] ;st0 += m[15] |
||
384 | faddp ;st0 += v.coord.Z * m[14] |
||
5175 | IgorA | 385 | faddp ;st0 += v.coord.Y * m[13] |
386 | fstp dword[esi+12] ;v.pc.W = v.coord.X * m[12] + v.coord.Y * m[13] + v.coord.Z * m[14] + m[15] |
||
5153 | IgorA | 387 | .end_els: |
388 | ffree st0 |
||
5175 | IgorA | 389 | fincstp |
390 | ffree st0 |
||
391 | fincstp |
||
392 | ffree st0 |
||
393 | fincstp |
||
394 | |||
395 | |||
5153 | IgorA | 396 | stdcall dbg_print,f_vt,txt_nl |
397 | mov edx,[v] |
||
398 | add edx,offs_vert_pc |
||
399 | stdcall gl_print_matrix,edx,1 |
||
400 | end if |
||
401 | mov edx,[v] |
||
402 | stdcall gl_clipcode, dword[edx+offs_vert_pc+offs_X], dword[edx+offs_vert_pc+offs_Y],\ |
||
403 | dword[edx+offs_vert_pc+offs_Z], dword[edx+offs_vert_pc+offs_W] |
||
404 | mov dword[edx+offs_vert_clip_code],eax |
||
405 | popad |
||
406 | ret |
||
407 | endp |
||
408 | |||
409 | |||
410 | proc glopVertex, context:dword, p:dword |
||
411 | locals |
||
412 | ;ebx = GLVertex * v |
||
413 | n dd ? ;ebp-4 |
||
414 | endl |
||
415 | pushad |
||
416 | mov edx,[context] |
||
417 | |||
418 | |||
419 | |||
420 | |||
421 | mov [n],ecx |
||
422 | inc dword[edx+offs_cont_vertex_cnt] |
||
423 | |||
424 | |||
425 | mov ecx,[edx+offs_cont_vertex_max] |
||
426 | cmp dword[n],ecx |
||
427 | jl @f |
||
428 | shl dword[edx+offs_cont_vertex_max],1 ; just double size |
||
429 | imul ecx,2*sizeof.GLVertex |
||
430 | stdcall gl_malloc,ecx |
||
431 | cmp eax,0 |
||
432 | jne .no_err |
||
433 | ;gl_fatal_error("unable to allocate GLVertex array.\n"); |
||
434 | .no_err: |
||
435 | mov edi,eax |
||
436 | mov ebx,eax |
||
437 | mov esi,[edx+offs_cont_vertex] |
||
438 | mov ecx,[n] |
||
439 | imul ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb |
||
440 | rep movsd |
||
441 | stdcall gl_free,dword[edx+offs_cont_vertex] |
||
442 | mov dword[edx+offs_cont_vertex],ebx |
||
443 | @@: |
||
444 | ; new vertex entry |
||
445 | mov ebx,[n] |
||
446 | imul ebx,sizeof.GLVertex |
||
447 | add ebx,[edx+offs_cont_vertex] |
||
448 | inc dword[n] |
||
449 | |||
450 | |||
451 | add esi,4 |
||
452 | mov edi,ebx |
||
453 | add edi,offs_vert_coord ;edi = &v.coord |
||
454 | mov ecx,4 |
||
455 | rep movsd |
||
456 | |||
457 | |||
458 | |||
459 | |||
460 | |||
461 | |||
462 | je .els_0 |
||
463 | stdcall gl_shade_vertex, edx,ebx |
||
464 | jmp @f |
||
465 | .els_0: |
||
466 | mov eax,[edx+offs_cont_current_color] |
||
467 | mov [ebx+offs_vert_color],eax |
||
468 | mov eax,[edx+offs_cont_current_color+4] |
||
5213 | IgorA | 469 | mov [ebx+offs_vert_color+4],eax |
470 | mov eax,[edx+offs_cont_current_color+8] |
||
471 | mov [ebx+offs_vert_color+8],eax |
||
472 | @@: |
||
5153 | IgorA | 473 | |
474 | |||
475 | cmp dword[edx+offs_cont_texture_2d_enabled],0 |
||
476 | je @f |
||
477 | cmp dword[edx+offs_cont_apply_texture_matrix],0 |
||
478 | je .els_1 |
||
479 | ; gl_M4_MulV4(&v->tex_coord, c->matrix_stack_ptr[2], &c->current_tex_coord); |
||
480 | jmp @f |
||
481 | .els_1: |
||
482 | mov eax,[edx+offs_cont_current_tex_coord] |
||
483 | mov [ebx+offs_vert_tex_coord],eax |
||
484 | @@: |
||
485 | |||
486 | |||
487 | cmp dword[ebx+offs_vert_clip_code],0 |
||
488 | jne @f |
||
489 | stdcall gl_transform_to_viewport, edx,ebx |
||
490 | @@: |
||
491 | |||
492 | |||
493 | mov eax,[edx+offs_cont_current_edge_flag] |
||
494 | mov dword[ebx+offs_vert_edge_flag],eax ;v.edge_flag = context.current_edge_flag |
||
495 | |||
496 | |||
497 | jne @f |
||
498 | stdcall gl_draw_point, edx, dword[edx+offs_cont_vertex] ;dword[edx+...] = &context.vertex[0] |
||
499 | mov dword[n],0 |
||
500 | jmp .end_f |
||
501 | @@: |
||
502 | cmp dword[edx+offs_cont_begin_type],GL_LINES |
||
503 | jne @f |
||
504 | cmp dword[n],2 |
||
505 | jne .end_f |
||
506 | mov eax,[edx+offs_cont_vertex] |
||
507 | push eax |
||
508 | add eax,sizeof.GLVertex |
||
509 | stdcall gl_draw_line, edx, eax |
||
5175 | IgorA | 510 | xor eax,eax |
5153 | IgorA | 511 | mov dword[n],eax |
512 | jmp .end_f |
||
513 | @@: |
||
514 | cmp dword[edx+offs_cont_begin_type],GL_LINE_STRIP |
||
515 | je .li_loop |
||
516 | cmp dword[edx+offs_cont_begin_type],GL_LINE_LOOP |
||
517 | jne @f |
||
518 | .li_loop: |
||
519 | cmp dword[n],1 |
||
520 | jne .els_2 |
||
521 | mov esi,[edx+offs_cont_vertex] |
||
522 | mov edi,esi |
||
523 | add edi,2*sizeof.GLVertex |
||
524 | mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb |
||
525 | rep movsd ;context.vertex[2] = context.vertex[0] |
||
526 | jmp .end_f |
||
527 | .els_2: |
||
528 | cmp dword[n],2 |
||
529 | jne .end_f ;else if (n == 2) |
||
530 | mov eax,[edx+offs_cont_vertex] |
||
531 | push eax |
||
532 | mov edi,eax |
||
5218 | IgorA | 533 | add eax,sizeof.GLVertex |
5153 | IgorA | 534 | mov esi,eax |
5218 | IgorA | 535 | stdcall gl_draw_line, edx, eax |
5175 | IgorA | 536 | mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb |
5153 | IgorA | 537 | rep movsd ;context.vertex[0] = context.vertex[1] |
538 | mov dword[n],1 |
||
539 | jmp .end_f |
||
540 | @@: |
||
541 | cmp dword[edx+offs_cont_begin_type],GL_TRIANGLES |
||
542 | jne @f |
||
543 | cmp dword[n],3 |
||
544 | jne .end_f |
||
545 | mov eax,[edx+offs_cont_vertex] |
||
5175 | IgorA | 546 | mov [esp-4],eax |
5218 | IgorA | 547 | add eax,sizeof.GLVertex |
5175 | IgorA | 548 | mov [esp-8],eax |
5218 | IgorA | 549 | add eax,sizeof.GLVertex |
5175 | IgorA | 550 | mov [esp-12],eax |
5218 | IgorA | 551 | sub esp,12 |
552 | stdcall gl_draw_triangle, edx |
||
553 | xor eax,eax |
||
5153 | IgorA | 554 | mov dword[n],eax |
555 | jmp .end_f |
||
556 | @@: |
||
557 | cmp dword[edx+offs_cont_begin_type],GL_TRIANGLE_STRIP |
||
558 | jne @f |
||
559 | ; if (c->vertex_cnt >= 3) { |
||
560 | ; if (n == 3) |
||
561 | ; n = 0; |
||
562 | ; /* needed to respect triangle orientation */ |
||
563 | ; switch(c->vertex_cnt & 1) { |
||
564 | ; case 0: |
||
565 | ; gl_draw_triangle(c,&c->vertex[2],&c->vertex[1],&c->vertex[0]); |
||
566 | ; break; |
||
567 | ; default: |
||
568 | ; case 1: |
||
569 | ; gl_draw_triangle(c,&c->vertex[0],&c->vertex[1],&c->vertex[2]); |
||
570 | ; break; |
||
571 | ; } |
||
572 | ; } |
||
573 | jmp .end_f |
||
574 | @@: |
||
575 | cmp dword[edx+offs_cont_begin_type],GL_TRIANGLE_FAN |
||
576 | jne @f |
||
577 | cmp dword[n],3 |
||
5218 | IgorA | 578 | jne .end_f |
5153 | IgorA | 579 | mov eax,[edx+offs_cont_vertex] |
5218 | IgorA | 580 | mov [esp-4],eax |
581 | add eax,sizeof.GLVertex |
||
582 | mov [esp-8],eax |
||
583 | mov edi,eax |
||
584 | add eax,sizeof.GLVertex |
||
585 | mov [esp-12],eax |
||
586 | mov esi,eax |
||
587 | sub esp,12 |
||
588 | stdcall gl_draw_triangle, edx |
||
589 | mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb |
||
590 | rep movsd ;context.vertex[1] = context.vertex[2] |
||
591 | mov dword[n],2 |
||
5153 | IgorA | 592 | jmp .end_f |
593 | @@: |
||
594 | cmp dword[edx+offs_cont_begin_type],GL_QUADS |
||
595 | jne @f |
||
596 | cmp dword[n],4 |
||
597 | jne .end_f |
||
598 | mov eax,[edx+offs_cont_vertex] |
||
5213 | IgorA | 599 | add eax,2*sizeof.GLVertex |
600 | mov dword[eax+offs_vert_edge_flag],0 ;context.vertex[2].edge_flag = 0 |
||
601 | push eax |
||
602 | sub eax,sizeof.GLVertex |
||
603 | push eax |
||
604 | sub eax,sizeof.GLVertex |
||
605 | stdcall gl_draw_triangle, edx,eax ;v0,v1,v2 |
||
606 | mov dword[eax+offs_vert_edge_flag],0 ;context.vertex[0].edge_flag = 0 |
||
607 | add eax,2*sizeof.GLVertex |
||
608 | mov dword[eax+offs_vert_edge_flag],1 ;context.vertex[2].edge_flag = 1 |
||
609 | add eax,sizeof.GLVertex |
||
610 | push eax |
||
611 | sub eax,sizeof.GLVertex |
||
612 | push eax |
||
613 | sub eax,2*sizeof.GLVertex |
||
614 | stdcall gl_draw_triangle, edx,eax ;v0,v2,v3 |
||
615 | xor eax,eax |
||
5153 | IgorA | 616 | mov dword[n],eax |
617 | jmp .end_f |
||
618 | @@: |
||
619 | cmp dword[edx+offs_cont_begin_type],GL_QUAD_STRIP |
||
620 | jne @f |
||
621 | cmp dword[n],4 |
||
5218 | IgorA | 622 | jne .end_f |
5153 | IgorA | 623 | mov eax,[edx+offs_cont_vertex] |
5218 | IgorA | 624 | mov [esp-4],eax |
625 | mov edi,eax |
||
626 | add eax,sizeof.GLVertex |
||
627 | mov [esp-8],eax |
||
628 | add eax,sizeof.GLVertex |
||
629 | mov [esp-12],eax |
||
630 | mov esi,eax |
||
631 | sub esp,12 |
||
632 | stdcall gl_draw_triangle, edx ;v0,v1,v2 |
||
633 | mov [esp-12],eax |
||
634 | add eax,sizeof.GLVertex |
||
635 | mov [esp-8],eax |
||
636 | sub eax,2*sizeof.GLVertex |
||
637 | mov [esp-4],eax |
||
638 | sub esp,12 |
||
639 | stdcall gl_draw_triangle, edx ;v1,v3,v2 |
||
640 | mov ecx,(sizeof.GLVertex)/2 ;((...)/2) копируем 2 вершины |
||
641 | rep movsd ;context.vertex[0] = context.vertex[2], context.vertex[1] = context.vertex[3] |
||
642 | mov dword[n],2 |
||
5153 | IgorA | 643 | jmp .end_f |
644 | @@: |
||
645 | cmp dword[edx+offs_cont_begin_type],GL_POLYGON |
||
646 | je .end_f |
||
5213 | IgorA | 647 | ; default: |
5153 | IgorA | 648 | ; gl_fatal_error("glBegin: type %x not handled\n", c->begin_type); |
649 | ; } |
||
650 | .end_f: |
||
651 | |||
652 | |||
653 | mov [edx+offs_cont_vertex_n],ecx |
||
654 | popad |
||
655 | ret |
||
656 | endp |
||
657 | |||
658 | |||
659 | proc glopEnd uses eax ebx ecx, context:dword, p:dword |
||
5213 | IgorA | 660 | mov eax,[context] |
5153 | IgorA | 661 | ; assert(c->in_begin == 1); |
662 | |||
663 | |||
664 | jne .else_i |
||
665 | cmp dword[eax+offs_cont_vertex_cnt],3 |
||
666 | jl .end_i |
||
667 | mov ebx,[eax+offs_cont_vertex] |
||
668 | push ebx |
||
669 | add ebx,2*sizeof.GLVertex |
||
670 | push ebx |
||
671 | stdcall gl_draw_line, eax |
||
672 | jmp .end_i |
||
673 | .else_i: |
||
674 | cmp dword[eax+offs_cont_begin_type],GL_POLYGON |
||
675 | jne .end_i |
||
676 | mov ebx,dword[eax+offs_cont_vertex_cnt] |
||
677 | @@: ;while (ebx >= 3) |
||
678 | cmp ebx,3 |
||
679 | jl .end_i |
||
680 | dec ebx |
||
5213 | IgorA | 681 | mov ecx,ebx |
682 | imul ecx,sizeof.GLVertex |
||
683 | add ecx,[eax+offs_cont_vertex] |
||
684 | push ecx ;ecx = &context.vertex[i] |
||
685 | sub ecx,sizeof.GLVertex |
||
686 | push ecx ;ecx = &context.vertex[i-1] |
||
687 | stdcall gl_draw_triangle, eax,[eax+offs_cont_vertex] |
||
688 | jmp @b |
||
5153 | IgorA | 689 | .end_i: |
690 | mov dword[eax+offs_cont_in_begin],0 |
||
691 | ret |
||
692 | endp |
||
693 |