2014-10-31 22:28:24 +01:00
|
|
|
|
; fill triangle profile
|
|
|
|
|
; #define PROFILE
|
|
|
|
|
|
|
|
|
|
CLIP_XMIN equ (1<<0)
|
|
|
|
|
CLIP_XMAX equ (1<<1)
|
|
|
|
|
CLIP_YMIN equ (1<<2)
|
|
|
|
|
CLIP_YMAX equ (1<<3)
|
|
|
|
|
CLIP_ZMIN equ (1<<4)
|
|
|
|
|
CLIP_ZMAX equ (1<<5)
|
|
|
|
|
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 16
|
2014-10-31 22:28:24 +01:00
|
|
|
|
proc gl_transform_to_viewport uses eax ebx ecx, context:dword,v:dword
|
|
|
|
|
mov eax,[context]
|
|
|
|
|
mov ebx,[v]
|
|
|
|
|
|
|
|
|
|
; coordinates
|
|
|
|
|
fld1
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fdiv dword[ebx+GLVertex.pc+offs_W] ;st0 = 1/v.pc.W
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fld dword[ebx+GLVertex.pc+offs_X] ;st0 = v.pc.X
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fmul st0,st1
|
2016-09-16 10:39:28 +02:00
|
|
|
|
fmul dword[eax+GLContext.viewport+offs_vpor_scale+offs_X]
|
|
|
|
|
fadd dword[eax+GLContext.viewport+offs_vpor_trans+offs_X]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fistp dword[ebx+GLVertex.zp] ;v.zp.x = st0, st0 = st1
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fld dword[ebx+GLVertex.pc+offs_Y] ;st0 = v.pc.Y
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fmul st0,st1
|
2016-09-16 10:39:28 +02:00
|
|
|
|
fmul dword[eax+GLContext.viewport+offs_vpor_scale+offs_Y]
|
|
|
|
|
fadd dword[eax+GLContext.viewport+offs_vpor_trans+offs_Y]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fistp dword[ebx+GLVertex.zp+offs_zbup_y] ;v.zp.y = st0, st0 = st1
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fld dword[ebx+GLVertex.pc+offs_Z] ;st0 = v.pc.Z
|
2016-02-05 21:49:30 +01:00
|
|
|
|
fmulp
|
2016-09-16 10:39:28 +02:00
|
|
|
|
fmul dword[eax+GLContext.viewport+offs_vpor_scale+offs_Z]
|
|
|
|
|
fadd dword[eax+GLContext.viewport+offs_vpor_trans+offs_Z]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fistp dword[ebx+GLVertex.zp+offs_zbup_z] ;v.zp.z = st0, st0 = st1
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
|
|
; color
|
2016-09-16 10:39:28 +02:00
|
|
|
|
cmp dword[eax+GLContext.lighting_enabled],0 ;if (context.lighting_enabled)
|
2014-12-01 17:52:18 +01:00
|
|
|
|
je @f
|
2020-09-16 08:59:01 +02:00
|
|
|
|
lea ecx,[ebx+GLVertex.zp+offs_zbup_b]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
push ecx
|
|
|
|
|
add ecx,offs_zbup_g-offs_zbup_b
|
|
|
|
|
push ecx
|
|
|
|
|
add ecx,offs_zbup_r-offs_zbup_g
|
|
|
|
|
push ecx
|
2020-09-16 08:59:01 +02:00
|
|
|
|
stdcall RGBFtoRGBI, dword[ebx+GLVertex.color],dword[ebx+GLVertex.color+4],dword[ebx+GLVertex.color+8]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
jmp .end_if
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
|
@@:
|
|
|
|
|
; no need to convert to integer if no lighting : take current color
|
2016-09-16 10:39:28 +02:00
|
|
|
|
mov ecx,[eax+GLContext.longcurrent_color]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov dword[ebx+GLVertex.zp+offs_zbup_r],ecx
|
2016-09-16 10:39:28 +02:00
|
|
|
|
mov ecx,[eax+GLContext.longcurrent_color+4]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov dword[ebx+GLVertex.zp+offs_zbup_g],ecx
|
2016-09-16 10:39:28 +02:00
|
|
|
|
mov ecx,[eax+GLContext.longcurrent_color+8]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov dword[ebx+GLVertex.zp+offs_zbup_b],ecx
|
2014-10-31 22:28:24 +01:00
|
|
|
|
.end_if:
|
|
|
|
|
|
|
|
|
|
; texture
|
2016-09-16 10:39:28 +02:00
|
|
|
|
cmp dword[eax+GLContext.texture_2d_enabled],0
|
2015-01-05 20:13:01 +01:00
|
|
|
|
je @f
|
2016-09-16 10:39:28 +02:00
|
|
|
|
mov eax,[eax+GLContext.current_texture] ;eax = &context.current_texture
|
2016-02-17 22:33:10 +01:00
|
|
|
|
mov eax,[eax] ;eax = context.current_texture
|
|
|
|
|
;[eax+offs_text_images] = im = &context.current_texture.images[0]
|
|
|
|
|
|
|
|
|
|
fild dword[eax+offs_text_images+offs_imag_s_bound]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fmul dword[ebx+GLVertex.tex_coord+offs_X]
|
|
|
|
|
fistp dword[ebx+GLVertex.zp+offs_zbup_s]
|
2016-02-17 22:33:10 +01:00
|
|
|
|
;v.zp.s=(int)(v.tex_coord.X * im.s_bound)
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
2016-02-17 22:33:10 +01:00
|
|
|
|
fild dword[eax+offs_text_images+offs_imag_t_bound]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fmul dword[ebx+GLVertex.tex_coord+offs_Y]
|
|
|
|
|
fistp dword[ebx+GLVertex.zp+offs_zbup_t]
|
2016-02-17 22:33:10 +01:00
|
|
|
|
;v.zp.t=(int)(v.tex_coord.Y * im.t_bound)
|
2014-10-31 22:28:24 +01:00
|
|
|
|
@@:
|
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 16
|
2014-10-31 22:28:24 +01:00
|
|
|
|
proc gl_add_select1 uses eax ebx ecx, context:dword, z1:dword,z2:dword,z3:dword
|
|
|
|
|
mov eax,[z1]
|
|
|
|
|
mov ebx,eax
|
|
|
|
|
cmp [z2],eax
|
|
|
|
|
jge @f
|
|
|
|
|
mov eax,[z2]
|
|
|
|
|
@@:
|
|
|
|
|
cmp [z3],eax
|
|
|
|
|
jge @f
|
|
|
|
|
mov eax,[z3]
|
|
|
|
|
@@:
|
|
|
|
|
cmp [z2],ebx
|
|
|
|
|
jle @f
|
|
|
|
|
mov ebx,[z2]
|
|
|
|
|
@@:
|
|
|
|
|
cmp [z3],ebx
|
|
|
|
|
jle @f
|
|
|
|
|
mov ebx,[z3]
|
|
|
|
|
@@:
|
|
|
|
|
mov ecx,0xffffffff
|
|
|
|
|
sub ecx,ebx
|
|
|
|
|
push ecx
|
|
|
|
|
mov ecx,0xffffffff
|
|
|
|
|
sub ecx,eax
|
|
|
|
|
push ecx
|
|
|
|
|
stdcall gl_add_select, [context] ;,0xffffffff-eax,0xffffffff-ebx
|
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
; point
|
|
|
|
|
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 16
|
2014-10-31 22:28:24 +01:00
|
|
|
|
proc gl_draw_point uses eax ebx, context:dword, p0:dword
|
|
|
|
|
mov ebx,[p0]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
cmp dword[ebx+GLVertex.clip_code],0 ;if (p0.clip_code == 0)
|
2014-10-31 22:28:24 +01:00
|
|
|
|
jne @f
|
|
|
|
|
mov eax,[context]
|
2016-09-16 10:39:28 +02:00
|
|
|
|
cmp dword[eax+GLContext.render_mode],GL_SELECT
|
2014-10-31 22:28:24 +01:00
|
|
|
|
jne .els
|
2020-09-16 08:59:01 +02:00
|
|
|
|
stdcall gl_add_select, eax,dword[ebx+GLVertex.zp+offs_zbup_z],dword[ebx+GLVertex.zp+offs_zbup_z] ;p0.zp.z,p0.zp.z
|
2014-10-31 22:28:24 +01:00
|
|
|
|
jmp @f
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
|
.els:
|
2020-09-16 08:59:01 +02:00
|
|
|
|
add ebx,GLVertex.zp
|
2016-09-16 10:39:28 +02:00
|
|
|
|
stdcall ZB_plot, dword[eax+GLContext.zb],ebx
|
2014-10-31 22:28:24 +01:00
|
|
|
|
@@:
|
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
; line
|
|
|
|
|
|
2016-02-08 16:32:44 +01:00
|
|
|
|
;input:
|
|
|
|
|
;q - регистр с адресом вершины для интерполяции
|
|
|
|
|
;p0 - регистр с адресом 1-й вершины
|
|
|
|
|
;p1 - регистр с адресом 2-й вершины
|
|
|
|
|
;t - float
|
|
|
|
|
macro interpolate q, p0, p1, t
|
|
|
|
|
{
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fld dword[t]
|
|
|
|
|
|
|
|
|
|
; интерполяция по координатам
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fld dword[p1+GLVertex.pc]
|
|
|
|
|
fsub dword[p0+GLVertex.pc]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fmul st0,st1
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fadd dword[p0+GLVertex.pc]
|
|
|
|
|
fstp dword[q+GLVertex.pc] ;q.pc.X = p0.pc.X + (p1.pc.X - p0.pc.X) * t
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fld dword[p1+GLVertex.pc+offs_Y]
|
|
|
|
|
fsub dword[p0+GLVertex.pc+offs_Y]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fmul st0,st1
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fadd dword[p0+GLVertex.pc+offs_Y]
|
|
|
|
|
fstp dword[q+GLVertex.pc+offs_Y]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fld dword[p1+GLVertex.pc+offs_Z]
|
|
|
|
|
fsub dword[p0+GLVertex.pc+offs_Z]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fmul st0,st1
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fadd dword[p0+GLVertex.pc+offs_Z]
|
|
|
|
|
fstp dword[q+GLVertex.pc+offs_Z]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fld dword[p1+GLVertex.pc+offs_W]
|
|
|
|
|
fsub dword[p0+GLVertex.pc+offs_W]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fmul st0,st1
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fadd dword[p0+GLVertex.pc+offs_W]
|
|
|
|
|
fstp dword[q+GLVertex.pc+offs_W]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
|
|
; интерполяция по цвету
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fld dword[p1+GLVertex.color]
|
|
|
|
|
fsub dword[p0+GLVertex.color]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fmul st0,st1
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fadd dword[p0+GLVertex.color]
|
|
|
|
|
fstp dword[q+GLVertex.color]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fld dword[p1+GLVertex.color+4]
|
|
|
|
|
fsub dword[p0+GLVertex.color+4]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fmul st0,st1
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fadd dword[p0+GLVertex.color+4]
|
|
|
|
|
fstp dword[q+GLVertex.color+4]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fld dword[p1+GLVertex.color+8]
|
|
|
|
|
fsub dword[p0+GLVertex.color+8]
|
2016-02-05 21:49:30 +01:00
|
|
|
|
fmulp
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fadd dword[p0+GLVertex.color+8]
|
|
|
|
|
fstp dword[q+GLVertex.color+8]
|
2016-02-08 16:32:44 +01:00
|
|
|
|
}
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
; Line Clipping
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
; Line Clipping algorithm from 'Computer Graphics', Principles and
|
|
|
|
|
; Practice
|
|
|
|
|
; tmin,tmax -> &float
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 16
|
2014-10-31 22:28:24 +01:00
|
|
|
|
proc ClipLine1 uses ebx, denom:dword,num:dword,tmin:dword,tmax:dword
|
2014-12-28 21:13:27 +01:00
|
|
|
|
fld dword[denom]
|
|
|
|
|
ftst
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fstsw ax
|
|
|
|
|
sahf
|
2014-12-28 21:13:27 +01:00
|
|
|
|
jbe .els_0 ;if (denom>0)
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fld dword[num]
|
2014-12-28 21:13:27 +01:00
|
|
|
|
fxch st1
|
|
|
|
|
fdivp ;t=num/denom
|
2014-10-31 22:28:24 +01:00
|
|
|
|
mov ebx,[tmax]
|
|
|
|
|
fcom dword[ebx]
|
|
|
|
|
fstsw ax
|
|
|
|
|
sahf
|
2014-12-28 21:13:27 +01:00
|
|
|
|
ja .r0_f1 ;if (t>*tmax) return 0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
mov ebx,[tmin]
|
|
|
|
|
fcom dword[ebx]
|
|
|
|
|
fstsw ax
|
|
|
|
|
sahf
|
2014-12-28 21:13:27 +01:00
|
|
|
|
jbe .r1_f1 ;if (t>*tmin) *tmin=t
|
|
|
|
|
fstp dword[ebx]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
jmp .r1
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-12-28 21:13:27 +01:00
|
|
|
|
.els_0: ;else if (denom<0)
|
|
|
|
|
jae .els_1
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fld dword[num]
|
2014-12-28 21:13:27 +01:00
|
|
|
|
fxch st1
|
|
|
|
|
fdivp ;t=num/denom
|
2014-10-31 22:28:24 +01:00
|
|
|
|
mov ebx,[tmin]
|
|
|
|
|
fcom dword[ebx]
|
|
|
|
|
fstsw ax
|
|
|
|
|
sahf
|
2014-12-28 21:13:27 +01:00
|
|
|
|
jb .r0_f1 ;if (t<*tmin) return 0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
mov ebx,[tmax]
|
|
|
|
|
fcom dword[ebx]
|
|
|
|
|
fstsw ax
|
|
|
|
|
sahf
|
2014-12-28 21:13:27 +01:00
|
|
|
|
jae .r1_f1
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fstp dword[ebx] ;if (t<*tmin) *tmax=t
|
2014-12-28 21:13:27 +01:00
|
|
|
|
jmp .r1
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-12-28 21:13:27 +01:00
|
|
|
|
.els_1: ;else if (num>0)
|
|
|
|
|
ffree st0 ;denom
|
|
|
|
|
fincstp
|
|
|
|
|
fld dword[num]
|
|
|
|
|
ftst
|
|
|
|
|
fstsw ax
|
|
|
|
|
sahf
|
|
|
|
|
ja .r0_f1 ;if (num>0) return 0
|
|
|
|
|
jmp .r1_f1
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-12-28 21:13:27 +01:00
|
|
|
|
.r0_f1: ;return 0 & free st0
|
2014-12-05 22:12:56 +01:00
|
|
|
|
ffree st0
|
|
|
|
|
fincstp
|
2014-12-28 21:13:27 +01:00
|
|
|
|
.r0: ;return 0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
xor eax,eax
|
|
|
|
|
jmp .end_f
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-12-28 21:13:27 +01:00
|
|
|
|
.r1_f1: ;return 1 & free st0
|
2014-12-05 22:12:56 +01:00
|
|
|
|
ffree st0
|
|
|
|
|
fincstp
|
2014-12-28 21:13:27 +01:00
|
|
|
|
.r1: ;return 1
|
2014-10-31 22:28:24 +01:00
|
|
|
|
xor eax,eax
|
|
|
|
|
inc eax
|
|
|
|
|
.end_f:
|
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 16
|
2014-12-05 22:12:56 +01:00
|
|
|
|
proc gl_draw_line, context:dword, p1:dword, p2:dword
|
2014-10-31 22:28:24 +01:00
|
|
|
|
locals
|
|
|
|
|
d_x dd ?
|
|
|
|
|
d_y dd ?
|
|
|
|
|
d_z dd ?
|
|
|
|
|
d_w dd ?
|
|
|
|
|
x1 dd ?
|
|
|
|
|
y1 dd ?
|
|
|
|
|
z1 dd ?
|
|
|
|
|
w1 dd ?
|
|
|
|
|
q1 GLVertex ?
|
|
|
|
|
q2 GLVertex ?
|
|
|
|
|
tmin dd ? ;ebp-8
|
|
|
|
|
tmax dd ? ;ebp-4
|
|
|
|
|
endl
|
2014-12-05 22:12:56 +01:00
|
|
|
|
pushad
|
2014-10-31 22:28:24 +01:00
|
|
|
|
mov edx,[context]
|
|
|
|
|
mov edi,[p1]
|
|
|
|
|
mov esi,[p2]
|
|
|
|
|
|
2020-09-16 08:59:01 +02:00
|
|
|
|
cmp dword[edi+GLVertex.clip_code],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
jne .els_i
|
2020-09-16 08:59:01 +02:00
|
|
|
|
cmp dword[esi+GLVertex.clip_code],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
jne .els_i
|
|
|
|
|
;if ( (p1.clip_code | p2.clip_code) == 0)
|
2016-09-16 10:39:28 +02:00
|
|
|
|
cmp dword[edx+GLContext.render_mode],GL_SELECT ;if (context.render_mode == GL_SELECT)
|
2014-10-31 22:28:24 +01:00
|
|
|
|
jne .els_1
|
2020-09-16 08:59:01 +02:00
|
|
|
|
stdcall gl_add_select1, edx,dword[edi+GLVertex.zp+offs_zbup_z],\
|
|
|
|
|
dword[esi+GLVertex.zp+offs_zbup_z],dword[esi+GLVertex.zp+offs_zbup_z]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
jmp .end_f
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
|
.els_1:
|
2020-09-16 08:59:01 +02:00
|
|
|
|
add edi,GLVertex.zp
|
|
|
|
|
add esi,GLVertex.zp
|
2014-10-31 22:28:24 +01:00
|
|
|
|
push esi
|
|
|
|
|
push edi
|
2016-09-16 10:39:28 +02:00
|
|
|
|
push dword[edx+GLContext.zb]
|
|
|
|
|
cmp dword[edx+GLContext.depth_test],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
je .els_2
|
|
|
|
|
;if (context.depth_test)
|
2016-09-16 10:39:28 +02:00
|
|
|
|
call ZB_line_z ;, dword[edx+GLContext.zb],edi,esi
|
2014-10-31 22:28:24 +01:00
|
|
|
|
jmp .end_f
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
|
.els_2:
|
2016-09-16 10:39:28 +02:00
|
|
|
|
call ZB_line ;, dword[edx+GLContext.zb],edi,esi
|
2014-10-31 22:28:24 +01:00
|
|
|
|
jmp .end_f
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
|
.els_i:
|
|
|
|
|
;else if ( (p1.clip_code & p2.clip_code) != 0 )
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov eax,[edi+GLVertex.clip_code]
|
|
|
|
|
and eax,[esi+GLVertex.clip_code]
|
2016-02-04 10:24:21 +01:00
|
|
|
|
or eax,eax
|
|
|
|
|
jnz .end_f
|
2014-10-31 22:28:24 +01:00
|
|
|
|
.els_0:
|
|
|
|
|
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fld dword[esi+GLVertex.pc+offs_X]
|
|
|
|
|
fsub dword[edi+GLVertex.pc+offs_X]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fstp dword[d_x] ;d_x = p2.pc.X - p1.pc.X
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fld dword[esi+GLVertex.pc+offs_Y]
|
|
|
|
|
fsub dword[edi+GLVertex.pc+offs_Y]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fstp dword[d_y] ;d_y = p2.pc.Y - p1.pc.Y
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fld dword[esi+GLVertex.pc+offs_Z]
|
|
|
|
|
fsub dword[edi+GLVertex.pc+offs_Z]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fstp dword[d_z] ;d_z = p2.pc.Z - p1.pc.Z
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fld dword[esi+GLVertex.pc+offs_W]
|
|
|
|
|
fsub dword[edi+GLVertex.pc+offs_W]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fstp dword[d_w] ;d_w = p2.pc.W - p1.pc.W
|
|
|
|
|
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov eax,[edi+GLVertex.pc+offs_X]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
mov [x1],eax ;x1 = p1.pc.X
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov eax,[edi+GLVertex.pc+offs_Y]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
mov [y1],eax ;y1 = p1.pc.Y
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov eax,[edi+GLVertex.pc+offs_Z]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
mov [z1],eax ;z1 = p1.pc.Z
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov eax,[edi+GLVertex.pc+offs_W]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
mov [w1],eax ;w1 = p1.pc.W
|
|
|
|
|
|
|
|
|
|
mov dword[tmin],0.0
|
|
|
|
|
mov dword[tmax],1.0
|
|
|
|
|
|
2020-09-16 08:59:01 +02:00
|
|
|
|
lea eax,[ebp-4]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
push eax ;толкаем в стек адрес &tmax
|
|
|
|
|
sub eax,4
|
|
|
|
|
push eax ;толкаем в стек адрес &tmin
|
|
|
|
|
fld dword[x1]
|
|
|
|
|
fadd dword[w1]
|
|
|
|
|
fchs
|
|
|
|
|
fstp dword[esp-4]
|
|
|
|
|
fld dword[d_x]
|
|
|
|
|
fadd dword[d_w]
|
|
|
|
|
fstp dword[esp-8]
|
|
|
|
|
sub esp,8
|
|
|
|
|
call ClipLine1 ;d_x+d_w,-x1-w1,&tmin,&tmax
|
|
|
|
|
bt eax,0
|
|
|
|
|
jnc .end_f
|
|
|
|
|
|
|
|
|
|
sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax
|
|
|
|
|
fld dword[x1]
|
|
|
|
|
fsub dword[w1]
|
|
|
|
|
fstp dword[esp-4]
|
|
|
|
|
fld dword[d_w]
|
|
|
|
|
fsub dword[d_x]
|
|
|
|
|
fstp dword[esp-8]
|
|
|
|
|
sub esp,8
|
|
|
|
|
call ClipLine1 ;-d_x+d_w,x1-w1,&tmin,&tmax
|
|
|
|
|
bt eax,0
|
|
|
|
|
jnc .end_f
|
|
|
|
|
|
|
|
|
|
sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax
|
|
|
|
|
fld dword[y1]
|
|
|
|
|
fadd dword[w1]
|
|
|
|
|
fchs
|
|
|
|
|
fstp dword[esp-4]
|
|
|
|
|
fld dword[d_y]
|
|
|
|
|
fadd dword[d_w]
|
|
|
|
|
fstp dword[esp-8]
|
|
|
|
|
sub esp,8
|
|
|
|
|
call ClipLine1 ;d_y+d_w,-y1-w1,&tmin,&tmax
|
|
|
|
|
bt eax,0
|
|
|
|
|
jnc .end_f
|
|
|
|
|
|
|
|
|
|
sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax
|
|
|
|
|
fld dword[y1]
|
|
|
|
|
fsub dword[w1]
|
|
|
|
|
fstp dword[esp-4]
|
|
|
|
|
fld dword[d_w]
|
|
|
|
|
fsub dword[d_y]
|
|
|
|
|
fstp dword[esp-8]
|
|
|
|
|
sub esp,8
|
|
|
|
|
call ClipLine1 ;-d_y+d_w,y1-w1,&tmin,&tmax
|
|
|
|
|
bt eax,0
|
|
|
|
|
jnc .end_f
|
|
|
|
|
|
|
|
|
|
sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax
|
|
|
|
|
fld dword[z1]
|
|
|
|
|
fadd dword[w1]
|
|
|
|
|
fchs
|
|
|
|
|
fstp dword[esp-4]
|
|
|
|
|
fld dword[d_z]
|
|
|
|
|
fadd dword[d_w]
|
|
|
|
|
fstp dword[esp-8]
|
|
|
|
|
sub esp,8
|
|
|
|
|
call ClipLine1 ;d_z+d_w,-z1-w1,&tmin,&tmax
|
|
|
|
|
bt eax,0
|
|
|
|
|
jnc .end_f
|
|
|
|
|
|
|
|
|
|
sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax
|
|
|
|
|
fld dword[z1]
|
|
|
|
|
fsub dword[w1]
|
|
|
|
|
fstp dword[esp-4]
|
|
|
|
|
fld dword[d_w]
|
|
|
|
|
fsub dword[d_z]
|
|
|
|
|
fstp dword[esp-8]
|
|
|
|
|
sub esp,8
|
|
|
|
|
call ClipLine1 ;-d_z+d_w,z1-w1,&tmin,&tmax
|
|
|
|
|
bt eax,0
|
|
|
|
|
jnc .end_f
|
|
|
|
|
|
2020-09-16 08:59:01 +02:00
|
|
|
|
lea eax,[ebp-8-2*sizeof.GLVertex] ;eax = &q1
|
2016-02-08 16:32:44 +01:00
|
|
|
|
interpolate eax,edi,esi,tmin
|
2014-10-31 22:28:24 +01:00
|
|
|
|
stdcall gl_transform_to_viewport, edx,eax
|
|
|
|
|
add eax,sizeof.GLVertex ;eax = &q2
|
2016-02-08 16:32:44 +01:00
|
|
|
|
interpolate eax,edi,esi,tmax
|
2014-10-31 22:28:24 +01:00
|
|
|
|
stdcall gl_transform_to_viewport, edx,eax
|
|
|
|
|
|
|
|
|
|
sub eax,sizeof.GLVertex ;eax = &q1
|
2020-09-16 08:59:01 +02:00
|
|
|
|
lea ebx,[eax+GLVertex.zp+offs_zbup_b]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
push ebx
|
|
|
|
|
add ebx,offs_zbup_g-offs_zbup_b
|
|
|
|
|
push ebx
|
|
|
|
|
add ebx,offs_zbup_r-offs_zbup_g
|
|
|
|
|
push ebx
|
2020-09-16 08:59:01 +02:00
|
|
|
|
stdcall RGBFtoRGBI, dword[eax+GLVertex.color],dword[eax+GLVertex.color+4],dword[eax+GLVertex.color+8]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
|
|
add eax,sizeof.GLVertex ;eax = &q2
|
2020-09-16 08:59:01 +02:00
|
|
|
|
lea ebx,[eax+GLVertex.zp+offs_zbup_b]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
push ebx
|
|
|
|
|
add ebx,offs_zbup_g-offs_zbup_b
|
|
|
|
|
push ebx
|
|
|
|
|
add ebx,offs_zbup_r-offs_zbup_g
|
|
|
|
|
push ebx
|
2020-09-16 08:59:01 +02:00
|
|
|
|
stdcall RGBFtoRGBI, dword[eax+GLVertex.color],dword[eax+GLVertex.color+4],dword[eax+GLVertex.color+8]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
2020-09-16 08:59:01 +02:00
|
|
|
|
add eax,GLVertex.zp ;eax = &q2.zp
|
2014-10-31 22:28:24 +01:00
|
|
|
|
push eax
|
|
|
|
|
sub eax,sizeof.GLVertex ;eax = &q1.zp
|
|
|
|
|
push eax
|
2016-09-16 10:39:28 +02:00
|
|
|
|
push dword[edx+GLContext.zb]
|
|
|
|
|
cmp dword[edx+GLContext.depth_test],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
je .els_3
|
|
|
|
|
call ZB_line_z ;(context.zb,&q1.zp,&q2.zp)
|
|
|
|
|
jmp .end_f
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
|
.els_3:
|
|
|
|
|
call ZB_line ;(context.zb,&q1.zp,&q2.zp)
|
|
|
|
|
.end_f:
|
2014-12-05 22:12:56 +01:00
|
|
|
|
popad
|
2014-10-31 22:28:24 +01:00
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
; triangle
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
; Clipping
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
; We clip the segment [a,b] against the 6 planes of the normal volume.
|
|
|
|
|
; We compute the point 'c' of intersection and the value of the parameter 't'
|
|
|
|
|
; of the intersection if x=a+t(b-a).
|
|
|
|
|
;
|
|
|
|
|
; sign: 0 -> '-', 1 -> '+'
|
|
|
|
|
macro clip_func sign,dir,dir1,dir2
|
|
|
|
|
{
|
|
|
|
|
locals
|
|
|
|
|
t dd ?
|
|
|
|
|
d_X dd ?
|
|
|
|
|
d_Y dd ?
|
|
|
|
|
d_Z dd ?
|
|
|
|
|
d_W dd ?
|
|
|
|
|
endl
|
|
|
|
|
mov edx,[a]
|
|
|
|
|
mov ebx,[b]
|
|
|
|
|
mov ecx,[c]
|
2014-11-07 16:23:03 +01:00
|
|
|
|
fld dword[ebx+offs_X]
|
|
|
|
|
fsub dword[edx+offs_X]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fstp dword[d_X] ;d_X = (b.X - a.X)
|
2014-11-07 16:23:03 +01:00
|
|
|
|
fld dword[ebx+offs_Y]
|
|
|
|
|
fsub dword[edx+offs_Y]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fstp dword[d_Y] ;d_Y = (b.Y - a.Y)
|
2014-11-07 16:23:03 +01:00
|
|
|
|
fld dword[ebx+offs_Z]
|
|
|
|
|
fsub dword[edx+offs_Z]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fstp dword[d_Z] ;d_Z = (b.Z - a.Z)
|
2014-11-07 16:23:03 +01:00
|
|
|
|
fld dword[ebx+offs_W]
|
|
|
|
|
fsub dword[edx+offs_W]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fst dword[d_W] ;d_W = (b.W - a.W)
|
|
|
|
|
if sign eq 0
|
|
|
|
|
fadd dword[d#dir]
|
|
|
|
|
else
|
|
|
|
|
fsub dword[d#dir]
|
|
|
|
|
end if
|
|
|
|
|
|
2014-12-05 22:12:56 +01:00
|
|
|
|
ftst
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fstsw ax
|
|
|
|
|
sahf
|
2014-12-01 17:52:18 +01:00
|
|
|
|
jne @f
|
|
|
|
|
fldz
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fst dword[t] ;t=0
|
|
|
|
|
jmp .e_zero
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
|
@@: ;else
|
|
|
|
|
fld dword[edx+offs#dir]
|
|
|
|
|
if sign eq 0
|
|
|
|
|
fchs
|
|
|
|
|
end if
|
|
|
|
|
fsub dword[edx+offs_W]
|
|
|
|
|
fdiv st0,st1
|
|
|
|
|
fst dword[t] ;t = ( sign a.dir - a.W) / den
|
|
|
|
|
.e_zero:
|
|
|
|
|
|
|
|
|
|
fmul dword[d#dir1] ;st0 = t * d.dir1
|
|
|
|
|
fadd dword[edx+offs#dir1]
|
|
|
|
|
fstp dword[ecx+offs#dir1] ;c.dir1 = a.dir1 + t * d.dir1
|
|
|
|
|
|
2014-12-01 17:52:18 +01:00
|
|
|
|
ffree st0
|
|
|
|
|
fincstp
|
|
|
|
|
|
2014-10-31 22:28:24 +01:00
|
|
|
|
fld dword[t]
|
|
|
|
|
fmul dword[d#dir2] ;st0 = t * d.dir2
|
|
|
|
|
fadd dword[edx+offs#dir2]
|
|
|
|
|
fstp dword[ecx+offs#dir2] ;c.dir2 = a.dir2 + t * d.dir2
|
|
|
|
|
|
|
|
|
|
fld dword[t]
|
|
|
|
|
fmul dword[d_W]
|
|
|
|
|
fadd dword[edx+offs_W]
|
|
|
|
|
fst dword[ecx+offs_W] ;c.W = a.W + t * d_W
|
|
|
|
|
|
|
|
|
|
if sign eq 0
|
|
|
|
|
fchs
|
|
|
|
|
end if
|
|
|
|
|
fstp dword[ecx+offs#dir] ;c.dir = sign c.W
|
|
|
|
|
mov eax,[t]
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 16
|
2014-10-31 22:28:24 +01:00
|
|
|
|
proc clip_xmin uses ebx ecx edx, c:dword, a:dword, b:dword
|
|
|
|
|
clip_func 0,_X,_Y,_Z
|
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 16
|
2014-10-31 22:28:24 +01:00
|
|
|
|
proc clip_xmax uses ebx ecx edx, c:dword, a:dword, b:dword
|
|
|
|
|
clip_func 1,_X,_Y,_Z
|
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 16
|
2014-10-31 22:28:24 +01:00
|
|
|
|
proc clip_ymin uses ebx ecx edx, c:dword, a:dword, b:dword
|
|
|
|
|
clip_func 0,_Y,_X,_Z
|
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 16
|
2014-10-31 22:28:24 +01:00
|
|
|
|
proc clip_ymax uses ebx ecx edx, c:dword, a:dword, b:dword
|
|
|
|
|
clip_func 1,_Y,_X,_Z
|
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 16
|
2014-10-31 22:28:24 +01:00
|
|
|
|
proc clip_zmin uses ebx ecx edx, c:dword, a:dword, b:dword
|
|
|
|
|
clip_func 0,_Z,_X,_Y
|
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 16
|
2014-10-31 22:28:24 +01:00
|
|
|
|
proc clip_zmax uses ebx ecx edx, c:dword, a:dword, b:dword
|
|
|
|
|
clip_func 1,_Z,_X,_Y
|
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
clip_proc dd clip_xmin,clip_xmax, clip_ymin,clip_ymax, clip_zmin,clip_zmax
|
|
|
|
|
|
2016-02-08 16:32:44 +01:00
|
|
|
|
;input:
|
|
|
|
|
;edi - q
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 16
|
2016-02-08 16:32:44 +01:00
|
|
|
|
proc updateTmp uses eax ecx edx, context:dword, p0:dword, p1:dword, t:dword
|
2014-12-01 17:52:18 +01:00
|
|
|
|
mov edx,[context]
|
|
|
|
|
mov eax,[p0]
|
2016-09-16 10:39:28 +02:00
|
|
|
|
cmp dword[edx+GLContext.current_shade_model],GL_SMOOTH ;if (context.current_shade_model == GL_SMOOTH)
|
2014-11-07 16:23:03 +01:00
|
|
|
|
jne .els_0
|
2014-12-01 17:52:18 +01:00
|
|
|
|
mov ecx,[p1]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fld dword[ecx+GLVertex.color]
|
|
|
|
|
fsub dword[eax+GLVertex.color]
|
2014-12-01 17:52:18 +01:00
|
|
|
|
fmul dword[t]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fadd dword[eax+GLVertex.color]
|
|
|
|
|
fstp dword[edi+GLVertex.color] ;q.color.v[0]=p0.color.v[0] + (p1.color.v[0]-p0.color.v[0])*t
|
|
|
|
|
fld dword[ecx+GLVertex.color+4]
|
|
|
|
|
fsub dword[eax+GLVertex.color+4]
|
2014-12-01 17:52:18 +01:00
|
|
|
|
fmul dword[t]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fadd dword[eax+GLVertex.color+4]
|
|
|
|
|
fstp dword[edi+GLVertex.color+4] ;q.color.v[1]=p0.color.v[1] + (p1.color.v[1]-p0.color.v[1])*t
|
|
|
|
|
fld dword[ecx+GLVertex.color+8]
|
|
|
|
|
fsub dword[eax+GLVertex.color+8]
|
2014-12-01 17:52:18 +01:00
|
|
|
|
fmul dword[t]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fadd dword[eax+GLVertex.color+8]
|
|
|
|
|
fstp dword[edi+GLVertex.color+8] ;q.color.v[2]=p0.color.v[2] + (p1.color.v[2]-p0.color.v[2])*t
|
2014-11-07 16:23:03 +01:00
|
|
|
|
jmp @f
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-11-07 16:23:03 +01:00
|
|
|
|
.els_0:
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov ecx,[eax+GLVertex.color]
|
|
|
|
|
mov [edi+GLVertex.color],ecx ;q.color.v[0]=p0.color.v[0]
|
|
|
|
|
mov ecx,[eax+GLVertex.color+4]
|
|
|
|
|
mov [edi+GLVertex.color+4],ecx ;q.color.v[1]=p0.color.v[1]
|
|
|
|
|
mov ecx,[eax+GLVertex.color+8]
|
|
|
|
|
mov [edi+GLVertex.color+8],ecx ;q.color.v[2]=p0.color.v[2]
|
2014-11-07 16:23:03 +01:00
|
|
|
|
@@:
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
2016-09-16 10:39:28 +02:00
|
|
|
|
cmp dword[edx+GLContext.texture_2d_enabled],0 ;if (context.texture_2d_enabled)
|
2014-11-07 16:23:03 +01:00
|
|
|
|
je @f
|
2014-12-01 17:52:18 +01:00
|
|
|
|
mov ecx,[p1]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fld dword[ecx+GLVertex.tex_coord+offs_X]
|
|
|
|
|
fsub dword[eax+GLVertex.tex_coord+offs_X]
|
2014-12-01 17:52:18 +01:00
|
|
|
|
fmul dword[t]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fadd dword[eax+GLVertex.tex_coord+offs_X]
|
|
|
|
|
fstp dword[edi+GLVertex.tex_coord+offs_X] ;q.tex_coord.X=p0.tex_coord.X + (p1.tex_coord.X-p0.tex_coord.X)*t
|
|
|
|
|
fld dword[ecx+GLVertex.tex_coord+offs_Y]
|
|
|
|
|
fsub dword[eax+GLVertex.tex_coord+offs_Y]
|
2014-12-01 17:52:18 +01:00
|
|
|
|
fmul dword[t]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
fadd dword[eax+GLVertex.tex_coord+offs_Y]
|
|
|
|
|
fstp dword[edi+GLVertex.tex_coord+offs_Y] ;q.tex_coord.Y=p0.tex_coord.Y + (p1.tex_coord.Y-p0.tex_coord.Y)*t
|
2014-11-07 16:23:03 +01:00
|
|
|
|
@@:
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
2020-09-16 08:59:01 +02:00
|
|
|
|
stdcall gl_clipcode, [edi+GLVertex.pc+offs_X],[edi+GLVertex.pc+offs_Y],\
|
|
|
|
|
[edi+GLVertex.pc+offs_Z],[edi+GLVertex.pc+offs_W]
|
|
|
|
|
mov dword[edi+GLVertex.clip_code],eax
|
2015-01-05 20:13:01 +01:00
|
|
|
|
or eax,eax ;if (q.clip_code==0)
|
|
|
|
|
jnz @f
|
2016-02-08 16:32:44 +01:00
|
|
|
|
stdcall gl_transform_to_viewport,[context],edi
|
2020-09-16 08:59:01 +02:00
|
|
|
|
lea eax,[edi+GLVertex.zp+offs_zbup_b]
|
2014-12-01 17:52:18 +01:00
|
|
|
|
push eax
|
|
|
|
|
add eax,offs_zbup_g-offs_zbup_b
|
|
|
|
|
push eax
|
|
|
|
|
add eax,offs_zbup_r-offs_zbup_g
|
|
|
|
|
push eax
|
2020-09-16 08:59:01 +02:00
|
|
|
|
stdcall RGBFtoRGBI, dword[edi+GLVertex.color],dword[edi+GLVertex.color+4],dword[edi+GLVertex.color+8]
|
2014-12-01 17:52:18 +01:00
|
|
|
|
@@:
|
2014-11-07 16:23:03 +01:00
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 16
|
2014-11-07 16:23:03 +01:00
|
|
|
|
proc gl_draw_triangle, context:dword, p0:dword, p1:dword, p2:dword
|
|
|
|
|
locals
|
|
|
|
|
cc rd 3
|
|
|
|
|
front dd ?
|
|
|
|
|
norm dd ? ;float
|
|
|
|
|
endl
|
|
|
|
|
pushad
|
|
|
|
|
mov ebx,[p0]
|
|
|
|
|
mov ecx,[p1]
|
|
|
|
|
mov edx,[p2]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov edi,[ebx+GLVertex.clip_code]
|
2014-11-07 16:23:03 +01:00
|
|
|
|
mov dword[cc],edi
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov eax,[ecx+GLVertex.clip_code]
|
2014-11-07 16:23:03 +01:00
|
|
|
|
mov dword[cc+4],eax
|
|
|
|
|
or edi,eax
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov eax,[edx+GLVertex.clip_code]
|
2014-11-07 16:23:03 +01:00
|
|
|
|
mov dword[cc+8],eax
|
2014-12-01 17:52:18 +01:00
|
|
|
|
or edi,eax ;co = cc[0] | cc[1] | cc[2]
|
2014-11-07 16:23:03 +01:00
|
|
|
|
|
|
|
|
|
; we handle the non clipped case here to go faster
|
2015-01-05 20:13:01 +01:00
|
|
|
|
;or edi,___ - было выше
|
|
|
|
|
jnz .els_0
|
|
|
|
|
;if (co==0)
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov edi,dword[edx+GLVertex.zp+offs_zbup_x]
|
|
|
|
|
sub edi,dword[ebx+GLVertex.zp+offs_zbup_x]
|
2015-02-18 00:01:48 +01:00
|
|
|
|
mov dword[norm],edi ;p2.x-p0.x
|
2014-11-07 16:23:03 +01:00
|
|
|
|
fild dword[norm]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov edi,dword[ecx+GLVertex.zp+offs_zbup_y]
|
|
|
|
|
sub edi,dword[ebx+GLVertex.zp+offs_zbup_y]
|
2015-02-18 00:01:48 +01:00
|
|
|
|
mov dword[norm],edi ;p1.y-p0.y
|
2014-11-07 16:23:03 +01:00
|
|
|
|
fimul dword[norm]
|
2015-02-18 00:01:48 +01:00
|
|
|
|
fchs
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov edi,dword[ecx+GLVertex.zp+offs_zbup_x]
|
|
|
|
|
sub edi,dword[ebx+GLVertex.zp+offs_zbup_x]
|
2015-02-18 00:01:48 +01:00
|
|
|
|
mov dword[norm],edi ;p1.x-p0.x
|
2014-11-07 16:23:03 +01:00
|
|
|
|
fild dword[norm]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov edi,dword[edx+GLVertex.zp+offs_zbup_y]
|
|
|
|
|
sub edi,dword[ebx+GLVertex.zp+offs_zbup_y]
|
2015-02-18 00:01:48 +01:00
|
|
|
|
mov dword[norm],edi ;p2.y-p0.y
|
2014-11-07 16:23:03 +01:00
|
|
|
|
fimul dword[norm]
|
2015-02-18 00:01:48 +01:00
|
|
|
|
faddp
|
2014-11-07 16:23:03 +01:00
|
|
|
|
;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)
|
|
|
|
|
|
|
|
|
|
mov dword[front],0
|
2015-02-18 00:01:48 +01:00
|
|
|
|
ftst
|
2014-11-07 16:23:03 +01:00
|
|
|
|
fstsw ax
|
2015-02-18 00:01:48 +01:00
|
|
|
|
ffree st0
|
|
|
|
|
fincstp
|
2014-11-07 16:23:03 +01:00
|
|
|
|
sahf
|
|
|
|
|
je .end_f
|
2015-02-18 00:01:48 +01:00
|
|
|
|
jae @f
|
|
|
|
|
inc dword[front] ;front = norm < 0.0
|
2014-11-07 16:23:03 +01:00
|
|
|
|
@@:
|
|
|
|
|
mov edi,[context]
|
2016-09-16 10:39:28 +02:00
|
|
|
|
mov eax,dword[edi+GLContext.current_front_face]
|
2014-11-07 16:23:03 +01:00
|
|
|
|
xor dword[front],eax ;front ^= context.current_front_face
|
2015-02-18 00:01:48 +01:00
|
|
|
|
|
2014-11-07 16:23:03 +01:00
|
|
|
|
; back face culling
|
2016-09-16 10:39:28 +02:00
|
|
|
|
cmp dword[edi+GLContext.cull_face_enabled],0
|
2014-11-07 16:23:03 +01:00
|
|
|
|
je .els_1
|
|
|
|
|
; most used case first
|
2016-09-16 10:39:28 +02:00
|
|
|
|
cmp dword[edi+GLContext.current_cull_face],GL_BACK
|
2014-11-07 16:23:03 +01:00
|
|
|
|
jne @f
|
|
|
|
|
cmp dword[front],0
|
|
|
|
|
je .end_f
|
2016-09-16 10:39:28 +02:00
|
|
|
|
stdcall dword[edi+GLContext.draw_triangle_front], edi,ebx,ecx,edx
|
2014-11-07 16:23:03 +01:00
|
|
|
|
jmp .end_f
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-11-07 16:23:03 +01:00
|
|
|
|
@@:
|
2016-09-16 10:39:28 +02:00
|
|
|
|
cmp dword[edi+GLContext.current_cull_face],GL_FRONT
|
2014-11-07 16:23:03 +01:00
|
|
|
|
jne .end_f
|
|
|
|
|
cmp dword[front],0
|
|
|
|
|
jne .end_f
|
2016-09-16 10:39:28 +02:00
|
|
|
|
stdcall dword[edi+GLContext.draw_triangle_back], edi,ebx,ecx,edx
|
2014-11-07 16:23:03 +01:00
|
|
|
|
jmp .end_f
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-11-07 16:23:03 +01:00
|
|
|
|
.els_1:
|
|
|
|
|
; no culling
|
|
|
|
|
cmp dword[front],0
|
|
|
|
|
je @f
|
2016-09-16 10:39:28 +02:00
|
|
|
|
stdcall dword[edi+GLContext.draw_triangle_front], edi,ebx,ecx,edx
|
2014-12-02 16:43:43 +01:00
|
|
|
|
jmp .end_f
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-11-07 16:23:03 +01:00
|
|
|
|
@@:
|
2016-09-16 10:39:28 +02:00
|
|
|
|
stdcall dword[edi+GLContext.draw_triangle_back], edi,ebx,ecx,edx
|
2014-11-07 16:23:03 +01:00
|
|
|
|
jmp .end_f
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-11-07 16:23:03 +01:00
|
|
|
|
.els_0:
|
2014-12-01 17:52:18 +01:00
|
|
|
|
;eax = cc[2]
|
2014-11-07 16:23:03 +01:00
|
|
|
|
and eax,[cc]
|
2014-12-01 17:52:18 +01:00
|
|
|
|
and eax,[cc+4] ;eax = c_and = cc[0] & cc[1] & cc[2]
|
2015-01-05 20:13:01 +01:00
|
|
|
|
or eax,eax ;if (c_and==0)
|
|
|
|
|
jnz .end_f
|
2014-11-07 16:23:03 +01:00
|
|
|
|
stdcall gl_draw_triangle_clip, [context],ebx,ecx,edx,0
|
|
|
|
|
.end_f:
|
|
|
|
|
popad
|
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 16
|
2014-11-07 16:23:03 +01:00
|
|
|
|
proc gl_draw_triangle_clip, context:dword, p0:dword, p1:dword, p2:dword, clip_bit:dword
|
|
|
|
|
locals
|
|
|
|
|
co dd ?
|
|
|
|
|
cc rd 3
|
|
|
|
|
edge_flag_tmp dd ?
|
|
|
|
|
clip_mask dd ?
|
2014-12-01 17:52:18 +01:00
|
|
|
|
q rd 3 ;GLVertex*
|
2014-11-07 16:23:03 +01:00
|
|
|
|
tmp1 GLVertex ?
|
|
|
|
|
tmp2 GLVertex ?
|
|
|
|
|
endl
|
|
|
|
|
pushad
|
|
|
|
|
mov ebx,[p0]
|
|
|
|
|
mov ecx,[p1]
|
|
|
|
|
mov edx,[p2]
|
2014-12-01 17:52:18 +01:00
|
|
|
|
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov edi,[ebx+GLVertex.clip_code]
|
2014-12-01 17:52:18 +01:00
|
|
|
|
mov [cc],edi
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov eax,[ecx+GLVertex.clip_code]
|
2014-12-01 17:52:18 +01:00
|
|
|
|
mov [cc+4],eax
|
2014-11-07 16:23:03 +01:00
|
|
|
|
or edi,eax
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov eax,[edx+GLVertex.clip_code]
|
2014-12-01 17:52:18 +01:00
|
|
|
|
mov [cc+8],eax
|
2014-11-07 16:23:03 +01:00
|
|
|
|
or edi,eax
|
2014-12-01 17:52:18 +01:00
|
|
|
|
mov [co],edi ;co = cc[0] | cc[1] | cc[2]
|
2014-11-07 16:23:03 +01:00
|
|
|
|
|
2015-01-05 20:13:01 +01:00
|
|
|
|
or edi,edi ;if (co == 0)
|
|
|
|
|
jnz .els_0
|
2014-11-07 16:23:03 +01:00
|
|
|
|
stdcall gl_draw_triangle, [context],ebx,ecx,edx
|
|
|
|
|
jmp .end_f
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-11-07 16:23:03 +01:00
|
|
|
|
.els_0:
|
2014-12-01 17:52:18 +01:00
|
|
|
|
;eax = cc[2]
|
2014-11-07 16:23:03 +01:00
|
|
|
|
and eax,[cc]
|
2014-12-01 17:52:18 +01:00
|
|
|
|
and eax,[cc+4] ;c_and = cc[0] & cc[1] & cc[2]
|
2014-11-07 16:23:03 +01:00
|
|
|
|
|
|
|
|
|
; the triangle is completely outside
|
2015-01-05 20:13:01 +01:00
|
|
|
|
or eax,eax ;if (c_and!=0) return
|
|
|
|
|
jnz .end_f
|
2014-11-07 16:23:03 +01:00
|
|
|
|
|
2014-12-01 17:52:18 +01:00
|
|
|
|
; find the next direction to clip
|
|
|
|
|
.cycle_0: ;while (clip_bit < 6 && (co & (1 << clip_bit)) == 0)
|
|
|
|
|
cmp dword[clip_bit],6
|
|
|
|
|
jge .cycle_0_end
|
|
|
|
|
xor eax,eax
|
|
|
|
|
inc eax
|
|
|
|
|
mov ecx,[clip_bit]
|
|
|
|
|
shl eax,cl
|
|
|
|
|
and eax,[co]
|
2015-01-05 20:13:01 +01:00
|
|
|
|
or eax,eax
|
|
|
|
|
jnz .cycle_0_end
|
2014-12-01 17:52:18 +01:00
|
|
|
|
inc dword[clip_bit]
|
|
|
|
|
jmp .cycle_0
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-12-01 17:52:18 +01:00
|
|
|
|
.cycle_0_end:
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
2014-11-07 16:23:03 +01:00
|
|
|
|
; this test can be true only in case of rounding errors
|
|
|
|
|
cmp dword[clip_bit],6
|
|
|
|
|
if 0
|
|
|
|
|
jne @f
|
2014-10-31 22:28:24 +01:00
|
|
|
|
; printf("Error:\n");
|
|
|
|
|
; printf("%f %f %f %f\n",p0->pc.X,p0->pc.Y,p0->pc.Z,p0->pc.W);
|
|
|
|
|
; printf("%f %f %f %f\n",p1->pc.X,p1->pc.Y,p1->pc.Z,p1->pc.W);
|
|
|
|
|
; printf("%f %f %f %f\n",p2->pc.X,p2->pc.Y,p2->pc.Z,p2->pc.W);
|
2014-11-07 16:23:03 +01:00
|
|
|
|
jmp .end_f
|
|
|
|
|
@@:
|
2014-12-01 17:52:18 +01:00
|
|
|
|
end if
|
|
|
|
|
if 1
|
2014-11-07 16:23:03 +01:00
|
|
|
|
je .end_f
|
|
|
|
|
end if
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
2014-12-01 17:52:18 +01:00
|
|
|
|
xor eax,eax
|
|
|
|
|
inc eax
|
|
|
|
|
mov ecx,[clip_bit]
|
|
|
|
|
shl eax,cl
|
|
|
|
|
mov [clip_mask],eax ;1 << clip_bit
|
|
|
|
|
mov edi,[cc]
|
|
|
|
|
xor edi,[cc+4]
|
|
|
|
|
xor edi,[cc+8]
|
|
|
|
|
and eax,edi ;eax = co1 = (cc[0] ^ cc[1] ^ cc[2]) & clip_mask
|
|
|
|
|
|
|
|
|
|
mov ecx,[p1] ;востанавливаем после shl ___,cl
|
|
|
|
|
|
2015-01-05 20:13:01 +01:00
|
|
|
|
or eax,eax ;if (co1)
|
|
|
|
|
jz .els_1
|
2014-12-01 17:52:18 +01:00
|
|
|
|
; one point outside
|
|
|
|
|
mov eax,[cc]
|
|
|
|
|
and eax,[clip_mask]
|
2015-01-05 20:13:01 +01:00
|
|
|
|
or eax,eax ;if (cc[0] & clip_mask)
|
|
|
|
|
jz .els_2
|
2014-12-01 17:52:18 +01:00
|
|
|
|
;q[0]=p0 q[1]=p1 q[2]=p2
|
|
|
|
|
mov [q],ebx
|
|
|
|
|
mov [q+4],ecx
|
|
|
|
|
mov [q+8],edx
|
|
|
|
|
jmp .els_2_end
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-12-01 17:52:18 +01:00
|
|
|
|
.els_2:
|
|
|
|
|
mov eax,[cc+4]
|
|
|
|
|
and eax,[clip_mask]
|
2015-01-05 20:13:01 +01:00
|
|
|
|
or eax,eax ;else if (cc[1] & clip_mask)
|
|
|
|
|
jz .els_3
|
2014-12-01 17:52:18 +01:00
|
|
|
|
;q[0]=p1 q[1]=p2 q[2]=p0
|
|
|
|
|
mov [q],ecx
|
|
|
|
|
mov [q+4],edx
|
|
|
|
|
mov [q+8],ebx
|
|
|
|
|
jmp .els_2_end
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-12-01 17:52:18 +01:00
|
|
|
|
.els_3:
|
|
|
|
|
;q[0]=p2 q[1]=p0 q[2]=p1
|
|
|
|
|
mov [q],edx
|
|
|
|
|
mov [q+4],ebx
|
|
|
|
|
mov [q+8],ecx
|
|
|
|
|
.els_2_end:
|
|
|
|
|
|
|
|
|
|
mov ebx,[q]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
add ebx,GLVertex.pc
|
2014-12-01 17:52:18 +01:00
|
|
|
|
mov ecx,[q+4]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
add ecx,GLVertex.pc
|
2014-12-01 17:52:18 +01:00
|
|
|
|
mov edx,[q+8]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
add edx,GLVertex.pc
|
2014-12-01 17:52:18 +01:00
|
|
|
|
|
|
|
|
|
lea eax,[clip_proc]
|
|
|
|
|
mov edi,[clip_bit]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
lea eax,[eax+4*edi]
|
|
|
|
|
lea edi,[ebp-(2*sizeof.GLVertex)+GLVertex.pc]
|
2014-12-01 17:52:18 +01:00
|
|
|
|
stdcall dword[eax],edi,ebx,ecx ;clip_proc[clip_bit](&tmp1.pc,&q[0].pc,&q[1].pc)
|
2020-09-16 08:59:01 +02:00
|
|
|
|
sub edi,GLVertex.pc
|
2014-12-01 17:52:18 +01:00
|
|
|
|
|
2020-09-16 08:59:01 +02:00
|
|
|
|
sub ebx,GLVertex.pc
|
|
|
|
|
sub ecx,GLVertex.pc
|
2016-02-08 16:32:44 +01:00
|
|
|
|
stdcall updateTmp,[context],ebx,ecx,eax ;(c,&tmp1,q[0],q[1],tt)
|
2020-09-16 08:59:01 +02:00
|
|
|
|
add ebx,GLVertex.pc
|
2014-12-01 17:52:18 +01:00
|
|
|
|
|
|
|
|
|
lea eax,[clip_proc]
|
|
|
|
|
mov edi,[clip_bit]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
lea eax,[eax+4*edi]
|
|
|
|
|
lea edi,[ebp-sizeof.GLVertex+GLVertex.pc]
|
2014-12-01 17:52:18 +01:00
|
|
|
|
stdcall dword[eax],edi,ebx,edx ;clip_proc[clip_bit](&tmp2.pc,&q[0].pc,&q[2].pc)
|
2020-09-16 08:59:01 +02:00
|
|
|
|
sub edi,GLVertex.pc
|
|
|
|
|
sub ebx,GLVertex.pc
|
|
|
|
|
sub edx,GLVertex.pc
|
2016-02-08 16:32:44 +01:00
|
|
|
|
stdcall updateTmp,[context],ebx,edx,eax ;(c,&tmp2,q[0],q[2],tt)
|
2014-12-01 17:52:18 +01:00
|
|
|
|
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov eax,[ebx+GLVertex.edge_flag]
|
2015-01-05 20:13:01 +01:00
|
|
|
|
mov [tmp1.edge_flag],eax ;q[0].edge_flag
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov eax,[edx+GLVertex.edge_flag]
|
2014-12-01 17:52:18 +01:00
|
|
|
|
mov [edge_flag_tmp],eax ;q[2].edge_flag
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov dword[edx+GLVertex.edge_flag],0 ;q[2].edge_flag=0
|
2014-12-01 17:52:18 +01:00
|
|
|
|
mov eax,[clip_bit]
|
|
|
|
|
inc eax
|
|
|
|
|
push eax ;для вызова нижней функции
|
2020-09-16 08:59:01 +02:00
|
|
|
|
lea edi,[ebp-2*sizeof.GLVertex]
|
2014-12-01 17:52:18 +01:00
|
|
|
|
stdcall gl_draw_triangle_clip,[context],edi,ecx,edx,eax ;gl_draw_triangle_clip(c,&tmp1,q[1],q[2],clip_bit+1)
|
|
|
|
|
|
|
|
|
|
mov dword[tmp2.edge_flag],0
|
|
|
|
|
mov dword[tmp1.edge_flag],0
|
|
|
|
|
mov eax,[edge_flag_tmp]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov [edx+GLVertex.edge_flag],eax ;q[2].edge_flag=edge_flag_tmp
|
2014-12-01 17:52:18 +01:00
|
|
|
|
push edx
|
|
|
|
|
push edi
|
|
|
|
|
add edi,sizeof.GLVertex ;edi = &tmp2
|
|
|
|
|
stdcall gl_draw_triangle_clip,[context],edi ;gl_draw_triangle_clip(c,&tmp2,&tmp1,q[2],clip_bit+1)
|
|
|
|
|
jmp .end_f
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-12-01 17:52:18 +01:00
|
|
|
|
.els_1:
|
|
|
|
|
; two points outside
|
|
|
|
|
mov eax,[cc]
|
|
|
|
|
and eax,[clip_mask]
|
|
|
|
|
cmp eax,0 ;if (cc[0] & clip_mask)==0
|
|
|
|
|
jne .els_4
|
|
|
|
|
;q[0]=p0 q[1]=p1 q[2]=p2
|
|
|
|
|
mov [q],ebx
|
|
|
|
|
mov [q+4],ecx
|
|
|
|
|
mov [q+8],edx
|
|
|
|
|
jmp .els_4_end
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-12-01 17:52:18 +01:00
|
|
|
|
.els_4:
|
|
|
|
|
mov eax,[cc+4]
|
|
|
|
|
and eax,[clip_mask]
|
|
|
|
|
cmp eax,0 ;else if (cc[1] & clip_mask)==0
|
|
|
|
|
jne .els_5
|
|
|
|
|
;q[0]=p1 q[1]=p2 q[2]=p0
|
|
|
|
|
mov [q],ecx
|
|
|
|
|
mov [q+4],edx
|
|
|
|
|
mov [q+8],ebx
|
|
|
|
|
jmp .els_4_end
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-12-01 17:52:18 +01:00
|
|
|
|
.els_5:
|
|
|
|
|
;q[0]=p2 q[1]=p0 q[2]=p1
|
|
|
|
|
mov [q],edx
|
|
|
|
|
mov [q+4],ebx
|
|
|
|
|
mov [q+8],ecx
|
|
|
|
|
.els_4_end:
|
|
|
|
|
|
|
|
|
|
mov ebx,[q]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
add ebx,GLVertex.pc
|
2014-12-01 17:52:18 +01:00
|
|
|
|
mov ecx,[q+4]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
add ecx,GLVertex.pc
|
2014-12-01 17:52:18 +01:00
|
|
|
|
mov edx,[q+8]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
add edx,GLVertex.pc
|
2014-12-01 17:52:18 +01:00
|
|
|
|
|
|
|
|
|
lea eax,[clip_proc]
|
|
|
|
|
mov edi,[clip_bit]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
lea eax,[eax+4*edi]
|
|
|
|
|
lea edi,[ebp-(2*sizeof.GLVertex)+GLVertex.pc]
|
2014-12-01 17:52:18 +01:00
|
|
|
|
stdcall dword[eax],edi,ebx,ecx ;clip_proc[clip_bit](&tmp1.pc,&q[0].pc,&q[1].pc)
|
2020-09-16 08:59:01 +02:00
|
|
|
|
sub edi,GLVertex.pc
|
2016-02-08 16:32:44 +01:00
|
|
|
|
stdcall updateTmp,[context],[q],[q+4],eax
|
2014-12-01 17:52:18 +01:00
|
|
|
|
|
|
|
|
|
lea eax,[clip_proc]
|
|
|
|
|
mov edi,[clip_bit]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
lea eax,[eax+4*edi]
|
|
|
|
|
lea edi,[ebp-sizeof.GLVertex+GLVertex.pc]
|
2014-12-01 17:52:18 +01:00
|
|
|
|
stdcall dword[eax],edi,ebx,edx ;clip_proc[clip_bit](&tmp2.pc,&q[0].pc,&q[2].pc)
|
2020-09-16 08:59:01 +02:00
|
|
|
|
sub edi,GLVertex.pc
|
2016-02-08 16:32:44 +01:00
|
|
|
|
stdcall updateTmp,[context],[q],[q+8],eax
|
2014-12-01 17:52:18 +01:00
|
|
|
|
|
2015-01-05 20:13:01 +01:00
|
|
|
|
mov dword[tmp1.edge_flag],1
|
2020-09-16 08:59:01 +02:00
|
|
|
|
mov eax,[edx+GLVertex.edge_flag-GLVertex.pc]
|
2015-01-05 20:13:01 +01:00
|
|
|
|
mov dword[tmp2.edge_flag],eax ;tmp2.edge_flag = q[2].edge_flag
|
2014-12-01 17:52:18 +01:00
|
|
|
|
mov eax,[clip_bit]
|
|
|
|
|
inc eax
|
|
|
|
|
push eax
|
|
|
|
|
push edi
|
|
|
|
|
sub edi,sizeof.GLVertex
|
|
|
|
|
stdcall gl_draw_triangle_clip,[context],[q],edi ;gl_draw_triangle_clip(c,q[0],&tmp1,&tmp2,clip_bit+1)
|
2014-11-07 16:23:03 +01:00
|
|
|
|
.end_f:
|
|
|
|
|
popad
|
|
|
|
|
ret
|
|
|
|
|
endp
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 16
|
2014-10-31 22:28:24 +01:00
|
|
|
|
proc gl_draw_triangle_select uses eax, context:dword, p0:dword,p1:dword,p2:dword
|
|
|
|
|
mov eax,[p2]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
push dword[eax+GLVertex.zp+offs_Z]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
mov eax,[p1]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
push dword[eax+GLVertex.zp+offs_Z]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
mov eax,[p0]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
push dword[eax+GLVertex.zp+offs_Z]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
stdcall gl_add_select1, [context] ;,p0.zp.z, p1.zp.z, p2.zp.z
|
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
2014-11-07 16:23:03 +01:00
|
|
|
|
if PROFILE eq 1
|
|
|
|
|
count_triangles dd ?
|
|
|
|
|
count_triangles_textured dd ?
|
|
|
|
|
count_pixels dd ?
|
|
|
|
|
end if
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 16
|
2014-11-07 16:23:03 +01:00
|
|
|
|
proc gl_draw_triangle_fill, context:dword, p0:dword,p1:dword,p2:dword
|
|
|
|
|
pushad
|
|
|
|
|
if PROFILE eq 1
|
2014-10-31 22:28:24 +01:00
|
|
|
|
; int norm;
|
|
|
|
|
; assert(p0->zp.x >= 0 && p0->zp.x < c->zb->xsize);
|
|
|
|
|
; assert(p0->zp.y >= 0 && p0->zp.y < c->zb->ysize);
|
|
|
|
|
; assert(p1->zp.x >= 0 && p1->zp.x < c->zb->xsize);
|
|
|
|
|
; assert(p1->zp.y >= 0 && p1->zp.y < c->zb->ysize);
|
|
|
|
|
; assert(p2->zp.x >= 0 && p2->zp.x < c->zb->xsize);
|
|
|
|
|
; assert(p2->zp.y >= 0 && p2->zp.y < c->zb->ysize);
|
|
|
|
|
|
|
|
|
|
; norm=(p1->zp.x-p0->zp.x)*(p2->zp.y-p0->zp.y)-
|
|
|
|
|
; (p2->zp.x-p0->zp.x)*(p1->zp.y-p0->zp.y);
|
|
|
|
|
; count_pixels+=abs(norm)/2;
|
2014-11-07 16:23:03 +01:00
|
|
|
|
inc dword[count_triangles]
|
|
|
|
|
end if
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
2014-11-07 16:23:03 +01:00
|
|
|
|
mov ebx,[p1]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
add ebx,GLVertex.zp
|
2014-11-07 16:23:03 +01:00
|
|
|
|
mov ecx,[p2]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
add ecx,GLVertex.zp
|
2014-10-31 22:28:24 +01:00
|
|
|
|
mov edx,[context]
|
2016-09-16 10:39:28 +02:00
|
|
|
|
cmp dword[edx+GLContext.texture_2d_enabled],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
je .els_i
|
|
|
|
|
;if (context.texture_2d_enabled)
|
2014-11-07 16:23:03 +01:00
|
|
|
|
if PROFILE eq 1
|
|
|
|
|
inc dword[count_triangles_textured]
|
|
|
|
|
end if
|
2016-09-16 10:39:28 +02:00
|
|
|
|
mov eax,[edx+GLContext.current_texture]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
mov eax,[eax] ;переход по указателю
|
|
|
|
|
;так как offs_text_images+offs_imag_pixmap = 0 то context.current_texture.images[0].pixmap = [eax]
|
2016-09-16 10:39:28 +02:00
|
|
|
|
stdcall ZB_setTexture, [edx+GLContext.zb], [eax],\
|
2016-02-17 22:33:10 +01:00
|
|
|
|
[eax+offs_imag_s_bound],[eax+offs_imag_t_bound],[eax+offs_imag_xsize_log2]
|
2014-11-07 16:23:03 +01:00
|
|
|
|
mov eax,[p0]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
add eax,GLVertex.zp
|
2016-02-04 10:24:21 +01:00
|
|
|
|
push ecx
|
|
|
|
|
push ebx
|
|
|
|
|
push eax
|
2016-09-16 10:39:28 +02:00
|
|
|
|
push dword[edx+GLContext.zb]
|
|
|
|
|
cmp dword[edx+GLContext.matrix_model_projection_no_w_transform],0
|
2016-02-04 10:24:21 +01:00
|
|
|
|
je @f
|
|
|
|
|
call ZB_fillTriangleMappingPerspective
|
|
|
|
|
jmp .end_f
|
|
|
|
|
align 4
|
|
|
|
|
@@:
|
|
|
|
|
call ZB_fillTriangleMapping
|
2014-10-31 22:28:24 +01:00
|
|
|
|
jmp .end_f
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
|
.els_i:
|
2014-11-07 16:23:03 +01:00
|
|
|
|
mov eax,[p0]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
add eax,GLVertex.zp
|
2016-09-16 10:39:28 +02:00
|
|
|
|
cmp dword[edx+GLContext.current_shade_model],GL_SMOOTH
|
2014-11-07 16:23:03 +01:00
|
|
|
|
jne .els
|
|
|
|
|
;else if (context.current_shade_model == GL_SMOOTH)
|
2016-09-16 10:39:28 +02:00
|
|
|
|
stdcall ZB_fillTriangleSmooth, dword[edx+GLContext.zb],eax,ebx,ecx
|
2014-11-07 16:23:03 +01:00
|
|
|
|
jmp .end_f
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-11-07 16:23:03 +01:00
|
|
|
|
.els:
|
2016-09-16 10:39:28 +02:00
|
|
|
|
stdcall ZB_fillTriangleFlat, dword[edx+GLContext.zb],eax,ebx,ecx
|
2014-10-31 22:28:24 +01:00
|
|
|
|
.end_f:
|
2014-11-07 16:23:03 +01:00
|
|
|
|
popad
|
2014-10-31 22:28:24 +01:00
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
; Render a clipped triangle in line mode
|
|
|
|
|
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 16
|
2014-10-31 22:28:24 +01:00
|
|
|
|
proc gl_draw_triangle_line uses eax ebx ecx edx, context:dword, p0:dword,p1:dword,p2:dword
|
|
|
|
|
mov edx,[context]
|
2016-09-16 10:39:28 +02:00
|
|
|
|
cmp dword[edx+GLContext.depth_test],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
je .els
|
|
|
|
|
lea ecx,[ZB_line_z]
|
|
|
|
|
jmp @f
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
|
.els:
|
|
|
|
|
lea ecx,[ZB_line]
|
|
|
|
|
@@:
|
|
|
|
|
|
|
|
|
|
;if (p0.edge_flag) ZB_line_z(context.zb,&p0.zp,&p1.zp)
|
|
|
|
|
mov eax,[p0]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
cmp dword[eax+GLVertex.edge_flag],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
je @f
|
2020-09-16 08:59:01 +02:00
|
|
|
|
lea ebx,[eax+GLVertex.zp]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
mov eax,[p1]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
add eax,GLVertex.zp
|
2016-09-16 10:39:28 +02:00
|
|
|
|
stdcall ecx,dword[edx+GLContext.zb],ebx,eax
|
2014-10-31 22:28:24 +01:00
|
|
|
|
@@:
|
|
|
|
|
;if (p1.edge_flag) ZB_line_z(context.zb,&p1.zp,&p2.zp)
|
|
|
|
|
mov eax,[p1]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
cmp dword[eax+GLVertex.edge_flag],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
je @f
|
2020-09-16 08:59:01 +02:00
|
|
|
|
lea ebx,[eax+GLVertex.zp]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
mov eax,[p2]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
add eax,GLVertex.zp
|
2016-09-16 10:39:28 +02:00
|
|
|
|
stdcall ecx,dword[edx+GLContext.zb],ebx,eax
|
2014-10-31 22:28:24 +01:00
|
|
|
|
@@:
|
|
|
|
|
;if (p2.edge_flag) ZB_line_z(context.zb,&p2.zp,&p0.zp);
|
|
|
|
|
mov eax,[p2]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
cmp dword[eax+GLVertex.edge_flag],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
je @f
|
2020-09-16 08:59:01 +02:00
|
|
|
|
lea ebx,[eax+GLVertex.zp]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
mov eax,[p0]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
add eax,GLVertex.zp
|
2016-09-16 10:39:28 +02:00
|
|
|
|
stdcall ecx,dword[edx+GLContext.zb],ebx,eax
|
2014-10-31 22:28:24 +01:00
|
|
|
|
@@:
|
|
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
; Render a clipped triangle in point mode
|
2016-02-04 10:24:21 +01:00
|
|
|
|
align 16
|
2020-09-16 08:59:01 +02:00
|
|
|
|
proc gl_draw_triangle_point uses eax edx, context:dword, p0:dword,p1:dword,p2:dword
|
2014-10-31 22:28:24 +01:00
|
|
|
|
mov edx,[context]
|
|
|
|
|
mov eax,[p0]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
cmp dword[eax+GLVertex.edge_flag],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
je @f
|
2020-09-16 08:59:01 +02:00
|
|
|
|
lea eax,[eax+GLVertex.zp]
|
|
|
|
|
stdcall ZB_plot,dword[edx+GLContext.zb],eax
|
2014-10-31 22:28:24 +01:00
|
|
|
|
@@:
|
2014-11-22 20:14:55 +01:00
|
|
|
|
mov eax,[p1]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
cmp dword[eax+GLVertex.edge_flag],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
je @f
|
2020-09-16 08:59:01 +02:00
|
|
|
|
lea eax,[eax+GLVertex.zp]
|
|
|
|
|
stdcall ZB_plot,dword[edx+GLContext.zb],eax
|
2014-10-31 22:28:24 +01:00
|
|
|
|
@@:
|
2014-11-22 20:14:55 +01:00
|
|
|
|
mov eax,[p2]
|
2020-09-16 08:59:01 +02:00
|
|
|
|
cmp dword[eax+GLVertex.edge_flag],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
je @f
|
2020-09-16 08:59:01 +02:00
|
|
|
|
lea eax,[eax+GLVertex.zp]
|
|
|
|
|
stdcall ZB_plot,dword[edx+GLContext.zb],eax
|
2014-10-31 22:28:24 +01:00
|
|
|
|
@@:
|
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|