fix vertex color; add primitives: GL_QUADS, GL_POLYGONS

git-svn-id: svn://kolibrios.org@5213 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2014-12-02 15:43:43 +00:00
parent a909419cc5
commit 1fd28e1eb4
3 changed files with 48 additions and 45 deletions

View File

@ -702,7 +702,7 @@ pushad
mov ebx,[p0] mov ebx,[p0]
mov ecx,[p1] mov ecx,[p1]
mov edx,[p2] mov edx,[p2]
mov edi,[ebx+offs_vert_clip_code] mov edi,[ebx+offs_vert_clip_code]
mov dword[cc],edi mov dword[cc],edi
mov eax,[ecx+offs_vert_clip_code] mov eax,[ecx+offs_vert_clip_code]
@ -719,8 +719,8 @@ pushad
sub edi,dword[ebx+offs_vert_zp+offs_zbup_x] sub edi,dword[ebx+offs_vert_zp+offs_zbup_x]
mov dword[norm],edi mov dword[norm],edi
fild dword[norm] fild dword[norm]
mov esi,dword[ecx+offs_vert_zp+offs_zbup_y] mov edi,dword[ecx+offs_vert_zp+offs_zbup_y]
sub esi,dword[ebx+offs_vert_zp+offs_zbup_y] sub edi,dword[ebx+offs_vert_zp+offs_zbup_y]
mov dword[norm],edi mov dword[norm],edi
fimul dword[norm] fimul dword[norm]
mov edi,dword[ecx+offs_vert_zp+offs_zbup_x] mov edi,dword[ecx+offs_vert_zp+offs_zbup_x]
@ -770,6 +770,7 @@ pushad
cmp dword[front],0 cmp dword[front],0
je @f je @f
stdcall dword[edi+offs_cont_draw_triangle_front], edi,ebx,ecx,edx stdcall dword[edi+offs_cont_draw_triangle_front], edi,ebx,ecx,edx
jmp .end_f
@@: @@:
stdcall dword[edi+offs_cont_draw_triangle_back], edi,ebx,ecx,edx stdcall dword[edi+offs_cont_draw_triangle_back], edi,ebx,ecx,edx
jmp .end_f jmp .end_f
@ -801,20 +802,6 @@ pushad
mov ecx,[p1] mov ecx,[p1]
mov edx,[p2] mov edx,[p2]
if DEBUG ;(1) gl_draw_triangle_clip
pushad
stdcall dbg_print,txt_sp,m_1
add ebx,offs_vert_color
add ecx,offs_vert_color
add edx,offs_vert_color
stdcall gl_print_matrix,ebx,1
stdcall gl_print_matrix,ecx,1
stdcall gl_print_matrix,edx,1
popad
end if
; finit ;???
mov edi,[ebx+offs_vert_clip_code] mov edi,[ebx+offs_vert_clip_code]
mov [cc],edi mov [cc],edi
mov eax,[ecx+offs_vert_clip_code] mov eax,[ecx+offs_vert_clip_code]

View File

