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