Subversion Repositories Kolibri OS

Rev

Rev 5218 | Rev 5353 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5153 IgorA 1
; fill triangle profile
2
; #define PROFILE
3
 
4
CLIP_XMIN equ (1<<0)
5
CLIP_XMAX equ (1<<1)
6
CLIP_YMIN equ (1<<2)
7
CLIP_YMAX equ (1<<3)
8
CLIP_ZMIN equ (1<<4)
9
CLIP_ZMAX equ (1<<5)
10
 
11
offs_X equ 0
12
offs_Y equ 4
13
offs_Z equ 8
14
offs_W equ 12
15
 
16
align 4
17
proc gl_transform_to_viewport uses eax ebx ecx, context:dword,v:dword
18
locals
19
	point dd ?
20
endl
21
	mov eax,[context]
22
	mov ebx,[v]
23
 
24
	; coordinates
25
	fld1
26
	fdiv dword[ebx+offs_vert_pc+offs_W] ;st0 = 1/v.pc.W
27
 
28
	fld dword[ebx+offs_vert_pc+offs_X] ;st0 = v.pc.X
29
	fmul st0,st1
30
	fmul dword[eax+offs_cont_viewport+offs_vpor_scale+offs_X]
31
	fadd dword[eax+offs_cont_viewport+offs_vpor_trans+offs_X]
32
	fistp dword[ebx+offs_vert_zp] ;v.zp.x = st0, st0 = st1
33
 
34
	fld dword[ebx+offs_vert_pc+offs_Y] ;st0 = v.pc.Y
35
	fmul st0,st1
36
	fmul dword[eax+offs_cont_viewport+offs_vpor_scale+offs_Y]
37
	fadd dword[eax+offs_cont_viewport+offs_vpor_trans+offs_Y]
38
	fistp dword[ebx+offs_vert_zp+offs_zbup_y] ;v.zp.y = st0, st0 = st1
39
 
40
	fld dword[ebx+offs_vert_pc+offs_Z] ;st0 = v.pc.Z
41
	fmul st0,st1
42
	fmul dword[eax+offs_cont_viewport+offs_vpor_scale+offs_Z]
43
	fadd dword[eax+offs_cont_viewport+offs_vpor_trans+offs_Z]
44
	fistp dword[ebx+offs_vert_zp+offs_zbup_z] ;v.zp.z = st0, st0 = st1
45
 
5187 IgorA 46
	ffree st0
47
	fincstp
48
 
5153 IgorA 49
	; color
5208 IgorA 50
	cmp dword[eax+offs_cont_lighting_enabled],0 ;if (context.lighting_enabled)
51
	je @f
5153 IgorA 52
		mov ecx,ebx
53
		add ecx,offs_vert_zp+offs_zbup_b
54
		push ecx
55
		add ecx,offs_zbup_g-offs_zbup_b
56
		push ecx
57
		add ecx,offs_zbup_r-offs_zbup_g
58
		push ecx
59
		stdcall RGBFtoRGBI, dword[ebx+offs_vert_color],dword[ebx+offs_vert_color+4],dword[ebx+offs_vert_color+8]
60
		jmp .end_if
61
	@@:
62
		; no need to convert to integer if no lighting : take current color
63
		mov ecx,[eax+offs_cont_longcurrent_color]
64
		mov dword[ebx+offs_vert_zp+offs_zbup_r],ecx
65
		mov ecx,[eax+offs_cont_longcurrent_color+4]
66
		mov dword[ebx+offs_vert_zp+offs_zbup_g],ecx
67
		mov ecx,[eax+offs_cont_longcurrent_color+8]
68
		mov dword[ebx+offs_vert_zp+offs_zbup_b],ecx
69
	.end_if:
70
 
71
	; texture
72
	bt dword[eax+offs_cont_texture_2d_enabled],0
73
	jnc @f
74
		mov dword[point],dword(ZB_POINT_S_MAX - ZB_POINT_S_MIN)
75
		fild dword[point]
76
		fmul dword[ebx+offs_vert_tex_coord] ;st0 *= v.tex_coord.X
77
		fistp dword[ebx+offs_vert_zp+offs_zbup_s]
78
		add dword[ebx+offs_vert_zp+offs_zbup_s],ZB_POINT_S_MIN
79
 
80
		mov dword[point],dword(ZB_POINT_T_MAX - ZB_POINT_T_MIN)
81
		fild dword[point]
82
		fmul dword[ebx+offs_vert_tex_coord+4] ;st0 *= v.tex_coord.Y
83
		fistp dword[ebx+offs_vert_zp+offs_zbup_t]
84
		add dword[ebx+offs_vert_zp+offs_zbup_s],ZB_POINT_T_MIN
85
	@@:
86
if DEBUG ;gl_transform_to_viewport
87
push edi
88
	mov ecx,80
89
	mov eax,[ebx+offs_vert_zp]
90
	lea edi,[buf_param]
91
	stdcall convert_int_to_str,ecx
92
	stdcall str_n_cat,edi,txt_zp_sp,2
93
	stdcall str_len,edi
94
	add edi,eax
95
	sub ecx,eax
96
 
97
	mov eax,[ebx+offs_vert_zp+offs_zbup_y]
98
	stdcall convert_int_to_str,ecx
99
	stdcall str_n_cat,edi,txt_zp_sp,2
100
	stdcall str_len,edi
101
	add edi,eax
102
	sub ecx,eax
103
 
104
	mov eax,[ebx+offs_vert_zp+offs_zbup_z]
105
	stdcall convert_int_to_str,ecx
106
 
107
	stdcall str_n_cat,edi,txt_nl,2
108
	stdcall dbg_print,f_ttv,buf_param
109
pop edi
110
end if
111
	ret
112
endp
113
 
114
align 4
115
proc gl_add_select1 uses eax ebx ecx, context:dword, z1:dword,z2:dword,z3:dword
116
	mov eax,[z1]
117
	mov ebx,eax
118
	cmp [z2],eax
119
	jge @f
120
		mov eax,[z2]
121
	@@:
122
	cmp [z3],eax
123
	jge @f
124
		mov eax,[z3]
125
	@@:
126
	cmp [z2],ebx
127
	jle @f
128
		mov ebx,[z2]
129
	@@:
130
	cmp [z3],ebx
131
	jle @f
132
		mov ebx,[z3]
133
	@@:
134
	mov ecx,0xffffffff
135
	sub ecx,ebx
136
	push ecx
137
	mov ecx,0xffffffff
138
	sub ecx,eax
139
	push ecx
140
	stdcall gl_add_select, [context] ;,0xffffffff-eax,0xffffffff-ebx
141
	ret
142
endp
143
 
144
; point
145
 
