Subversion Repositories Kolibri OS

Rev

Rev 5380 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5153 IgorA 1
VERTEX_ARRAY   equ 0x0001
2
COLOR_ARRAY    equ 0x0002
3
NORMAL_ARRAY   equ 0x0004
4
TEXCOORD_ARRAY equ 0x0008
5
 
5337 IgorA 6
;glArrayElement - использование (рисование) одного элемента из массива
7
;glDrawArrays - рисование всех элементов в массиве
8
;glDrawElements - рисование тех элементов в массиве, которые заданны в массиве индексов
9
 
5153 IgorA 10
align 4
11
proc glopArrayElement uses eax ebx ecx edx, context:dword, param:dword
12
locals
13
	p rd 5
14
endl
15
	mov eax,[context]
16
	mov ebx,[param]
17
	mov ebx,[ebx+4] ;ebx = p[1]
18
 
6523 IgorA 19
	bt dword[eax+GLContext.client_states],1 ;2^1=COLOR_ARRAY
5153 IgorA 20
	jnc @f
6523 IgorA 21
		mov ecx,[eax+GLContext.color_array_size]
22
		add ecx,[eax+GLContext.color_array_stride]
5153 IgorA 23
		imul ecx,ebx
24
		shl ecx,2
6523 IgorA 25
		add ecx,[eax+GLContext.color_array] ;ecx = &context.color_array[i]
5153 IgorA 26
		mov ebx,ebp
27
		sub ebx,20 ;=sizeof(dd)*5
28
		mov edx,[ecx]
29
		mov [ebx+4],edx
30
		mov edx,[ecx+4]
31
		mov [ebx+8],edx
32
		mov edx,[ecx+8]
33
		mov [ebx+12],edx
6523 IgorA 34
		cmp dword[eax+GLContext.color_array_size],3
5153 IgorA 35
		jg .l0
36
			mov edx,1.0
37
			jmp .l1
38
		.l0:
39
			mov edx,[ecx+12]
40
		.l1:
41
		mov [ebx+16],edx
5337 IgorA 42
		stdcall glopColor, eax,ebx
5153 IgorA 43
	@@:
6523 IgorA 44
	bt dword[eax+GLContext.client_states],2 ;2^2=NORMAL_ARRAY
5153 IgorA 45
	jnc @f
6523 IgorA 46
		mov esi,dword[eax+GLContext.normal_array_stride]
5153 IgorA 47
		add esi,3
48
		imul esi,ebx
49
		shl esi,2
6523 IgorA 50
		add esi,[eax+GLContext.normal_array] ;esi = &normal_array[ebx * (3 + c->normal_array_stride)]
5153 IgorA 51
		mov edi,eax
6523 IgorA 52
		add edi,GLContext.current_normal
5153 IgorA 53
		mov ecx,3
54
		rep movsd
55
		mov dword[edi],0.0
56
	@@:
6523 IgorA 57
	bt dword[eax+GLContext.client_states],3 ;2^3=TEXCOORD_ARRAY
5153 IgorA 58
	jnc @f
6523 IgorA 59
		mov ecx,[eax+GLContext.texcoord_array_size]
60
		add ecx,[eax+GLContext.texcoord_array_stride]
5153 IgorA 61
		imul ecx,ebx
62
		shl ecx,2
6523 IgorA 63
		add ecx,[eax+GLContext.texcoord_array] ;ecx = &context.texcoord_array[i]
5153 IgorA 64
		mov edx,[ecx]
6523 IgorA 65
		mov [eax+GLContext.current_tex_coord],edx
5153 IgorA 66
		mov edx,[ecx+4]
6523 IgorA 67
		mov [eax+GLContext.current_tex_coord+4],edx
5153 IgorA 68
 
6523 IgorA 69
		cmp dword[eax+GLContext.texcoord_array_size],2
5153 IgorA 70
		jg .l2
71
			mov edx,0.0
72
			jmp .l3
73
		.l2:
74
			mov edx,[ecx+8]
75
		.l3:
6523 IgorA 76
		mov [eax+GLContext.current_tex_coord+8],edx
5153 IgorA 77
 
6523 IgorA 78
		cmp dword[eax+GLContext.texcoord_array_size],3
5153 IgorA 79
		jg .l4
80
			mov edx,1.0
81
			jmp .l5
82
		.l4:
83
			mov edx,[ecx+12]
84
		.l5:
85
 
6523 IgorA 86
		mov [eax+GLContext.current_tex_coord+12],edx
5153 IgorA 87
	@@:
6523 IgorA 88
	bt dword[eax+GLContext.client_states],0 ;2^0=VERTEX_ARRAY
5153 IgorA 89
	jnc @f
6523 IgorA 90
		mov ecx,[eax+GLContext.vertex_array_size]
91
		add ecx,[eax+GLContext.vertex_array_stride]
5153 IgorA 92
		imul ecx,ebx
93
		shl ecx,2
