Rev 5153 | Rev 5213 | 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,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 | finit |
||
239 | fld dword[edx+offs_vert_coord+offs_X] |
||
240 | fld dword[edx+offs_vert_coord+offs_Y] |
||
241 | fld dword[edx+offs_vert_coord+offs_Z] |
||
242 | |||
243 | |||
244 | .cycle_0: |
||
245 | fld dword[ebx] ;st0 = m[0] |
||
246 | fmul st0,st3 ;st0 *= v.coord.X |
||
247 | fld dword[ebx+4] ;st0 = m[1] |
||
248 | fmul st0,st3 ;st0 *= v.coord.Y |
||
249 | fld dword[ebx+8] ;st0 = m[2] |
||
250 | fmul st0,st3 ;st0 *= v.coord.Z |
||
251 | fadd dword[ebx+12] ;st0 += m[3] |
||
252 | faddp ;st0 += v.coord.Z * m[2] |
||
5175 | IgorA | 253 | faddp ;st0 += v.coord.Y * m[1] |
254 | 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 | 255 | add ebx,16 ;следущая строка матрицы |
256 | add edx,4 ;следущая координата вектора |
||
257 | loop .cycle_0 |
||
258 | |||
259 | |||
260 | mov ebx,dword[eax+offs_cont_matrix_stack_ptr+4] |
||
261 | mov edx,[v] |
||
262 | finit |
||
263 | fld dword[edx+offs_vert_ec+offs_X] |
||
264 | fld dword[edx+offs_vert_ec+offs_Y] |
||
265 | fld dword[edx+offs_vert_ec+offs_Z] |
||
266 | |||
267 | |||
268 | .cycle_1: |
||
269 | fld dword[ebx] ;st0 = m[0] |
||
270 | fmul st0,st3 ;st0 *= v.ec.X |
||
271 | fld dword[ebx+4] ;st0 = m[1] |
||
272 | fmul st0,st3 ;st0 *= v.ec.Y |
||
273 | fld dword[ebx+8] ;st0 = m[2] |
||
274 | fmul st0,st3 ;st0 *= v.ec.Z |
||
275 | fadd dword[ebx+12] ;st0 += m[3] |
||
276 | faddp ;st0 += v.ec.Z * m[2] |
||
5175 | IgorA | 277 | faddp ;st0 += v.ec.Y * m[1] |
278 | 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 | 279 | add ebx,16 ;следущая строка матрицы |
280 | add edx,4 ;следущая координата вектора |
||
281 | loop .cycle_1 |
||
282 | |||
283 | |||
284 | add ebx,offs_cont_matrix_model_view_inv |
||
285 | mov edi,eax |
||
286 | add edi,offs_cont_current_normal |
||
287 | mov edx,[v] |
||
288 | finit |
||
289 | fld dword[edi+offs_X] |
||
290 | fld dword[edi+offs_Y] |
||
291 | fld dword[edi+offs_Z] |
||
292 | |||
293 | |||
294 | .cycle_2: |
||
295 | fld dword[ebx] ;st0 = m[0] |
||
296 | fmul st0,st3 ;st0 *= n.X |
||
297 | fld dword[ebx+4] ;st0 = m[1] |
||
298 | fmul st0,st3 ;st0 *= n.Y |
||
299 | fld dword[ebx+8] ;st0 = m[2] |
||
300 | fmul st0,st3 ;st0 *= n.Z |
||
301 | faddp ;st0 += n.Z * m[2] |
||
5175 | IgorA | 302 | faddp ;st0 += n.Y * m[1] |
303 | fstp dword[edx+offs_vert_normal] ;v.normal.X = n.X * m[0] + n.Y * m[1] + n.Z * m[2] |
||
5153 | IgorA | 304 | add ebx,16 ;следущая строка матрицы |
305 | add edx,4 ;следущая координата вектора |
||
306 | loop .cycle_2 |
||
307 | |||
308 | |||
309 | je .end_els |
||
310 | ;stdcall gl_V3_Norm(&v->normal) |
||
311 | jmp .end_els |
||
312 | .els_0: |
||
313 | ; no eye coordinates needed, no normal |
||
314 | ; NOTE: W = 1 is assumed |
||
315 | mov ebx,eax |
||
316 | add ebx,offs_cont_matrix_model_projection |
||
317 | |||
318 | |||
319 | fld dword[edx+offs_vert_coord+offs_X] |
||
320 | fld dword[edx+offs_vert_coord+offs_Y] |
||
321 | fld dword[edx+offs_vert_coord+offs_Z] |
||
322 | |||
323 | |||
324 | add esi,offs_vert_pc |
||
325 | |||
326 | |||
327 | fmul st0,st3 ;st0 *= v.coord.X |
||
328 | fld dword[ebx+4] ;st0 = m[1] |
||
329 | fmul st0,st3 ;st0 *= v.coord.Y |
||
330 | fld dword[ebx+8] ;st0 = m[2] |
||
331 | fmul st0,st3 ;st0 *= v.coord.Z |
||
332 | fadd dword[ebx+12] ;st0 += m[3] |
||
333 | faddp ;st0 += v.coord.Z * m[2] |
||
5175 | IgorA | 334 | faddp ;st0 += v.coord.Y * m[1] |
335 | 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 | 336 | |
5175 | IgorA | 337 | |
5153 | IgorA | 338 | fmul st0,st3 ;st0 *= v.coord.X |
339 | fld dword[ebx+20] ;st0 = m[5] |
||
340 | fmul st0,st3 ;st0 *= v.coord.Y |
||
341 | fld dword[ebx+24] ;st0 = m[6] |
||
342 | fmul st0,st3 ;st0 *= v.coord.Z |
||
343 | fadd dword[ebx+28] ;st0 += m[7] |
||
344 | faddp ;st0 += v.coord.Z * m[6] |
||
5175 | IgorA | 345 | faddp ;st0 += v.coord.Y * m[5] |
346 | 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 | 347 | |
5175 | IgorA | 348 | |
5153 | IgorA | 349 | fmul st0,st3 ;st0 *= v.coord.X |
350 | fld dword[ebx+36] ;st0 = m[9] |
||
351 | fmul st0,st3 ;st0 *= v.coord.Y |
||
352 | fld dword[ebx+40] ;st0 = m[10] |
||
353 | fmul st0,st3 ;st0 *= v.coord.Z |
||
354 | fadd dword[ebx+44] ;st0 += m[11] |
||
355 | faddp ;st0 += v.coord.Z * m[10] |
||
5175 | IgorA | 356 | faddp ;st0 += v.coord.Y * m[9] |
357 | 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 | 358 | |
359 | |||
360 | je .els_1 |
||
361 | ;if (context.matrix_model_projection_no_w_transform) |
||
362 | mov ebx,dword[ebx+60] ;ebx = m[15] |
||
363 | mov dword[esi+12],ebx ;v.pc.W = m[15] |
||
364 | jmp .end_els |
||
365 | .els_1: |
||
366 | fld dword[ebx+48] ;st0 = m[12] |
||
367 | fmul st0,st3 ;st0 *= v.coord.X |
||
368 | fld dword[ebx+52] ;st0 = m[13] |
||
369 | fmul st0,st3 ;st0 *= v.coord.Y |
||
370 | fld dword[ebx+56] ;st0 = m[14] |
||
371 | fmul st0,st3 ;st0 *= v.coord.Z |
||
372 | fadd dword[ebx+60] ;st0 += m[15] |
||
373 | faddp ;st0 += v.coord.Z * m[14] |
||
5175 | IgorA | 374 | faddp ;st0 += v.coord.Y * m[13] |
375 | 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 | 376 | .end_els: |
377 | ffree st0 |
||
5175 | IgorA | 378 | fincstp |
379 | ffree st0 |
||
380 | fincstp |
||
381 | ffree st0 |
||
382 | fincstp |
||
383 | |||
384 | |||
5153 | IgorA | 385 | stdcall dbg_print,f_vt,txt_nl |
386 | mov edx,[v] |
||
387 | add edx,offs_vert_pc |
||
388 | stdcall gl_print_matrix,edx,1 |
||
389 | end if |
||
390 | mov edx,[v] |
||
391 | stdcall gl_clipcode, dword[edx+offs_vert_pc+offs_X], dword[edx+offs_vert_pc+offs_Y],\ |
||
392 | dword[edx+offs_vert_pc+offs_Z], dword[edx+offs_vert_pc+offs_W] |
||
393 | mov dword[edx+offs_vert_clip_code],eax |
||
394 | popad |
||
395 | ret |
||
396 | endp |
||
397 | |||
398 | |||
399 | proc glopVertex, context:dword, p:dword |
||
400 | locals |
||
401 | ;ebx = GLVertex * v |
||
402 | n dd ? ;ebp-4 |
||
403 | endl |
||
404 | pushad |
||
405 | mov edx,[context] |
||
406 | |||
407 | |||
408 | |||
409 | |||
410 | mov [n],ecx |
||
411 | inc dword[edx+offs_cont_vertex_cnt] |
||
412 | |||
413 | |||
414 | mov ecx,[edx+offs_cont_vertex_max] |
||
415 | cmp dword[n],ecx |
||
416 | jl @f |
||
417 | shl dword[edx+offs_cont_vertex_max],1 ; just double size |
||
418 | imul ecx,2*sizeof.GLVertex |
||
419 | stdcall gl_malloc,ecx |
||
420 | cmp eax,0 |
||
421 | jne .no_err |
||
422 | ;gl_fatal_error("unable to allocate GLVertex array.\n"); |
||
423 | .no_err: |
||
424 | mov edi,eax |
||
425 | mov ebx,eax |
||
426 | mov esi,[edx+offs_cont_vertex] |
||
427 | mov ecx,[n] |
||
428 | imul ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb |
||
429 | rep movsd |
||
430 | stdcall gl_free,dword[edx+offs_cont_vertex] |
||
431 | mov dword[edx+offs_cont_vertex],ebx |
||
432 | @@: |
||
433 | ; new vertex entry |
||
434 | mov ebx,[n] |
||
435 | imul ebx,sizeof.GLVertex |
||
436 | add ebx,[edx+offs_cont_vertex] |
||
437 | inc dword[n] |
||
438 | |||
439 | |||
440 | add esi,4 |
||
441 | mov edi,ebx |
||
442 | add edi,offs_vert_coord ;edi = &v.coord |
||
443 | mov ecx,4 |
||
444 | rep movsd |
||
445 | |||
446 | |||
447 | |||
448 | |||
449 | |||
450 | |||
451 | je .els_0 |
||
452 | stdcall gl_shade_vertex, edx,ebx |
||
453 | jmp @f |
||
454 | .els_0: |
||
455 | mov eax,[edx+offs_cont_current_color] |
||
456 | mov [ebx+offs_vert_color],eax |
||
457 | @@: |
||
458 | |||
459 | |||
460 | cmp dword[edx+offs_cont_texture_2d_enabled],0 |
||
461 | je @f |
||
462 | cmp dword[edx+offs_cont_apply_texture_matrix],0 |
||
463 | je .els_1 |
||
464 | ; gl_M4_MulV4(&v->tex_coord, c->matrix_stack_ptr[2], &c->current_tex_coord); |
||
465 | jmp @f |
||
466 | .els_1: |
||
467 | mov eax,[edx+offs_cont_current_tex_coord] |
||
468 | mov [ebx+offs_vert_tex_coord],eax |
||
469 | @@: |
||
470 | |||
471 | |||
472 | cmp dword[ebx+offs_vert_clip_code],0 |
||
473 | jne @f |
||
474 | stdcall gl_transform_to_viewport, edx,ebx |
||
475 | @@: |
||
476 | |||
477 | |||
478 | mov eax,[edx+offs_cont_current_edge_flag] |
||
479 | mov dword[ebx+offs_vert_edge_flag],eax ;v.edge_flag = context.current_edge_flag |
||
480 | |||
481 | |||
482 | jne @f |
||
483 | stdcall gl_draw_point, edx, dword[edx+offs_cont_vertex] ;dword[edx+...] = &context.vertex[0] |
||
484 | mov dword[n],0 |
||
485 | jmp .end_f |
||
486 | @@: |
||
487 | cmp dword[edx+offs_cont_begin_type],GL_LINES |
||
488 | jne @f |
||
489 | cmp dword[n],2 |
||
490 | jne .end_f |
||
491 | mov eax,[edx+offs_cont_vertex] |
||
492 | push eax |
||
493 | add eax,sizeof.GLVertex |
||
494 | stdcall gl_draw_line, edx, eax |
||
5175 | IgorA | 495 | xor eax,eax |
5153 | IgorA | 496 | mov dword[n],eax |
497 | jmp .end_f |
||
498 | @@: |
||
499 | cmp dword[edx+offs_cont_begin_type],GL_LINE_STRIP |
||
500 | je .li_loop |
||
501 | cmp dword[edx+offs_cont_begin_type],GL_LINE_LOOP |
||
502 | jne @f |
||
503 | .li_loop: |
||
504 | cmp dword[n],1 |
||
505 | jne .els_2 |
||
506 | mov esi,[edx+offs_cont_vertex] |
||
507 | mov edi,esi |
||
508 | add edi,2*sizeof.GLVertex |
||
509 | mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb |
||
510 | rep movsd ;context.vertex[2] = context.vertex[0] |
||
511 | jmp .end_f |
||
512 | .els_2: |
||
513 | cmp dword[n],2 |
||
514 | jne .end_f ;else if (n == 2) |
||
515 | mov eax,[edx+offs_cont_vertex] |
||
516 | push eax |
||
517 | add eax,sizeof.GLVertex |
||
518 | stdcall gl_draw_line, edx, eax |
||
5175 | IgorA | 519 | mov edi,[edx+offs_cont_vertex] |
5153 | IgorA | 520 | mov esi,edi |
521 | add esi,sizeof.GLVertex |
||
522 | mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb |
||
523 | rep movsd ;context.vertex[0] = context.vertex[1] |
||
524 | mov dword[n],1 |
||
525 | jmp .end_f |
||
526 | @@: |
||
527 | cmp dword[edx+offs_cont_begin_type],GL_TRIANGLES |
||
528 | jne @f |
||
529 | cmp dword[n],3 |
||
530 | jne .end_f |
||
531 | mov eax,[edx+offs_cont_vertex] |
||
5175 | IgorA | 532 | push eax |
533 | add eax,sizeof.GLVertex |
||
534 | push eax |
||
535 | add eax,sizeof.GLVertex |
||
536 | stdcall gl_draw_triangle, edx, eax |
||
537 | xor eax,eax |
||
5153 | IgorA | 538 | mov dword[n],eax |
539 | jmp .end_f |
||
540 | @@: |
||
541 | cmp dword[edx+offs_cont_begin_type],GL_TRIANGLE_STRIP |
||
542 | jne @f |
||
543 | ; if (c->vertex_cnt >= 3) { |
||
544 | ; if (n == 3) |
||
545 | ; n = 0; |
||
546 | ; /* needed to respect triangle orientation */ |
||
547 | ; switch(c->vertex_cnt & 1) { |
||
548 | ; case 0: |
||
549 | ; gl_draw_triangle(c,&c->vertex[2],&c->vertex[1],&c->vertex[0]); |
||
550 | ; break; |
||
551 | ; default: |
||
552 | ; case 1: |
||
553 | ; gl_draw_triangle(c,&c->vertex[0],&c->vertex[1],&c->vertex[2]); |
||
554 | ; break; |
||
555 | ; } |
||
556 | ; } |
||
557 | jmp .end_f |
||
558 | @@: |
||
559 | cmp dword[edx+offs_cont_begin_type],GL_TRIANGLE_FAN |
||
560 | jne @f |
||
561 | cmp dword[n],2 |
||
562 | jne .end_f |
||
563 | ; gl_draw_triangle(c, &c->vertex[0], &c->vertex[1], &c->vertex[2]); |
||
564 | ; c->vertex[1] = c->vertex[2]; |
||
565 | mov dword[n],2 |
||
566 | jmp .end_f |
||
567 | @@: |
||
568 | cmp dword[edx+offs_cont_begin_type],GL_QUADS |
||
569 | jne @f |
||
570 | cmp dword[n],4 |
||
571 | jne .end_f |
||
572 | ; c->vertex[2].edge_flag = 0; |
||
573 | ; gl_draw_triangle(c, &c->vertex[0], &c->vertex[1], &c->vertex[2]); |
||
574 | ; c->vertex[2].edge_flag = 1; |
||
575 | ; c->vertex[0].edge_flag = 0; |
||
576 | ; gl_draw_triangle(c, &c->vertex[0], &c->vertex[2], &c->vertex[3]); |
||
577 | xor eax,eax |
||
578 | mov dword[n],eax |
||
579 | jmp .end_f |
||
580 | @@: |
||
581 | cmp dword[edx+offs_cont_begin_type],GL_QUAD_STRIP |
||
582 | jne @f |
||
583 | cmp dword[n],2 |
||
584 | jne .end_f |
||
585 | ; gl_draw_triangle(c, &c->vertex[0], &c->vertex[1], &c->vertex[2]); |
||
586 | ; gl_draw_triangle(c, &c->vertex[1], &c->vertex[3], &c->vertex[2]); |
||
587 | ; for (i = 0; i < 2; i++) |
||
588 | ; c->vertex[i] = c->vertex[i + 2]; |
||
589 | mov dword[n],2 |
||
590 | jmp .end_f |
||
591 | @@: |
||
592 | cmp dword[edx+offs_cont_begin_type],GL_POLYGON |
||
593 | jne @f |
||
594 | ;... |
||
595 | jmp .end_f |
||
596 | @@: |
||
597 | ; default: |
||
598 | ; gl_fatal_error("glBegin: type %x not handled\n", c->begin_type); |
||
599 | ; } |
||
600 | .end_f: |
||
601 | |||
602 | |||
603 | mov [edx+offs_cont_vertex_n],ecx |
||
604 | popad |
||
605 | ret |
||
606 | endp |
||
607 | |||
608 | |||
609 | proc glopEnd uses eax ebx, context:dword, p:dword |
||
610 | mov eax,[context] |
||
611 | ; assert(c->in_begin == 1); |
||
612 | |||
613 | |||
614 | jne .else_i |
||
615 | cmp dword[eax+offs_cont_vertex_cnt],3 |
||
616 | jl .end_i |
||
617 | mov ebx,[eax+offs_cont_vertex] |
||
618 | push ebx |
||
619 | add ebx,2*sizeof.GLVertex |
||
620 | push ebx |
||
621 | stdcall gl_draw_line, eax |
||
622 | jmp .end_i |
||
623 | .else_i: |
||
624 | cmp dword[eax+offs_cont_begin_type],GL_POLYGON |
||
625 | jne .end_i |
||
626 | mov ebx,dword[eax+offs_cont_vertex_cnt] |
||
627 | @@: ;while (ebx >= 3) |
||
628 | cmp ebx,3 |
||
629 | jl .end_i |
||
630 | dec ebx |
||
631 | ; gl_draw_triangle(c, &c->vertex[i], &c->vertex[0], &c->vertex[i - 1]); |
||
632 | jmp @b |
||
633 | .end_i: |
||
634 | mov dword[eax+offs_cont_in_begin],0 |
||
635 | ret |
||
636 | endp> |
||
637 |