146
align 4
147
proc gl_draw_point uses eax ebx, context:dword, p0:dword
148
	mov ebx,[p0]
149
	cmp dword[ebx+offs_vert_clip_code],0 ;if (p0.clip_code == 0)
150
	jne @f
151
	mov eax,[context]
152
	cmp dword[eax+offs_cont_render_mode],GL_SELECT
153
	jne .els
154
		stdcall gl_add_select, eax,dword[ebx+offs_vert_zp+offs_zbup_z],dword[ebx+offs_vert_zp+offs_zbup_z] ;p0.zp.z,p0.zp.z
155
		jmp @f
156
	.els:
157
		add ebx,offs_vert_zp
158
		stdcall ZB_plot, dword[eax+offs_cont_zb],ebx
159
	@@:
160
	ret
161
endp
162
 
163
; line
164
 
165
align 4
166
proc interpolate uses eax ebx ecx, q:dword,p0:dword,p1:dword,t:dword
167
	mov eax,[q]
168
	mov ebx,[p0]
169
	mov ecx,[p1]
170
	fld dword[t]
171
 
172
	; интерполяция по координатам
5175 IgorA 173
	fld dword[ecx+offs_vert_pc+offs_X]
174
	fsub dword[ebx+offs_vert_pc+offs_X]
5153 IgorA 175
	fmul st0,st1
5175 IgorA 176
	fadd dword[ebx+offs_vert_pc+offs_X]
177
	fstp dword[eax+offs_vert_pc+offs_X]
5153 IgorA 178
 
5175 IgorA 179
	fld dword[ecx+offs_vert_pc+offs_Y]
180
	fsub dword[ebx+offs_vert_pc+offs_Y]
5153 IgorA 181
	fmul st0,st1
5175 IgorA 182
	fadd dword[ebx+offs_vert_pc+offs_Y]
183
	fstp dword[eax+offs_vert_pc+offs_Y]
5153 IgorA 184
 
5175 IgorA 185
	fld dword[ecx+offs_vert_pc+offs_Z]
186
	fsub dword[ebx+offs_vert_pc+offs_Z]
5153 IgorA 187
	fmul st0,st1
5175 IgorA 188
	fadd dword[ebx+offs_vert_pc+offs_Z]
189
	fstp dword[eax+offs_vert_pc+offs_Z]
5153 IgorA 190
 
5175 IgorA 191
	fld dword[ecx+offs_vert_pc+offs_W]
192
	fsub dword[ebx+offs_vert_pc+offs_W]
5153 IgorA 193
	fmul st0,st1
5175 IgorA 194
	fadd dword[ebx+offs_vert_pc+offs_W]
195
	fstp dword[eax+offs_vert_pc+offs_W]
5153 IgorA 196
 
197
	; интерполяция по цвету
198
	fld dword[ecx+offs_vert_color]
199
	fsub dword[ebx+offs_vert_color]
200
	fmul st0,st1
201
	fadd dword[ebx+offs_vert_color]
202
	fstp dword[eax+offs_vert_color]
203
 
204
	fld dword[ecx+offs_vert_color+4]
205
	fsub dword[ebx+offs_vert_color+4]
206
	fmul st0,st1
207
	fadd dword[ebx+offs_vert_color+4]
208
	fstp dword[eax+offs_vert_color+4]
209
 
210
	fld dword[ecx+offs_vert_color+8]
211
	fsub dword[ebx+offs_vert_color+8]
212
	fmul st0,st1
213
	fadd dword[ebx+offs_vert_color+8]
214
	fstp dword[eax+offs_vert_color+8]
5208 IgorA 215
 
216
	ffree st0
217
	fincstp
5153 IgorA 218
	ret
219
endp
220
 
221
;
222
; Line Clipping
223
;
224
 
225
; Line Clipping algorithm from 'Computer Graphics', Principles and
226
; Practice
227
; tmin,tmax -> &float
228
align 4
229
proc ClipLine1 uses ebx, denom:dword,num:dword,tmin:dword,tmax:dword
5278 IgorA 230
	fld dword[denom]
231
	ftst
5153 IgorA 232
	fstsw ax
233
	sahf
5278 IgorA 234
	jbe .els_0 ;if (denom>0)
5153 IgorA 235
		fld dword[num]
5278 IgorA 236
		fxch st1
237
		fdivp ;t=num/denom
5153 IgorA 238
		mov ebx,[tmax]
239
		fcom dword[ebx]
240
		fstsw ax
241
		sahf
5278 IgorA 242
		ja .r0_f1 ;if (t>*tmax) return 0
5153 IgorA 243
		mov ebx,[tmin]
244
		fcom dword[ebx]
245
		fstsw ax
246
		sahf
5278 IgorA 247
		jbe .r1_f1 ;if (t>*tmin) *tmin=t
248
			fstp dword[ebx]
5153 IgorA 249
		jmp .r1
5278 IgorA 250
	.els_0: ;else if (denom<0)
251
		jae .els_1
5153 IgorA 252
		fld dword[num]
5278 IgorA 253
		fxch st1
254
		fdivp ;t=num/denom
5153 IgorA 255
		mov ebx,[tmin]
256
		fcom dword[ebx]
257
		fstsw ax
258
		sahf
5278 IgorA 259
		jb .r0_f1 ;if (t<*tmin) return 0
5153 IgorA 260
		mov ebx,[tmax]
261
		fcom dword[ebx]
262
		fstsw ax
263
		sahf
5278 IgorA 264
		jae .r1_f1
5153 IgorA 265
			fstp dword[ebx] ;if (t<*tmin) *tmax=t
5278 IgorA 266
		jmp .r1
267
	.els_1: ;else if (num>0)
268
		ffree st0 ;denom
269
		fincstp
270
		fld dword[num]
271
		ftst
272
		fstsw ax
273
		sahf
274
		ja .r0_f1 ;if (num>0) return 0
275
		jmp .r1_f1
5153 IgorA 276
 
5278 IgorA 277
	.r0_f1: ;return 0 & free st0
5218 IgorA 278
		ffree st0
279
		fincstp
5278 IgorA 280
	.r0: ;return 0
5153 IgorA 281
		xor eax,eax
282
		jmp .end_f
5278 IgorA 283
	.r1_f1: ;return 1 & free st0
5218 IgorA 284
		ffree st0
285
		fincstp
5278 IgorA 286
	.r1: ;return 1
5153 IgorA 287
		xor eax,eax
288
		inc eax
289
	.end_f:
290
	ret
291
endp
292
 
293
align 4
5218 IgorA 294
proc gl_draw_line, context:dword, p1:dword, p2:dword
5153 IgorA 295
locals
296
	d_x dd ?
297
	d_y dd ?
298
	d_z dd ?