@ -46,8 +46,8 @@ endl
rep movsd rep movsd
mov eax,[context] mov eax,[context]
cmp dword[eax+offs_cont_color_material_enabled],1 cmp dword[eax+offs_cont_color_material_enabled],0
jne @f je @f
mov dword[q],OP_Material mov dword[q],OP_Material
mov ecx,[eax+offs_cont_current_color_material_mode] mov ecx,[eax+offs_cont_current_color_material_mode]
mov dword[q+4],ecx mov dword[q+4],ecx
@ -55,7 +55,8 @@ endl
mov dword[q+8],ecx mov dword[q+8],ecx
mov esi,[p] mov esi,[p]
add esi,4 add esi,4
mov edi,dword[q+12] ;edi = [q3] mov edi,ebp
sub edi,16 ;edi = &q[3]
mov ecx,4 mov ecx,4
rep movsd rep movsd
stdcall glopMaterial, eax,[q] stdcall glopMaterial, eax,[q]
@ -147,11 +148,7 @@ endl
add ecx,offs_cont_matrix_model_projection add ecx,offs_cont_matrix_model_projection
; precompute projection matrix ; precompute projection matrix
stdcall gl_M4_Mul, ecx,dword[edx+offs_cont_matrix_stack_ptr+4],dword[edx+offs_cont_matrix_stack_ptr] stdcall gl_M4_Mul, ecx,dword[edx+offs_cont_matrix_stack_ptr+4],dword[edx+offs_cont_matrix_stack_ptr]
;if DEBUG ;glopBegin
;stdcall gl_print_matrix,ecx,4
;stdcall gl_print_matrix,[edx+offs_cont_matrix_stack_ptr+4],4
;stdcall gl_print_matrix,[edx+offs_cont_matrix_stack_ptr],4
;end if
; test to accelerate computation ; test to accelerate computation
mov dword[edx+offs_cont_matrix_model_projection_no_w_transform],0 mov dword[edx+offs_cont_matrix_model_projection_no_w_transform],0
fldz fldz
@ -455,6 +452,10 @@ pushad
.els_0: .els_0:
mov eax,[edx+offs_cont_current_color] mov eax,[edx+offs_cont_current_color]
mov [ebx+offs_vert_color],eax mov [ebx+offs_vert_color],eax
mov eax,[edx+offs_cont_current_color+4]
mov [ebx+offs_vert_color+4],eax
mov eax,[edx+offs_cont_current_color+8]
mov [ebx+offs_vert_color+8],eax
@@: @@:
; tex coords ; tex coords
@ -570,11 +571,23 @@ pushad
jne @f jne @f
cmp dword[n],4 cmp dword[n],4
jne .end_f jne .end_f
; c->vertex[2].edge_flag = 0; mov eax,[edx+offs_cont_vertex]
; gl_draw_triangle(c, &c->vertex[0], &c->vertex[1], &c->vertex[2]); add eax,2*sizeof.GLVertex
; c->vertex[2].edge_flag = 1; mov dword[eax+offs_vert_edge_flag],0 ;context.vertex[2].edge_flag = 0
; c->vertex[0].edge_flag = 0; push eax
; gl_draw_triangle(c, &c->vertex[0], &c->vertex[2], &c->vertex[3]); sub eax,sizeof.GLVertex
push eax
sub eax,sizeof.GLVertex
stdcall gl_draw_triangle, edx,eax ;v0,v1,v2
mov dword[eax+offs_vert_edge_flag],0 ;context.vertex[0].edge_flag = 0
add eax,2*sizeof.GLVertex
mov dword[eax+offs_vert_edge_flag],1 ;context.vertex[2].edge_flag = 1
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
xor eax,eax xor eax,eax
mov dword[n],eax mov dword[n],eax
jmp .end_f jmp .end_f
@ -591,10 +604,7 @@ pushad
jmp .end_f jmp .end_f
@@: @@:
cmp dword[edx+offs_cont_begin_type],GL_POLYGON cmp dword[edx+offs_cont_begin_type],GL_POLYGON
jne @f je .end_f
;...
jmp .end_f
@@:
; default: ; default:
; gl_fatal_error("glBegin: type %x not handled\n", c->begin_type); ; gl_fatal_error("glBegin: type %x not handled\n", c->begin_type);
; } ; }
@ -607,7 +617,7 @@ popad
endp endp
align 4 align 4
proc glopEnd uses eax ebx, context:dword, p:dword proc glopEnd uses eax ebx ecx, context:dword, p:dword
mov eax,[context] mov eax,[context]
; assert(c->in_begin == 1); ; assert(c->in_begin == 1);
@ -628,8 +638,14 @@ proc glopEnd uses eax ebx, context:dword, p:dword
@@: ;while (ebx >= 3) @@: ;while (ebx >= 3)
cmp ebx,3 cmp ebx,3
jl .end_i jl .end_i
dec ebx dec ebx
; gl_draw_triangle(c, &c->vertex[i], &c->vertex[0], &c->vertex[i - 1]); mov ecx,ebx
imul ecx,sizeof.GLVertex
add ecx,[eax+offs_cont_vertex]
push ecx ;ecx = &context.vertex[i]
sub ecx,sizeof.GLVertex
push ecx ;ecx = &context.vertex[i-1]
stdcall gl_draw_triangle, eax,[eax+offs_cont_vertex]
jmp @b jmp @b
.end_i: .end_i:
mov dword[eax+offs_cont_in_begin],0 mov dword[eax+offs_cont_in_begin],0

View File

@ -8,17 +8,17 @@ ZB_Z_BITS equ 16
ZB_POINT_Z_FRAC_BITS equ 14 ZB_POINT_Z_FRAC_BITS equ 14
ZB_POINT_S_MIN equ ( (1 shl 13) ) ZB_POINT_S_MIN equ (1 shl 13)
ZB_POINT_S_MAX equ ( (1 shl 22)-(1 shl 13) ) ZB_POINT_S_MAX equ ( (1 shl 22)-(1 shl 13) )
ZB_POINT_T_MIN equ ( (1 shl 21) ) ZB_POINT_T_MIN equ (1 shl 21)
ZB_POINT_T_MAX equ ( (1 shl 30)-(1 shl 21) ) ZB_POINT_T_MAX equ ( (1 shl 30)-(1 shl 21) )
ZB_POINT_RED_MIN equ ( (1 shl 10) ) ZB_POINT_RED_MIN equ (1 shl 8)
ZB_POINT_RED_MAX equ ( (1 shl 16)-(1 shl 10) ) ZB_POINT_RED_MAX equ ( (1 shl 16)-1 )
ZB_POINT_GREEN_MIN equ ( (1 shl 9) ) ZB_POINT_GREEN_MIN equ (1 shl 8)
ZB_POINT_GREEN_MAX equ ( (1 shl 16)-(1 shl 9) ) ZB_POINT_GREEN_MAX equ ( (1 shl 16)-1 )
ZB_POINT_BLUE_MIN equ ( (1 shl 10) ) ZB_POINT_BLUE_MIN equ (1 shl 8)
ZB_POINT_BLUE_MAX equ ( (1 shl 16)-(1 shl 10) ) ZB_POINT_BLUE_MAX equ ( (1 shl 16)-1 )
; display modes ; display modes
ZB_MODE_5R6G5B equ 1 ; true color 16 bits ZB_MODE_5R6G5B equ 1 ; true color 16 bits