Subversion Repositories Kolibri OS

Rev

Rev 5153 | Rev 5213 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5153 Rev 5175
Line 234... Line 234...
234
	cmp dword[eax+offs_cont_lighting_enabled],0 ;if (context.lighting_enabled)
234
	cmp dword[eax+offs_cont_lighting_enabled],0 ;if (context.lighting_enabled)
235
	je .els_0
235
	je .els_0
236
		; eye coordinates needed for lighting
236
		; eye coordinates needed for lighting
237
		mov ebx,dword[eax+offs_cont_matrix_stack_ptr]
237
		mov ebx,dword[eax+offs_cont_matrix_stack_ptr]
238
		;;;mov edx,[v]
238
		finit
239
		finit
-
 
240
		fld dword[edx+offs_vert_coord+offs_X]
239
		fld dword[edx+offs_vert_coord+offs_X]
241
		fld dword[edx+offs_vert_coord+offs_Y]
240
		fld dword[edx+offs_vert_coord+offs_Y]
242
		fld dword[edx+offs_vert_coord+offs_Z]
241
		fld dword[edx+offs_vert_coord+offs_Z]
243
 
242
 
Line 249... Line 248...
249
			fmul st0,st3       ;st0 *= v.coord.Y
248
			fmul st0,st3       ;st0 *= v.coord.Y
250
			fld dword[ebx+8]   ;st0 = m[2]
249
			fld dword[ebx+8]   ;st0 = m[2]
251
			fmul st0,st3       ;st0 *= v.coord.Z
250
			fmul st0,st3       ;st0 *= v.coord.Z
252
			fadd dword[ebx+12] ;st0 += m[3]
251
			fadd dword[ebx+12] ;st0 += m[3]
253
			fadd st0,st1       ;st0 += v.coord.Z * m[2] 
252
			faddp              ;st0 += v.coord.Z * m[2] 
254
			fadd st0,st2       ;st0 += v.coord.Y * m[1] 
253
			faddp              ;st0 += v.coord.Y * m[1] 
255
			fstp dword[edx+offs_vert_ec] ;v.ec.X = v.coord.X * m[0] + v.coord.Y * m[1] + v.coord.Z * m[2] + m[3]
254
			fstp dword[edx+offs_vert_ec] ;v.ec.X = v.coord.X * m[0] + v.coord.Y * m[1] + v.coord.Z * m[2] + m[3]
256
			ffree st0
255
			add ebx,16 ;следущая строка матрицы
257
			fincstp
-
 
258
			ffree st0
-
 
259
			fincstp
-
 
260
			add ebx,16 ;следущая строка матрицы
-
 
261
			add edx,4  ;следущая координата вектора
256
			add edx,4  ;следущая координата вектора
262
		loop .cycle_0
257
		loop .cycle_0
263
 
258
 
Line 264... Line 259...
264
		; projection coordinates
259
		; projection coordinates
Line 277... Line 272...
277
			fmul st0,st3       ;st0 *= v.ec.Y
272
			fmul st0,st3       ;st0 *= v.ec.Y
278
			fld dword[ebx+8]   ;st0 = m[2]
273
			fld dword[ebx+8]   ;st0 = m[2]
279
			fmul st0,st3       ;st0 *= v.ec.Z
274
			fmul st0,st3       ;st0 *= v.ec.Z
280
			fadd dword[ebx+12] ;st0 += m[3]
275
			fadd dword[ebx+12] ;st0 += m[3]
281
			fadd st0,st1       ;st0 += v.ec.Z * m[2]
276
			faddp              ;st0 += v.ec.Z * m[2]
282
			fadd st0,st2       ;st0 += v.ec.Y * m[1]
277
			faddp              ;st0 += v.ec.Y * m[1]
283
			fstp dword[edx+offs_vert_pc] ;v.pc.X = v.ec.X * m[0] + v.ec.Y * m[1] + v.ec.Z * m[2] + m[3]
278
			fstp dword[edx+offs_vert_pc] ;v.pc.X = v.ec.X * m[0] + v.ec.Y * m[1] + v.ec.Z * m[2] + m[3]
284
			ffree st0
279
			add ebx,16 ;следущая строка матрицы
285
			fincstp
-
 
286
			ffree st0
-
 
287
			fincstp
-
 
288
			add ebx,16 ;следущая строка матрицы
-
 
289
			add edx,4  ;следущая координата вектора
280
			add edx,4  ;следущая координата вектора
290
		loop .cycle_1
