2015-01-05 20:13:01 +01:00
|
|
|
if DEBUG
|
|
|
|
f_vt db ' gl_vertex_transform',0
|
|
|
|
end if
|
2014-10-31 22:28:24 +01:00
|
|
|
|
2016-02-05 21:49:30 +01:00
|
|
|
align 16
|
2014-10-31 22:28:24 +01:00
|
|
|
proc glopNormal uses ecx esi edi, context:dword, p:dword
|
|
|
|
mov esi,[p]
|
|
|
|
add esi,4
|
|
|
|
mov edi,[context]
|
2016-09-16 10:39:28 +02:00
|
|
|
add edi,GLContext.current_normal
|
2014-12-05 22:12:56 +01:00
|
|
|
mov ecx,3
|
2014-10-31 22:28:24 +01:00
|
|
|
rep movsd
|
2014-12-05 22:12:56 +01:00
|
|
|
mov dword[edi],0.0 ;context.current_normal.W = 0.0
|
2014-10-31 22:28:24 +01:00
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
2016-02-05 21:49:30 +01:00
|
|
|
align 16
|
2014-10-31 22:28:24 +01:00
|
|
|
proc glopTexCoord uses ecx esi edi, context:dword, p:dword
|
|
|
|
mov esi,[p]
|
|
|
|
add esi,4
|
|
|
|
mov edi,[context]
|
2016-09-16 10:39:28 +02:00
|
|
|
add edi,GLContext.current_tex_coord
|
2014-10-31 22:28:24 +01:00
|
|
|
mov ecx,4
|
|
|
|
rep movsd
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
2016-02-05 21:49:30 +01:00
|
|
|
align 16
|
2014-10-31 22:28:24 +01:00
|
|
|
proc glopEdgeFlag uses eax ebx, context:dword, p:dword
|
|
|
|
mov eax,[context]
|
|
|
|
mov ebx,[p]
|
|
|
|
mov ebx,[ebx+4] ;ebx = p[1]
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[eax+GLContext.current_edge_flag],ebx
|
2014-10-31 22:28:24 +01:00
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
2016-02-05 21:49:30 +01:00
|
|
|
align 16
|
2014-10-31 22:28:24 +01:00
|
|
|
proc glopColor uses eax ecx esi edi, context:dword, p:dword
|
|
|
|
locals
|
|
|
|
q rd 7
|
|
|
|
endl
|
|
|
|
;current_color[3] = p[1-4]
|
|
|
|
;longcurrent_color[2] = p[5-7]
|
|
|
|
mov esi,[p]
|
|
|
|
add esi,4
|
|
|
|
mov edi,[context]
|
2016-09-16 10:39:28 +02:00
|
|
|
add edi,GLContext.current_color
|
2014-10-31 22:28:24 +01:00
|
|
|
mov ecx,7
|
|
|
|
rep movsd
|
|
|
|
|
|
|
|
mov eax,[context]
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[eax+GLContext.color_material_enabled],0
|
2014-12-02 16:43:43 +01:00
|
|
|
je @f
|
2014-10-31 22:28:24 +01:00
|
|
|
mov dword[q],OP_Material
|
2016-09-16 10:39:28 +02:00
|
|
|
mov ecx,[eax+GLContext.current_color_material_mode]
|
2014-10-31 22:28:24 +01:00
|
|
|
mov dword[q+4],ecx
|
2016-09-16 10:39:28 +02:00
|
|
|
mov ecx,[eax+GLContext.current_color_material_type]
|
2014-10-31 22:28:24 +01:00
|
|
|
mov dword[q+8],ecx
|
|
|
|
mov esi,[p]
|
|
|
|
add esi,4
|
2020-09-14 23:31:00 +02:00
|
|
|
lea edi,[ebp-16] ;edi = &q[3]
|
2014-10-31 22:28:24 +01:00
|
|
|
mov ecx,4
|
|
|
|
rep movsd
|
2014-12-23 23:07:07 +01:00
|
|
|
;mov edi,ebp
|
|
|
|
sub edi,28 ;edi = &q
|
|
|
|
stdcall glopMaterial, eax,edi
|
2014-10-31 22:28:24 +01:00
|
|
|
@@:
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
2016-02-05 21:49:30 +01:00
|
|
|
align 16
|
2014-10-31 22:28:24 +01:00
|
|
|
proc gl_eval_viewport uses eax, context:dword
|
|
|
|
locals
|
|
|
|
zsize dd ? ;float
|
|
|
|
endl
|
|
|
|
mov eax,[context]
|
2016-09-16 10:39:28 +02:00
|
|
|
add eax,GLContext.viewport ;eax = (GLViewport*) v
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
mov dword[zsize],(1 shl (ZB_Z_BITS + ZB_POINT_Z_FRAC_BITS))
|
|
|
|
fild dword[zsize]
|
|
|
|
fstp dword[zsize]
|
|
|
|
|
|
|
|
fld1
|
|
|
|
fld1
|
|
|
|
fadd st1,st0 ;st1 = 2.0
|
|
|
|
fdiv st0,st1 ;st0 = 0.5
|
|
|
|
|
|
|
|
fild dword[eax+offs_vpor_xsize]
|
|
|
|
fsub st0,st1
|
|
|
|
fdiv st0,st2
|
|
|
|
fst dword[eax+offs_vpor_scale+offs_X]
|
|
|
|
fiadd dword[eax+offs_vpor_xmin]
|
|
|
|
fstp dword[eax+offs_vpor_trans+offs_X]
|
|
|
|
|
|
|
|
fild dword[eax+offs_vpor_ysize]
|
|
|
|
fsub st0,st1
|
|
|
|
fdiv st0,st2
|
|
|
|
fchs
|
|
|
|
fst dword[eax+offs_vpor_scale+offs_Y]
|
|
|
|
fchs
|
|
|
|
fiadd dword[eax+offs_vpor_ymin]
|
|
|
|
fstp dword[eax+offs_vpor_trans+offs_Y]
|
|
|
|
|
|
|
|
fld dword[zsize]
|
|
|
|
fsub st0,st1
|
|
|
|
fdiv st0,st2
|
|
|
|
fchs
|
|
|
|
fst dword[eax+offs_vpor_scale+offs_Z]
|
|
|
|
fchs
|
|
|
|
mov dword[zsize],(1 shl ZB_POINT_Z_FRAC_BITS) / 2
|
|
|
|
fiadd dword[zsize]
|
|
|
|
fstp dword[eax+offs_vpor_trans+offs_Z]
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
2016-02-05 21:49:30 +01:00
|
|
|
align 16
|
2014-10-31 22:28:24 +01:00
|
|
|
proc glopBegin uses eax ebx ecx edx, context:dword, p:dword
|
|
|
|
locals
|
|
|
|
tmp M4
|
|
|
|
endl
|
2015-01-05 20:13:01 +01:00
|
|
|
;assert(context.in_begin == 0)
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
mov edx,[context]
|
|
|
|
mov ebx,[p]
|
|
|
|
mov ebx,[ebx+4] ;ebx = p[1]
|
2016-09-16 10:39:28 +02:00
|
|
|
mov [edx+GLContext.begin_type],ebx
|
|
|
|
mov dword[edx+GLContext.in_begin],1
|
|
|
|
mov dword[edx+GLContext.vertex_n],0
|
|
|
|
mov dword[edx+GLContext.vertex_cnt],0
|
2014-10-31 22:28:24 +01:00
|
|
|
|
2016-09-16 10:39:28 +02:00
|
|
|
bt dword[edx+GLContext.matrix_model_projection_updated],0
|
2014-10-31 22:28:24 +01:00
|
|
|
jnc .end_mmpu
|
|
|
|
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[edx+GLContext.lighting_enabled],0 ;if(context.lighting_enabled)
|
2016-02-05 21:49:30 +01:00
|
|
|
jne .if_0
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[eax+GLContext.texture_2d_enabled],0
|
2016-02-05 21:49:30 +01:00
|
|
|
jne .if_0
|
|
|
|
jmp @f
|
|
|
|
align 4
|
|
|
|
.if_0:
|
2014-12-22 10:21:22 +01:00
|
|
|
if DEBUG ;context.matrix_stack_ptr[0]
|
2016-09-16 10:39:28 +02:00
|
|
|
stdcall gl_print_matrix,dword[edx+GLContext.matrix_stack_ptr],4
|
2014-12-22 10:21:22 +01:00
|
|
|
end if
|
2014-10-31 22:28:24 +01:00
|
|
|
; precompute inverse modelview
|
2020-09-14 23:31:00 +02:00
|
|
|
lea ebx,[ebp-sizeof.M4]
|
2016-09-16 10:39:28 +02:00
|
|
|
stdcall gl_M4_Inv, ebx,dword[edx+GLContext.matrix_stack_ptr]
|
2014-12-22 10:21:22 +01:00
|
|
|
if DEBUG ;tmp
|
|
|
|
stdcall dbg_print,txt_sp,txt_nl
|
|
|
|
stdcall gl_print_matrix,ebx,4
|
|
|
|
end if
|
|
|
|
push ebx
|
2020-09-14 23:31:00 +02:00
|
|
|
lea ebx,[edx+GLContext.matrix_model_view_inv]
|
2014-12-22 10:21:22 +01:00
|
|
|
stdcall gl_M4_Transpose, ebx
|
|
|
|
if DEBUG ;context.matrix_model_view_inv
|
|
|
|
stdcall dbg_print,txt_sp,txt_nl
|
|
|
|
stdcall gl_print_matrix,ebx,4
|
|
|
|
end if
|
2014-10-31 22:28:24 +01:00
|
|
|
jmp .end_if_0
|
2016-02-05 21:49:30 +01:00
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
@@:
|
2020-09-14 23:31:00 +02:00
|
|
|
lea ecx,[edx+GLContext.matrix_model_projection]
|
2014-10-31 22:28:24 +01:00
|
|
|
; precompute projection matrix
|
2016-09-16 10:39:28 +02:00
|
|
|
stdcall gl_M4_Mul, ecx,dword[edx+GLContext.matrix_stack_ptr+4],dword[edx+GLContext.matrix_stack_ptr]
|
2014-12-02 16:43:43 +01:00
|
|
|
|
2014-10-31 22:28:24 +01:00
|
|
|
; test to accelerate computation
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.matrix_model_projection_no_w_transform],0
|
2014-10-31 22:28:24 +01:00
|
|
|
fldz
|
|
|
|
fld dword[ecx+12*4]
|
|
|
|
fcomp st1
|
|
|
|
fstsw ax
|
|
|
|
sahf
|
2015-01-05 20:13:01 +01:00
|
|
|
jne @f
|
2014-10-31 22:28:24 +01:00
|
|
|
fld dword[ecx+13*4]
|
|
|
|
fcomp st1
|
|
|
|
fstsw ax
|
|
|
|
sahf
|
2015-01-05 20:13:01 +01:00
|
|
|
jne @f
|
2014-10-31 22:28:24 +01:00
|
|
|
fld dword[ecx+14*4]
|
|
|
|
fcomp st1
|
|
|
|
fstsw ax
|
|
|
|
sahf
|
2015-01-05 20:13:01 +01:00
|
|
|
jne @f
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.matrix_model_projection_no_w_transform],1
|
2015-01-05 20:13:01 +01:00
|
|
|
@@:
|
|
|
|
ffree st0 ;0.0
|
|
|
|
fincstp
|
2014-10-31 22:28:24 +01:00
|
|
|
.end_if_0:
|
|
|
|
|
|
|
|
; test if the texture matrix is not Identity
|
2020-09-14 23:31:00 +02:00
|
|
|
lea eax,[edx+GLContext.matrix_stack_ptr+8]
|
2014-12-05 22:12:56 +01:00
|
|
|
stdcall gl_M4_IsId,eax
|
|
|
|
xor eax,1
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.apply_texture_matrix],eax
|
2014-10-31 22:28:24 +01:00
|
|
|
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.matrix_model_projection_updated],0
|
2014-10-31 22:28:24 +01:00
|
|
|
.end_mmpu:
|
|
|
|
|
|
|
|
; viewport
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[edx+GLContext.viewport+offs_vpor_updated],0 ;if (context.viewport.updated)
|
2014-10-31 22:28:24 +01:00
|
|
|
je @f
|
|
|
|
stdcall gl_eval_viewport,edx
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.viewport+offs_vpor_updated],0
|
2014-10-31 22:28:24 +01:00
|
|
|
@@:
|
|
|
|
; triangle drawing functions
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[edx+GLContext.render_mode],GL_SELECT
|
2014-10-31 22:28:24 +01:00
|
|
|
jne @f
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.draw_triangle_front],gl_draw_triangle_select
|
|
|
|
mov dword[edx+GLContext.draw_triangle_back],gl_draw_triangle_select
|
2014-10-31 22:28:24 +01:00
|
|
|
jmp .end_if_2
|
2016-02-05 21:49:30 +01:00
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
@@:
|
|
|
|
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[edx+GLContext.polygon_mode_front],GL_POINT
|
2014-10-31 22:28:24 +01:00
|
|
|
jne @f
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.draw_triangle_front],gl_draw_triangle_point
|
2014-10-31 22:28:24 +01:00
|
|
|
jmp .end_if_1
|
2016-02-05 21:49:30 +01:00
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
@@:
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[edx+GLContext.polygon_mode_front],GL_LINE
|
2014-10-31 22:28:24 +01:00
|
|
|
jne @f
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.draw_triangle_front],gl_draw_triangle_line
|
2014-10-31 22:28:24 +01:00
|
|
|
jmp .end_if_1
|
2016-02-05 21:49:30 +01:00
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
@@: ;default:
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.draw_triangle_front],gl_draw_triangle_fill
|
2014-10-31 22:28:24 +01:00
|
|
|
.end_if_1:
|
|
|
|
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[edx+GLContext.polygon_mode_back],GL_POINT
|
2014-10-31 22:28:24 +01:00
|
|
|
jne @f
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.draw_triangle_back],gl_draw_triangle_point
|
2014-10-31 22:28:24 +01:00
|
|
|
jmp .end_if_2
|
2016-02-05 21:49:30 +01:00
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
@@:
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[edx+GLContext.polygon_mode_back],GL_LINE
|
2014-10-31 22:28:24 +01:00
|
|
|
jne @f
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.draw_triangle_back],gl_draw_triangle_line
|
2014-10-31 22:28:24 +01:00
|
|
|
jmp .end_if_2
|
2016-02-05 21:49:30 +01:00
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
@@: ;default:
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[edx+GLContext.draw_triangle_back],gl_draw_triangle_fill
|
2014-10-31 22:28:24 +01:00
|
|
|
.end_if_2:
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
|
|
|
; coords, tranformation , clip code and projection
|
|
|
|
; TODO : handle all cases
|
2016-02-05 21:49:30 +01:00
|
|
|
align 16
|
2014-10-31 22:28:24 +01:00
|
|
|
proc gl_vertex_transform, context:dword, v:dword
|
|
|
|
pushad
|
|
|
|
mov eax,[context]
|
|
|
|
mov edx,[v]
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[eax+GLContext.lighting_enabled],0 ;if (context.lighting_enabled)
|
2016-02-05 21:49:30 +01:00
|
|
|
jne @f
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[eax+GLContext.texture_2d_enabled],0
|
2016-02-05 21:49:30 +01:00
|
|
|
jne @f
|
|
|
|
jmp .els_0
|
|
|
|
align 4
|
|
|
|
@@:
|
2014-10-31 22:28:24 +01:00
|
|
|
; eye coordinates needed for lighting
|
2016-09-16 10:39:28 +02:00
|
|
|
mov ebx,dword[eax+GLContext.matrix_stack_ptr]
|
2014-10-31 22:28:24 +01:00
|
|
|
finit
|
2020-09-14 23:31:00 +02:00
|
|
|
fld dword[edx+GLVertex.coord+offs_X]
|
|
|
|
fld dword[edx+GLVertex.coord+offs_Y]
|
|
|
|
fld dword[edx+GLVertex.coord+offs_Z]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
mov ecx,4
|
|
|
|
.cycle_0:
|
|
|
|
fld dword[ebx] ;st0 = m[0]
|
|
|
|
fmul st0,st3 ;st0 *= v.coord.X
|
|
|
|
fld dword[ebx+4] ;st0 = m[1]
|
|
|
|
fmul st0,st3 ;st0 *= v.coord.Y
|
2014-12-26 22:47:10 +01:00
|
|
|
faddp ;st0 = v.coord.X * m[0] + v.coord.Y * m[1]
|
2014-10-31 22:28:24 +01:00
|
|
|
fld dword[ebx+8] ;st0 = m[2]
|
2014-12-26 22:47:10 +01:00
|
|
|
fmul st0,st2 ;st0 *= v.coord.Z
|
2014-10-31 22:28:24 +01:00
|
|
|
fadd dword[ebx+12] ;st0 += m[3]
|
2015-02-10 22:00:36 +01:00
|
|
|
faddp ;st0 = v.ec.X
|
2020-09-14 23:31:00 +02:00
|
|
|
fstp dword[edx+GLVertex.ec] ;v.ec.X = v.coord.X * m[0] + v.coord.Y * m[1] + v.coord.Z * m[2] + m[3]
|
2014-10-31 22:28:24 +01:00
|
|
|
add ebx,16 ;следущая строка матрицы
|
|
|
|
add edx,4 ;следущая координата вектора
|
|
|
|
loop .cycle_0
|
2014-12-05 22:12:56 +01:00
|
|
|
ffree st0
|
|
|
|
fincstp
|
|
|
|
ffree st0
|
|
|
|
fincstp
|
|
|
|
ffree st0
|
|
|
|
fincstp
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
; projection coordinates
|
2016-09-16 10:39:28 +02:00
|
|
|
mov ebx,dword[eax+GLContext.matrix_stack_ptr+4]
|
2014-10-31 22:28:24 +01:00
|
|
|
mov edx,[v]
|
2014-12-05 22:12:56 +01:00
|
|
|
|
2020-09-14 23:31:00 +02:00
|
|
|
fld dword[edx+GLVertex.ec+offs_X]
|
|
|
|
fld dword[edx+GLVertex.ec+offs_Y]
|
|
|
|
fld dword[edx+GLVertex.ec+offs_Z]
|
|
|
|
fld dword[edx+GLVertex.ec+offs_W]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
mov ecx,4
|
|
|
|
.cycle_1:
|
|
|
|
fld dword[ebx] ;st0 = m[0]
|
2015-02-10 22:00:36 +01:00
|
|
|
fmul st0,st4 ;st0 *= v.ec.X
|
2014-10-31 22:28:24 +01:00
|
|
|
fld dword[ebx+4] ;st0 = m[1]
|
2015-02-10 22:00:36 +01:00
|
|
|
fmul st0,st4 ;st0 *= v.ec.Y
|
2014-12-26 22:47:10 +01:00
|
|
|
faddp ;st0 = v.ec.X * m[0] + v.ec.Y * m[1]
|
2014-10-31 22:28:24 +01:00
|
|
|
fld dword[ebx+8] ;st0 = m[2]
|
2015-02-10 22:00:36 +01:00
|
|
|
fmul st0,st3 ;st0 *= v.ec.Z
|
|
|
|
faddp ;st0 = v.ec.X * m[0] + v.ec.Y * m[1] + v.ec.Z * m[2]
|
|
|
|
fld dword[ebx+12] ;st0 = m[3]
|
|
|
|
fmul st0,st2 ;st0 *= v.ec.W
|
2014-12-26 22:47:10 +01:00
|
|
|
faddp ;st0 = v.pc.X
|
2020-09-14 23:31:00 +02:00
|
|
|
fstp dword[edx+GLVertex.pc] ;v.pc.X = v.ec.X * m[0] + v.ec.Y * m[1] + v.ec.Z * m[2] + v.ec.W * m[3]
|
2014-10-31 22:28:24 +01:00
|
|
|
add ebx,16 ;следущая строка матрицы
|
|
|
|
add edx,4 ;следущая координата вектора
|
|
|
|
loop .cycle_1
|
2014-12-05 22:12:56 +01:00
|
|
|
ffree st0
|
|
|
|
fincstp
|
|
|
|
ffree st0
|
|
|
|
fincstp
|
|
|
|
ffree st0
|
|
|
|
fincstp
|
2015-02-10 22:00:36 +01:00
|
|
|
ffree st0
|
|
|
|
fincstp
|
2014-10-31 22:28:24 +01:00
|
|
|
|
2020-09-14 23:31:00 +02:00
|
|
|
lea ebx,[eax+GLContext.matrix_model_view_inv]
|
|
|
|
lea edi,[eax+GLContext.current_normal]
|
2014-10-31 22:28:24 +01:00
|
|
|
mov edx,[v]
|
2014-12-05 22:12:56 +01:00
|
|
|
|
2014-12-22 10:21:22 +01:00
|
|
|
fld dword[edi] ;edi = &n
|
2014-10-31 22:28:24 +01:00
|
|
|
fld dword[edi+offs_Y]
|
|
|
|
fld dword[edi+offs_Z]
|
|
|
|
|
2020-09-14 23:31:00 +02:00
|
|
|
add edx,GLVertex.normal
|
2015-02-10 22:00:36 +01:00
|
|
|
|
|
|
|
fld dword[ebx] ;st0 = m[0]
|
|
|
|
fmul st0,st3 ;st0 *= n.X
|
|
|
|
fld dword[ebx+4] ;st0 = m[1]
|
|
|
|
fmul st0,st3 ;st0 *= n.Y
|
|
|
|
faddp ;st0 = n.X * m[0] + n.Y * m[1]
|
|
|
|
fld dword[ebx+8] ;st0 = m[2]
|
|
|
|
fmul st0,st2 ;st0 *= n.Z
|
|
|
|
faddp ;st0 = v.normal.X
|
|
|
|
fstp dword[edx] ;v.normal.X = n.X * m[0] + n.Y * m[1] + n.Z * m[2]
|
|
|
|
|
|
|
|
fld dword[ebx+16];st0 = m[4]
|
|
|
|
fmul st0,st3 ;st0 *= n.X
|
|
|
|
fld dword[ebx+20];st0 = m[5]
|
|
|
|
fmul st0,st3 ;st0 *= n.Y
|
|
|
|
faddp ;st0 = n.X * m[4] + n.Y * m[5]
|
|
|
|
fld dword[ebx+24];st0 = m[6]
|
|
|
|
fmul st0,st2 ;st0 *= n.Z
|
|
|
|
faddp ;st0 = v.normal.X
|
|
|
|
fstp dword[edx+4];v.normal.X = n.X * m[4] + n.Y * m[5] + n.Z * m[6]
|
|
|
|
|
|
|
|
fld dword[ebx+32];st0 = m[8]
|
|
|
|
fmul st0,st3 ;st0 *= n.X
|
|
|
|
fld dword[ebx+36];st0 = m[9]
|
|
|
|
fmul st0,st3 ;st0 *= n.Y
|
|
|
|
faddp ;st0 = n.X * m[8] + n.Y * m[9]
|
|
|
|
fld dword[ebx+40];st0 = m[10]
|
|
|
|
fmul st0,st2 ;st0 *= n.Z
|
|
|
|
faddp ;st0 = v.normal.X
|
|
|
|
fstp dword[edx+8];v.normal.X = n.X * m[8] + n.Y * m[9] + n.Z * m[10]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[eax+GLContext.normalize_enabled],0
|
2014-10-31 22:28:24 +01:00
|
|
|
je .end_els
|
2014-12-05 22:12:56 +01:00
|
|
|
stdcall gl_V3_Norm,edx
|
2014-10-31 22:28:24 +01:00
|
|
|
jmp .end_els
|
2016-02-05 21:49:30 +01:00
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
.els_0:
|
|
|
|
; no eye coordinates needed, no normal
|
|
|
|
; NOTE: W = 1 is assumed
|
2020-09-14 23:31:00 +02:00
|
|
|
lea ebx,[eax+GLContext.matrix_model_projection]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
finit
|
2020-09-14 23:31:00 +02:00
|
|
|
fld dword[edx+GLVertex.coord+offs_X]
|
|
|
|
fld dword[edx+GLVertex.coord+offs_Y]
|
|
|
|
fld dword[edx+GLVertex.coord+offs_Z]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
2020-09-14 23:31:00 +02:00
|
|
|
lea esi,[edx+GLVertex.pc]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
fld dword[ebx] ;st0 = m[0]
|
|
|
|
fmul st0,st3 ;st0 *= v.coord.X
|
|
|
|
fld dword[ebx+4] ;st0 = m[1]
|
|
|
|
fmul st0,st3 ;st0 *= v.coord.Y
|
2014-12-26 22:47:10 +01:00
|
|
|
faddp ;st0 = v.coord.X * m[0] + v.coord.Y * m[1]
|
2014-10-31 22:28:24 +01:00
|
|
|
fld dword[ebx+8] ;st0 = m[2]
|
2014-12-26 22:47:10 +01:00
|
|
|
fmul st0,st2 ;st0 *= v.coord.Z
|
2014-10-31 22:28:24 +01:00
|
|
|
fadd dword[ebx+12] ;st0 += m[3]
|
2014-12-26 22:47:10 +01:00
|
|
|
faddp ;st0 = v.pc.X
|
2014-10-31 22:28:24 +01:00
|
|
|
fstp dword[esi] ;v.pc.X = v.coord.X * m[0] + v.coord.Y * m[1] + v.coord.Z * m[2] + m[3]
|
2014-11-07 16:23:03 +01:00
|
|
|
|
2014-10-31 22:28:24 +01:00
|
|
|
fld dword[ebx+16] ;st0 = m[4]
|
|
|
|
fmul st0,st3 ;st0 *= v.coord.X
|
|
|
|
fld dword[ebx+20] ;st0 = m[5]
|
|
|
|
fmul st0,st3 ;st0 *= v.coord.Y
|
2014-12-26 22:47:10 +01:00
|
|
|
faddp ;st0 = v.coord.X * m[4] + v.coord.Y * m[5]
|
2014-10-31 22:28:24 +01:00
|
|
|
fld dword[ebx+24] ;st0 = m[6]
|
2014-12-26 22:47:10 +01:00
|
|
|
fmul st0,st2 ;st0 *= v.coord.Z
|
2014-10-31 22:28:24 +01:00
|
|
|
fadd dword[ebx+28] ;st0 += m[7]
|
2014-12-26 22:47:10 +01:00
|
|
|
faddp ;st0 = v.pc.Y
|
|
|
|
fstp dword[esi+4] ;v.pc.Y = v.coord.X * m[4] + v.coord.Y * m[5] + v.coord.Z * m[6] + m[7]
|
2014-11-07 16:23:03 +01:00
|
|
|
|
2014-10-31 22:28:24 +01:00
|
|
|
fld dword[ebx+32] ;st0 = m[8]
|
|
|
|
fmul st0,st3 ;st0 *= v.coord.X
|
|
|
|
fld dword[ebx+36] ;st0 = m[9]
|
|
|
|
fmul st0,st3 ;st0 *= v.coord.Y
|
2014-12-26 22:47:10 +01:00
|
|
|
faddp ;st0 = v.coord.X * m[8] + v.coord.Y * m[9]
|
2014-10-31 22:28:24 +01:00
|
|
|
fld dword[ebx+40] ;st0 = m[10]
|
2014-12-26 22:47:10 +01:00
|
|
|
fmul st0,st2 ;st0 *= v.coord.Z
|
2014-10-31 22:28:24 +01:00
|
|
|
fadd dword[ebx+44] ;st0 += m[11]
|
2014-12-26 22:47:10 +01:00
|
|
|
faddp ;st0 = v.pc.Z
|
|
|
|
fstp dword[esi+8] ;v.pc.Z = v.coord.X * m[8] + v.coord.Y * m[9] + v.coord.Z * m[10] + m[11]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[eax+GLContext.matrix_model_projection_no_w_transform],0
|
2014-10-31 22:28:24 +01:00
|
|
|
je .els_1
|
|
|
|
;if (context.matrix_model_projection_no_w_transform)
|
|
|
|
mov ebx,dword[ebx+60] ;ebx = m[15]
|
|
|
|
mov dword[esi+12],ebx ;v.pc.W = m[15]
|
|
|
|
jmp .end_els
|
2016-02-05 21:49:30 +01:00
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
.els_1:
|
|
|
|
fld dword[ebx+48] ;st0 = m[12]
|
|
|
|
fmul st0,st3 ;st0 *= v.coord.X
|
|
|
|
fld dword[ebx+52] ;st0 = m[13]
|
|
|
|
fmul st0,st3 ;st0 *= v.coord.Y
|
2014-12-26 22:47:10 +01:00
|
|
|
faddp ;st0 = v.coord.X * m[12] + v.coord.Y * m[13]
|
2014-10-31 22:28:24 +01:00
|
|
|
fld dword[ebx+56] ;st0 = m[14]
|
2014-12-26 22:47:10 +01:00
|
|
|
fmul st0,st2 ;st0 *= v.coord.Z
|
2014-10-31 22:28:24 +01:00
|
|
|
fadd dword[ebx+60] ;st0 += m[15]
|
2014-12-26 22:47:10 +01:00
|
|
|
faddp ;st0 = v.pc.W
|
2014-10-31 22:28:24 +01:00
|
|
|
fstp dword[esi+12] ;v.pc.W = v.coord.X * m[12] + v.coord.Y * m[13] + v.coord.Z * m[14] + m[15]
|
|
|
|
.end_els:
|
2014-11-07 16:23:03 +01:00
|
|
|
ffree st0
|
|
|
|
fincstp
|
|
|
|
ffree st0
|
|
|
|
fincstp
|
|
|
|
ffree st0
|
|
|
|
fincstp
|
|
|
|
|
2014-10-31 22:28:24 +01:00
|
|
|
if DEBUG ;gl_vertex_transform
|
|
|
|
stdcall dbg_print,f_vt,txt_nl
|
|
|
|
mov edx,[v]
|
2020-09-14 23:31:00 +02:00
|
|
|
add edx,GLVertex.pc
|
2014-10-31 22:28:24 +01:00
|
|
|
stdcall gl_print_matrix,edx,1
|
|
|
|
end if
|
|
|
|
mov edx,[v]
|
2020-09-14 23:31:00 +02:00
|
|
|
stdcall gl_clipcode, dword[edx+GLVertex.pc+offs_X], dword[edx+GLVertex.pc+offs_Y],\
|
|
|
|
dword[edx+GLVertex.pc+offs_Z], dword[edx+GLVertex.pc+offs_W]
|
|
|
|
mov dword[edx+GLVertex.clip_code],eax
|
2014-10-31 22:28:24 +01:00
|
|
|
popad
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
2016-02-05 21:49:30 +01:00
|
|
|
align 16
|
2014-10-31 22:28:24 +01:00
|
|
|
proc glopVertex, context:dword, p:dword
|
|
|
|
locals
|
|
|
|
;ebx = GLVertex * v
|
|
|
|
n dd ? ;ebp-4
|
|
|
|
endl
|
|
|
|
pushad
|
|
|
|
mov edx,[context]
|
|
|
|
|
|
|
|
; assert(c->in_begin != 0);
|
|
|
|
|
2016-09-16 10:39:28 +02:00
|
|
|
mov ecx,[edx+GLContext.vertex_n]
|
2014-10-31 22:28:24 +01:00
|
|
|
mov [n],ecx
|
2016-09-16 10:39:28 +02:00
|
|
|
inc dword[edx+GLContext.vertex_cnt]
|
2014-10-31 22:28:24 +01:00
|
|
|
|
|
|
|
; quick fix to avoid crashes on large polygons
|
2016-09-16 10:39:28 +02:00
|
|
|
mov ecx,[edx+GLContext.vertex_max]
|
2014-10-31 22:28:24 +01:00
|
|
|
cmp dword[n],ecx
|
|
|
|
jl @f
|
2016-09-16 10:39:28 +02:00
|
|
|
shl dword[edx+GLContext.vertex_max],1 ; just double size
|
2014-10-31 22:28:24 +01:00
|
|
|
imul ecx,2*sizeof.GLVertex
|
|
|
|
stdcall gl_malloc,ecx
|
|
|
|
cmp eax,0
|
|
|
|
jne .no_err
|
|
|
|
;gl_fatal_error("unable to allocate GLVertex array.\n");
|
|
|
|
.no_err:
|
|
|
|
mov edi,eax
|
|
|
|
mov ebx,eax
|
2016-09-16 10:39:28 +02:00
|
|
|
mov esi,[edx+GLContext.vertex]
|
2014-10-31 22:28:24 +01:00
|
|
|
mov ecx,[n]
|
|
|
|
imul ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb
|
|
|
|
rep movsd
|
2016-09-16 10:39:28 +02:00
|
|
|
stdcall gl_free,dword[edx+GLContext.vertex]
|
|
|
|
mov dword[edx+GLContext.vertex],ebx
|
2014-10-31 22:28:24 +01:00
|
|
|
@@:
|
|
|
|
; new vertex entry
|
|
|
|
mov ebx,[n]
|
|
|
|
imul ebx,sizeof.GLVertex
|
2016-09-16 10:39:28 +02:00
|
|
|
add ebx,[edx+GLContext.vertex]
|
2014-10-31 22:28:24 +01:00
|
|
|
inc dword[n]
|
|
|
|
|
|
|
|
mov esi,[p]
|
|
|
|
add esi,4
|
2020-09-14 23:31:00 +02:00
|
|
|
lea edi,[ebx+GLVertex.coord] ;edi = &v.coord
|
2014-10-31 22:28:24 +01:00
|
|
|
mov ecx,4
|
|
|
|
rep movsd
|
|
|
|
|
|
|
|
stdcall gl_vertex_transform, edx, ebx
|
|
|
|
|
|
|
|
; color
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[edx+GLContext.lighting_enabled],0
|
2014-10-31 22:28:24 +01:00
|
|
|
je .els_0
|
|
|
|
stdcall gl_shade_vertex, edx,ebx
|
|
|
|
jmp @f
|
2016-02-05 21:49:30 +01:00
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
.els_0:
|
2020-09-14 23:31:00 +02:00
|
|
|
lea esi,[edx+GLContext.current_color]
|
|
|
|
lea edi,[ebx+GLVertex.color] ;edi = &v.color
|
2015-02-10 22:00:36 +01:00
|
|
|
mov ecx,4
|
|
|
|
rep movsd
|
2014-10-31 22:28:24 +01:00
|
|
|
@@:
|
|
|
|
|
|
|
|
; tex coords
|
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 @f
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[edx+GLContext.apply_texture_matrix],0
|
2014-10-31 22:28:24 +01:00
|
|
|
je .els_1
|
2020-09-14 23:31:00 +02:00
|
|
|
lea eax,[edx+GLContext.current_tex_coord]
|
2014-12-26 22:47:10 +01:00
|
|
|
push eax ;&context.current_tex_coord
|
2020-09-14 23:31:00 +02:00
|
|
|
lea eax,[ebx+GLVertex.tex_coord]
|
2016-09-16 10:39:28 +02:00
|
|
|
stdcall gl_M4_MulV4, eax, dword[edx+GLContext.matrix_stack_ptr+8]
|
2014-10-31 22:28:24 +01:00
|
|
|
jmp @f
|
2016-02-05 21:49:30 +01:00
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
.els_1:
|
2020-09-14 23:31:00 +02:00
|
|
|
lea esi,[edx+GLContext.current_tex_coord]
|
|
|
|
lea edi,[ebx+GLVertex.tex_coord]
|
2014-12-26 22:47:10 +01:00
|
|
|
mov ecx,4
|
|
|
|
rep movsd
|
2014-10-31 22:28:24 +01:00
|
|
|
@@:
|
|
|
|
|
|
|
|
; precompute the mapping to the viewport
|
2020-09-14 23:31:00 +02:00
|
|
|
cmp dword[ebx+GLVertex.clip_code],0
|
2014-10-31 22:28:24 +01:00
|
|
|
jne @f
|
|
|
|
stdcall gl_transform_to_viewport, edx,ebx
|
|
|
|
@@:
|
|
|
|
|
|
|
|
; edge flag
|
2016-09-16 10:39:28 +02:00
|
|
|
mov eax,[edx+GLContext.current_edge_flag]
|
2020-09-14 23:31:00 +02:00
|
|
|
mov dword[ebx+GLVertex.edge_flag],eax ;v.edge_flag = context.current_edge_flag
|
2014-10-31 22:28:24 +01:00
|
|
|
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[edx+GLContext.begin_type],GL_POINTS
|
2014-10-31 22:28:24 +01:00
|
|
|
jne @f
|
2016-09-16 10:39:28 +02:00
|
|
|
stdcall gl_draw_point, edx, dword[edx+GLContext.vertex] ;dword[edx+...] = &context.vertex[0]
|
2014-10-31 22:28:24 +01:00
|
|
|
mov dword[n],0
|
|
|
|
jmp .end_f
|
2016-02-05 21:49:30 +01:00
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
@@:
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[edx+GLContext.begin_type],GL_LINES
|
2014-10-31 22:28:24 +01:00
|
|
|
jne @f
|
|
|
|
cmp dword[n],2
|
|
|
|
jne .end_f
|
2016-09-16 10:39:28 +02:00
|
|
|
mov eax,[edx+GLContext.vertex]
|
2014-10-31 22:28:24 +01:00
|
|
|
push eax
|
|
|
|
add eax,sizeof.GLVertex
|
2014-11-07 16:23:03 +01:00
|
|
|
stdcall gl_draw_line, edx, eax
|
2014-10-31 22:28:24 +01:00
|
|
|
xor eax,eax
|
|
|
|
mov dword[n],eax
|
|
|
|
jmp .end_f
|
2016-02-05 21:49:30 +01:00
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
@@:
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[edx+GLContext.begin_type],GL_LINE_STRIP
|
2014-10-31 22:28:24 +01:00
|
|
|
je .li_loop
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[edx+GLContext.begin_type],GL_LINE_LOOP
|
2014-10-31 22:28:24 +01:00
|
|
|
jne @f
|
|
|
|
.li_loop:
|
|
|
|
cmp dword[n],1
|
|
|
|
jne .els_2
|
2016-09-16 10:39:28 +02:00
|
|
|
mov esi,[edx+GLContext.vertex]
|
2020-09-14 23:31:00 +02:00
|
|
|
lea edi,[esi+2*sizeof.GLVertex]
|
2014-10-31 22:28:24 +01:00
|
|
|
mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb
|
|
|
|
rep movsd ;context.vertex[2] = context.vertex[0]
|
|
|
|
jmp .end_f
|
2016-02-05 21:49:30 +01:00
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
.els_2:
|
|
|
|
cmp dword[n],2
|
|
|
|
jne .end_f ;else if (n == 2)
|
2020-09-14 23:31:00 +02:00
|
|
|
mov edi,[edx+GLContext.vertex]
|
|
|
|
lea esi,[edi+sizeof.GLVertex]
|
|
|
|
stdcall gl_draw_line, edx, esi, edi
|
2014-10-31 22:28:24 +01:00
|
|
|
mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb
|
|
|
|
rep movsd ;context.vertex[0] = context.vertex[1]
|
|
|
|
mov dword[n],1
|
|
|
|
jmp .end_f
|
2016-02-05 21:49:30 +01:00
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
@@:
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[edx+GLContext.begin_type],GL_TRIANGLES
|
2014-10-31 22:28:24 +01:00
|
|
|
jne @f
|
|
|
|
cmp dword[n],3
|
|
|
|
jne .end_f
|
2016-09-16 10:39:28 +02:00
|
|
|
mov eax,[edx+GLContext.vertex]
|
2015-02-18 00:01:48 +01:00
|
|
|
mov [esp-12],eax
|
2014-11-07 16:23:03 +01:00
|
|
|
add eax,sizeof.GLVertex
|
2014-12-05 22:12:56 +01:00
|
|
|
mov [esp-8],eax
|
2014-11-07 16:23:03 +01:00
|
|
|
add eax,sizeof.GLVertex
|
2015-02-18 00:01:48 +01:00
|
|
|
mov [esp-4],eax
|
2014-12-05 22:12:56 +01:00
|
|
|
sub esp,12
|
2015-02-18 00:01:48 +01:00
|
|
|
stdcall gl_draw_triangle, edx ;v0,v1,v2
|
2014-10-31 22:28:24 +01:00
|
|
|
xor eax,eax
|
|
|
|
mov dword[n],eax
|
|
|
|
jmp .end_f
|
2016-02-05 21:49:30 +01:00
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
@@:
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[edx+GLContext.begin_type],GL_TRIANGLE_STRIP
|
2014-10-31 22:28:24 +01:00
|
|
|
jne @f
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[edx+GLContext.vertex_cnt],3 ;if (context.vertex_cnt >= 3)
|
2014-12-26 22:47:10 +01:00
|
|
|
jl .end_f
|
|
|
|
cmp dword[n],3
|
|
|
|
jne .ts3
|
|
|
|
xor eax,eax
|
|
|
|
mov dword[n],eax
|
|
|
|
.ts3:
|
|
|
|
; needed to respect triangle orientation
|
2016-09-16 10:39:28 +02:00
|
|
|
mov eax,[edx+GLContext.vertex]
|
|
|
|
bt dword[edx+GLContext.vertex_cnt],0
|
2014-12-26 22:47:10 +01:00
|
|
|
jc .case_1
|
2015-02-18 00:01:48 +01:00
|
|
|
mov [esp-4],eax
|
2014-12-26 22:47:10 +01:00
|
|
|
add eax,sizeof.GLVertex
|
|
|
|
mov [esp-8],eax
|
|
|
|
add eax,sizeof.GLVertex
|
2015-02-18 00:01:48 +01:00
|
|
|
mov [esp-12],eax
|
2014-12-26 22:47:10 +01:00
|
|
|
sub esp,12
|
2015-02-18 00:01:48 +01:00
|
|
|
stdcall gl_draw_triangle, edx ;v2,v1,v0
|
2014-12-26 22:47:10 +01:00
|
|
|
jmp .end_f
|
2016-02-05 21:49:30 +01:00
|
|
|
align 4
|
2014-12-26 22:47:10 +01:00
|
|
|
.case_1:
|
2015-02-18 00:01:48 +01:00
|
|
|
mov [esp-12],eax
|
2014-12-26 22:47:10 +01:00
|
|
|
add eax,sizeof.GLVertex
|
|
|
|
mov [esp-8],eax
|
|
|
|
add eax,sizeof.GLVertex
|
2015-02-18 00:01:48 +01:00
|
|
|
mov [esp-4],eax
|
2014-12-26 22:47:10 +01:00
|
|
|
sub esp,12
|
2015-02-18 00:01:48 +01:00
|
|
|
stdcall gl_draw_triangle, edx ;v0,v1,v2
|
2014-10-31 22:28:24 +01:00
|
|
|
jmp .end_f
|
2016-02-05 21:49:30 +01:00
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
@@:
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[edx+GLContext.begin_type],GL_TRIANGLE_FAN
|
2014-10-31 22:28:24 +01:00
|
|
|
jne @f
|
2014-12-05 22:12:56 +01:00
|
|
|
cmp dword[n],3
|
2014-10-31 22:28:24 +01:00
|
|
|
jne .end_f
|
2016-09-16 10:39:28 +02:00
|
|
|
mov eax,[edx+GLContext.vertex]
|
2015-02-18 00:01:48 +01:00
|
|
|
mov [esp-12],eax
|
2020-09-14 23:31:00 +02:00
|
|
|
lea edi,[eax+sizeof.GLVertex]
|
|
|
|
mov [esp-8],edi
|
|
|
|
lea esi,[edi+sizeof.GLVertex]
|
|
|
|
mov [esp-4],esi
|
2014-12-05 22:12:56 +01:00
|
|
|
sub esp,12
|
2015-02-18 00:01:48 +01:00
|
|
|
stdcall gl_draw_triangle, edx ;v0,v1,v2
|
2014-12-05 22:12:56 +01:00
|
|
|
mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb
|
|
|
|
rep movsd ;context.vertex[1] = context.vertex[2]
|
2014-10-31 22:28:24 +01:00
|
|
|
mov dword[n],2
|
|
|
|
jmp .end_f
|
2016-02-05 21:49:30 +01:00
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
@@:
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[edx+GLContext.begin_type],GL_QUADS
|
2014-10-31 22:28:24 +01:00
|
|
|
jne @f
|
|
|
|
cmp dword[n],4
|
|
|
|
jne .end_f
|
2016-09-16 10:39:28 +02:00
|
|
|
mov eax,[edx+GLContext.vertex]
|
2014-12-02 16:43:43 +01:00
|
|
|
add eax,2*sizeof.GLVertex
|
2020-09-14 23:31:00 +02:00
|
|
|
mov dword[eax+GLVertex.edge_flag],0 ;context.vertex[2].edge_flag = 0
|
2014-12-02 16:43:43 +01:00
|
|
|
push eax
|
|
|
|
sub eax,sizeof.GLVertex
|
|
|
|
push eax
|
|
|
|
sub eax,sizeof.GLVertex
|
|
|
|
stdcall gl_draw_triangle, edx,eax ;v0,v1,v2
|
2020-09-14 23:31:00 +02:00
|
|
|
mov dword[eax+GLVertex.edge_flag],0 ;context.vertex[0].edge_flag = 0
|
2014-12-02 16:43:43 +01:00
|
|
|
add eax,2*sizeof.GLVertex
|
2020-09-14 23:31:00 +02:00
|
|
|
mov dword[eax+GLVertex.edge_flag],1 ;context.vertex[2].edge_flag = 1
|
2014-12-02 16:43:43 +01:00
|
|
|
add eax,sizeof.GLVertex
|
|
|
|
push eax
|
|
|
|
sub eax,sizeof.GLVertex
|
|
|
|
push eax
|
|
|
|
sub eax,2*sizeof.GLVertex
|
|
|
|
stdcall gl_draw_triangle, edx,eax ;v0,v2,v3
|
2014-10-31 22:28:24 +01:00
|
|
|
xor eax,eax
|
|
|
|
mov dword[n],eax
|
|
|
|
jmp .end_f
|
2016-02-05 21:49:30 +01:00
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
@@:
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[edx+GLContext.begin_type],GL_QUAD_STRIP
|
2014-10-31 22:28:24 +01:00
|
|
|
jne @f
|
2014-12-05 22:12:56 +01:00
|
|
|
cmp dword[n],4
|
2014-10-31 22:28:24 +01:00
|
|
|
jne .end_f
|
2016-09-16 10:39:28 +02:00
|
|
|
mov eax,[edx+GLContext.vertex]
|
2015-02-18 00:01:48 +01:00
|
|
|
mov [esp-12],eax
|
2014-12-05 22:12:56 +01:00
|
|
|
mov edi,eax
|
|
|
|
add eax,sizeof.GLVertex
|
|
|
|
mov [esp-8],eax
|
|
|
|
add eax,sizeof.GLVertex
|
2015-02-18 00:01:48 +01:00
|
|
|
mov [esp-4],eax
|
2014-12-05 22:12:56 +01:00
|
|
|
mov esi,eax
|
|
|
|
sub esp,12
|
|
|
|
stdcall gl_draw_triangle, edx ;v0,v1,v2
|
2015-02-18 00:01:48 +01:00
|
|
|
mov [esp-4],eax
|
2014-12-05 22:12:56 +01:00
|
|
|
add eax,sizeof.GLVertex
|
|
|
|
mov [esp-8],eax
|
|
|
|
sub eax,2*sizeof.GLVertex
|
2015-02-18 00:01:48 +01:00
|
|
|
mov [esp-12],eax
|
2014-12-05 22:12:56 +01:00
|
|
|
sub esp,12
|
|
|
|
stdcall gl_draw_triangle, edx ;v1,v3,v2
|
|
|
|
mov ecx,(sizeof.GLVertex)/2 ;((...)/2) копируем 2 вершины
|
|
|
|
rep movsd ;context.vertex[0] = context.vertex[2], context.vertex[1] = context.vertex[3]
|
2014-10-31 22:28:24 +01:00
|
|
|
mov dword[n],2
|
|
|
|
jmp .end_f
|
2016-02-05 21:49:30 +01:00
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
@@:
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[edx+GLContext.begin_type],GL_POLYGON
|
2014-12-02 16:43:43 +01:00
|
|
|
je .end_f
|
2014-10-31 22:28:24 +01:00
|
|
|
; default:
|
|
|
|
; gl_fatal_error("glBegin: type %x not handled\n", c->begin_type);
|
|
|
|
; }
|
|
|
|
.end_f:
|
|
|
|
|
|
|
|
mov ecx,[n]
|
2016-09-16 10:39:28 +02:00
|
|
|
mov [edx+GLContext.vertex_n],ecx
|
2014-10-31 22:28:24 +01:00
|
|
|
popad
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
2016-02-05 21:49:30 +01:00
|
|
|
align 16
|
2014-12-02 16:43:43 +01:00
|
|
|
proc glopEnd uses eax ebx ecx, context:dword, p:dword
|
2014-10-31 22:28:24 +01:00
|
|
|
mov eax,[context]
|
|
|
|
; assert(c->in_begin == 1);
|
|
|
|
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[eax+GLContext.begin_type],GL_LINE_LOOP
|
2014-10-31 22:28:24 +01:00
|
|
|
jne .else_i
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[eax+GLContext.vertex_cnt],3
|
2014-10-31 22:28:24 +01:00
|
|
|
jl .end_i
|
2016-09-16 10:39:28 +02:00
|
|
|
mov ebx,[eax+GLContext.vertex]
|
2014-10-31 22:28:24 +01:00
|
|
|
push ebx
|
|
|
|
add ebx,2*sizeof.GLVertex
|
|
|
|
push ebx
|
|
|
|
stdcall gl_draw_line, eax
|
|
|
|
jmp .end_i
|
2016-02-05 21:49:30 +01:00
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
.else_i:
|
2016-09-16 10:39:28 +02:00
|
|
|
cmp dword[eax+GLContext.begin_type],GL_POLYGON
|
2014-10-31 22:28:24 +01:00
|
|
|
jne .end_i
|
2016-09-16 10:39:28 +02:00
|
|
|
mov ebx,dword[eax+GLContext.vertex_cnt]
|
2014-10-31 22:28:24 +01:00
|
|
|
@@: ;while (ebx >= 3)
|
|
|
|
cmp ebx,3
|
|
|
|
jl .end_i
|
2014-12-02 16:43:43 +01:00
|
|
|
dec ebx
|
|
|
|
mov ecx,ebx
|
|
|
|
imul ecx,sizeof.GLVertex
|
2016-09-16 10:39:28 +02:00
|
|
|
add ecx,[eax+GLContext.vertex]
|
2014-12-02 16:43:43 +01:00
|
|
|
push ecx ;ecx = &context.vertex[i]
|
|
|
|
sub ecx,sizeof.GLVertex
|
|
|
|
push ecx ;ecx = &context.vertex[i-1]
|
2016-09-16 10:39:28 +02:00
|
|
|
stdcall gl_draw_triangle, eax,[eax+GLContext.vertex]
|
2014-10-31 22:28:24 +01:00
|
|
|
jmp @b
|
2016-02-05 21:49:30 +01:00
|
|
|
align 4
|
2014-10-31 22:28:24 +01:00
|
|
|
.end_i:
|
2016-09-16 10:39:28 +02:00
|
|
|
mov dword[eax+GLContext.in_begin],0
|
2014-10-31 22:28:24 +01:00
|
|
|
ret
|
|
|
|
endp
|