299
	d_w dd ?
300
	x1 dd ?
301
	y1 dd ?
302
	z1 dd ?
303
	w1 dd ?
304
	q1 GLVertex ?
305
	q2 GLVertex ?
306
	tmin dd ? ;ebp-8
307
	tmax dd ? ;ebp-4
308
endl
5218 IgorA 309
pushad
5153 IgorA 310
	mov edx,[context]
311
	mov edi,[p1]
312
	mov esi,[p2]
313
 
314
	cmp dword[edi+offs_vert_clip_code],0
315
	jne .els_i
316
	cmp dword[esi+offs_vert_clip_code],0
317
	jne .els_i
318
		;if ( (p1.clip_code | p2.clip_code) == 0)
319
		cmp dword[edx+offs_cont_render_mode],GL_SELECT ;if (context.render_mode == GL_SELECT)
320
		jne .els_1
321
			stdcall gl_add_select1, edx,dword[edi+offs_vert_zp+offs_zbup_z],\
322
				dword[esi+offs_vert_zp+offs_zbup_z],dword[esi+offs_vert_zp+offs_zbup_z]
323
			jmp .end_f
324
		.els_1:
325
			add edi,offs_vert_zp
326
			add esi,offs_vert_zp
327
			push esi
328
			push edi
329
			push dword[edx+offs_cont_zb]
330
			cmp dword[edx+offs_cont_depth_test],0
331
			je .els_2
332
				;if (context.depth_test)
333
				call ZB_line_z ;, dword[edx+offs_cont_zb],edi,esi
334
				jmp .end_f
335
			.els_2:
336
				call ZB_line ;, dword[edx+offs_cont_zb],edi,esi
337
				jmp .end_f
338
	.els_i:
339
		;else if ( (p1.clip_code & p2.clip_code) != 0 )
340
		mov eax,[edi+offs_vert_clip_code]
341
		and eax,[esi+offs_vert_clip_code]
342
		cmp eax,0
343
		jne .end_f
344
	.els_0:
345
 
346
	fld dword[esi+offs_vert_pc+offs_X]
347
	fsub dword[edi+offs_vert_pc+offs_X]
348
	fstp dword[d_x] ;d_x = p2.pc.X - p1.pc.X
349
	fld dword[esi+offs_vert_pc+offs_Y]
350
	fsub dword[edi+offs_vert_pc+offs_Y]
351
	fstp dword[d_y] ;d_y = p2.pc.Y - p1.pc.Y
352
	fld dword[esi+offs_vert_pc+offs_Z]
353
	fsub dword[edi+offs_vert_pc+offs_Z]
354
	fstp dword[d_z] ;d_z = p2.pc.Z - p1.pc.Z
355
	fld dword[esi+offs_vert_pc+offs_W]
356
	fsub dword[edi+offs_vert_pc+offs_W]
357
	fstp dword[d_w] ;d_w = p2.pc.W - p1.pc.W
358
 
359
	mov eax,[edi+offs_vert_pc+offs_X]
360
	mov [x1],eax ;x1 = p1.pc.X
361
	mov eax,[edi+offs_vert_pc+offs_Y]
362
	mov [y1],eax ;y1 = p1.pc.Y
363
	mov eax,[edi+offs_vert_pc+offs_Z]
364
	mov [z1],eax ;z1 = p1.pc.Z
365
	mov eax,[edi+offs_vert_pc+offs_W]
366
	mov [w1],eax ;w1 = p1.pc.W
367
 
368
	mov dword[tmin],0.0
369
	mov dword[tmax],1.0
370
 
371
	mov eax,ebp
372
	sub eax,4
373
	push eax ;толкаем в стек адрес &tmax
374
	sub eax,4
375
	push eax ;толкаем в стек адрес &tmin
376
	fld dword[x1]
377
	fadd dword[w1]
378
	fchs
379
	fstp dword[esp-4]
380
	fld dword[d_x]
381
	fadd dword[d_w]
382
	fstp dword[esp-8]
383
	sub esp,8
384
	call ClipLine1 ;d_x+d_w,-x1-w1,&tmin,&tmax
385
	bt eax,0
386
	jnc .end_f
387
 
388
	sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax
389
	fld dword[x1]
390
	fsub dword[w1]
391
	fstp dword[esp-4]
392
	fld dword[d_w]
393
	fsub dword[d_x]
394
	fstp dword[esp-8]
395
	sub esp,8
396
	call ClipLine1 ;-d_x+d_w,x1-w1,&tmin,&tmax
397
	bt eax,0
398
	jnc .end_f
399
 
400
	sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax
401
	fld dword[y1]
402
	fadd dword[w1]
403
	fchs
404
	fstp dword[esp-4]
405
	fld dword[d_y]
406
	fadd dword[d_w]
407
	fstp dword[esp-8]
408
	sub esp,8
409
	call ClipLine1 ;d_y+d_w,-y1-w1,&tmin,&tmax
410
	bt eax,0
411
	jnc .end_f
412
 
413
	sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax
414
	fld dword[y1]
415
	fsub dword[w1]
416
	fstp dword[esp-4]
417
	fld dword[d_w]
418
	fsub dword[d_y]
419
	fstp dword[esp-8]
420
	sub esp,8
421
	call ClipLine1 ;-d_y+d_w,y1-w1,&tmin,&tmax
422
	bt eax,0
423
	jnc .end_f
424
 
425
	sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax
426
	fld dword[z1]
427
	fadd dword[w1]
428
	fchs
429
	fstp dword[esp-4]
430
	fld dword[d_z]
431
	fadd dword[d_w]
432
	fstp dword[esp-8]
433
	sub esp,8
434
	call ClipLine1 ;d_z+d_w,-z1-w1,&tmin,&tmax
435
	bt eax,0
436
	jnc .end_f
437
 
438
	sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax
439
	fld dword[z1]
440
	fsub dword[w1]
441
	fstp dword[esp-4]
442
	fld dword[d_w]
443
	fsub dword[d_z]
444
	fstp dword[esp-8]
445
	sub esp,8
446
	call ClipLine1 ;-d_z+d_w,z1-w1,&tmin,&tmax
447
	bt eax,0
448
	jnc .end_f
449
 
450
	mov eax,ebp
451
	sub eax,8+2*sizeof.GLVertex ;eax = &q1
452
	stdcall interpolate, eax,edi,esi,[tmin]
453
	stdcall gl_transform_to_viewport, edx,eax
454
	add eax,sizeof.GLVertex ;eax = &q2
455
	stdcall interpolate, eax,edi,esi,[tmax]
456
	stdcall gl_transform_to_viewport, edx,eax
457
 
458
	sub eax,sizeof.GLVertex ;eax = &q1
459
	mov ebx,eax
