fix library and update example 'textures1'

git-svn-id: svn://kolibrios.org@6145 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2016-02-05 20:49:30 +00:00
parent 4b978f2310
commit 84cfd5cf57
4 changed files with 60 additions and 29 deletions

View File

@ -33,14 +33,11 @@ endl
fistp dword[ebx+offs_vert_zp+offs_zbup_y] ;v.zp.y = st0, st0 = st1 fistp dword[ebx+offs_vert_zp+offs_zbup_y] ;v.zp.y = st0, st0 = st1
fld dword[ebx+offs_vert_pc+offs_Z] ;st0 = v.pc.Z fld dword[ebx+offs_vert_pc+offs_Z] ;st0 = v.pc.Z
fmul st0,st1 fmulp
fmul dword[eax+offs_cont_viewport+offs_vpor_scale+offs_Z] fmul dword[eax+offs_cont_viewport+offs_vpor_scale+offs_Z]
fadd dword[eax+offs_cont_viewport+offs_vpor_trans+offs_Z] fadd dword[eax+offs_cont_viewport+offs_vpor_trans+offs_Z]
fistp dword[ebx+offs_vert_zp+offs_zbup_z] ;v.zp.z = st0, st0 = st1 fistp dword[ebx+offs_vert_zp+offs_zbup_z] ;v.zp.z = st0, st0 = st1
ffree st0
fincstp
; color ; color
cmp dword[eax+offs_cont_lighting_enabled],0 ;if (context.lighting_enabled) cmp dword[eax+offs_cont_lighting_enabled],0 ;if (context.lighting_enabled)
je @f je @f
@ -77,7 +74,7 @@ align 4
fild dword[point] fild dword[point]
fmul dword[ebx+offs_vert_tex_coord+offs_Y] ;st0 *= v.tex_coord.Y fmul dword[ebx+offs_vert_tex_coord+offs_Y] ;st0 *= v.tex_coord.Y
fistp dword[ebx+offs_vert_zp+offs_zbup_t] fistp dword[ebx+offs_vert_zp+offs_zbup_t]
add dword[ebx+offs_vert_zp+offs_zbup_s],ZB_POINT_T_MIN add dword[ebx+offs_vert_zp+offs_zbup_t],ZB_POINT_T_MIN
@@: @@:
ret ret
endp endp
@ -181,12 +178,9 @@ proc interpolate uses eax ebx ecx, q:dword,p0:dword,p1:dword,t:dword
fld dword[ecx+offs_vert_color+8] fld dword[ecx+offs_vert_color+8]
fsub dword[ebx+offs_vert_color+8] fsub dword[ebx+offs_vert_color+8]
fmul st0,st1 fmulp
fadd dword[ebx+offs_vert_color+8] fadd dword[ebx+offs_vert_color+8]
fstp dword[eax+offs_vert_color+8] fstp dword[eax+offs_vert_color+8]
ffree st0
fincstp
ret ret
endp endp

View File