281
		loop .cycle_1
291
 
282
 
Line 292... Line 283...
292
		mov ebx,eax
283
		mov ebx,eax
Line 306... Line 297...
306
			fld dword[ebx+4]   ;st0 = m[1]
297
			fld dword[ebx+4]   ;st0 = m[1]
307
			fmul st0,st3       ;st0 *= n.Y
298
			fmul st0,st3       ;st0 *= n.Y
308
			fld dword[ebx+8]   ;st0 = m[2]
299
			fld dword[ebx+8]   ;st0 = m[2]
309
			fmul st0,st3       ;st0 *= n.Z
300
			fmul st0,st3       ;st0 *= n.Z
310
			fadd st0,st1       ;st0 += n.Z * m[2]
301
			faddp              ;st0 += n.Z * m[2]
311
			fadd st0,st2       ;st0 += n.Y * m[1]
302
			faddp              ;st0 += n.Y * m[1]
312
			fstp dword[edx+offs_vert_normal] ;v.normal.X = n.X * m[0] + n.Y * m[1] + n.Z * m[2]
303
			fstp dword[edx+offs_vert_normal] ;v.normal.X = n.X * m[0] + n.Y * m[1] + n.Z * m[2]
313
			ffree st0
304
			add ebx,16 ;следущая строка матрицы
314
			fincstp
-
 
315
			ffree st0
-
 
316
			fincstp
-
 
317
			add ebx,16 ;следущая строка матрицы
-
 
318
			add edx,4  ;следущая координата вектора
305
			add edx,4  ;следущая координата вектора
319
		loop .cycle_2
306
		loop .cycle_2
320
 
307
 
Line 321... Line 308...
321
		cmp dword[eax+offs_cont_normalize_enabled],0
308
		cmp dword[eax+offs_cont_normalize_enabled],0
Line 327... Line 314...
327
		; NOTE: W = 1 is assumed
314
		; NOTE: W = 1 is assumed
328
		mov ebx,eax
315
		mov ebx,eax
329
		add ebx,offs_cont_matrix_model_projection
316
		add ebx,offs_cont_matrix_model_projection
330
 
317
 
Line 331... Line -...
331
		;;;mov edx,[v]
-
 
332
		finit
318
		finit
333
		fld dword[edx+offs_vert_coord+offs_X]
319
		fld dword[edx+offs_vert_coord+offs_X]
334
		fld dword[edx+offs_vert_coord+offs_Y]
320
		fld dword[edx+offs_vert_coord+offs_Y]
335
		fld dword[edx+offs_vert_coord+offs_Z]
321
		fld dword[edx+offs_vert_coord+offs_Z]
Line 343... Line 329...
343
		fmul st0,st3       ;st0 *= v.coord.Y
329
		fmul st0,st3       ;st0 *= v.coord.Y
344
		fld dword[ebx+8]   ;st0 = m[2]
330
		fld dword[ebx+8]   ;st0 = m[2]
345
		fmul st0,st3       ;st0 *= v.coord.Z
331
		fmul st0,st3       ;st0 *= v.coord.Z
346
		fadd dword[ebx+12] ;st0 += m[3]
332
		fadd dword[ebx+12] ;st0 += m[3]
347
		fadd st0,st1       ;st0 += v.coord.Z * m[2]
333
		faddp              ;st0 += v.coord.Z * m[2]
348
		fadd st0,st2       ;st0 += v.coord.Y * m[1]
334
		faddp              ;st0 += v.coord.Y * m[1]
349
		fstp dword[esi]    ;v.pc.X = v.coord.X * m[0] + v.coord.Y * m[1] + v.coord.Z * m[2] + m[3]
335
		fstp dword[esi]    ;v.pc.X = v.coord.X * m[0] + v.coord.Y * m[1] + v.coord.Z * m[2] + m[3]
350
		ffree st0
336
 
351
		fincstp
-
 
352
		ffree st0
-
 
353
		fincstp
-
 
354
		fld dword[ebx+16]  ;st0 = m[4]
337
		fld dword[ebx+16]  ;st0 = m[4]
355
		fmul st0,st3       ;st0 *= v.coord.X
338
		fmul st0,st3       ;st0 *= v.coord.X
356
		fld dword[ebx+20]  ;st0 = m[5]
339
		fld dword[ebx+20]  ;st0 = m[5]
357
		fmul st0,st3       ;st0 *= v.coord.Y
340
		fmul st0,st3       ;st0 *= v.coord.Y
