Rev 6145 | Rev 8062 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6145 | Rev 6523 | ||
---|---|---|---|
Line 5... | Line 5... | ||
5 | align 16 |
5 | align 16 |
6 | proc glopNormal uses ecx esi edi, context:dword, p:dword |
6 | proc glopNormal uses ecx esi edi, context:dword, p:dword |
7 | mov esi,[p] |
7 | mov esi,[p] |
8 | add esi,4 |
8 | add esi,4 |
9 | mov edi,[context] |
9 | mov edi,[context] |
10 | add edi,offs_cont_current_normal |
10 | add edi,GLContext.current_normal |
11 | mov ecx,3 |
11 | mov ecx,3 |
12 | rep movsd |
12 | rep movsd |
13 | mov dword[edi],0.0 ;context.current_normal.W = 0.0 |
13 | mov dword[edi],0.0 ;context.current_normal.W = 0.0 |
14 | ret |
14 | ret |
15 | endp |
15 | endp |
Line 17... | Line 17... | ||
17 | align 16 |
17 | align 16 |
18 | proc glopTexCoord uses ecx esi edi, context:dword, p:dword |
18 | proc glopTexCoord uses ecx esi edi, context:dword, p:dword |
19 | mov esi,[p] |
19 | mov esi,[p] |
20 | add esi,4 |
20 | add esi,4 |
21 | mov edi,[context] |
21 | mov edi,[context] |
22 | add edi,offs_cont_current_tex_coord |
22 | add edi,GLContext.current_tex_coord |
23 | mov ecx,4 |
23 | mov ecx,4 |
24 | rep movsd |
24 | rep movsd |
25 | ret |
25 | ret |
26 | endp |
26 | endp |
Line 27... | Line 27... | ||
27 | 27 | ||
28 | align 16 |
28 | align 16 |
29 | proc glopEdgeFlag uses eax ebx, context:dword, p:dword |
29 | proc glopEdgeFlag uses eax ebx, context:dword, p:dword |
30 | mov eax,[context] |
30 | mov eax,[context] |
31 | mov ebx,[p] |
31 | mov ebx,[p] |
32 | mov ebx,[ebx+4] ;ebx = p[1] |
32 | mov ebx,[ebx+4] ;ebx = p[1] |
33 | mov dword[eax+offs_cont_current_edge_flag],ebx |
33 | mov dword[eax+GLContext.current_edge_flag],ebx |
34 | ret |
34 | ret |
Line 35... | Line 35... | ||
35 | endp |
35 | endp |
36 | 36 | ||
Line 42... | Line 42... | ||
42 | ;current_color[3] = p[1-4] |
42 | ;current_color[3] = p[1-4] |
43 | ;longcurrent_color[2] = p[5-7] |
43 | ;longcurrent_color[2] = p[5-7] |
44 | mov esi,[p] |
44 | mov esi,[p] |
45 | add esi,4 |
45 | add esi,4 |
46 | mov edi,[context] |
46 | mov edi,[context] |
47 | add edi,offs_cont_current_color |
47 | add edi,GLContext.current_color |
48 | mov ecx,7 |
48 | mov ecx,7 |
49 | rep movsd |
49 | rep movsd |
Line 50... | Line 50... | ||
50 | 50 | ||
51 | mov eax,[context] |
51 | mov eax,[context] |
52 | cmp dword[eax+offs_cont_color_material_enabled],0 |
52 | cmp dword[eax+GLContext.color_material_enabled],0 |
53 | je @f |
53 | je @f |
54 | mov dword[q],OP_Material |
54 | mov dword[q],OP_Material |
55 | mov ecx,[eax+offs_cont_current_color_material_mode] |
55 | mov ecx,[eax+GLContext.current_color_material_mode] |
56 | mov dword[q+4],ecx |
56 | mov dword[q+4],ecx |
57 | mov ecx,[eax+offs_cont_current_color_material_type] |
57 | mov ecx,[eax+GLContext.current_color_material_type] |
58 | mov dword[q+8],ecx |
58 | mov dword[q+8],ecx |
59 | mov esi,[p] |
59 | mov esi,[p] |
60 | add esi,4 |
60 | add esi,4 |
61 | mov edi,ebp |
61 | mov edi,ebp |
Line 73... | Line 73... | ||
73 | proc gl_eval_viewport uses eax, context:dword |
73 | proc gl_eval_viewport uses eax, context:dword |
74 | locals |
74 | locals |
75 | zsize dd ? ;float |
75 | zsize dd ? ;float |
76 | endl |
76 | endl |
77 | mov eax,[context] |
77 | mov eax,[context] |
78 | add eax,offs_cont_viewport ;eax = (GLViewport*) v |
78 | add eax,GLContext.viewport ;eax = (GLViewport*) v |
Line 79... | Line 79... | ||
79 | 79 | ||
80 | mov dword[zsize],(1 shl (ZB_Z_BITS + ZB_POINT_Z_FRAC_BITS)) |
80 | mov dword[zsize],(1 shl (ZB_Z_BITS + ZB_POINT_Z_FRAC_BITS)) |
81 | fild dword[zsize] |
81 | fild dword[zsize] |
Line 123... | Line 123... | ||
123 | ;assert(context.in_begin == 0) |
123 | ;assert(context.in_begin == 0) |
Line 124... | Line 124... | ||
124 | 124 | ||
125 | mov edx,[context] |
125 | mov edx,[context] |
126 | mov ebx,[p] |
126 | mov ebx,[p] |
127 | mov ebx,[ebx+4] ;ebx = p[1] |
127 | mov ebx,[ebx+4] ;ebx = p[1] |
128 | mov [edx+offs_cont_begin_type],ebx |
128 | mov [edx+GLContext.begin_type],ebx |
129 | mov dword[edx+offs_cont_in_begin],1 |
129 | mov dword[edx+GLContext.in_begin],1 |
130 | mov dword[edx+offs_cont_vertex_n],0 |
130 | mov dword[edx+GLContext.vertex_n],0 |
Line 131... | Line 131... | ||
131 | mov dword[edx+offs_cont_vertex_cnt],0 |
131 | mov dword[edx+GLContext.vertex_cnt],0 |
132 | 132 | ||
Line 133... | Line 133... | ||
133 | bt dword[edx+offs_cont_matrix_model_projection_updated],0 |
133 | bt dword[edx+GLContext.matrix_model_projection_updated],0 |
134 | jnc .end_mmpu |
134 | jnc .end_mmpu |
135 | 135 | ||
136 | cmp dword[edx+offs_cont_lighting_enabled],0 ;if(context.lighting_enabled) |
136 | cmp dword[edx+GLContext.lighting_enabled],0 ;if(context.lighting_enabled) |
137 | jne .if_0 |
137 | jne .if_0 |
138 | cmp dword[eax+offs_cont_texture_2d_enabled],0 |
138 | cmp dword[eax+GLContext.texture_2d_enabled],0 |
139 | jne .if_0 |
139 | jne .if_0 |
140 | jmp @f |
140 | jmp @f |
141 | align 4 |
141 | align 4 |
142 | .if_0: |
142 | .if_0: |
143 | if DEBUG ;context.matrix_stack_ptr[0] |
143 | if DEBUG ;context.matrix_stack_ptr[0] |
144 | stdcall gl_print_matrix,dword[edx+offs_cont_matrix_stack_ptr],4 |
144 | stdcall gl_print_matrix,dword[edx+GLContext.matrix_stack_ptr],4 |
145 | end if |
145 | end if |
146 | ; precompute inverse modelview |
146 | ; precompute inverse modelview |
147 | mov ebx,ebp |
147 | mov ebx,ebp |
148 | sub ebx,sizeof.M4 |
148 | sub ebx,sizeof.M4 |
149 | stdcall gl_M4_Inv, ebx,dword[edx+offs_cont_matrix_stack_ptr] |
149 | stdcall gl_M4_Inv, ebx,dword[edx+GLContext.matrix_stack_ptr] |
150 | if DEBUG ;tmp |
150 | if DEBUG ;tmp |
151 | stdcall dbg_print,txt_sp,txt_nl |
151 | stdcall dbg_print,txt_sp,txt_nl |
152 | stdcall gl_print_matrix,ebx,4 |
152 | stdcall gl_print_matrix,ebx,4 |
153 | end if |
153 | end if |
154 | push ebx |
154 | push ebx |
155 | mov ebx,edx |
155 | mov ebx,edx |
156 | add ebx,offs_cont_matrix_model_view_inv |
156 | add ebx,GLContext.matrix_model_view_inv |
157 | stdcall gl_M4_Transpose, ebx |
157 | stdcall gl_M4_Transpose, ebx |
158 | if DEBUG ;context.matrix_model_view_inv |
158 | if DEBUG ;context.matrix_model_view_inv |
159 | stdcall dbg_print,txt_sp,txt_nl |
159 | stdcall dbg_print,txt_sp,txt_nl |
160 | stdcall gl_print_matrix,ebx,4 |
160 | stdcall gl_print_matrix,ebx,4 |
161 | end if |
161 | end if |
162 | jmp .end_if_0 |
162 | jmp .end_if_0 |
163 | align 4 |
163 | align 4 |
164 | @@: |
164 | @@: |
165 | mov ecx,edx |
165 | mov ecx,edx |
Line 166... | Line 166... | ||
166 | add ecx,offs_cont_matrix_model_projection |
166 | add ecx,GLContext.matrix_model_projection |
167 | ; precompute projection matrix |
167 | ; precompute projection matrix |
168 | stdcall gl_M4_Mul, ecx,dword[edx+offs_cont_matrix_stack_ptr+4],dword[edx+offs_cont_matrix_stack_ptr] |
168 | stdcall gl_M4_Mul, ecx,dword[edx+GLContext.matrix_stack_ptr+4],dword[edx+GLContext.matrix_stack_ptr] |
169 | 169 | ||
170 | ; test to accelerate computation |
170 | ; test to accelerate computation |
171 | mov dword[edx+offs_cont_matrix_model_projection_no_w_transform],0 |
171 | mov dword[edx+GLContext.matrix_model_projection_no_w_transform],0 |
172 | fldz |
172 | fldz |
Line 183... | Line 183... | ||
183 | fld dword[ecx+14*4] |
183 | fld dword[ecx+14*4] |
184 | fcomp st1 |
184 | fcomp st1 |
185 | fstsw ax |
185 | fstsw ax |
186 | sahf |
186 | sahf |
187 | jne @f |
187 | jne @f |
188 | mov dword[edx+offs_cont_matrix_model_projection_no_w_transform],1 |
188 | mov dword[edx+GLContext.matrix_model_projection_no_w_transform],1 |
189 | @@: |
189 | @@: |
190 | ffree st0 ;0.0 |
190 | ffree st0 ;0.0 |
191 | fincstp |
191 | fincstp |
192 | .end_if_0: |
192 | .end_if_0: |
Line 193... | Line 193... | ||
193 | 193 | ||
194 | ; test if the texture matrix is not Identity |
194 | ; test if the texture matrix is not Identity |
195 | mov eax,edx |
195 | mov eax,edx |
196 | add eax,offs_cont_matrix_stack_ptr+8 |
196 | add eax,GLContext.matrix_stack_ptr+8 |
197 | stdcall gl_M4_IsId,eax |
197 | stdcall gl_M4_IsId,eax |
198 | xor eax,1 |
198 | xor eax,1 |
Line 199... | Line 199... | ||
199 | mov dword[edx+offs_cont_apply_texture_matrix],eax |
199 | mov dword[edx+GLContext.apply_texture_matrix],eax |
200 | 200 | ||
Line 201... | Line 201... | ||
201 | mov dword[edx+offs_cont_matrix_model_projection_updated],0 |
201 | mov dword[edx+GLContext.matrix_model_projection_updated],0 |
202 | .end_mmpu: |
202 | .end_mmpu: |
203 | 203 | ||
204 | ; viewport |
204 | ; viewport |
205 | cmp dword[edx+offs_cont_viewport+offs_vpor_updated],0 ;if (context.viewport.updated) |
205 | cmp dword[edx+GLContext.viewport+offs_vpor_updated],0 ;if (context.viewport.updated) |
206 | je @f |
206 | je @f |
207 | stdcall gl_eval_viewport,edx |
207 | stdcall gl_eval_viewport,edx |
208 | mov dword[edx+offs_cont_viewport+offs_vpor_updated],0 |
208 | mov dword[edx+GLContext.viewport+offs_vpor_updated],0 |
209 | @@: |
209 | @@: |
210 | ; triangle drawing functions |
210 | ; triangle drawing functions |
211 | cmp dword[edx+offs_cont_render_mode],GL_SELECT |
211 | cmp dword[edx+GLContext.render_mode],GL_SELECT |
212 | jne @f |
212 | jne @f |
213 | mov dword[edx+offs_cont_draw_triangle_front],gl_draw_triangle_select |
213 | mov dword[edx+GLContext.draw_triangle_front],gl_draw_triangle_select |
214 | mov dword[edx+offs_cont_draw_triangle_back],gl_draw_triangle_select |
214 | mov dword[edx+GLContext.draw_triangle_back],gl_draw_triangle_select |
Line 215... | Line 215... | ||
215 | jmp .end_if_2 |
215 | jmp .end_if_2 |
216 | align 4 |
216 | align 4 |
217 | @@: |
217 | @@: |
218 | 218 | ||
219 | cmp dword[edx+offs_cont_polygon_mode_front],GL_POINT |
219 | cmp dword[edx+GLContext.polygon_mode_front],GL_POINT |
220 | jne @f |
220 | jne @f |
221 | mov dword[edx+offs_cont_draw_triangle_front],gl_draw_triangle_point |
221 | mov dword[edx+GLContext.draw_triangle_front],gl_draw_triangle_point |
222 | jmp .end_if_1 |
222 | jmp .end_if_1 |
223 | align 4 |
223 | align 4 |
224 | @@: |
224 | @@: |
225 | cmp dword[edx+offs_cont_polygon_mode_front],GL_LINE |
225 | cmp dword[edx+GLContext.polygon_mode_front],GL_LINE |
226 | jne @f |
226 | jne @f |
227 | mov dword[edx+offs_cont_draw_triangle_front],gl_draw_triangle_line |
227 | mov dword[edx+GLContext.draw_triangle_front],gl_draw_triangle_line |
228 | jmp .end_if_1 |
228 | jmp .end_if_1 |
Line 229... | Line 229... | ||
229 | align 4 |
229 | align 4 |
230 | @@: ;default: |
230 | @@: ;default: |
231 | mov dword[edx+offs_cont_draw_triangle_front],gl_draw_triangle_fill |
231 | mov dword[edx+GLContext.draw_triangle_front],gl_draw_triangle_fill |
232 | .end_if_1: |
232 | .end_if_1: |
233 | 233 | ||
234 | cmp dword[edx+offs_cont_polygon_mode_back],GL_POINT |
234 | cmp dword[edx+GLContext.polygon_mode_back],GL_POINT |
235 | jne @f |
235 | jne @f |
236 | mov dword[edx+offs_cont_draw_triangle_back],gl_draw_triangle_point |
236 | mov dword[edx+GLContext.draw_triangle_back],gl_draw_triangle_point |
237 | jmp .end_if_2 |
237 | jmp .end_if_2 |
238 | align 4 |
238 | align 4 |
239 | @@: |
239 | @@: |
240 | cmp dword[edx+offs_cont_polygon_mode_back],GL_LINE |
240 | cmp dword[edx+GLContext.polygon_mode_back],GL_LINE |
241 | jne @f |
241 | jne @f |
242 | mov dword[edx+offs_cont_draw_triangle_back],gl_draw_triangle_line |
242 | mov dword[edx+GLContext.draw_triangle_back],gl_draw_triangle_line |
243 | jmp .end_if_2 |
243 | jmp .end_if_2 |
244 | align 4 |
244 | align 4 |
Line 245... | Line 245... | ||
245 | @@: ;default: |
245 | @@: ;default: |
Line 253... | Line 253... | ||
253 | align 16 |
253 | align 16 |
254 | proc gl_vertex_transform, context:dword, v:dword |
254 | proc gl_vertex_transform, context:dword, v:dword |
255 | pushad |
255 | pushad |
256 | mov eax,[context] |
256 | mov eax,[context] |
257 | mov edx,[v] |
257 | mov edx,[v] |
258 | cmp dword[eax+offs_cont_lighting_enabled],0 ;if (context.lighting_enabled) |
258 | cmp dword[eax+GLContext.lighting_enabled],0 ;if (context.lighting_enabled) |
259 | jne @f |
259 | jne @f |
260 | cmp dword[eax+offs_cont_texture_2d_enabled],0 |
260 | cmp dword[eax+GLContext.texture_2d_enabled],0 |
261 | jne @f |
261 | jne @f |
262 | jmp .els_0 |
262 | jmp .els_0 |
263 | align 4 |
263 | align 4 |
264 | @@: |
264 | @@: |
265 | ; eye coordinates needed for lighting |
265 | ; eye coordinates needed for lighting |
266 | mov ebx,dword[eax+offs_cont_matrix_stack_ptr] |
266 | mov ebx,dword[eax+GLContext.matrix_stack_ptr] |
267 | finit |
267 | finit |
268 | fld dword[edx+offs_vert_coord+offs_X] |
268 | fld dword[edx+offs_vert_coord+offs_X] |
269 | fld dword[edx+offs_vert_coord+offs_Y] |
269 | fld dword[edx+offs_vert_coord+offs_Y] |
270 | fld dword[edx+offs_vert_coord+offs_Z] |
270 | fld dword[edx+offs_vert_coord+offs_Z] |
Line 290... | Line 290... | ||
290 | fincstp |
290 | fincstp |
291 | ffree st0 |
291 | ffree st0 |
292 | fincstp |
292 | fincstp |
Line 293... | Line 293... | ||
293 | 293 | ||
294 | ; projection coordinates |
294 | ; projection coordinates |
295 | mov ebx,dword[eax+offs_cont_matrix_stack_ptr+4] |
295 | mov ebx,dword[eax+GLContext.matrix_stack_ptr+4] |
Line 296... | Line 296... | ||
296 | mov edx,[v] |
296 | mov edx,[v] |
297 | 297 | ||
298 | fld dword[edx+offs_vert_ec+offs_X] |
298 | fld dword[edx+offs_vert_ec+offs_X] |
Line 325... | Line 325... | ||
325 | fincstp |
325 | fincstp |
326 | ffree st0 |
326 | ffree st0 |
327 | fincstp |
327 | fincstp |
Line 328... | Line 328... | ||
328 | 328 | ||
329 | mov ebx,eax |
329 | mov ebx,eax |
330 | add ebx,offs_cont_matrix_model_view_inv |
330 | add ebx,GLContext.matrix_model_view_inv |
331 | mov edi,eax |
331 | mov edi,eax |
332 | add edi,offs_cont_current_normal |
332 | add edi,GLContext.current_normal |
Line 333... | Line 333... | ||
333 | mov edx,[v] |
333 | mov edx,[v] |
334 | 334 | ||
335 | fld dword[edi] ;edi = &n |
335 | fld dword[edi] ;edi = &n |
Line 366... | Line 366... | ||
366 | fld dword[ebx+40];st0 = m[10] |
366 | fld dword[ebx+40];st0 = m[10] |
367 | fmul st0,st2 ;st0 *= n.Z |
367 | fmul st0,st2 ;st0 *= n.Z |
368 | faddp ;st0 = v.normal.X |
368 | faddp ;st0 = v.normal.X |
369 | fstp dword[edx+8];v.normal.X = n.X * m[8] + n.Y * m[9] + n.Z * m[10] |
369 | fstp dword[edx+8];v.normal.X = n.X * m[8] + n.Y * m[9] + n.Z * m[10] |
Line 370... | Line 370... | ||
370 | 370 | ||
371 | cmp dword[eax+offs_cont_normalize_enabled],0 |
371 | cmp dword[eax+GLContext.normalize_enabled],0 |
372 | je .end_els |
372 | je .end_els |
373 | stdcall gl_V3_Norm,edx |
373 | stdcall gl_V3_Norm,edx |
374 | jmp .end_els |
374 | jmp .end_els |
375 | align 4 |
375 | align 4 |
376 | .els_0: |
376 | .els_0: |
377 | ; no eye coordinates needed, no normal |
377 | ; no eye coordinates needed, no normal |
378 | ; NOTE: W = 1 is assumed |
378 | ; NOTE: W = 1 is assumed |
379 | mov ebx,eax |
379 | mov ebx,eax |
Line 380... | Line 380... | ||
380 | add ebx,offs_cont_matrix_model_projection |
380 | add ebx,GLContext.matrix_model_projection |
381 | 381 | ||
382 | finit |
382 | finit |
383 | fld dword[edx+offs_vert_coord+offs_X] |
383 | fld dword[edx+offs_vert_coord+offs_X] |
Line 418... | Line 418... | ||
418 | fmul st0,st2 ;st0 *= v.coord.Z |
418 | fmul st0,st2 ;st0 *= v.coord.Z |
419 | fadd dword[ebx+44] ;st0 += m[11] |
419 | fadd dword[ebx+44] ;st0 += m[11] |
420 | faddp ;st0 = v.pc.Z |
420 | faddp ;st0 = v.pc.Z |
421 | fstp dword[esi+8] ;v.pc.Z = v.coord.X * m[8] + v.coord.Y * m[9] + v.coord.Z * m[10] + m[11] |
421 | fstp dword[esi+8] ;v.pc.Z = v.coord.X * m[8] + v.coord.Y * m[9] + v.coord.Z * m[10] + m[11] |
Line 422... | Line 422... | ||
422 | 422 | ||
423 | cmp dword[eax+offs_cont_matrix_model_projection_no_w_transform],0 |
423 | cmp dword[eax+GLContext.matrix_model_projection_no_w_transform],0 |
424 | je .els_1 |
424 | je .els_1 |
425 | ;if (context.matrix_model_projection_no_w_transform) |
425 | ;if (context.matrix_model_projection_no_w_transform) |
426 | mov ebx,dword[ebx+60] ;ebx = m[15] |
426 | mov ebx,dword[ebx+60] ;ebx = m[15] |
427 | mov dword[esi+12],ebx ;v.pc.W = m[15] |
427 | mov dword[esi+12],ebx ;v.pc.W = m[15] |
Line 469... | Line 469... | ||
469 | pushad |
469 | pushad |
470 | mov edx,[context] |
470 | mov edx,[context] |
Line 471... | Line 471... | ||
471 | 471 | ||
Line 472... | Line 472... | ||
472 | ; assert(c->in_begin != 0); |
472 | ; assert(c->in_begin != 0); |
473 | 473 | ||
474 | mov ecx,[edx+offs_cont_vertex_n] |
474 | mov ecx,[edx+GLContext.vertex_n] |
Line 475... | Line 475... | ||
475 | mov [n],ecx |
475 | mov [n],ecx |
476 | inc dword[edx+offs_cont_vertex_cnt] |
476 | inc dword[edx+GLContext.vertex_cnt] |
477 | 477 | ||
478 | ; quick fix to avoid crashes on large polygons |
478 | ; quick fix to avoid crashes on large polygons |
479 | mov ecx,[edx+offs_cont_vertex_max] |
479 | mov ecx,[edx+GLContext.vertex_max] |
480 | cmp dword[n],ecx |
480 | cmp dword[n],ecx |
481 | jl @f |
481 | jl @f |
482 | shl dword[edx+offs_cont_vertex_max],1 ; just double size |
482 | shl dword[edx+GLContext.vertex_max],1 ; just double size |
483 | imul ecx,2*sizeof.GLVertex |
483 | imul ecx,2*sizeof.GLVertex |
484 | stdcall gl_malloc,ecx |
484 | stdcall gl_malloc,ecx |
485 | cmp eax,0 |
485 | cmp eax,0 |
486 | jne .no_err |
486 | jne .no_err |
487 | ;gl_fatal_error("unable to allocate GLVertex array.\n"); |
487 | ;gl_fatal_error("unable to allocate GLVertex array.\n"); |
488 | .no_err: |
488 | .no_err: |
489 | mov edi,eax |
489 | mov edi,eax |
490 | mov ebx,eax |
490 | mov ebx,eax |
491 | mov esi,[edx+offs_cont_vertex] |
491 | mov esi,[edx+GLContext.vertex] |
492 | mov ecx,[n] |
492 | mov ecx,[n] |
493 | imul ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb |
493 | imul ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb |
494 | rep movsd |
494 | rep movsd |
495 | stdcall gl_free,dword[edx+offs_cont_vertex] |
495 | stdcall gl_free,dword[edx+GLContext.vertex] |
496 | mov dword[edx+offs_cont_vertex],ebx |
496 | mov dword[edx+GLContext.vertex],ebx |
497 | @@: |
497 | @@: |
498 | ; new vertex entry |
498 | ; new vertex entry |
499 | mov ebx,[n] |
499 | mov ebx,[n] |
Line 500... | Line 500... | ||
500 | imul ebx,sizeof.GLVertex |
500 | imul ebx,sizeof.GLVertex |
501 | add ebx,[edx+offs_cont_vertex] |
501 | add ebx,[edx+GLContext.vertex] |
502 | inc dword[n] |
502 | inc dword[n] |
Line 509... | Line 509... | ||
509 | rep movsd |
509 | rep movsd |
Line 510... | Line 510... | ||
510 | 510 | ||
Line 511... | Line 511... | ||
511 | stdcall gl_vertex_transform, edx, ebx |
511 | stdcall gl_vertex_transform, edx, ebx |
512 | 512 | ||
513 | ; color |
513 | ; color |
514 | cmp dword[edx+offs_cont_lighting_enabled],0 |
514 | cmp dword[edx+GLContext.lighting_enabled],0 |
515 | je .els_0 |
515 | je .els_0 |
516 | stdcall gl_shade_vertex, edx,ebx |
516 | stdcall gl_shade_vertex, edx,ebx |
517 | jmp @f |
517 | jmp @f |
518 | align 4 |
518 | align 4 |
519 | .els_0: |
519 | .els_0: |
520 | mov esi,edx |
520 | mov esi,edx |
521 | add esi,offs_cont_current_color |
521 | add esi,GLContext.current_color |
522 | mov edi,ebx |
522 | mov edi,ebx |
523 | add edi,offs_vert_color ;edi = &v.color |
523 | add edi,offs_vert_color ;edi = &v.color |
524 | mov ecx,4 |
524 | mov ecx,4 |
Line 525... | Line 525... | ||
525 | rep movsd |
525 | rep movsd |
526 | @@: |
526 | @@: |
527 | 527 | ||
528 | ; tex coords |
528 | ; tex coords |
529 | cmp dword[edx+offs_cont_texture_2d_enabled],0 |
529 | cmp dword[edx+GLContext.texture_2d_enabled],0 |
530 | je @f |
530 | je @f |
531 | cmp dword[edx+offs_cont_apply_texture_matrix],0 |
531 | cmp dword[edx+GLContext.apply_texture_matrix],0 |
532 | je .els_1 |
532 | je .els_1 |
533 | mov eax,edx |
533 | mov eax,edx |
534 | add eax,offs_cont_current_tex_coord |
534 | add eax,GLContext.current_tex_coord |
535 | push eax ;&context.current_tex_coord |
535 | push eax ;&context.current_tex_coord |
536 | mov eax,ebx |
536 | mov eax,ebx |
537 | add eax,offs_vert_tex_coord |
537 | add eax,offs_vert_tex_coord |
538 | stdcall gl_M4_MulV4, eax, dword[edx+offs_cont_matrix_stack_ptr+8] |
538 | stdcall gl_M4_MulV4, eax, dword[edx+GLContext.matrix_stack_ptr+8] |
539 | jmp @f |
539 | jmp @f |
540 | align 4 |
540 | align 4 |
541 | .els_1: |
541 | .els_1: |
542 | mov esi,edx |
542 | mov esi,edx |
543 | add esi,offs_cont_current_tex_coord |
543 | add esi,GLContext.current_tex_coord |
544 | mov edi,ebx |
544 | mov edi,ebx |
545 | add edi,offs_vert_tex_coord |
545 | add edi,offs_vert_tex_coord |
Line 552... | Line 552... | ||
552 | jne @f |
552 | jne @f |
553 | stdcall gl_transform_to_viewport, edx,ebx |
553 | stdcall gl_transform_to_viewport, edx,ebx |
554 | @@: |
554 | @@: |
Line 555... | Line 555... | ||
555 | 555 | ||
556 | ; edge flag |
556 | ; edge flag |
557 | mov eax,[edx+offs_cont_current_edge_flag] |
557 | mov eax,[edx+GLContext.current_edge_flag] |
Line 558... | Line 558... | ||
558 | mov dword[ebx+offs_vert_edge_flag],eax ;v.edge_flag = context.current_edge_flag |
558 | mov dword[ebx+offs_vert_edge_flag],eax ;v.edge_flag = context.current_edge_flag |
559 | 559 | ||
560 | cmp dword[edx+offs_cont_begin_type],GL_POINTS |
560 | cmp dword[edx+GLContext.begin_type],GL_POINTS |
561 | jne @f |
561 | jne @f |
562 | stdcall gl_draw_point, edx, dword[edx+offs_cont_vertex] ;dword[edx+...] = &context.vertex[0] |
562 | stdcall gl_draw_point, edx, dword[edx+GLContext.vertex] ;dword[edx+...] = &context.vertex[0] |
563 | mov dword[n],0 |
563 | mov dword[n],0 |
564 | jmp .end_f |
564 | jmp .end_f |
565 | align 4 |
565 | align 4 |
566 | @@: |
566 | @@: |
567 | cmp dword[edx+offs_cont_begin_type],GL_LINES |
567 | cmp dword[edx+GLContext.begin_type],GL_LINES |
568 | jne @f |
568 | jne @f |
569 | cmp dword[n],2 |
569 | cmp dword[n],2 |
570 | jne .end_f |
570 | jne .end_f |
571 | mov eax,[edx+offs_cont_vertex] |
571 | mov eax,[edx+GLContext.vertex] |
572 | push eax |
572 | push eax |
573 | add eax,sizeof.GLVertex |
573 | add eax,sizeof.GLVertex |
574 | stdcall gl_draw_line, edx, eax |
574 | stdcall gl_draw_line, edx, eax |
575 | xor eax,eax |
575 | xor eax,eax |
576 | mov dword[n],eax |
576 | mov dword[n],eax |
577 | jmp .end_f |
577 | jmp .end_f |
578 | align 4 |
578 | align 4 |
579 | @@: |
579 | @@: |
580 | cmp dword[edx+offs_cont_begin_type],GL_LINE_STRIP |
580 | cmp dword[edx+GLContext.begin_type],GL_LINE_STRIP |
581 | je .li_loop |
581 | je .li_loop |
582 | cmp dword[edx+offs_cont_begin_type],GL_LINE_LOOP |
582 | cmp dword[edx+GLContext.begin_type],GL_LINE_LOOP |
583 | jne @f |
583 | jne @f |
584 | .li_loop: |
584 | .li_loop: |
585 | cmp dword[n],1 |
585 | cmp dword[n],1 |
586 | jne .els_2 |
586 | jne .els_2 |
587 | mov esi,[edx+offs_cont_vertex] |
587 | mov esi,[edx+GLContext.vertex] |
588 | mov edi,esi |
588 | mov edi,esi |
589 | add edi,2*sizeof.GLVertex |
589 | add edi,2*sizeof.GLVertex |
590 | mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb |
590 | mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb |
591 | rep movsd ;context.vertex[2] = context.vertex[0] |
591 | rep movsd ;context.vertex[2] = context.vertex[0] |
592 | jmp .end_f |
592 | jmp .end_f |
593 | align 4 |
593 | align 4 |
594 | .els_2: |
594 | .els_2: |
595 | cmp dword[n],2 |
595 | cmp dword[n],2 |
596 | jne .end_f ;else if (n == 2) |
596 | jne .end_f ;else if (n == 2) |
597 | mov eax,[edx+offs_cont_vertex] |
597 | mov eax,[edx+GLContext.vertex] |
598 | push eax |
598 | push eax |
599 | mov edi,eax |
599 | mov edi,eax |
600 | add eax,sizeof.GLVertex |
600 | add eax,sizeof.GLVertex |
Line 604... | Line 604... | ||
604 | rep movsd ;context.vertex[0] = context.vertex[1] |
604 | rep movsd ;context.vertex[0] = context.vertex[1] |
605 | mov dword[n],1 |
605 | mov dword[n],1 |
606 | jmp .end_f |
606 | jmp .end_f |
607 | align 4 |
607 | align 4 |
608 | @@: |
608 | @@: |
609 | cmp dword[edx+offs_cont_begin_type],GL_TRIANGLES |
609 | cmp dword[edx+GLContext.begin_type],GL_TRIANGLES |
610 | jne @f |
610 | jne @f |
611 | cmp dword[n],3 |
611 | cmp dword[n],3 |
612 | jne .end_f |
612 | jne .end_f |
613 | mov eax,[edx+offs_cont_vertex] |
613 | mov eax,[edx+GLContext.vertex] |
614 | mov [esp-12],eax |
614 | mov [esp-12],eax |
615 | add eax,sizeof.GLVertex |
615 | add eax,sizeof.GLVertex |
616 | mov [esp-8],eax |
616 | mov [esp-8],eax |
617 | add eax,sizeof.GLVertex |
617 | add eax,sizeof.GLVertex |
618 | mov [esp-4],eax |
618 | mov [esp-4],eax |
Line 621... | Line 621... | ||
621 | xor eax,eax |
621 | xor eax,eax |
622 | mov dword[n],eax |
622 | mov dword[n],eax |
623 | jmp .end_f |
623 | jmp .end_f |
624 | align 4 |
624 | align 4 |
625 | @@: |
625 | @@: |
626 | cmp dword[edx+offs_cont_begin_type],GL_TRIANGLE_STRIP |
626 | cmp dword[edx+GLContext.begin_type],GL_TRIANGLE_STRIP |
627 | jne @f |
627 | jne @f |
628 | cmp dword[edx+offs_cont_vertex_cnt],3 ;if (context.vertex_cnt >= 3) |
628 | cmp dword[edx+GLContext.vertex_cnt],3 ;if (context.vertex_cnt >= 3) |
629 | jl .end_f |
629 | jl .end_f |
630 | cmp dword[n],3 |
630 | cmp dword[n],3 |
631 | jne .ts3 |
631 | jne .ts3 |
632 | xor eax,eax |
632 | xor eax,eax |
633 | mov dword[n],eax |
633 | mov dword[n],eax |
634 | .ts3: |
634 | .ts3: |
635 | ; needed to respect triangle orientation |
635 | ; needed to respect triangle orientation |
636 | mov eax,[edx+offs_cont_vertex] |
636 | mov eax,[edx+GLContext.vertex] |
637 | bt dword[edx+offs_cont_vertex_cnt],0 |
637 | bt dword[edx+GLContext.vertex_cnt],0 |
638 | jc .case_1 |
638 | jc .case_1 |
639 | mov [esp-4],eax |
639 | mov [esp-4],eax |
640 | add eax,sizeof.GLVertex |
640 | add eax,sizeof.GLVertex |
641 | mov [esp-8],eax |
641 | mov [esp-8],eax |
642 | add eax,sizeof.GLVertex |
642 | add eax,sizeof.GLVertex |
Line 654... | Line 654... | ||
654 | sub esp,12 |
654 | sub esp,12 |
655 | stdcall gl_draw_triangle, edx ;v0,v1,v2 |
655 | stdcall gl_draw_triangle, edx ;v0,v1,v2 |
656 | jmp .end_f |
656 | jmp .end_f |
657 | align 4 |
657 | align 4 |
658 | @@: |
658 | @@: |
659 | cmp dword[edx+offs_cont_begin_type],GL_TRIANGLE_FAN |
659 | cmp dword[edx+GLContext.begin_type],GL_TRIANGLE_FAN |
660 | jne @f |
660 | jne @f |
661 | cmp dword[n],3 |
661 | cmp dword[n],3 |
662 | jne .end_f |
662 | jne .end_f |
663 | mov eax,[edx+offs_cont_vertex] |
663 | mov eax,[edx+GLContext.vertex] |
664 | mov [esp-12],eax |
664 | mov [esp-12],eax |
665 | add eax,sizeof.GLVertex |
665 | add eax,sizeof.GLVertex |
666 | mov [esp-8],eax |
666 | mov [esp-8],eax |
667 | mov edi,eax |
667 | mov edi,eax |
668 | add eax,sizeof.GLVertex |
668 | add eax,sizeof.GLVertex |
Line 674... | Line 674... | ||
674 | rep movsd ;context.vertex[1] = context.vertex[2] |
674 | rep movsd ;context.vertex[1] = context.vertex[2] |
675 | mov dword[n],2 |
675 | mov dword[n],2 |
676 | jmp .end_f |
676 | jmp .end_f |
677 | align 4 |
677 | align 4 |
678 | @@: |
678 | @@: |
679 | cmp dword[edx+offs_cont_begin_type],GL_QUADS |
679 | cmp dword[edx+GLContext.begin_type],GL_QUADS |
680 | jne @f |
680 | jne @f |
681 | cmp dword[n],4 |
681 | cmp dword[n],4 |
682 | jne .end_f |
682 | jne .end_f |
683 | mov eax,[edx+offs_cont_vertex] |
683 | mov eax,[edx+GLContext.vertex] |
684 | add eax,2*sizeof.GLVertex |
684 | add eax,2*sizeof.GLVertex |
685 | mov dword[eax+offs_vert_edge_flag],0 ;context.vertex[2].edge_flag = 0 |
685 | mov dword[eax+offs_vert_edge_flag],0 ;context.vertex[2].edge_flag = 0 |
686 | push eax |
686 | push eax |
687 | sub eax,sizeof.GLVertex |
687 | sub eax,sizeof.GLVertex |
688 | push eax |
688 | push eax |
Line 700... | Line 700... | ||
700 | xor eax,eax |
700 | xor eax,eax |
701 | mov dword[n],eax |
701 | mov dword[n],eax |
702 | jmp .end_f |
702 | jmp .end_f |
703 | align 4 |
703 | align 4 |
704 | @@: |
704 | @@: |
705 | cmp dword[edx+offs_cont_begin_type],GL_QUAD_STRIP |
705 | cmp dword[edx+GLContext.begin_type],GL_QUAD_STRIP |
706 | jne @f |
706 | jne @f |
707 | cmp dword[n],4 |
707 | cmp dword[n],4 |
708 | jne .end_f |
708 | jne .end_f |
709 | mov eax,[edx+offs_cont_vertex] |
709 | mov eax,[edx+GLContext.vertex] |
710 | mov [esp-12],eax |
710 | mov [esp-12],eax |
711 | mov edi,eax |
711 | mov edi,eax |
712 | add eax,sizeof.GLVertex |
712 | add eax,sizeof.GLVertex |
713 | mov [esp-8],eax |
713 | mov [esp-8],eax |
714 | add eax,sizeof.GLVertex |
714 | add eax,sizeof.GLVertex |
Line 727... | Line 727... | ||
727 | rep movsd ;context.vertex[0] = context.vertex[2], context.vertex[1] = context.vertex[3] |
727 | rep movsd ;context.vertex[0] = context.vertex[2], context.vertex[1] = context.vertex[3] |
728 | mov dword[n],2 |
728 | mov dword[n],2 |
729 | jmp .end_f |
729 | jmp .end_f |
730 | align 4 |
730 | align 4 |
731 | @@: |
731 | @@: |
732 | cmp dword[edx+offs_cont_begin_type],GL_POLYGON |
732 | cmp dword[edx+GLContext.begin_type],GL_POLYGON |
733 | je .end_f |
733 | je .end_f |
734 | ; default: |
734 | ; default: |
735 | ; gl_fatal_error("glBegin: type %x not handled\n", c->begin_type); |
735 | ; gl_fatal_error("glBegin: type %x not handled\n", c->begin_type); |
736 | ; } |
736 | ; } |
737 | .end_f: |
737 | .end_f: |
Line 738... | Line 738... | ||
738 | 738 | ||
739 | mov ecx,[n] |
739 | mov ecx,[n] |
740 | mov [edx+offs_cont_vertex_n],ecx |
740 | mov [edx+GLContext.vertex_n],ecx |
741 | popad |
741 | popad |
742 | ret |
742 | ret |
Line 743... | Line 743... | ||
743 | endp |
743 | endp |
744 | 744 | ||
745 | align 16 |
745 | align 16 |
746 | proc glopEnd uses eax ebx ecx, context:dword, p:dword |
746 | proc glopEnd uses eax ebx ecx, context:dword, p:dword |
Line 747... | Line 747... | ||
747 | mov eax,[context] |
747 | mov eax,[context] |
748 | ; assert(c->in_begin == 1); |
748 | ; assert(c->in_begin == 1); |
749 | 749 | ||
750 | cmp dword[eax+offs_cont_begin_type],GL_LINE_LOOP |
750 | cmp dword[eax+GLContext.begin_type],GL_LINE_LOOP |
751 | jne .else_i |
751 | jne .else_i |
752 | cmp dword[eax+offs_cont_vertex_cnt],3 |
752 | cmp dword[eax+GLContext.vertex_cnt],3 |
753 | jl .end_i |
753 | jl .end_i |
754 | mov ebx,[eax+offs_cont_vertex] |
754 | mov ebx,[eax+GLContext.vertex] |
755 | push ebx |
755 | push ebx |
756 | add ebx,2*sizeof.GLVertex |
756 | add ebx,2*sizeof.GLVertex |
757 | push ebx |
757 | push ebx |
758 | stdcall gl_draw_line, eax |
758 | stdcall gl_draw_line, eax |
759 | jmp .end_i |
759 | jmp .end_i |
760 | align 4 |
760 | align 4 |
761 | .else_i: |
761 | .else_i: |
762 | cmp dword[eax+offs_cont_begin_type],GL_POLYGON |
762 | cmp dword[eax+GLContext.begin_type],GL_POLYGON |
763 | jne .end_i |
763 | jne .end_i |
764 | mov ebx,dword[eax+offs_cont_vertex_cnt] |
764 | mov ebx,dword[eax+GLContext.vertex_cnt] |
765 | @@: ;while (ebx >= 3) |
765 | @@: ;while (ebx >= 3) |
766 | cmp ebx,3 |
766 | cmp ebx,3 |
767 | jl .end_i |
767 | jl .end_i |
768 | dec ebx |
768 | dec ebx |
769 | mov ecx,ebx |
769 | mov ecx,ebx |
770 | imul ecx,sizeof.GLVertex |
770 | imul ecx,sizeof.GLVertex |
771 | add ecx,[eax+offs_cont_vertex] |
771 | add ecx,[eax+GLContext.vertex] |
772 | push ecx ;ecx = &context.vertex[i] |
772 | push ecx ;ecx = &context.vertex[i] |
773 | sub ecx,sizeof.GLVertex |
773 | sub ecx,sizeof.GLVertex |
774 | push ecx ;ecx = &context.vertex[i-1] |
774 | push ecx ;ecx = &context.vertex[i-1] |
775 | stdcall gl_draw_triangle, eax,[eax+offs_cont_vertex] |
775 | stdcall gl_draw_triangle, eax,[eax+GLContext.vertex] |
776 | jmp @b |
776 | jmp @b |
777 | align 4 |
777 | align 4 |
778 | .end_i: |
778 | .end_i: |