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