mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-24 23:56:49 +03:00
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
|
||||
align 4
|
||||
proc ClipLine1 uses ebx, denom:dword,num:dword,tmin:dword,tmax:dword
|
||||
fldz
|
||||
fcom dword[denom]
|
||||
fld dword[denom]
|
||||
ftst
|
||||
fstsw ax
|
||||
sahf
|
||||
je .u2
|
||||
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)
|
||||
jbe .els_0 ;if (denom>0)
|
||||
fld dword[num]
|
||||
fdiv dword[denom]
|
||||
|
||||
fxch st1
|
||||
fdivp ;t=num/denom
|
||||
mov ebx,[tmax]
|
||||
fcom dword[ebx]
|
||||
fstsw ax
|
||||
sahf
|
||||
ja .r0_f2 ;if (t>*tmax) return 0
|
||||
|
||||
ja .r0_f1 ;if (t>*tmax) return 0
|
||||
mov ebx,[tmin]
|
||||
fcom dword[ebx]
|
||||
fstsw ax
|
||||
sahf
|
||||
jbe .r1_f2
|
||||
fstp dword[ebx] ;if (t>*tmin) *tmin=t
|
||||
jbe .r1_f1 ;if (t>*tmin) *tmin=t
|
||||
fstp dword[ebx]
|
||||
jmp .r1
|
||||
|
||||
.els_0: ;else if (0>denom)
|
||||
.els_0: ;else if (denom<0)
|
||||
jae .els_1
|
||||
fld dword[num]
|
||||
fdiv dword[denom]
|
||||
|
||||
fxch st1
|
||||
fdivp ;t=num/denom
|
||||
mov ebx,[tmin]
|
||||
fcom dword[ebx]
|
||||
fstsw ax
|
||||
sahf
|
||||
jb .r0_f2 ;if (t<*tmin) return 0
|
||||
|
||||
jb .r0_f1 ;if (t<*tmin) return 0
|
||||
mov ebx,[tmax]
|
||||
fcom dword[ebx]
|
||||
fstsw ax
|
||||
sahf
|
||||
jae .r1_f2
|
||||
jae .r1_f1
|
||||
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
|
||||
fincstp
|
||||
.r0: ;return 0 & free st0
|
||||
.r0: ;return 0
|
||||
xor eax,eax
|
||||
jmp .end_f
|
||||
.r1_f2: ;return 1 & free st0,st1
|
||||
.r1_f1: ;return 1 & free st0
|
||||
ffree st0
|
||||
fincstp
|
||||
.r1: ;return 1 & free st0
|
||||
.r1: ;return 1
|
||||
xor eax,eax
|
||||
inc eax
|
||||
.end_f:
|
||||
ffree st0
|
||||
fincstp
|
||||
ret
|
||||
endp
|
||||
|
||||
|
@ -24,13 +24,13 @@ start:
|
||||
|
||||
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_NORMALIZE ;делам нормали одинаковой величины во избежание артефактов
|
||||
stdcall [gluNewQuadric]
|
||||
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
|
||||
|
||||
call draw_3d
|
||||
@ -56,7 +56,7 @@ draw_window:
|
||||
mcall 12,1
|
||||
|
||||
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]
|
||||
|
||||
mcall 12,2
|
||||
@ -141,14 +141,13 @@ align 4
|
||||
draw_3d:
|
||||
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
|
||||
|
||||
stdcall [glColor3f], 1.0, 1.0, 0.0
|
||||
|
||||
stdcall [glPushMatrix]
|
||||
call SetLight
|
||||
|
||||
stdcall [glTranslatef], 0.0,0.0,0.5
|
||||
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_y],0.0,1.0,0.0
|
||||
stdcall [gluSphere], [qObj], 1.0, 32,32
|
||||
@ -189,9 +188,10 @@ angle_z dd 0.0
|
||||
angle_y dd 0.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 ;направление лампы
|
||||
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 ; Размер блика (обратная пропорция)
|
||||
white_light dd 0.8, 0.8, 0.8, 1.0 ; Цвет и интенсивность освещения, генерируемого источником
|
||||
lmodel_ambient dd 0.2, 0.2, 0.2, 1.0 ; Параметры фонового освещения
|
||||
|
@ -203,7 +203,7 @@ pushad
|
||||
fcom dword[an180f] ;if (a != 180)
|
||||
fstsw ax
|
||||
sahf
|
||||
jne @f
|
||||
je @f
|
||||
fldpi
|
||||
fmulp
|
||||
fdiv dword[an180f]
|
||||
@ -289,7 +289,7 @@ local .end_m
|
||||
fcompp
|
||||
fstsw ax
|
||||
sahf
|
||||
jb .o_2
|
||||
ja .o_2
|
||||
mov eax,1.0
|
||||
jmp .end_m ;return 1.0
|
||||
.o_2:
|
||||
@ -355,19 +355,19 @@ fl_1e_3 dd 1.0e-3
|
||||
if DEBUG
|
||||
txt_mate db 'Material',0
|
||||
txt_colo db 'Color',0
|
||||
txt_rgba db 'R, G, B',0
|
||||
end if
|
||||
|
||||
; non optimized lightening model
|
||||
align 4
|
||||
proc gl_shade_vertex, context:dword, v:dword
|
||||
locals
|
||||
R dd ? ;float ebp-100
|
||||
G dd ? ;float ebp-96
|
||||
B dd ? ;float ebp-92
|
||||
A dd ? ;float ebp-88
|
||||
s V3 ;ebp-84
|
||||
d V3 ;ebp-72
|
||||
dist dd ? ;float ebp-60
|
||||
R dd ? ;float ebp-96
|
||||
G dd ? ;float ebp-92
|
||||
B dd ? ;float ebp-88
|
||||
A dd ? ;float ebp-84
|
||||
s V3 ;ebp-80
|
||||
d V3 ;ebp-68
|
||||
tmp dd ? ;float ebp-56
|
||||
att dd ? ;float ebp-52
|
||||
dot_spot dd ? ;float ebp-48
|
||||
@ -480,8 +480,7 @@ end if
|
||||
fld dword[d+offs_Z]
|
||||
fmul st0,st0
|
||||
faddp
|
||||
fsqrt
|
||||
fst dword[dist] ;dist=sqrt(d.X^2+d.Y^2+d.Z^2)
|
||||
fsqrt ;dist=sqrt(d.X^2+d.Y^2+d.Z^2)
|
||||
fcom dword[fl_1e_3]
|
||||
fstsw ax
|
||||
sahf
|
||||
@ -557,7 +556,7 @@ end if
|
||||
fcomp dword[an180f] ;if (l.spot_cutoff != 180)
|
||||
fstsw ax
|
||||
sahf
|
||||
jne .if1_end
|
||||
je .if1_end
|
||||
fld dword[ebx+offs_ligh_norm_spot_direction]
|
||||
fmul dword[d]
|
||||
fld dword[ebx+offs_ligh_norm_spot_direction+4]
|
||||
@ -675,7 +674,7 @@ end if
|
||||
faddp
|
||||
fld dword[s+offs_Z]
|
||||
fmul st0,st0
|
||||
faddp
|
||||
faddp ;st0 = s.X^2 +s.Y^2 +s.Z^2
|
||||
fsqrt
|
||||
fcom dword[fl_1e_3]
|
||||
fstsw ax
|
||||
@ -697,7 +696,7 @@ end if
|
||||
fstsw ax
|
||||
fild dword[idx]
|
||||
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
|
||||
@@:
|
||||
fistp dword[idx]
|
||||
@ -711,16 +710,22 @@ end if
|
||||
fmul dword[ecx+offs_mate_specular]
|
||||
fadd dword[lR]
|
||||
fstp dword[lR] ;lR+=dot_spec * l.specular.v[0] * m.specular.v[0]
|
||||
;ffree st0
|
||||
;fincstp
|
||||
fld dword[ebx+offs_ligh_specular+4]
|
||||
fmul st0,st1
|
||||
fmul dword[ecx+offs_mate_specular+4]
|
||||
fadd dword[lG]
|
||||
fstp dword[lG] ;lG+=dot_spec * l.specular.v[1] * m.specular.v[1]
|
||||
;ffree st0
|
||||
;fincstp
|
||||
fld dword[ebx+offs_ligh_specular+8]
|
||||
fmul st0,st1
|
||||
fmul dword[ecx+offs_mate_specular+8]
|
||||
fadd dword[lB]
|
||||
fstp dword[lB] ;lB+=dot_spec * l.specular.v[2] * m.specular.v[2]
|
||||
;ffree st0
|
||||
;fincstp
|
||||
ffree st0 ;dot_spec
|
||||
fincstp
|
||||
jmp .if2_end
|
||||
|
Loading…
Reference in New Issue
Block a user