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