@ -149,12 +149,14 @@ draw_window:
mcall SF_CREATE_WINDOW,(50 shl 16)+420,(30 shl 16)+410,0x33ffffff,,caption mcall SF_CREATE_WINDOW,(50 shl 16)+420,(30 shl 16)+410,0x33ffffff,,caption
mov esi,[sc.work_button] mov esi,[sc.work_button]
mcall SF_DEFINE_BUTTON,(6 shl 16)+19,(6 shl 16)+19,3+0x40000000 ;земля 1 mcall SF_DEFINE_BUTTON,(6 shl 16)+19,(6 shl 16)+19,3+0x40000000 ;земля с меридиан.
mcall ,(36 shl 16)+19,,4+0x40000000 ;земля 2 mcall ,(36 shl 16)+19,,4+0x40000000 ;земля
mcall SF_PUT_IMAGE,[image_data_toolbar],(21 shl 16)+21,(5 shl 16)+5 ;земля 1 mov ebx,[image_data_toolbar]
;add ebx,2*IMAGE_TOOLBAR_ICON_SIZE add ebx,IMAGE_TOOLBAR_ICON_SIZE
mcall ,,,(35 shl 16)+5 ;земля 2 mcall SF_PUT_IMAGE,,(21 shl 16)+21,(5 shl 16)+5 ;земля с меридиан.
add ebx,IMAGE_TOOLBAR_ICON_SIZE
mcall ,,,(35 shl 16)+5 ;земля
stdcall [kosglSwapBuffers] stdcall [kosglSwapBuffers]
mcall SF_REDRAW,SSF_END_DRAW mcall SF_REDRAW,SSF_END_DRAW
@ -302,18 +304,22 @@ stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим б
stdcall [glPushMatrix] stdcall [glPushMatrix]
stdcall [glTranslatef], 0.0,0.0,0.5 stdcall [glTranslatef], 0.0,0.0,0.5
stdcall [glScalef], [scale], [scale], [scale] stdcall [glScalef], [scale], [scale], [scale]
;stdcall [glRotatef], [angle_z],0.0,0.0,1.0
stdcall [glRotatef], [angle_y],0.0,1.0,0.0 stdcall [glRotatef], [angle_y],0.0,1.0,0.0
stdcall [glRotatef], [angle_x],1.0,0.0,0.0 stdcall [glRotatef], [angle_x],1.0,0.0,0.0
cmp dword[dr_figure],0 cmp dword[dr_figure],0
jne @f jne @f
; рисование земли ; рисование земли с меридианами
stdcall [gluSphere], [qObj], 1.0, 16,16 stdcall [glColor3f], 0.0, 0.0, 1.0
stdcall [gluQuadricDrawStyle], [qObj],GLU_LINE
stdcall [gluSphere], [qObj], 1.0, 24,18 ;меридианы
stdcall [gluQuadricDrawStyle], [qObj],GLU_FILL
stdcall [gluSphere], [qObj], 0.995, 24,18 ;земля
@@: @@:
cmp dword[dr_figure],1 cmp dword[dr_figure],1
jne @f jne @f
; рисование земли ; рисование земли
stdcall [gluQuadricDrawStyle], [qObj],GLU_FILL
stdcall [gluSphere], [qObj], 1.0, 64,64 stdcall [gluSphere], [qObj], 1.0, 64,64
@@: @@:
stdcall [glPopMatrix] stdcall [glPopMatrix]

View File