358
		fld dword[ebx+24]  ;st0 = m[6]
341
		fld dword[ebx+24]  ;st0 = m[6]
359
		fmul st0,st3       ;st0 *= v.coord.Z
342
		fmul st0,st3       ;st0 *= v.coord.Z
360
		fadd dword[ebx+28] ;st0 += m[7]
343
		fadd dword[ebx+28] ;st0 += m[7]
361
		fadd st0,st1       ;st0 += v.coord.Z * m[6]
344
		faddp              ;st0 += v.coord.Z * m[6]
362
		fadd st0,st2       ;st0 += v.coord.Y * m[5]
345
		faddp              ;st0 += v.coord.Y * m[5]
363
		fstp dword[esi+4]  ;v.pc.X = v.coord.X * m[4] + v.coord.Y * m[5] + v.coord.Z * m[6] + m[7]
346
		fstp dword[esi+4]  ;v.pc.X = v.coord.X * m[4] + v.coord.Y * m[5] + v.coord.Z * m[6] + m[7]
364
		ffree st0
347
 
365
		fincstp
-
 
366
		ffree st0
-
 
367
		fincstp
-
 
368
		fld dword[ebx+32]  ;st0 = m[8]
348
		fld dword[ebx+32]  ;st0 = m[8]
369
		fmul st0,st3       ;st0 *= v.coord.X
349
		fmul st0,st3       ;st0 *= v.coord.X
370
		fld dword[ebx+36]  ;st0 = m[9]
350
		fld dword[ebx+36]  ;st0 = m[9]
371
		fmul st0,st3       ;st0 *= v.coord.Y
351
		fmul st0,st3       ;st0 *= v.coord.Y
372
		fld dword[ebx+40]  ;st0 = m[10]
352
		fld dword[ebx+40]  ;st0 = m[10]
373
		fmul st0,st3       ;st0 *= v.coord.Z
353
		fmul st0,st3       ;st0 *= v.coord.Z
374
		fadd dword[ebx+44] ;st0 += m[11]
354
		fadd dword[ebx+44] ;st0 += m[11]
375
		fadd st0,st1       ;st0 += v.coord.Z * m[10]
355
		faddp              ;st0 += v.coord.Z * m[10]
376
		fadd st0,st2       ;st0 += v.coord.Y * m[9]
356
		faddp              ;st0 += v.coord.Y * m[9]
377
		fstp dword[esi+8]  ;v.pc.X = v.coord.X * m[8] + v.coord.Y * m[9] + v.coord.Z * m[10] + m[11]
357
		fstp dword[esi+8]  ;v.pc.X = v.coord.X * m[8] + v.coord.Y * m[9] + v.coord.Z * m[10] + m[11]
378
 
358
 
Line 379... Line 359...
379
		cmp dword[eax+offs_cont_matrix_model_projection_no_w_transform],0
359
		cmp dword[eax+offs_cont_matrix_model_projection_no_w_transform],0
380
		je .els_1
360
		je .els_1
381
			;if (context.matrix_model_projection_no_w_transform)
361
			;if (context.matrix_model_projection_no_w_transform)
382
			mov ebx,dword[ebx+60] ;ebx = m[15]
362
			mov ebx,dword[ebx+60] ;ebx = m[15]
383
			mov dword[esi+12],ebx ;v.pc.W = m[15]
363
			mov dword[esi+12],ebx ;v.pc.W = m[15]
384
			jmp .end_els
364
			jmp .end_els
385
		.els_1:
365
		.els_1:
386
			ffree st0
-
 
387
			fincstp
-
 
388
			ffree st0
-
 
389
			fincstp
-
 
390
			fld dword[ebx+48]  ;st0 = m[12]
366
			fld dword[ebx+48]  ;st0 = m[12]
391
			fmul st0,st3       ;st0 *= v.coord.X
367
			fmul st0,st3       ;st0 *= v.coord.X
392
			fld dword[ebx+52]  ;st0 = m[13]
368
			fld dword[ebx+52]  ;st0 = m[13]
393
			fmul st0,st3       ;st0 *= v.coord.Y
369
			fmul st0,st3       ;st0 *= v.coord.Y
394
			fld dword[ebx+56]  ;st0 = m[14]
370
			fld dword[ebx+56]  ;st0 = m[14]
395
			fmul st0,st3       ;st0 *= v.coord.Z
371
			fmul st0,st3       ;st0 *= v.coord.Z
396
			fadd dword[ebx+60] ;st0 += m[15]
