forked from KolibriOS/kolibrios
some fixes
git-svn-id: svn://kolibrios.org@5278 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
07b6e3f4f2
commit
470be179f7
@ -227,74 +227,66 @@ endp
|
|||||||
; tmin,tmax -> &float
|
; tmin,tmax -> &float
|
||||||
align 4
|
align 4
|
||||||
proc ClipLine1 uses ebx, denom:dword,num:dword,tmin:dword,tmax:dword
|
proc ClipLine1 uses ebx, denom:dword,num:dword,tmin:dword,tmax:dword
|
||||||
fldz
|
fld dword[denom]
|
||||||
fcom dword[denom]
|
ftst
|
||||||
fstsw ax
|
fstsw ax
|
||||||
sahf
|
sahf
|
||||||
je .u2
|
jbe .els_0 ;if (denom>0)
|
||||||
jmp @f
|
|
||||||
.u2:
|
|
||||||
fcom dword[num]
|
|
||||||
fstsw ax
|
|
||||||
sahf
|
|
||||||
jb .r0 ;if (denom==0 && num>0) return 0
|
|
||||||
jmp .r1
|
|
||||||
@@:
|
|
||||||
|
|
||||||
fcom dword[denom]
|
|
||||||
fstsw ax
|
|
||||||
sahf
|
|
||||||
ja .els_0 ;if (0<denom)
|
|
||||||
fld dword[num]
|
fld dword[num]
|
||||||
fdiv dword[denom]
|
fxch st1
|
||||||
|
fdivp ;t=num/denom
|
||||||
mov ebx,[tmax]
|
mov ebx,[tmax]
|
||||||
fcom dword[ebx]
|
fcom dword[ebx]
|
||||||
fstsw ax
|
fstsw ax
|
||||||
sahf
|
sahf
|
||||||
ja .r0_f2 ;if (t>*tmax) return 0
|
ja .r0_f1 ;if (t>*tmax) return 0
|
||||||
|
|
||||||
mov ebx,[tmin]
|
mov ebx,[tmin]
|
||||||
fcom dword[ebx]
|
fcom dword[ebx]
|
||||||
fstsw ax
|
fstsw ax
|
||||||
sahf
|
sahf
|
||||||
jbe .r1_f2
|
jbe .r1_f1 ;if (t>*tmin) *tmin=t
|
||||||
fstp dword[ebx] ;if (t>*tmin) *tmin=t
|
fstp dword[ebx]
|
||||||
jmp .r1
|
jmp .r1
|
||||||
|
.els_0: ;else if (denom<0)
|
||||||
.els_0: ;else if (0>denom)
|
jae .els_1
|
||||||
fld dword[num]
|
fld dword[num]
|
||||||
fdiv dword[denom]
|
fxch st1
|
||||||
|
fdivp ;t=num/denom
|
||||||
mov ebx,[tmin]
|
mov ebx,[tmin]
|
||||||
fcom dword[ebx]
|
fcom dword[ebx]
|
||||||
fstsw ax
|
fstsw ax
|
||||||
sahf
|
sahf
|
||||||
jb .r0_f2 ;if (t<*tmin) return 0
|
jb .r0_f1 ;if (t<*tmin) return 0
|
||||||
|
|
||||||
mov ebx,[tmax]
|
mov ebx,[tmax]
|
||||||
fcom dword[ebx]
|
fcom dword[ebx]
|
||||||
fstsw ax
|
fstsw ax
|
||||||
sahf
|
sahf
|
||||||
jae .r1_f2
|
jae .r1_f1
|
||||||
fstp dword[ebx] ;if (t<*tmin) *tmax=t
|
fstp dword[ebx] ;if (t<*tmin) *tmax=t
|
||||||
jmp .r1
|
jmp .r1
|
||||||
|
.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
|
||||||
|
|
||||||
.r0_f2: ;return 0 & free st0,st1
|
.r0_f1: ;return 0 & free st0
|
||||||
ffree st0
|
ffree st0
|
||||||
fincstp
|
fincstp
|
||||||
.r0: ;return 0 & free st0
|
.r0: ;return 0
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
jmp .end_f
|
jmp .end_f
|
||||||
.r1_f2: ;return 1 & free st0,st1
|
.r1_f1: ;return 1 & free st0
|
||||||
ffree st0
|
ffree st0
|
||||||
fincstp
|
fincstp
|
||||||
.r1: ;return 1 & free st0
|
.r1: ;return 1
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
inc eax
|
inc eax
|
||||||
.end_f:
|
.end_f:
|
||||||
ffree st0
|
|
||||||
fincstp
|
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
|
@ -24,13 +24,13 @@ start:
|
|||||||
|
|
||||||
mcall 40,0x27
|
mcall 40,0x27
|
||||||
|
|
||||||
stdcall [kosglMakeCurrent], 10,10,400,325,ctx1
|
stdcall [kosglMakeCurrent], 10,10,400,350,ctx1
|
||||||
stdcall [glEnable], GL_DEPTH_TEST
|
stdcall [glEnable], GL_DEPTH_TEST
|
||||||
stdcall [glEnable], GL_NORMALIZE ;делам нормали одинаковой величины во избежание артефактов
|
stdcall [glEnable], GL_NORMALIZE ;делам нормали одинаковой величины во избежание артефактов
|
||||||
stdcall [gluNewQuadric]
|
stdcall [gluNewQuadric]
|
||||||
mov [qObj],eax
|
mov [qObj],eax
|
||||||
|
|
||||||
stdcall [glClearColor], 0.5,0.5,0.5,0.0
|
stdcall [glClearColor], 0.25,0.25,0.25,0.0
|
||||||
stdcall [glShadeModel], GL_SMOOTH
|
stdcall [glShadeModel], GL_SMOOTH
|
||||||
|
|
||||||
call draw_3d
|
call draw_3d
|
||||||
@ -56,7 +56,7 @@ draw_window:
|
|||||||
mcall 12,1
|
mcall 12,1
|
||||||
|
|
||||||
mov edx,0x33ffffff ;0x73ffffff
|
mov edx,0x33ffffff ;0x73ffffff
|
||||||
mcall 0,(50 shl 16)+430,(30 shl 16)+375,,,caption
|
mcall 0,(50 shl 16)+430,(30 shl 16)+400,,,caption
|
||||||
stdcall [kosglSwapBuffers]
|
stdcall [kosglSwapBuffers]
|
||||||
|
|
||||||
mcall 12,2
|
mcall 12,2
|
||||||
@ -141,14 +141,13 @@ align 4
|
|||||||
draw_3d:
|
draw_3d:
|
||||||
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
|
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
|
||||||
|
|
||||||
stdcall [glColor3f], 1.0, 1.0, 0.0
|
|
||||||
|
|
||||||
stdcall [glPushMatrix]
|
stdcall [glPushMatrix]
|
||||||
call SetLight
|
call SetLight
|
||||||
|
|
||||||
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 [glColor3f], 1.0, 1.0, 0.0
|
||||||
stdcall [glRotatef], [angle_z],0.0,0.0,1.0
|
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 [gluSphere], [qObj], 1.0, 32,32
|
stdcall [gluSphere], [qObj], 1.0, 32,32
|
||||||
@ -189,9 +188,10 @@ angle_z dd 0.0
|
|||||||
angle_y dd 0.0
|
angle_y dd 0.0
|
||||||
delt_size dd 3.0
|
delt_size dd 3.0
|
||||||
|
|
||||||
light_position dd 0.0, 0.0, 2.0, 1000.0 ; Расположение источника [0][1][2], чем ближе [3] к 0, тем ярче свет
|
light_position dd 3.0, 2.0, -10.0, 1.0 ; Расположение источника [0][1][2]
|
||||||
|
;[3] = (0.0 - бесконечно удаленный источник, 1.0 - источник света на определенном расстоянии)
|
||||||
light_dir dd 0.0,0.0,0.0 ;направление лампы
|
light_dir dd 0.0,0.0,0.0 ;направление лампы
|
||||||
mat_specular dd 0.3, 0.3, 0.3, 1.0 ; Цвет блика
|
mat_specular dd 0.1, 0.1, 0.1, 1.0 ; Цвет блика
|
||||||
mat_shininess dd 3.0 ; Размер блика (обратная пропорция)
|
mat_shininess dd 3.0 ; Размер блика (обратная пропорция)
|
||||||
white_light dd 0.8, 0.8, 0.8, 1.0 ; Цвет и интенсивность освещения, генерируемого источником
|
white_light dd 0.8, 0.8, 0.8, 1.0 ; Цвет и интенсивность освещения, генерируемого источником
|
||||||
lmodel_ambient dd 0.2, 0.2, 0.2, 1.0 ; Параметры фонового освещения
|
lmodel_ambient dd 0.2, 0.2, 0.2, 1.0 ; Параметры фонового освещения
|
||||||
|
@ -203,7 +203,7 @@ pushad
|
|||||||
fcom dword[an180f] ;if (a != 180)
|
fcom dword[an180f] ;if (a != 180)
|
||||||
fstsw ax
|
fstsw ax
|
||||||
sahf
|
sahf
|
||||||
jne @f
|
je @f
|
||||||
fldpi
|
fldpi
|
||||||
fmulp
|
fmulp
|
||||||
fdiv dword[an180f]
|
fdiv dword[an180f]
|
||||||
@ -289,7 +289,7 @@ local .end_m
|
|||||||
fcompp
|
fcompp
|
||||||
fstsw ax
|
fstsw ax
|
||||||
sahf
|
sahf
|
||||||
jb .o_2
|
ja .o_2
|
||||||
mov eax,1.0
|
mov eax,1.0
|
||||||
jmp .end_m ;return 1.0
|
jmp .end_m ;return 1.0
|
||||||
.o_2:
|
.o_2:
|
||||||
@ -355,19 +355,19 @@ fl_1e_3 dd 1.0e-3
|
|||||||
if DEBUG
|
if DEBUG
|
||||||
txt_mate db 'Material',0
|
txt_mate db 'Material',0
|
||||||
txt_colo db 'Color',0
|
txt_colo db 'Color',0
|
||||||
|
txt_rgba db 'R, G, B',0
|
||||||
end if
|
end if
|
||||||
|
|
||||||
; non optimized lightening model
|
; non optimized lightening model
|
||||||
align 4
|
align 4
|
||||||
proc gl_shade_vertex, context:dword, v:dword
|
proc gl_shade_vertex, context:dword, v:dword
|
||||||
locals
|
locals
|
||||||
R dd ? ;float ebp-100
|
R dd ? ;float ebp-96
|
||||||
G dd ? ;float ebp-96
|
G dd ? ;float ebp-92
|
||||||
B dd ? ;float ebp-92
|
B dd ? ;float ebp-88
|
||||||
A dd ? ;float ebp-88
|
A dd ? ;float ebp-84
|
||||||
s V3 ;ebp-84
|
s V3 ;ebp-80
|
||||||
d V3 ;ebp-72
|
d V3 ;ebp-68
|
||||||
dist dd ? ;float ebp-60
|
|
||||||
tmp dd ? ;float ebp-56
|
tmp dd ? ;float ebp-56
|
||||||
att dd ? ;float ebp-52
|
att dd ? ;float ebp-52
|
||||||
dot_spot dd ? ;float ebp-48
|
dot_spot dd ? ;float ebp-48
|
||||||
@ -480,8 +480,7 @@ end if
|
|||||||
fld dword[d+offs_Z]
|
fld dword[d+offs_Z]
|
||||||
fmul st0,st0
|
fmul st0,st0
|
||||||
faddp
|
faddp
|
||||||
fsqrt
|
fsqrt ;dist=sqrt(d.X^2+d.Y^2+d.Z^2)
|
||||||
fst dword[dist] ;dist=sqrt(d.X^2+d.Y^2+d.Z^2)
|
|
||||||
fcom dword[fl_1e_3]
|
fcom dword[fl_1e_3]
|
||||||
fstsw ax
|
fstsw ax
|
||||||
sahf
|
sahf
|
||||||
@ -557,7 +556,7 @@ end if
|
|||||||
fcomp dword[an180f] ;if (l.spot_cutoff != 180)
|
fcomp dword[an180f] ;if (l.spot_cutoff != 180)
|
||||||
fstsw ax
|
fstsw ax
|
||||||
sahf
|
sahf
|
||||||
jne .if1_end
|
je .if1_end
|
||||||
fld dword[ebx+offs_ligh_norm_spot_direction]
|
fld dword[ebx+offs_ligh_norm_spot_direction]
|
||||||
fmul dword[d]
|
fmul dword[d]
|
||||||
fld dword[ebx+offs_ligh_norm_spot_direction+4]
|
fld dword[ebx+offs_ligh_norm_spot_direction+4]
|
||||||
@ -675,7 +674,7 @@ end if
|
|||||||
faddp
|
faddp
|
||||||
fld dword[s+offs_Z]
|
fld dword[s+offs_Z]
|
||||||
fmul st0,st0
|
fmul st0,st0
|
||||||
faddp
|
faddp ;st0 = s.X^2 +s.Y^2 +s.Z^2
|
||||||
fsqrt
|
fsqrt
|
||||||
fcom dword[fl_1e_3]
|
fcom dword[fl_1e_3]
|
||||||
fstsw ax
|
fstsw ax
|
||||||
@ -697,7 +696,7 @@ end if
|
|||||||
fstsw ax
|
fstsw ax
|
||||||
fild dword[idx]
|
fild dword[idx]
|
||||||
sahf
|
sahf
|
||||||
jae @f ;if(dot_spec < 1.0)
|
jbe @f ;if(dot_spec < 1.0) st0=1 st1=dot_spec
|
||||||
fmul st0,st1 ;idx *= dot_spec
|
fmul st0,st1 ;idx *= dot_spec
|
||||||
@@:
|
@@:
|
||||||
fistp dword[idx]
|
fistp dword[idx]
|
||||||
@ -711,16 +710,22 @@ end if
|
|||||||
fmul dword[ecx+offs_mate_specular]
|
fmul dword[ecx+offs_mate_specular]
|
||||||
fadd dword[lR]
|
fadd dword[lR]
|
||||||
fstp dword[lR] ;lR+=dot_spec * l.specular.v[0] * m.specular.v[0]
|
fstp dword[lR] ;lR+=dot_spec * l.specular.v[0] * m.specular.v[0]
|
||||||
|
;ffree st0
|
||||||
|
;fincstp
|
||||||
fld dword[ebx+offs_ligh_specular+4]
|
fld dword[ebx+offs_ligh_specular+4]
|
||||||
fmul st0,st1
|
fmul st0,st1
|
||||||
fmul dword[ecx+offs_mate_specular+4]
|
fmul dword[ecx+offs_mate_specular+4]
|
||||||
fadd dword[lG]
|
fadd dword[lG]
|
||||||
fstp dword[lG] ;lG+=dot_spec * l.specular.v[1] * m.specular.v[1]
|
fstp dword[lG] ;lG+=dot_spec * l.specular.v[1] * m.specular.v[1]
|
||||||
|
;ffree st0
|
||||||
|
;fincstp
|
||||||
fld dword[ebx+offs_ligh_specular+8]
|
fld dword[ebx+offs_ligh_specular+8]
|
||||||
fmul st0,st1
|
fmul st0,st1
|
||||||
fmul dword[ecx+offs_mate_specular+8]
|
fmul dword[ecx+offs_mate_specular+8]
|
||||||
fadd dword[lB]
|
fadd dword[lB]
|
||||||
fstp dword[lB] ;lB+=dot_spec * l.specular.v[2] * m.specular.v[2]
|
fstp dword[lB] ;lB+=dot_spec * l.specular.v[2] * m.specular.v[2]
|
||||||
|
;ffree st0
|
||||||
|
;fincstp
|
||||||
ffree st0 ;dot_spec
|
ffree st0 ;dot_spec
|
||||||
fincstp
|
fincstp
|
||||||
jmp .if2_end
|
jmp .if2_end
|
||||||
|
Loading…
Reference in New Issue
Block a user