6523 IgorA 94
		add ecx,[eax+GLContext.vertex_array] ;ecx = &context.vertex_array[i]
5153 IgorA 95
		mov ebx,ebp
96
		sub ebx,20 ;=sizeof(dd)*5
97
		mov edx,[ecx]
98
		mov [ebx+4],edx
99
		mov edx,[ecx+4]
100
		mov [ebx+8],edx
101
 
6523 IgorA 102
		cmp dword[eax+GLContext.vertex_array_size],2
5153 IgorA 103
		jg .l6
104
			mov edx,0.0
105
			jmp .l7
106
		.l6:
107
			mov edx,[ecx+8]
108
		.l7:
109
		mov [ebx+12],edx
6523 IgorA 110
		cmp dword[eax+GLContext.vertex_array_size],3
5153 IgorA 111
		jg .l8
112
			mov edx,1.0
113
			jmp .l9
114
		.l8:
115
			mov edx,[ecx+12]
116
		.l9:
117
 
118
		mov [ebx+16],edx
5337 IgorA 119
		stdcall glopVertex, eax,ebx
5153 IgorA 120
	@@:
121
	ret
122
endp
123
 
124
align 4
125
proc glArrayElement uses eax, i:dword
126
locals
127
	p rd 2
128
endl
129
	mov dword[p],OP_ArrayElement
130
	mov eax,[i]
131
	mov dword[p+4],eax
132
 
133
	mov eax,ebp
134
	sub eax,8 ;=sizeof(dd)*2
135
	stdcall gl_add_op,eax
136
	ret
137
endp
138
 
139
align 4
5337 IgorA 140
proc glopDrawArrays, context:dword, param:dword
141
locals
142
	vi dd ?
143
	idx dd ?
144
	states dd ?
145
	size dd ?
146
	p rd 8 ;функция glopColor требует 8 параметров, другие функции требуют меньше, берем по максимуму что-бы не портить стек
147
endl
148
pushad
149
	mov edx,[context]
150
	mov ebx,[param]
151
	mov ecx,[ebx+12] ;count = param[3].i
6523 IgorA 152
	mov eax,[edx+GLContext.client_states]
5337 IgorA 153
	mov [states],eax
154
	mov eax,[ebx+8]
155
	mov [idx],eax ;param[2].i
156
	mov eax,[ebx+4]
157
	mov [p+4],eax ;p[1].i = param[1].i
158
	mov eax,ebp
159
	sub eax,32 ;=sizeof(dd)*8
160
	stdcall glopBegin, edx,eax
161
 
162
	mov dword[vi],0
163
align 4
164
	.cycle_0: ;for (int vi=0; vi
165
	cmp dword[vi],ecx
166
	jge .cycle_0_end
167
		bt dword[states],1 ;2^1=COLOR_ARRAY
168
		jnc @f
6523 IgorA 169
			mov esi,[edx+GLContext.color_array_size]
5337 IgorA 170
			mov [size],esi
6523 IgorA 171
			add esi,[edx+GLContext.color_array_stride]
5337 IgorA 172
			imul esi,[idx] ;esi = i
173
			shl esi,2
6523 IgorA 174
			add esi,[edx+GLContext.color_array] ;esi = &context.color_array[i]
5337 IgorA 175
			mov edi,ebp
176
			sub edi,28 ;edi = &p[1]
5353 IgorA 177
			mov ebx,[esi+8]
178
			mov [edi],ebx   ;p[1].f = context.color_array[i+2]
179
			mov ebx,[esi+4]
180
			mov [edi+4],ebx ;p[2].f = context.color_array[i+1]
181
			mov ebx,[esi]
182
			mov [edi+8],ebx ;p[3].f = context.color_array[i]
183
			add edi,12
5337 IgorA 184
			cmp dword[size],3
185
			jle .e1
5353 IgorA 186
				add esi,12
5337 IgorA 187
				movsd
188
				jmp .e2
189
			.e1:
190
				mov dword[edi],1.0 ;если задано 3 параметра, то 4-й ставим по умолчанию 1.0
191
			.e2:
5353 IgorA 192
			mov edi,ebp
193
			sub edi,32 ;edi = &p[0]
5337 IgorA 194
			mov ebx,ebp
195
			sub ebx,12 ;ebp-12 = &p[5]
196
			push ebx
197
			add ebx,4 ;ebp-8 = &p[6]
198
			push ebx
199
			add ebx,4 ;ebp-4 = &p[7]
200
			push ebx
201
			stdcall RGBFtoRGBI,[edi+12],[edi+8],[edi+4] ;call: r,g,b,&p[7],&p[6],&p[5]
202
			stdcall glopColor, edx,edi ;(context, p(op,rf,gf,bf,af,ri,gi,bi))
203
		@@:
204
		bt dword[states],2 ;2^2=NORMAL_ARRAY
205
		jnc @f
6523 IgorA 206
			mov esi,[edx+GLContext.normal_array_stride]
5337 IgorA 207
			add esi,3
</