372
			fadd dword[ebx+60] ;st0 += m[15]
397
			fadd st0,st1       ;st0 += v.coord.Z * m[14] 
373
			faddp              ;st0 += v.coord.Z * m[14] 
398
			fadd st0,st2       ;st0 += v.coord.Y * m[13] 
374
			faddp              ;st0 += v.coord.Y * m[13] 
399
			fstp dword[esi+12] ;v.pc.W = v.coord.X * m[12] + v.coord.Y * m[13] + v.coord.Z * m[14] + m[15]
375
			fstp dword[esi+12] ;v.pc.W = v.coord.X * m[12] + v.coord.Y * m[13] + v.coord.Z * m[14] + m[15]
400
	.end_els:
376
	.end_els:
-
 
377
	ffree st0
-
 
378
	fincstp
-
 
379
	ffree st0
-
 
380
	fincstp
-
 
381
	ffree st0
-
 
382
	fincstp
-
 
383
 
401
if DEBUG ;gl_vertex_transform
384
if DEBUG ;gl_vertex_transform
402
	stdcall dbg_print,f_vt,txt_nl
385
	stdcall dbg_print,f_vt,txt_nl
403
	mov edx,[v]
386
	mov edx,[v]
404
	add edx,offs_vert_pc
387
	add edx,offs_vert_pc
405
	stdcall gl_print_matrix,edx,1
388
	stdcall gl_print_matrix,edx,1
Line 507... Line 490...
507
		jne .end_f
490
		jne .end_f
508
			mov eax,[edx+offs_cont_vertex]
491
			mov eax,[edx+offs_cont_vertex]
509
			push eax
492
			push eax
510
			add eax,sizeof.GLVertex
493
			add eax,sizeof.GLVertex
511
			push eax
494
			stdcall gl_draw_line, edx, eax
512
			stdcall gl_draw_line, edx
-
 
513
			xor eax,eax
495
			xor eax,eax
514
			mov dword[n],eax
496
			mov dword[n],eax
515
		jmp .end_f
497
		jmp .end_f
516
	@@:
498
	@@:
517
	cmp dword[edx+offs_cont_begin_type],GL_LINE_STRIP
499
	cmp dword[edx+offs_cont_begin_type],GL_LINE_STRIP
518
	je .li_loop
500
	je .li_loop
Line 532... Line 514...
532
		jne .end_f ;else if (n == 2)
514
		jne .end_f ;else if (n == 2)
533
			mov eax,[edx+offs_cont_vertex]
515
			mov eax,[edx+offs_cont_vertex]
534
			push eax
516
			push eax
535
			add eax,sizeof.GLVertex
517
			add eax,sizeof.GLVertex
536
			push eax
518
			stdcall gl_draw_line, edx, eax
537
			stdcall gl_draw_line, edx
-
 
538
			mov edi,[edx+offs_cont_vertex]
519
			mov edi,[edx+offs_cont_vertex]
539
			mov esi,edi
520
			mov esi,edi
540
			add esi,sizeof.GLVertex
521
			add esi,sizeof.GLVertex
541
			mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb
522
			mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb
542
			rep movsd ;context.vertex[0] = context.vertex[1]
523
			rep movsd ;context.vertex[0] = context.vertex[1]
543
			mov dword[n],1
524
			mov dword[n],1
Line 546... Line 527...
546
	cmp dword[edx+offs_cont_begin_type],GL_TRIANGLES
527
	cmp dword[edx+offs_cont_begin_type],GL_TRIANGLES
547
	jne @f
528
	jne @f
548
		cmp dword[n],3
529
		cmp dword[n],3
549
		jne .end_f
530
		jne .end_f
550
;               gl_draw_triangle(c, &c->vertex[0], &c->vertex[1], &c->vertex[2]);
531
			mov eax,[edx+offs_cont_vertex]
-
 
532
			push eax
-
 
533
			add eax,sizeof.GLVertex
-
 
534
			push eax
-
 
535
			add eax,sizeof.GLVertex
-
 
536
			stdcall gl_draw_triangle, edx, eax
551
			xor eax,eax
537
			xor eax,eax
552
			mov dword[n],eax
538
			mov dword[n],eax
553
		jmp .end_f
539
		jmp .end_f
554
	@@:
540
	@@:
555
	cmp dword[edx+offs_cont_begin_type],GL_TRIANGLE_STRIP
541
	cmp dword[edx+offs_cont_begin_type],GL_TRIANGLE_STRIP
556
	jne @f
542
	jne @f