Subversion Repositories Kolibri OS

Rev

Rev 5269 | Rev 7929 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5153 IgorA 1
 
2
proc initSharedState uses eax ebx, context:dword
3
	mov ebx,[context]
4
5
 
6
	mov [ebx+GLContext.shared_state],eax ;...lists=gl_zalloc(...)
6523 IgorA 7
	stdcall gl_zalloc, 4*TEXTURE_HASH_TABLE_SIZE
5153 IgorA 8
	mov [ebx+GLContext.shared_state+4],eax ;...texture_hash_table=gl_zalloc(...)
6523 IgorA 9
5153 IgorA 10
 
11
	ret
12
endp
13
14
 
15
proc endSharedState uses eax ebx, context:dword
16
	mov ebx,[context]
17
18
 
19
;    /* TODO */
20
;  }
21
	stdcall gl_free, dword[ebx+GLContext.shared_state] ;lists
6523 IgorA 22
	stdcall gl_free, dword[ebx+GLContext.shared_state+4] ;texture_hash_table
23
	ret
5153 IgorA 24
endp
25
26
 
27
proc glInit uses eax ebx ecx edx, zbuffer1:dword
28
	stdcall gl_zalloc,sizeof.GLContext
29
	mov dword[gl_ctx],eax
30
	mov edx,eax
31
32
 
33
	mov dword[edx+GLContext.zb],ecx
6523 IgorA 34
5153 IgorA 35
 
36
	mov dword[edx+GLContext.vertex_max],POLYGON_MAX_VERTEX
6523 IgorA 37
	stdcall gl_malloc, POLYGON_MAX_VERTEX*sizeof.GLVertex
5153 IgorA 38
	mov dword[edx+GLContext.vertex],eax
6523 IgorA 39
5153 IgorA 40
 
41
	xor eax,eax
5269 IgorA 42
	mov dword[edx+GLContext.viewport+offs_vpor_xmin],eax
6523 IgorA 43
	mov dword[edx+GLContext.viewport+offs_vpor_ymin],eax
44
	mov eax,[ecx+offs_zbuf_xsize]
5153 IgorA 45
	mov dword[edx+GLContext.viewport+offs_vpor_xsize],eax
6523 IgorA 46
	mov eax,[ecx+offs_zbuf_ysize]
5153 IgorA 47
	mov dword[edx+GLContext.viewport+offs_vpor_ysize],eax
6523 IgorA 48
	mov dword[edx+GLContext.viewport+offs_vpor_updated],1
49
5153 IgorA 50
 
51
	stdcall initSharedState,edx
52
53
 
54
	mov dword[edx+GLContext.exec_flag],1
6523 IgorA 55
	mov dword[edx+GLContext.compile_flag],0
56
	mov dword[edx+GLContext.print_flag],0
57
5153 IgorA 58
 
6523 IgorA 59
5153 IgorA 60
 
61
	mov ecx,MAX_LIGHTS
62
	mov eax,edx
63
	add eax,GLContext.lights
6523 IgorA 64
	.cycle_0:
5153 IgorA 65
		gl_V4_New eax+offs_ligh_ambient, 0.0,0.0,0.0,1.0
66
		gl_V4_New eax+offs_ligh_diffuse, 1.0,1.0,1.0,1.0
67
		gl_V4_New eax+offs_ligh_specular, 1.0,1.0,1.0,1.0
68
		gl_V4_New eax+offs_ligh_position, 0.0,0.0,1.0,0.0
69
		gl_V3_New eax+offs_ligh_norm_position, 0.0,0.0,1.0
70
		gl_V3_New eax+offs_ligh_spot_direction, 0.0,0.0,-1.0
71
		gl_V3_New eax+offs_ligh_norm_spot_direction, 0.0,0.0,-1.0
72
		mov dword[eax+offs_ligh_spot_exponent],0.0
73
		mov dword[eax+offs_ligh_spot_cutoff],180.0
74
		gl_V3_New eax+offs_ligh_attenuation, 1.0,0.0,0.0
5269 IgorA 75
		mov dword[eax+offs_ligh_enabled],0
5153 IgorA 76
		add eax,sizeof.GLLight
77
		dec ecx
78
		cmp ecx,0
79
	jg .cycle_0
80
81
 
6523 IgorA 82
	gl_V4_New edx+GLContext.ambient_light_model, 0.2,0.2,0.2,1.0
83
	mov dword[edx+GLContext.local_light_model],0
84
	mov dword[edx+GLContext.lighting_enabled],0
85
	mov dword[edx+GLContext.light_model_two_side],0