460
	add ebx,offs_vert_zp+offs_zbup_b
461
	push ebx
462
	add ebx,offs_zbup_g-offs_zbup_b
463
	push ebx
464
	add ebx,offs_zbup_r-offs_zbup_g
465
	push ebx
466
	stdcall RGBFtoRGBI, dword[eax+offs_vert_color],dword[eax+offs_vert_color+4],dword[eax+offs_vert_color+8]
467
 
468
	add eax,sizeof.GLVertex ;eax = &q2
469
	mov ebx,eax
470
	add ebx,offs_vert_zp+offs_zbup_b
471
	push ebx
472
	add ebx,offs_zbup_g-offs_zbup_b
473
	push ebx
474
	add ebx,offs_zbup_r-offs_zbup_g
475
	push ebx
476
	stdcall RGBFtoRGBI, dword[eax+offs_vert_color],dword[eax+offs_vert_color+4],dword[eax+offs_vert_color+8]
477
 
478
	add eax,offs_vert_zp ;eax = &q2.zp
479
	push eax
480
	sub eax,sizeof.GLVertex ;eax = &q1.zp
481
	push eax
482
	push dword[edx+offs_cont_zb]
483
	cmp dword[edx+offs_cont_depth_test],0
484
	je .els_3
485
		call ZB_line_z ;(context.zb,&q1.zp,&q2.zp)
486
		jmp .end_f
487
	.els_3:
488
		call ZB_line ;(context.zb,&q1.zp,&q2.zp)
489
	.end_f:
5218 IgorA 490
popad
5153 IgorA 491
	ret
492
endp
493
 
494
; triangle
495
 
496
;
497
; Clipping
498
;
499
 