@ -2,7 +2,7 @@ if DEBUG
f_vt db ' gl_vertex_transform',0 f_vt db ' gl_vertex_transform',0
end if end if
align 4 align 16
proc glopNormal uses ecx esi edi, context:dword, p:dword proc glopNormal uses ecx esi edi, context:dword, p:dword
mov esi,[p] mov esi,[p]
add esi,4 add esi,4
@ -14,7 +14,7 @@ proc glopNormal uses ecx esi edi, context:dword, p:dword
ret ret
endp endp
align 4 align 16
proc glopTexCoord uses ecx esi edi, context:dword, p:dword proc glopTexCoord uses ecx esi edi, context:dword, p:dword
mov esi,[p] mov esi,[p]
add esi,4 add esi,4
@ -25,7 +25,7 @@ proc glopTexCoord uses ecx esi edi, context:dword, p:dword
ret ret
endp endp
align 4 align 16
proc glopEdgeFlag uses eax ebx, context:dword, p:dword proc glopEdgeFlag uses eax ebx, context:dword, p:dword
mov eax,[context] mov eax,[context]
mov ebx,[p] mov ebx,[p]
@ -34,7 +34,7 @@ proc glopEdgeFlag uses eax ebx, context:dword, p:dword
ret ret
endp endp
align 4 align 16
proc glopColor uses eax ecx esi edi, context:dword, p:dword proc glopColor uses eax ecx esi edi, context:dword, p:dword
locals locals
q rd 7 q rd 7
@ -69,7 +69,7 @@ endl
ret ret
endp endp
align 4 align 16
proc gl_eval_viewport uses eax, context:dword proc gl_eval_viewport uses eax, context:dword
locals locals
zsize dd ? ;float zsize dd ? ;float
@ -115,7 +115,7 @@ endl
endp endp
align 4 align 16
proc glopBegin uses eax ebx ecx edx, context:dword, p:dword proc glopBegin uses eax ebx ecx edx, context:dword, p:dword
locals locals
tmp M4 tmp M4
@ -134,7 +134,12 @@ endl
jnc .end_mmpu jnc .end_mmpu
cmp dword[edx+offs_cont_lighting_enabled],0 ;if(context.lighting_enabled) cmp dword[edx+offs_cont_lighting_enabled],0 ;if(context.lighting_enabled)
je @f jne .if_0
cmp dword[eax+offs_cont_texture_2d_enabled],0
jne .if_0
jmp @f
align 4
.if_0:
if DEBUG ;context.matrix_stack_ptr[0] if DEBUG ;context.matrix_stack_ptr[0]
stdcall gl_print_matrix,dword[edx+offs_cont_matrix_stack_ptr],4 stdcall gl_print_matrix,dword[edx+offs_cont_matrix_stack_ptr],4
end if end if
@ -155,6 +160,7 @@ if DEBUG ;context.matrix_model_view_inv
stdcall gl_print_matrix,ebx,4 stdcall gl_print_matrix,ebx,4
end if end if
jmp .end_if_0 jmp .end_if_0
align 4
@@: @@:
mov ecx,edx mov ecx,edx
add ecx,offs_cont_matrix_model_projection add ecx,offs_cont_matrix_model_projection
@ -207,17 +213,20 @@ end if
mov dword[edx+offs_cont_draw_triangle_front],gl_draw_triangle_select mov dword[edx+offs_cont_draw_triangle_front],gl_draw_triangle_select
mov dword[edx+offs_cont_draw_triangle_back],gl_draw_triangle_select mov dword[edx+offs_cont_draw_triangle_back],gl_draw_triangle_select
jmp .end_if_2 jmp .end_if_2
align 4
@@: @@:
cmp dword[edx+offs_cont_polygon_mode_front],GL_POINT cmp dword[edx+offs_cont_polygon_mode_front],GL_POINT
jne @f jne @f
mov dword[edx+offs_cont_draw_triangle_front],gl_draw_triangle_point mov dword[edx+offs_cont_draw_triangle_front],gl_draw_triangle_point
jmp .end_if_1 jmp .end_if_1
align 4
@@: @@:
cmp dword[edx+offs_cont_polygon_mode_front],GL_LINE cmp dword[edx+offs_cont_polygon_mode_front],GL_LINE
jne @f jne @f
mov dword[edx+offs_cont_draw_triangle_front],gl_draw_triangle_line mov dword[edx+offs_cont_draw_triangle_front],gl_draw_triangle_line
jmp .end_if_1 jmp .end_if_1
align 4
@@: ;default: @@: ;default:
mov dword[edx+offs_cont_draw_triangle_front],gl_draw_triangle_fill mov dword[edx+offs_cont_draw_triangle_front],gl_draw_triangle_fill
.end_if_1: .end_if_1:
@ -226,11 +235,13 @@ end if
jne @f jne @f
mov dword[edx+offs_cont_draw_triangle_back],gl_draw_triangle_point mov dword[edx+offs_cont_draw_triangle_back],gl_draw_triangle_point
jmp .end_if_2 jmp .end_if_2
align 4
@@: @@:
cmp dword[edx+offs_cont_polygon_mode_back],GL_LINE cmp dword[edx+offs_cont_polygon_mode_back],GL_LINE
jne @f jne @f
mov dword[edx+offs_cont_draw_triangle_back],gl_draw_triangle_line mov dword[edx+offs_cont_draw_triangle_back],gl_draw_triangle_line
jmp .end_if_2 jmp .end_if_2
align 4
@@: ;default: @@: ;default:
mov dword[edx+offs_cont_draw_triangle_back],gl_draw_triangle_fill mov dword[edx+offs_cont_draw_triangle_back],gl_draw_triangle_fill
.end_if_2: .end_if_2:
@ -239,13 +250,18 @@ endp
; coords, tranformation , clip code and projection ; coords, tranformation , clip code and projection
; TODO : handle all cases ; TODO : handle all cases
align 4 align 16
proc gl_vertex_transform, context:dword, v:dword proc gl_vertex_transform, context:dword, v:dword
pushad pushad
mov eax,[context] mov eax,[context]
mov edx,[v] mov edx,[v]
cmp dword[eax+offs_cont_lighting_enabled],0 ;if (context.lighting_enabled) cmp dword[eax+offs_cont_lighting_enabled],0 ;if (context.lighting_enabled)
je .els_0 jne @f
cmp dword[eax+offs_cont_texture_2d_enabled],0
jne @f
jmp .els_0
align 4
@@:
; eye coordinates needed for lighting ; eye coordinates needed for lighting
mov ebx,dword[eax+offs_cont_matrix_stack_ptr] mov ebx,dword[eax+offs_cont_matrix_stack_ptr]
finit finit
@ -356,6 +372,7 @@ pushad
je .end_els je .end_els
stdcall gl_V3_Norm,edx stdcall gl_V3_Norm,edx
jmp .end_els jmp .end_els
align 4
.els_0: .els_0:
; no eye coordinates needed, no normal ; no eye coordinates needed, no normal
; NOTE: W = 1 is assumed ; NOTE: W = 1 is assumed
@ -409,6 +426,7 @@ pushad
mov ebx,dword[ebx+60] ;ebx = m[15] mov ebx,dword[ebx+60] ;ebx = m[15]
mov dword[esi+12],ebx ;v.pc.W = m[15] mov dword[esi+12],ebx ;v.pc.W = m[15]
jmp .end_els jmp .end_els
align 4
.els_1: .els_1:
fld dword[ebx+48] ;st0 = m[12] fld dword[ebx+48] ;st0 = m[12]
fmul st0,st3 ;st0 *= v.coord.X fmul st0,st3 ;st0 *= v.coord.X
@ -442,7 +460,7 @@ popad
ret ret
endp endp
align 4 align 16
proc glopVertex, context:dword, p:dword proc glopVertex, context:dword, p:dword
locals locals
;ebx = GLVertex * v ;ebx = GLVertex * v
@ -497,6 +515,7 @@ pushad
je .els_0 je .els_0
stdcall gl_shade_vertex, edx,ebx stdcall gl_shade_vertex, edx,ebx
jmp @f jmp @f
align 4
.els_0: .els_0:
mov esi,edx mov esi,edx
add esi,offs_cont_current_color add esi,offs_cont_current_color
@ -518,6 +537,7 @@ pushad
add eax,offs_vert_tex_coord add eax,offs_vert_tex_coord
stdcall gl_M4_MulV4, eax, dword[edx+offs_cont_matrix_stack_ptr+8] stdcall gl_M4_MulV4, eax, dword[edx+offs_cont_matrix_stack_ptr+8]
jmp @f jmp @f
align 4
.els_1: .els_1:
mov esi,edx mov esi,edx
add esi,offs_cont_current_tex_coord add esi,offs_cont_current_tex_coord
@ -542,6 +562,7 @@ pushad
stdcall gl_draw_point, edx, dword[edx+offs_cont_vertex] ;dword[edx+...] = &context.vertex[0] stdcall gl_draw_point, edx, dword[edx+offs_cont_vertex] ;dword[edx+...] = &context.vertex[0]
mov dword[n],0 mov dword[n],0
jmp .end_f jmp .end_f
align 4
@@: @@:
cmp dword[edx+offs_cont_begin_type],GL_LINES cmp dword[edx+offs_cont_begin_type],GL_LINES
jne @f jne @f
@ -554,6 +575,7 @@ pushad
xor eax,eax xor eax,eax
mov dword[n],eax mov dword[n],eax
jmp .end_f jmp .end_f
align 4
@@: @@:
cmp dword[edx+offs_cont_begin_type],GL_LINE_STRIP cmp dword[edx+offs_cont_begin_type],GL_LINE_STRIP
je .li_loop je .li_loop
@ -568,6 +590,7 @@ pushad
mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb
rep movsd ;context.vertex[2] = context.vertex[0] rep movsd ;context.vertex[2] = context.vertex[0]
jmp .end_f jmp .end_f
align 4
.els_2: .els_2:
cmp dword[n],2 cmp dword[n],2
jne .end_f ;else if (n == 2) jne .end_f ;else if (n == 2)
@ -581,6 +604,7 @@ pushad
rep movsd ;context.vertex[0] = context.vertex[1] rep movsd ;context.vertex[0] = context.vertex[1]
mov dword[n],1 mov dword[n],1
jmp .end_f jmp .end_f
align 4
@@: @@:
cmp dword[edx+offs_cont_begin_type],GL_TRIANGLES cmp dword[edx+offs_cont_begin_type],GL_TRIANGLES
jne @f jne @f
@ -597,6 +621,7 @@ pushad
xor eax,eax xor eax,eax
mov dword[n],eax mov dword[n],eax
jmp .end_f jmp .end_f
align 4
@@: @@:
cmp dword[edx+offs_cont_begin_type],GL_TRIANGLE_STRIP cmp dword[edx+offs_cont_begin_type],GL_TRIANGLE_STRIP
jne @f jne @f
@ -619,6 +644,7 @@ pushad
sub esp,12 sub esp,12
stdcall gl_draw_triangle, edx ;v2,v1,v0 stdcall gl_draw_triangle, edx ;v2,v1,v0
jmp .end_f jmp .end_f
align 4
.case_1: .case_1:
mov [esp-12],eax mov [esp-12],eax
add eax,sizeof.GLVertex add eax,sizeof.GLVertex
@ -628,6 +654,7 @@ pushad
sub esp,12 sub esp,12
stdcall gl_draw_triangle, edx ;v0,v1,v2 stdcall gl_draw_triangle, edx ;v0,v1,v2
jmp .end_f jmp .end_f
align 4
@@: @@:
cmp dword[edx+offs_cont_begin_type],GL_TRIANGLE_FAN cmp dword[edx+offs_cont_begin_type],GL_TRIANGLE_FAN
jne @f jne @f
@ -647,6 +674,7 @@ pushad
rep movsd ;context.vertex[1] = context.vertex[2] rep movsd ;context.vertex[1] = context.vertex[2]
mov dword[n],2 mov dword[n],2
jmp .end_f jmp .end_f
align 4
@@: @@:
cmp dword[edx+offs_cont_begin_type],GL_QUADS cmp dword[edx+offs_cont_begin_type],GL_QUADS
jne @f jne @f
@ -672,6 +700,7 @@ pushad
xor eax,eax xor eax,eax
mov dword[n],eax mov dword[n],eax
jmp .end_f jmp .end_f
align 4
@@: @@:
cmp dword[edx+offs_cont_begin_type],GL_QUAD_STRIP cmp dword[edx+offs_cont_begin_type],GL_QUAD_STRIP
jne @f jne @f
@ -698,6 +727,7 @@ pushad
rep movsd ;context.vertex[0] = context.vertex[2], context.vertex[1] = context.vertex[3] rep movsd ;context.vertex[0] = context.vertex[2], context.vertex[1] = context.vertex[3]
mov dword[n],2 mov dword[n],2
jmp .end_f jmp .end_f
align 4
@@: @@:
cmp dword[edx+offs_cont_begin_type],GL_POLYGON cmp dword[edx+offs_cont_begin_type],GL_POLYGON
je .end_f je .end_f
@ -712,7 +742,7 @@ popad
ret ret
endp endp
align 4 align 16
proc glopEnd uses eax ebx ecx, 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);
@ -727,6 +757,7 @@ proc glopEnd uses eax ebx ecx, context:dword, p:dword
push ebx push ebx
stdcall gl_draw_line, eax stdcall gl_draw_line, eax
jmp .end_i jmp .end_i
align 4
.else_i: .else_i:
cmp dword[eax+offs_cont_begin_type],GL_POLYGON cmp dword[eax+offs_cont_begin_type],GL_POLYGON
jne .end_i jne .end_i
@ -743,6 +774,7 @@ proc glopEnd uses eax ebx ecx, context:dword, p:dword
push ecx ;ecx = &context.vertex[i-1] push ecx ;ecx = &context.vertex[i-1]
stdcall gl_draw_triangle, eax,[eax+offs_cont_vertex] stdcall gl_draw_triangle, eax,[eax+offs_cont_vertex]
jmp @b jmp @b
align 4
.end_i: .end_i:
mov dword[eax+offs_cont_in_begin],0 mov dword[eax+offs_cont_in_begin],0
ret ret

View File

@ -465,7 +465,6 @@ end if
if INTERP_ST eq 1 if INTERP_ST eq 1
mov ebx,[l1] mov ebx,[l1]
mov eax,[ebx+offs_zbup_s] mov eax,[ebx+offs_zbup_s]
add eax,0x00200000 ;прокручиваем горизонтальную координату на 0.5
mov [s1],eax ;s1 = l1.s mov [s1],eax ;s1 = l1.s
mov eax,[dsdx] mov eax,[dsdx]
imul eax,[dxdy_min] imul eax,[dxdy_min]