86
5153 IgorA 87
 
88
	mov ecx,2 ;for(i=0;i<2;i++)
89
	mov eax,edx
90
	add eax,GLContext.materials
6523 IgorA 91
	@@:
5153 IgorA 92
		gl_V4_New eax+offs_mate_emission, 0.0,0.0,0.0,1.0
93
		gl_V4_New eax+offs_mate_ambient, 0.2,0.2,0.2,1.0
94
		gl_V4_New eax+offs_mate_diffuse, 0.8,0.8,0.8,1.0
95
		gl_V4_New eax+offs_mate_specular, 0.0,0.0,0.0,1.0
96
		mov dword[eax+offs_mate_shininess], 0.0
97
		add eax,sizeof.GLMaterial
98
	loop @b
99
100
 
6523 IgorA 101
	mov dword[edx+GLContext.current_color_material_type],GL_AMBIENT_AND_DIFFUSE
102
	mov dword[edx+GLContext.color_material_enabled],0
103
5153 IgorA 104
 
105
	stdcall glInitTextures,edx
106
107
 
108
	gl_V4_New edx+GLContext.current_color, 1.0,1.0,1.0,1.0
6523 IgorA 109
	gl_V3_New edx+GLContext.longcurrent_color, 65535,65535,65535
110
5153 IgorA 111
 
6523 IgorA 112
5153 IgorA 113
 
6523 IgorA 114
5153 IgorA 115
 
6523 IgorA 116
5153 IgorA 117
 
6523 IgorA 118
	mov dword[edx+GLContext.polygon_mode_back],GL_FILL
119
5153 IgorA 120
 
6523 IgorA 121
	mov dword[edx+GLContext.current_cull_face],GL_BACK
122
	mov dword[edx+GLContext.current_shade_model],GL_SMOOTH
123
	mov dword[edx+GLContext.cull_face_enabled],0
124
5153 IgorA 125
 
126
	gl_V4_New edx+GLContext.clear_color, 0.0,0.0,0.0,0.0
6523 IgorA 127
	mov dword[edx+GLContext.clear_depth],0
128
5153 IgorA 129
 
130
	mov dword[edx+GLContext.render_mode],GL_RENDER
6523 IgorA 131
	mov dword[edx+GLContext.select_buffer],0 ;NULL
132
	mov dword[edx+GLContext.name_stack_size],0
133
5153 IgorA 134
 
135
	mov dword[edx+GLContext.matrix_mode],0
6523 IgorA 136
5153 IgorA 137
 
6523 IgorA 138
		MAX_MODELVIEW_STACK_DEPTH,MAX_PROJECTION_STACK_DEPTH,MAX_TEXTURE_STACK_DEPTH
5269 IgorA 139
5153 IgorA 140
 
141
	mov ebx,edx
142
	@@:
143
		mov edi,[ebx+GLContext.matrix_stack_depth_max]
6523 IgorA 144
		shl edi,6 ;вместо imul edi,sizeof(M4)
5153 IgorA 145
		stdcall gl_zalloc,edi
146
		mov [ebx+GLContext.matrix_stack],eax
6523 IgorA 147
		mov [ebx+GLContext.matrix_stack_ptr],eax
148
		add ebx,4
5153 IgorA 149
	loop @b
150
151
 
152
	call glLoadIdentity
153
	stdcall glMatrixMode,GL_TEXTURE
154
	call glLoadIdentity
155
	stdcall glMatrixMode,GL_MODELVIEW
156
	call glLoadIdentity
157
158
 
6523 IgorA 159
5153 IgorA 160
 
161
	mov dword[edx+GLContext.client_states],0
6523 IgorA 162
5153 IgorA 163
 
164
	mov dword[edx+GLContext.offset_states],0
6523 IgorA 165
5153 IgorA 166
 
167
	mov dword[edx+GLContext.gl_resize_viewport],0 ;NULL
6523 IgorA 168
5153 IgorA 169
 
170
	mov dword[edx+GLContext.specbuf_first],0 ;NULL
6523 IgorA 171
	mov dword[edx+GLContext.specbuf_used_counter],0
172
	mov dword[edx+GLContext.specbuf_num_buffers],0
173
5153 IgorA 174
 
175
	mov dword[edx+GLContext.depth_test],0
6523 IgorA 176
5153 IgorA 177
 
178
endp
179
180
 
181
proc glClose uses eax
182
	call gl_get_context
183
	stdcall endSharedState,eax
184
	stdcall gl_free,eax
185
	ret
186
endp
187
>