TinyGL:
All checks were successful
Build system / Check kernel codestyle (pull_request) Successful in 24s
Build system / Build (pull_request) Successful in 7m5s

- fixed setting of 'GL_FRONT_AND_BACK' mode
- fixed setting of 'GL_SPOT_DIRECTION' angle
- optimization of drawing triangles and lines
- fixes in 'gluCylinder' and 'gluSphere' functions
- 'gluDisk' function added
- optimize function 'calc_buf'
- clean code

Flag: add lighting

info3ds, info3ds_u, test_glu0, test_glu1, test_glu2,
textures0, textures1, textures2:
- updated programs using 'gluCylinder' and 'gluSphere'
This commit is contained in:
2025-04-22 21:43:12 +03:00
committed by Max Logaev
parent cd1c2ce969
commit 062aa527fb
23 changed files with 1155 additions and 722 deletions

View File

@@ -1,5 +1,5 @@
;
; функции для вычисления зеркального цвета (блики)
; functions for calculating specular color (glare)
;
align 4
@@ -10,49 +10,41 @@ locals
endl
mov dword[f_inc],SPECULAR_BUFFER_SIZE
mov ebx,[buf]
add ebx,offs_spec_buf
add ebx,GLSpecBuf.buf
mov dword[ebx],0.0 ;buf.buf[0] = 0.0
xor ecx,ecx
inc ecx
fld dword[shininess] ;сначала берем y
fld1
fidiv dword[f_inc]
fst dword[f_inc] ;f_inc = 1.0f/SPECULAR_BUFFER_SIZE
fst dword[val]
fstp dword[f_inc] ;f_inc = 1.0f/SPECULAR_BUFFER_SIZE
mov dword[val],0.0
align 4
.cycle_0: ;for (i = 1; i <= SPECULAR_BUFFER_SIZE; i++)
.cycle_0: ;for (i = 1; i < SPECULAR_BUFFER_SIZE; i++)
inc ecx
cmp ecx,SPECULAR_BUFFER_SIZE
jg @f
;Вычисляем x^y
jge @f
fld dword[shininess]
fld dword[val]
fadd dword[f_inc]
fst dword[val] ;val += f_inc
;need to calculate pow(val, shininess)
fyl2x ;Стек FPU теперь содержит: st0=z=y*log2(x):
;Теперь считаем 2**z:
fld st0 ;Создаем еще одну копию z
frndint ;Округляем
fyl2x ;the FPU stack now contains: st0=z=y*log2(x):
;now we count 2**z:
fld st0 ;copy z
frndint
fsubr st0,st1 ;st1=z, st0=z-trunc(z)
f2xm1 ;st1=z, st0=2**(z-trunc(z))-1
fld1
faddp ;st1=z, st0=2**(z-trunc(z))
fscale ;st1=z, st0=(2**trunc(z))*(2**(z-trunc(z)))=2**t
fxch st1
fstp st ;Результат остается на вершине стека st0
fstp st ;the result remains on the top of the stack st0
add ebx,4
fstp dword[ebx] ;buf.buf[i] = pow(val, shininess)
ffree st0 ;испорченный shininess
fincstp
fld dword[shininess] ;сначала берем y
fld dword[val]
fadd dword[f_inc]
fst dword[val] ;val += f_inc
inc ecx
jmp .cycle_0
@@:
ffree st0 ;val
fincstp
ffree st0 ;shininess
fincstp
mov dword[ebx+4],1.0
ret
endp
@@ -70,22 +62,22 @@ endl
.cycle_0:
or eax,eax ;while (found)
jz @f
cmp [eax+offs_spec_shininess_i],ebx ;while (found.shininess_i != shininess_i)
cmp [eax+GLSpecBuf.shininess_i],ebx ;while (found.shininess_i != shininess_i)
je @f
mov ecx,[oldest]
mov ecx,[ecx+offs_spec_last_used]
cmp [eax+offs_spec_last_used],ecx ;if (found.last_used < oldest.last_used)
mov ecx,[ecx+GLSpecBuf.last_used]
cmp [eax+GLSpecBuf.last_used],ecx ;if (found.last_used < oldest.last_used)
jge .end_0
mov [oldest],eax ;oldest = found
.end_0:
mov eax,[eax+offs_spec_next] ;found = found.next
mov eax,[eax+GLSpecBuf.next] ;found = found.next
jmp .cycle_0
@@:
cmp dword[found],0 ;if (found) /* hey, found one! */
je @f
mov eax,[found]
mov ecx,[edx+GLContext.specbuf_used_counter]
mov [eax+offs_spec_last_used],ecx ;found.last_used = context.specbuf_used_counter
mov [eax+GLSpecBuf.last_used],ecx ;found.last_used = context.specbuf_used_counter
inc dword[edx+GLContext.specbuf_used_counter]
jmp .end_f ;return found
@@:
@@ -102,21 +94,21 @@ endl
@@:
inc dword[edx+GLContext.specbuf_num_buffers]
mov ecx,[edx+GLContext.specbuf_first]
mov [eax+offs_spec_next],ecx
mov [eax+GLSpecBuf.next],ecx
mov [edx+GLContext.specbuf_first],eax
mov ecx,[edx+GLContext.specbuf_used_counter]
mov [eax+offs_spec_last_used],ecx
mov [eax+GLSpecBuf.last_used],ecx
inc dword[edx+GLContext.specbuf_used_counter]
mov [eax+offs_spec_shininess_i],ebx
mov [eax+GLSpecBuf.shininess_i],ebx
stdcall calc_buf, eax,dword[shininess]
jmp .end_f
.end_1:
; overwrite the lru buffer
;tgl_trace("overwriting spec buffer :(\n");
mov eax,[oldest]
mov [eax+offs_spec_shininess_i],ebx
mov [eax+GLSpecBuf.shininess_i],ebx
mov ecx,[edx+GLContext.specbuf_used_counter]
mov [eax+offs_spec_last_used],ecx
mov [eax+GLSpecBuf.last_used],ecx
inc dword[edx+GLContext.specbuf_used_counter]
stdcall calc_buf, eax,dword[shininess]
.end_f: