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