500
; We clip the segment [a,b] against the 6 planes of the normal volume.
501
; We compute the point 'c' of intersection and the value of the parameter 't'
502
; of the intersection if x=a+t(b-a).
503
;
504
; sign: 0 -> '-', 1 -> '+'
505
macro clip_func sign,dir,dir1,dir2
506
{
507
locals
508
	t dd ?
509
	d_X dd ?
510
	d_Y dd ?
511
	d_Z dd ?
512
	d_W dd ?
513
endl
514
	mov edx,[a]
515
	mov ebx,[b]
516
	mov ecx,[c]
5175 IgorA 517
	fld dword[ebx+offs_X]
518
	fsub dword[edx+offs_X]
5153 IgorA 519
	fstp dword[d_X] ;d_X = (b.X - a.X)
5175 IgorA 520
	fld dword[ebx+offs_Y]
521
	fsub dword[edx+offs_Y]
5153 IgorA 522
	fstp dword[d_Y] ;d_Y = (b.Y - a.Y)
5175 IgorA 523
	fld dword[ebx+offs_Z]
524
	fsub dword[edx+offs_Z]
5153 IgorA 525
	fstp dword[d_Z] ;d_Z = (b.Z - a.Z)
5175 IgorA 526
	fld dword[ebx+offs_W]
527
	fsub dword[edx+offs_W]
5153 IgorA 528
	fst dword[d_W] ;d_W = (b.W - a.W)
529
if sign eq 0
530
	fadd dword[d#dir]
531
else
532
	fsub dword[d#dir]
533
end if
534
 
5218 IgorA 535
	ftst
5153 IgorA 536
	fstsw ax
537
	sahf
5208 IgorA 538
	jne @f
539
		fldz
5153 IgorA 540
		fst dword[t] ;t=0
541
		jmp .e_zero
542
	@@: ;else
543
		fld dword[edx+offs#dir]
544
if sign eq 0
545
		fchs
546
end if
547
		fsub dword[edx+offs_W]
548
		fdiv st0,st1
549
		fst dword[t] ;t = ( sign a.dir - a.W) / den
550
	.e_zero:
551
 
552
	fmul dword[d#dir1] ;st0 = t * d.dir1
553
	fadd dword[edx+offs#dir1]
554
	fstp dword[ecx+offs#dir1] ;c.dir1 = a.dir1 + t * d.dir1
555
 
5208 IgorA 556
	ffree st0
557
	fincstp
558
 
5153 IgorA 559
	fld dword[t]
560
	fmul dword[d#dir2] ;st0 = t * d.dir2
561
	fadd dword[edx+offs#dir2]
562
	fstp dword[ecx+offs#dir2] ;c.dir2 = a.dir2 + t * d.dir2
563
 
564
	fld dword[t]
565
	fmul dword[d_W]
566
	fadd dword[edx+offs_W]
567
	fst dword[ecx+offs_W] ;c.W = a.W + t * d_W
568
 
569
if sign eq 0
570
		fchs
571
end if
572
	fstp dword[ecx+offs#dir] ;c.dir = sign c.W
573
	mov eax,[t]
574
}
575
 
576
align 4
577
proc clip_xmin uses ebx ecx edx, c:dword, a:dword, b:dword
578
	clip_func 0,_X,_Y,_Z
579
	ret
580
endp
581
 
582
align 4
583
proc clip_xmax uses ebx ecx edx, c:dword, a:dword, b:dword
584
	clip_func 1,_X,_Y,_Z
585
	ret
586
endp
587
 
588
align 4
589
proc clip_ymin uses ebx ecx edx, c:dword, a:dword, b:dword
590
	clip_func 0,_Y,_X,_Z
591
	ret
592
endp
593
 
594
align 4
595
proc clip_ymax uses ebx ecx edx, c:dword, a:dword, b:dword
596
	clip_func 1,_Y,_X,_Z
597
	ret
598
endp
599
 
600
align 4
601
proc clip_zmin uses ebx ecx edx, c:dword, a:dword, b:dword
602
	clip_func 0,_Z,_X,_Y
603
	ret
604
endp
605
 
606
align 4
607
proc clip_zmax uses ebx ecx edx, c:dword, a:dword, b:dword
608
	clip_func 1,_Z,_X,_Y
609
	ret
610
endp
611
 
612
align 4
613
clip_proc dd clip_xmin,clip_xmax, clip_ymin,clip_ymax, clip_zmin,clip_zmax
614
 
5175 IgorA 615
align 4
5208 IgorA 616
proc updateTmp uses eax ebx ecx edx, context:dword, q:dword, p0:dword, p1:dword, t:dword
617
	mov ebx,[q]
618
	mov edx,[context]
619
	mov eax,[p0]
5175 IgorA 620
	cmp dword[edx+offs_cont_current_shade_model],GL_SMOOTH ;if (context.current_shade_model == GL_SMOOTH)
621
	jne .els_0
5208 IgorA 622
		mov ecx,[p1]
623
		fld dword[ecx+offs_vert_color]
624
		fsub dword[eax+offs_vert_color]
625
		fmul dword[t]
626
		fadd dword[eax+offs_vert_color]
627
		fstp dword[ebx+offs_vert_color] ;q.color.v[0]=p0.color.v[0] + (p1.color.v[0]-p0.color.v[0])*t
628
		fld dword[ecx+offs_vert_color+4]
629
		fsub dword[eax+offs_vert_color+4]
630
		fmul dword[t]
631
		fadd dword[eax+offs_vert_color+4]
632
		fstp dword[ebx+offs_vert_color+4] ;q.color.v[1]=p0.color.v[1] + (p1.color.v[1]-p0.color.v[1])*t
633
		fld dword[ecx+offs_vert_color+8]
634
		fsub dword[eax+offs_vert_color+8]
635
		fmul dword[t]
636
		fadd dword[eax+offs_vert_color+8]
637
		fstp dword[ebx+offs_vert_color+8] ;q.color.v[2]=p0.color.v[2] + (p1.color.v[2]-p0.color.v[2])*t
5175 IgorA 638
		jmp @f
639
	.els_0:
5208 IgorA 640
		mov ecx,[eax+offs_vert_color]
641
		mov [ebx+offs_vert_color],ecx ;q.color.v[0]=p0.color.v[0]
642
		mov ecx,[eax+offs_vert_color+4]
643
		mov [ebx+offs_vert_color+4],ecx ;q.color.v[1]=p0.color.v[1]
644
		mov ecx,[eax+offs_vert_color+8]
645
		mov [ebx+offs_vert_color+8],ecx ;q.color.v[2]=p0.color.v[2]
5175 IgorA 646
	@@:
5153 IgorA 647
 
5175 IgorA 648
	cmp dword[edx+offs_cont_texture_2d_enabled],0 ;if (context.texture_2d_enabled)
649
	je @f
5208 IgorA 650
		mov ecx,[p1]
651
		fld dword[ecx+offs_vert_tex_coord+offs_X]
652
		fsub dword[eax+offs_vert_tex_coord+offs_X]
653
		fmul dword[t]
654
		fadd dword[eax+offs_vert_tex_coord+offs_X]
655
		fstp dword[ebx+offs_vert_tex_coord+offs_X] ;q.tex_coord.X=p0.tex_coord.X + (p1.tex_coord.X-p0.tex_coord.X)*t
656
		fld dword[ecx+offs_vert_tex_coord+offs_Y]
657
		fsub dword[eax+offs_vert_tex_coord+offs_Y]
658
		fmul dword[t]
659
		fadd dword[eax+offs_vert_tex_coord+offs_Y]
660
		fstp dword[ebx+offs_vert_tex_coord+offs_Y] ;q.tex_coord.Y=p0.tex_coord.Y + (p1.tex_coord.Y-p0.tex_coord.Y)*t
5175 IgorA 661
	@@:
5153 IgorA 662
 
5208 IgorA 663
	stdcall gl_clipcode, [ebx+offs_vert_pc+offs_X],[ebx+offs_vert_pc+offs_Y],\
664
		[ebx+offs_vert_pc+offs_Z],[ebx+offs_vert_pc+offs_W]
665
	mov dword[ebx+offs_vert_clip_code],eax
666
	cmp eax,0 ;if (q.clip_code==0)
667
	jne @f
668
		stdcall gl_transform_to_viewport,[context],ebx
669
		mov eax,ebx
670
		add eax,offs_vert_zp+offs_zbup_b
671
		push eax
672
		add eax,offs_zbup_g-offs_zbup_b
673
		push eax
674
		add eax,offs_zbup_r-offs_zbup_g
675
		push eax
676
		stdcall RGBFtoRGBI, dword[ebx+offs_vert_color],dword[ebx+offs_vert_color+4],dword[ebx+offs_vert_color+8]
677
	@@:
5175 IgorA 678
	ret
679
endp
5153 IgorA 680
 
5175 IgorA 681
align 4
682
proc gl_draw_triangle, context:dword, p0:dword, p1:dword, p2:dword
683
locals
684
	cc rd 3
685
	front dd ?
686
	norm dd ? ;float
687
endl
688
pushad
689
	mov ebx,[p0]
690
	mov ecx,[p1]
691
	mov edx,[p2]
5213 IgorA 692
 
5175 IgorA 693
	mov edi,[ebx+offs_vert_clip_code]
694
	mov dword[cc],edi
695
	mov eax,[ecx+offs_vert_clip_code]
696
	mov dword[cc+4],eax
697
	or edi,eax
698
	mov eax,[edx+offs_vert_clip_code]
699
	mov dword[cc+8],eax
5208 IgorA 700
	or edi,eax ;co = cc[0] | cc[1] | cc[2]
5153 IgorA 701
 
5175 IgorA 702
	; we handle the non clipped case here to go faster
5208 IgorA 703
	cmp edi,0 ;if (co==0)
5175 IgorA 704
	jne .els_0
705
		mov edi,dword[edx+offs_vert_zp+offs_zbup_x]
5208 IgorA 706
		sub edi,dword[ebx+offs_vert_zp+offs_zbup_x]
5175 IgorA 707
		mov dword[norm],edi
708
		fild dword[norm]
5213 IgorA 709
		mov edi,dword[ecx+offs_vert_zp+offs_zbup_y]
710
		sub edi,dword[ebx+offs_vert_zp+offs_zbup_y]
5175 IgorA 711
		mov dword[norm],edi
712
		fimul dword[norm]
713
		mov edi,dword[ecx+offs_vert_zp+offs_zbup_x]
714
		sub edi,dword[ebx+offs_vert_zp+offs_zbup_x]
715
		mov dword[norm],edi
716
		fild dword[norm]
717
		mov edi,dword[edx+offs_vert_zp+offs_zbup_y]
5208 IgorA 718
		sub edi,dword[ebx+offs_vert_zp+offs_zbup_y]
5175 IgorA 719
		mov dword[norm],edi
720
		fimul dword[norm]
5187 IgorA 721
		fsubp
5153 IgorA 722
 
5175 IgorA 723
		;st0 = (p1.zp.x-p0.zp.x)*(p2.zp.y-p0.zp.y) - (p2.zp.x-p0.zp.x)*(p1.zp.y-p0.zp.y)
5153 IgorA 724
 
5175 IgorA 725
		mov dword[front],0
726
		fldz
5187 IgorA 727
		fcompp
5175 IgorA 728
		fstsw ax
729
		sahf
730
		je .end_f
731
		jb @f
732
			inc dword[front] ;front = 0.0 > norm
733
		@@:
734
		mov edi,[context]
735
		mov eax,dword[edi+offs_cont_current_front_face]
736
		xor dword[front],eax ;front ^= context.current_front_face
5153 IgorA 737
 
5175 IgorA 738
		; back face culling
739
		cmp dword[edi+offs_cont_cull_face_enabled],0
740
		je .els_1
741
			; most used case first
742
			cmp dword[edi+offs_cont_current_cull_face],GL_BACK
743
			jne @f
744
				cmp dword[front],0
745
				je .end_f
746
					stdcall dword[edi+offs_cont_draw_triangle_front], edi,ebx,ecx,edx
747
				jmp .end_f
748
			@@:
749
			cmp dword[edi+offs_cont_current_cull_face],GL_FRONT
750
			jne .end_f
751
				cmp dword[front],0
752
				jne .end_f
753
					stdcall dword[edi+offs_cont_draw_triangle_back], edi,ebx,ecx,edx
754
			jmp .end_f
755
		.els_1:
756
			; no culling
757
			cmp dword[front],0
758
			je @f
759
				stdcall dword[edi+offs_cont_draw_triangle_front], edi,ebx,ecx,edx
5213 IgorA 760
				jmp .end_f
5175 IgorA 761
			@@:
762
				stdcall dword[edi+offs_cont_draw_triangle_back], edi,ebx,ecx,edx
763
		jmp .end_f
764
	.els_0:
5208 IgorA 765
		;eax = cc[2]
5175 IgorA 766
		and eax,[cc]
5208 IgorA 767
		and eax,[cc+4] ;eax = c_and = cc[0] & cc[1] & cc[2]
768
		cmp eax,0 ;if (c_and==0)
5187 IgorA 769
		jne .end_f
5175 IgorA 770
			stdcall gl_draw_triangle_clip, [context],ebx,ecx,edx,0
771
	.end_f:
772
popad
773
	ret
774
endp
5153 IgorA 775
 
5175 IgorA 776
align 4
777
proc gl_draw_triangle_clip, context:dword, p0:dword, p1:dword, p2:dword, clip_bit:dword
778
locals
779
	co dd ?
780
	cc rd 3
781
	edge_flag_tmp dd ?
782
	clip_mask dd ?
5208 IgorA 783
	q rd 3 ;GLVertex*
5175 IgorA 784
	tmp1 GLVertex ?
785
	tmp2 GLVertex ?
786
endl
787
pushad
788
	mov ebx,[p0]
789
	mov ecx,[p1]
790
	mov edx,[p2]
5208 IgorA 791
 
5175 IgorA 792
	mov edi,[ebx+offs_vert_clip_code]
5208 IgorA 793
	mov [cc],edi
5175 IgorA 794
	mov eax,[ecx+offs_vert_clip_code]
5208 IgorA 795
	mov [cc+4],eax
5175 IgorA 796
	or edi,eax
797
	mov eax,[edx+offs_vert_clip_code]
5208 IgorA 798
	mov [cc+8],eax
5175 IgorA 799
	or edi,eax
5208 IgorA 800
	mov [co],edi ;co = cc[0] | cc[1] | cc[2]
5175 IgorA 801
 
5208 IgorA 802
	cmp edi,0 ;if (co == 0)
5175 IgorA 803
	jne .els_0
804
		stdcall gl_draw_triangle, [context],ebx,ecx,edx
805
		jmp .end_f
806
	.els_0:
5208 IgorA 807
		;eax = cc[2]
5175 IgorA 808
		and eax,[cc]
5208 IgorA 809
		and eax,[cc+4] ;c_and = cc[0] & cc[1] & cc[2]
5175 IgorA 810
 
811
		; the triangle is completely outside
5208 IgorA 812
		cmp eax,0 ;if (c_and!=0) return
5175 IgorA 813
		jne .end_f
814
 
5208 IgorA 815
		; find the next direction to clip
816
		.cycle_0: ;while (clip_bit < 6 && (co & (1 << clip_bit)) == 0)
817
		cmp dword[clip_bit],6
818
		jge .cycle_0_end
819
		xor eax,eax
820
		inc eax
821
		mov ecx,[clip_bit]
822
		shl eax,cl
823
		and eax,[co]
824
		cmp eax,0
825
		jne .cycle_0_end
826
			inc dword[clip_bit]
827
			jmp .cycle_0
828
		.cycle_0_end:
5153 IgorA 829
 
5175 IgorA 830
	; this test can be true only in case of rounding errors
831
	cmp dword[clip_bit],6
832
if 0
833
	jne @f
5153 IgorA 834
;      printf("Error:\n");
835
;      printf("%f %f %f %f\n",p0->pc.X,p0->pc.Y,p0->pc.Z,p0->pc.W);
836
;      printf("%f %f %f %f\n",p1->pc.X,p1->pc.Y,p1->pc.Z,p1->pc.W);
837
;      printf("%f %f %f %f\n",p2->pc.X,p2->pc.Y,p2->pc.Z,p2->pc.W);
5175 IgorA 838
		jmp .end_f
839
	@@:
5208 IgorA 840
end if
841
if 1
5175 IgorA 842
	je .end_f
843
end if
5153 IgorA 844
 
5208 IgorA 845
	xor eax,eax
846
	inc eax
847
	mov ecx,[clip_bit]
848
	shl eax,cl
849
	mov [clip_mask],eax ;1 << clip_bit
850
	mov edi,[cc]
851
	xor edi,[cc+4]
852
	xor edi,[cc+8]
853
	and eax,edi ;eax = co1 = (cc[0] ^ cc[1] ^ cc[2]) & clip_mask
5153 IgorA 854
 
5208 IgorA 855
	mov ecx,[p1] ;востанавливаем после shl ___,cl
5153 IgorA 856
 
5208 IgorA 857
	cmp eax,0 ;if (co1)
858
	je .els_1
859
		; one point outside
860
		mov eax,[cc]
861
		and eax,[clip_mask]
862
		cmp eax,0 ;if (cc[0] & clip_mask)
863
		je .els_2
864
			;q[0]=p0 q[1]=p1 q[2]=p2
865
			mov [q],ebx
866
			mov [q+4],ecx
867
			mov [q+8],edx
868
			jmp .els_2_end
869
		.els_2:
870
		mov eax,[cc+4]
871
		and eax,[clip_mask]
872
		cmp eax,0 ;else if (cc[1] & clip_mask)
873
		je .els_3
874
			;q[0]=p1 q[1]=p2 q[2]=p0
875
			mov [q],ecx
876
			mov [q+4],edx
877
			mov [q+8],ebx
878
			jmp .els_2_end
879
		.els_3:
880
			;q[0]=p2 q[1]=p0 q[2]=p1
881
			mov [q],edx
882
			mov [q+4],ebx
883
			mov [q+8],ecx
884
		.els_2_end:
5153 IgorA 885
 
5208 IgorA 886
		mov ebx,[q]
887
		add ebx,offs_vert_pc
888
		mov ecx,[q+4]
889
		add ecx,offs_vert_pc
890
		mov edx,[q+8]
891
		add edx,offs_vert_pc
5153 IgorA 892
 
5208 IgorA 893
		lea eax,[clip_proc]
894
		mov edi,[clip_bit]
895
		shl edi,2
896
		add eax,edi
897
		mov edi,ebp
898
		sub edi,(2*sizeof.GLVertex)-offs_vert_pc
899
		stdcall dword[eax],edi,ebx,ecx ;clip_proc[clip_bit](&tmp1.pc,&q[0].pc,&q[1].pc)
900
		sub edi,offs_vert_pc
5153 IgorA 901
 
5208 IgorA 902
		sub ebx,offs_vert_pc
903
		sub ecx,offs_vert_pc
904
		stdcall updateTmp,[context],edi,ebx,ecx,eax ;updateTmp(c,&tmp1,q[0],q[1],tt)
905
		add ebx,offs_vert_pc
5153 IgorA 906
 
5208 IgorA 907
		lea eax,[clip_proc]
908
		mov edi,[clip_bit]
909
		shl edi,2
910
		add eax,edi
911
		mov edi,ebp
912
		sub edi,sizeof.GLVertex-offs_vert_pc
913
		stdcall dword[eax],edi,ebx,edx ;clip_proc[clip_bit](&tmp2.pc,&q[0].pc,&q[2].pc)
914
		sub edi,offs_vert_pc
915
		sub ebx,offs_vert_pc
916
		sub edx,offs_vert_pc
917
		stdcall updateTmp,[context],edi,ebx,edx,eax ;updateTmp(c,&tmp2,q[0],q[2],tt)
918
 
919
		mov eax,[ebx+offs_vert_edge_flag]
920
		mov [tmp1+offs_vert_edge_flag],eax ;q[0].edge_flag
921
		mov eax,[edx+offs_vert_edge_flag]
922
		mov [edge_flag_tmp],eax	;q[2].edge_flag
923
		mov dword[edx+offs_vert_edge_flag],0 ;q[2].edge_flag=0
924
		mov eax,[clip_bit]
925
		inc eax
926
		push eax ;для вызова нижней функции
927
		mov edi,ebp
928
		sub edi,2*sizeof.GLVertex
929
		stdcall gl_draw_triangle_clip,[context],edi,ecx,edx,eax ;gl_draw_triangle_clip(c,&tmp1,q[1],q[2],clip_bit+1)
930
 
931
		mov dword[tmp2.edge_flag],0
932
		mov dword[tmp1.edge_flag],0
933
		mov eax,[edge_flag_tmp]
934
		mov [edx+offs_vert_edge_flag],eax ;q[2].edge_flag=edge_flag_tmp
935
		push edx
936
		push edi
937
		add edi,sizeof.GLVertex ;edi = &tmp2
938
		stdcall gl_draw_triangle_clip,[context],edi ;gl_draw_triangle_clip(c,&tmp2,&tmp1,q[2],clip_bit+1)
939
		jmp .end_f
940
	.els_1:
941
		; two points outside
942
		mov eax,[cc]
943
		and eax,[clip_mask]
944
		cmp eax,0 ;if (cc[0] & clip_mask)==0
945
		jne .els_4
946
			;q[0]=p0 q[1]=p1 q[2]=p2
947
			mov [q],ebx
948
			mov [q+4],ecx
949
			mov [q+8],edx
950
			jmp .els_4_end
951
		.els_4:
952
		mov eax,[cc+4]
953
		and eax,[clip_mask]
954
		cmp eax,0 ;else if (cc[1] & clip_mask)==0
955
		jne .els_5
956
			;q[0]=p1 q[1]=p2 q[2]=p0
957
			mov [q],ecx
958
			mov [q+4],edx
959
			mov [q+8],ebx
960
			jmp .els_4_end
961
		.els_5:
962
			;q[0]=p2 q[1]=p0 q[2]=p1
963
			mov [q],edx
964
			mov [q+4],ebx
965
			mov [q+8],ecx
966
		.els_4_end:
967
 
968
		mov ebx,[q]
969
		add ebx,offs_vert_pc
970
		mov ecx,[q+4]
971
		add ecx,offs_vert_pc
972
		mov edx,[q+8]
973
		add edx,offs_vert_pc
974
 
975
		lea eax,[clip_proc]
976
		mov edi,[clip_bit]
977
		shl edi,2
978
		add eax,edi
979
		mov edi,ebp
980
		sub edi,(2*sizeof.GLVertex)-offs_vert_pc
981
		stdcall dword[eax],edi,ebx,ecx ;clip_proc[clip_bit](&tmp1.pc,&q[0].pc,&q[1].pc)
982
		sub edi,offs_vert_pc
983
		stdcall updateTmp,[context],edi,[q],[q+4],eax
984
 
985
		lea eax,[clip_proc]
986
		mov edi,[clip_bit]
987
		shl edi,2
988
		add eax,edi
989
		mov edi,ebp
990
		sub edi,sizeof.GLVertex-offs_vert_pc
991
		stdcall dword[eax],edi,ebx,edx ;clip_proc[clip_bit](&tmp2.pc,&q[0].pc,&q[2].pc)
992
		sub edi,offs_vert_pc
993
		stdcall updateTmp,[context],edi,[q],[q+8],eax
994
 
995
		mov edx,[q+8]
996
 
997
		mov dword[tmp1+offs_vert_edge_flag],1
998
		mov eax,[edx+offs_vert_edge_flag]
999
		mov dword[tmp1+offs_vert_edge_flag],eax ;tmp2.edge_flag = q[2].edge_flag
1000
		mov eax,[clip_bit]
1001
		inc eax
1002
		push eax
1003
		push edi
1004
		sub edi,sizeof.GLVertex
1005
		stdcall gl_draw_triangle_clip,[context],[q],edi ;gl_draw_triangle_clip(c,q[0],&tmp1,&tmp2,clip_bit+1)
5175 IgorA 1006
	.end_f:
1007
popad
1008
	ret
1009
endp
5153 IgorA 1010
 
1011
align 4
1012
proc gl_draw_triangle_select uses eax, context:dword, p0:dword,p1:dword,p2:dword
1013
	mov eax,[p2]
1014
	push dword[eax+offs_vert_zp+offs_Z]
1015
	mov eax,[p1]
1016
	push dword[eax+offs_vert_zp+offs_Z]
1017
	mov eax,[p0]
1018
	push dword[eax+offs_vert_zp+offs_Z]
1019
	stdcall gl_add_select1, [context] ;,p0.zp.z, p1.zp.z, p2.zp.z
1020
	ret
1021
endp
1022
 
5175 IgorA 1023
if PROFILE eq 1
1024
	count_triangles dd ?
1025
	count_triangles_textured dd ?
1026
	count_pixels dd ?
1027
end if
5153 IgorA 1028
 
1029
align 4
5175 IgorA 1030
proc gl_draw_triangle_fill, context:dword, p0:dword,p1:dword,p2:dword
1031
pushad
1032
if PROFILE eq 1
5153 IgorA 1033
;    int norm;
1034
;    assert(p0->zp.x >= 0 && p0->zp.x < c->zb->xsize);
1035
;    assert(p0->zp.y >= 0 && p0->zp.y < c->zb->ysize);
1036
;    assert(p1->zp.x >= 0 && p1->zp.x < c->zb->xsize);
1037
;    assert(p1->zp.y >= 0 && p1->zp.y < c->zb->ysize);
1038
;    assert(p2->zp.x >= 0 && p2->zp.x < c->zb->xsize);
1039
;    assert(p2->zp.y >= 0 && p2->zp.y < c->zb->ysize);
1040
 
1041
;    norm=(p1->zp.x-p0->zp.x)*(p2->zp.y-p0->zp.y)-
1042
;      (p2->zp.x-p0->zp.x)*(p1->zp.y-p0->zp.y);
1043
;    count_pixels+=abs(norm)/2;
5175 IgorA 1044
	inc dword[count_triangles]
1045
end if
5153 IgorA 1046
 
5175 IgorA 1047
	mov ebx,[p1]
1048
	add ebx,offs_vert_zp
1049
	mov ecx,[p2]
1050
	add ecx,offs_vert_zp
5153 IgorA 1051
	mov edx,[context]
1052
	cmp dword[edx+offs_cont_texture_2d_enabled],0
1053
	je .els_i
1054
		;if (context.texture_2d_enabled)
5175 IgorA 1055
if PROFILE eq 1
1056
	inc dword[count_triangles_textured]
1057
end if
5153 IgorA 1058
		mov eax,dword[edx+offs_cont_current_texture]
1059
		mov eax,[eax] ;переход по указателю
1060
		;так как offs_text_images+offs_imag_pixmap = 0 то context.current_texture.images[0].pixmap = [eax]
1061
		stdcall ZB_setTexture, dword[edx+offs_cont_zb],dword[eax]
5175 IgorA 1062
		mov eax,[p0]
1063
		add eax,offs_vert_zp
1064
		stdcall ZB_fillTriangleMappingPerspective, dword[edx+offs_cont_zb],eax,ebx,ecx
5153 IgorA 1065
		jmp .end_f
1066
	.els_i:
5175 IgorA 1067
		mov eax,[p0]
1068
		add eax,offs_vert_zp
1069
		cmp dword[edx+offs_cont_current_shade_model],GL_SMOOTH
1070
		jne .els
1071
			;else if (context.current_shade_model == GL_SMOOTH)
1072
			stdcall ZB_fillTriangleSmooth, dword[edx+offs_cont_zb],eax,ebx,ecx
1073
			jmp .end_f
1074
		.els:
1075
			stdcall ZB_fillTriangleFlat, dword[edx+offs_cont_zb],eax,ebx,ecx
5153 IgorA 1076
	.end_f:
5175 IgorA 1077
popad
5153 IgorA 1078
	ret
1079
endp
1080
 
1081
; Render a clipped triangle in line mode
1082
 
1083
align 4
1084
proc gl_draw_triangle_line uses eax ebx ecx edx, context:dword, p0:dword,p1:dword,p2:dword
1085
	mov edx,[context]
1086
	cmp dword[edx+offs_cont_depth_test],0
1087
	je .els
1088
		lea ecx,[ZB_line_z]
1089
		jmp @f
1090
	.els:
1091
		lea ecx,[ZB_line]
1092
	@@:
1093
 
1094
	;if (p0.edge_flag) ZB_line_z(context.zb,&p0.zp,&p1.zp)
1095
	mov eax,[p0]
1096
	cmp dword[eax+offs_vert_edge_flag],0
1097
	je @f
1098
		mov ebx,eax
1099
		add ebx,offs_vert_zp
1100
		mov eax,[p1]
1101
		add eax,offs_vert_zp
1102
		stdcall ecx,dword[edx+offs_cont_zb],ebx,eax
1103
	@@:
1104
	;if (p1.edge_flag) ZB_line_z(context.zb,&p1.zp,&p2.zp)
1105
	mov eax,[p1]
1106
	cmp dword[eax+offs_vert_edge_flag],0
1107
	je @f
1108
		mov ebx,eax
1109
		add ebx,offs_vert_zp
1110
		mov eax,[p2]
1111
		add eax,offs_vert_zp
1112
		stdcall ecx,dword[edx+offs_cont_zb],ebx,eax
1113
	@@:
1114
	;if (p2.edge_flag) ZB_line_z(context.zb,&p2.zp,&p0.zp);
1115
	mov eax,[p2]
1116
	cmp dword[eax+offs_vert_edge_flag],0
1117
	je @f
1118
		mov ebx,eax
1119
		add ebx,offs_vert_zp
1120
		mov eax,[p0]
1121
		add eax,offs_vert_zp
1122
		stdcall ecx,dword[edx+offs_cont_zb],ebx,eax
1123
	@@:
1124
 
1125
	ret
1126
endp
1127
 
1128
; Render a clipped triangle in point mode
1129
align 4
1130
proc gl_draw_triangle_point uses eax ebx edx, context:dword, p0:dword,p1:dword,p2:dword
1131
	mov edx,[context]
1132
	mov eax,[p0]
1133
	cmp dword[eax+offs_vert_edge_flag],0
1134
	je @f
1135
		mov ebx,eax
1136
		add ebx,offs_vert_zp
1137
		stdcall ZB_plot,dword[edx+offs_cont_zb],ebx
1138
	@@:
5187 IgorA 1139
	mov eax,[p1]
5153 IgorA 1140
	cmp dword[eax+offs_vert_edge_flag],0
1141
	je @f
1142
		mov ebx,eax
1143
		add ebx,offs_vert_zp
1144
		stdcall ZB_plot,dword[edx+offs_cont_zb],ebx
1145
	@@:
5187 IgorA 1146
	mov eax,[p2]
5153 IgorA 1147
	cmp dword[eax+offs_vert_edge_flag],0
1148
	je @f
1149
		mov ebx,eax
1150
		add ebx,offs_vert_zp
1151
		stdcall ZB_plot,dword[edx+offs_cont_zb],ebx
1152
	@@:
1153
	ret
1154
endp
1155
 
1156
 
1157
 
1158