Rev 6523 | Rev 8063 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6523 | Rev 7929 | ||
---|---|---|---|
1 | align 4 |
1 | align 4 |
2 | proc initSharedState uses eax ebx, context:dword |
2 | proc initSharedState uses eax ebx, context:dword |
3 | mov ebx,[context] |
3 | mov ebx,[context] |
4 | 4 | ||
5 | stdcall gl_zalloc, 4*MAX_DISPLAY_LISTS |
5 | stdcall gl_zalloc, 4*MAX_DISPLAY_LISTS |
6 | mov [ebx+GLContext.shared_state],eax ;...lists=gl_zalloc(...) |
6 | mov [ebx+GLContext.shared_state],eax ;...lists=gl_zalloc(...) |
7 | stdcall gl_zalloc, 4*TEXTURE_HASH_TABLE_SIZE |
7 | stdcall gl_zalloc, 4*TEXTURE_HASH_TABLE_SIZE |
8 | mov [ebx+GLContext.shared_state+4],eax ;...texture_hash_table=gl_zalloc(...) |
8 | mov [ebx+GLContext.shared_state+4],eax ;...texture_hash_table=gl_zalloc(...) |
9 | 9 | ||
10 | stdcall alloc_texture, [context],0 |
10 | stdcall alloc_texture, [context],0 |
11 | ret |
11 | ret |
12 | endp |
12 | endp |
13 | 13 | ||
14 | align 4 |
14 | align 4 |
15 | proc endSharedState uses eax ebx, context:dword |
15 | proc endSharedState uses eax ebx, context:dword |
16 | mov ebx,[context] |
16 | mov ebx,[context] |
17 | 17 | ||
18 | ; for(i=0;i |
18 | ; for(i=0;i |
19 | ; /* TODO */ |
19 | ; /* TODO */ |
20 | ; } |
20 | ; } |
21 | stdcall gl_free, dword[ebx+GLContext.shared_state] ;lists |
21 | stdcall gl_free, dword[ebx+GLContext.shared_state] ;lists |
22 | stdcall gl_free, dword[ebx+GLContext.shared_state+4] ;texture_hash_table |
22 | stdcall gl_free, dword[ebx+GLContext.shared_state+4] ;texture_hash_table |
23 | ret |
23 | ret |
24 | endp |
24 | endp |
25 | 25 | ||
26 | align 4 |
26 | align 4 |
27 | proc glInit uses eax ebx ecx edx, zbuffer1:dword |
27 | proc glInit, zbuffer1:dword |
28 | stdcall gl_zalloc,sizeof.GLContext |
28 | pushad |
- | 29 | stdcall gl_zalloc,sizeof.GLContext |
|
29 | mov dword[gl_ctx],eax |
30 | mov dword[gl_ctx],eax |
30 | mov edx,eax |
31 | mov edx,eax |
31 | 32 | ||
32 | mov ecx,[zbuffer1] |
33 | mov ecx,[zbuffer1] |
33 | mov dword[edx+GLContext.zb],ecx |
34 | mov dword[edx+GLContext.zb],ecx |
34 | 35 | ||
35 | ; allocate GLVertex array |
36 | ; allocate GLVertex array |
36 | mov dword[edx+GLContext.vertex_max],POLYGON_MAX_VERTEX |
37 | mov dword[edx+GLContext.vertex_max],POLYGON_MAX_VERTEX |
37 | stdcall gl_malloc, POLYGON_MAX_VERTEX*sizeof.GLVertex |
38 | stdcall gl_malloc, POLYGON_MAX_VERTEX*sizeof.GLVertex |
38 | mov dword[edx+GLContext.vertex],eax |
39 | mov dword[edx+GLContext.vertex],eax |
39 | 40 | ||
40 | ; viewport |
41 | ; viewport |
41 | xor eax,eax |
42 | xor eax,eax |
42 | mov dword[edx+GLContext.viewport+offs_vpor_xmin],eax |
43 | mov dword[edx+GLContext.viewport+offs_vpor_xmin],eax |
43 | mov dword[edx+GLContext.viewport+offs_vpor_ymin],eax |
44 | mov dword[edx+GLContext.viewport+offs_vpor_ymin],eax |
44 | mov eax,[ecx+offs_zbuf_xsize] |
45 | mov eax,[ecx+offs_zbuf_xsize] |
45 | mov dword[edx+GLContext.viewport+offs_vpor_xsize],eax |
46 | mov dword[edx+GLContext.viewport+offs_vpor_xsize],eax |
46 | mov eax,[ecx+offs_zbuf_ysize] |
47 | mov eax,[ecx+offs_zbuf_ysize] |
47 | mov dword[edx+GLContext.viewport+offs_vpor_ysize],eax |
48 | mov dword[edx+GLContext.viewport+offs_vpor_ysize],eax |
48 | mov dword[edx+GLContext.viewport+offs_vpor_updated],1 |
49 | mov dword[edx+GLContext.viewport+offs_vpor_updated],1 |
49 | 50 | ||
50 | ; shared state |
51 | ; shared state |
51 | stdcall initSharedState,edx |
52 | stdcall initSharedState,edx |
52 | 53 | ||
53 | ; lists |
54 | ; lists |
54 | mov dword[edx+GLContext.exec_flag],1 |
55 | mov dword[edx+GLContext.exec_flag],1 |
55 | mov dword[edx+GLContext.compile_flag],0 |
56 | mov dword[edx+GLContext.compile_flag],0 |
56 | mov dword[edx+GLContext.print_flag],0 |
57 | mov dword[edx+GLContext.print_flag],0 |
57 | 58 | ||
58 | mov dword[edx+GLContext.in_begin],0 |
59 | mov dword[edx+GLContext.in_begin],0 |
59 | 60 | ||
60 | ; lights |
61 | ; lights |
61 | mov ecx,MAX_LIGHTS |
62 | mov ecx,MAX_LIGHTS |
62 | mov eax,edx |
63 | mov eax,edx |
63 | add eax,GLContext.lights |
64 | add eax,GLContext.lights |
64 | .cycle_0: |
65 | .cycle_0: |
65 | gl_V4_New eax+offs_ligh_ambient, 0.0,0.0,0.0,1.0 |
66 | 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_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_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_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_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_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 | 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_exponent],0.0 |
73 | mov dword[eax+offs_ligh_spot_cutoff],180.0 |
74 | mov dword[eax+offs_ligh_spot_cutoff],180.0 |
74 | gl_V3_New eax+offs_ligh_attenuation, 1.0,0.0,0.0 |
75 | gl_V3_New eax+offs_ligh_attenuation, 1.0,0.0,0.0 |
75 | mov dword[eax+offs_ligh_enabled],0 |
76 | mov dword[eax+offs_ligh_enabled],0 |
76 | add eax,sizeof.GLLight |
77 | add eax,sizeof.GLLight |
77 | dec ecx |
78 | dec ecx |
78 | cmp ecx,0 |
79 | cmp ecx,0 |
79 | jg .cycle_0 |
80 | jg .cycle_0 |
80 | 81 | ||
81 | mov dword[edx+GLContext.first_light],0 ;NULL |
82 | mov dword[edx+GLContext.first_light],0 ;NULL |
82 | gl_V4_New edx+GLContext.ambient_light_model, 0.2,0.2,0.2,1.0 |
83 | 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.local_light_model],0 |
84 | mov dword[edx+GLContext.lighting_enabled],0 |
85 | mov dword[edx+GLContext.lighting_enabled],0 |
85 | mov dword[edx+GLContext.light_model_two_side],0 |
86 | mov dword[edx+GLContext.light_model_two_side],0 |
86 | 87 | ||
87 | ; default materials |
88 | ; default materials |
88 | mov ecx,2 ;for(i=0;i<2;i++) |
89 | mov ecx,2 ;for(i=0;i<2;i++) |
89 | mov eax,edx |
90 | mov eax,edx |
90 | add eax,GLContext.materials |
91 | add eax,GLContext.materials |
91 | @@: |
92 | @@: |
92 | gl_V4_New eax+offs_mate_emission, 0.0,0.0,0.0,1.0 |
93 | 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_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_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 | 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 | mov dword[eax+offs_mate_shininess], 0.0 |
97 | add eax,sizeof.GLMaterial |
98 | add eax,sizeof.GLMaterial |
98 | loop @b |
99 | loop @b |
99 | 100 | ||
100 | mov dword[edx+GLContext.current_color_material_mode],GL_FRONT_AND_BACK |
101 | mov dword[edx+GLContext.current_color_material_mode],GL_FRONT_AND_BACK |
101 | mov dword[edx+GLContext.current_color_material_type],GL_AMBIENT_AND_DIFFUSE |
102 | mov dword[edx+GLContext.current_color_material_type],GL_AMBIENT_AND_DIFFUSE |
102 | mov dword[edx+GLContext.color_material_enabled],0 |
103 | mov dword[edx+GLContext.color_material_enabled],0 |
103 | 104 | ||
104 | ; textures |
105 | ; textures |
105 | stdcall glInitTextures,edx |
106 | stdcall glInitTextures,edx |
106 | 107 | ||
107 | ; default state |
108 | ; default state |
108 | gl_V4_New edx+GLContext.current_color, 1.0,1.0,1.0,1.0 |
109 | gl_V4_New edx+GLContext.current_color, 1.0,1.0,1.0,1.0 |
109 | gl_V3_New edx+GLContext.longcurrent_color, 65535,65535,65535 |
110 | gl_V3_New edx+GLContext.longcurrent_color, 65535,65535,65535 |
110 | 111 | ||
111 | gl_V4_New edx+GLContext.current_normal, 1.0,0.0,0.0,0.0 |
112 | gl_V4_New edx+GLContext.current_normal, 1.0,0.0,0.0,0.0 |
112 | 113 | ||
113 | mov dword[edx+GLContext.current_edge_flag],1 |
114 | mov dword[edx+GLContext.current_edge_flag],1 |
114 | 115 | ||
115 | gl_V4_New edx+GLContext.current_tex_coord, 0.0,0.0,0.0,1.0 |
116 | gl_V4_New edx+GLContext.current_tex_coord, 0.0,0.0,0.0,1.0 |
116 | 117 | ||
117 | mov dword[edx+GLContext.polygon_mode_front],GL_FILL |
118 | mov dword[edx+GLContext.polygon_mode_front],GL_FILL |
118 | mov dword[edx+GLContext.polygon_mode_back],GL_FILL |
119 | mov dword[edx+GLContext.polygon_mode_back],GL_FILL |
119 | 120 | ||
120 | mov dword[edx+GLContext.current_front_face],0 ;0 = GL_CCW 1 = GL_CW |
121 | mov dword[edx+GLContext.current_front_face],0 ;0 = GL_CCW 1 = GL_CW |
121 | mov dword[edx+GLContext.current_cull_face],GL_BACK |
122 | mov dword[edx+GLContext.current_cull_face],GL_BACK |
122 | mov dword[edx+GLContext.current_shade_model],GL_SMOOTH |
123 | mov dword[edx+GLContext.current_shade_model],GL_SMOOTH |
123 | mov dword[edx+GLContext.cull_face_enabled],0 |
124 | mov dword[edx+GLContext.cull_face_enabled],0 |
124 | 125 | ||
125 | ; clear |
126 | ; clear |
126 | gl_V4_New edx+GLContext.clear_color, 0.0,0.0,0.0,0.0 |
127 | gl_V4_New edx+GLContext.clear_color, 0.0,0.0,0.0,0.0 |
127 | mov dword[edx+GLContext.clear_depth],0 |
128 | mov dword[edx+GLContext.clear_depth],0 |
128 | 129 | ||
129 | ; selection |
130 | ; selection |
130 | mov dword[edx+GLContext.render_mode],GL_RENDER |
131 | mov dword[edx+GLContext.render_mode],GL_RENDER |
131 | mov dword[edx+GLContext.select_buffer],0 ;NULL |
132 | mov dword[edx+GLContext.select_buffer],0 ;NULL |
132 | mov dword[edx+GLContext.name_stack_size],0 |
133 | mov dword[edx+GLContext.name_stack_size],0 |
133 | 134 | ||
134 | ; matrix |
135 | ; matrix |
135 | mov dword[edx+GLContext.matrix_mode],0 |
136 | mov dword[edx+GLContext.matrix_mode],0 |
136 | 137 | ||
137 | gl_V3_New edx+GLContext.matrix_stack_depth_max,\ |
138 | gl_V3_New edx+GLContext.matrix_stack_depth_max,\ |
138 | MAX_MODELVIEW_STACK_DEPTH,MAX_PROJECTION_STACK_DEPTH,MAX_TEXTURE_STACK_DEPTH |
139 | MAX_MODELVIEW_STACK_DEPTH,MAX_PROJECTION_STACK_DEPTH,MAX_TEXTURE_STACK_DEPTH |
139 | 140 | ||
140 | mov ecx,3 ;for(i=0;i<3;i++) |
141 | mov ecx,3 ;for(i=0;i<3;i++) |
141 | mov ebx,edx |
142 | mov ebx,edx |
142 | @@: |
143 | @@: |
143 | mov edi,[ebx+GLContext.matrix_stack_depth_max] |
144 | mov edi,[ebx+GLContext.matrix_stack_depth_max] |
144 | shl edi,6 ;вместо imul edi,sizeof(M4) |
145 | shl edi,6 ;вместо imul edi,sizeof(M4) |
145 | stdcall gl_zalloc,edi |
146 | stdcall gl_zalloc,edi |
146 | mov [ebx+GLContext.matrix_stack],eax |
147 | mov [ebx+GLContext.matrix_stack],eax |
147 | mov [ebx+GLContext.matrix_stack_ptr],eax |
148 | mov [ebx+GLContext.matrix_stack_ptr],eax |
148 | add ebx,4 |
149 | add ebx,4 |
149 | loop @b |
150 | loop @b |
150 | 151 | ||
151 | stdcall glMatrixMode,GL_PROJECTION |
152 | stdcall glMatrixMode,GL_PROJECTION |
152 | call glLoadIdentity |
153 | call glLoadIdentity |
153 | stdcall glMatrixMode,GL_TEXTURE |
154 | stdcall glMatrixMode,GL_TEXTURE |
154 | call glLoadIdentity |
155 | call glLoadIdentity |
155 | stdcall glMatrixMode,GL_MODELVIEW |
156 | stdcall glMatrixMode,GL_MODELVIEW |
156 | call glLoadIdentity |
157 | call glLoadIdentity |
157 | 158 | ||
158 | mov dword[edx+GLContext.matrix_model_projection_updated],1 |
159 | mov dword[edx+GLContext.matrix_model_projection_updated],1 |
159 | 160 | ||
160 | ; opengl 1.1 arrays |
161 | ; opengl 1.1 arrays |
161 | mov dword[edx+GLContext.client_states],0 |
162 | mov dword[edx+GLContext.client_states],0 |
162 | 163 | ||
163 | ; opengl 1.1 polygon offset |
164 | ; opengl 1.1 polygon offset |
164 | mov dword[edx+GLContext.offset_states],0 |
165 | mov dword[edx+GLContext.offset_states],0 |
165 | 166 | ||
166 | ; clear the resize callback function pointer |
167 | ; clear the resize callback function pointer |
167 | mov dword[edx+GLContext.gl_resize_viewport],0 ;NULL |
168 | mov dword[edx+GLContext.gl_resize_viewport],0 ;NULL |
168 | 169 | ||
169 | ; specular buffer |
170 | ; specular buffer |
170 | mov dword[edx+GLContext.specbuf_first],0 ;NULL |
171 | mov dword[edx+GLContext.specbuf_first],0 ;NULL |
171 | mov dword[edx+GLContext.specbuf_used_counter],0 |
172 | mov dword[edx+GLContext.specbuf_used_counter],0 |
172 | mov dword[edx+GLContext.specbuf_num_buffers],0 |
173 | mov dword[edx+GLContext.specbuf_num_buffers],0 |
173 | 174 | ||
174 | ; depth test |
175 | ; depth test |
175 | mov dword[edx+GLContext.depth_test],0 |
176 | mov dword[edx+GLContext.depth_test],0 |
176 | 177 | popad |
|
177 | ret |
178 | ret |
178 | endp |
179 | endp |
179 | 180 | ||
180 | align 4 |
181 | align 4 |
181 | proc glClose uses eax |
182 | proc glClose uses eax |
182 | call gl_get_context |
183 | call gl_get_context |
183 | stdcall endSharedState,eax |
184 | stdcall endSharedState,eax |
184 | stdcall gl_free,eax |
185 | stdcall gl_free,eax |
185 | ret |
186 | ret |
186 | endp3;i++) |
187 | endp3;i++) |
187 | >2;i++) |
188 | >2;i++) |
188 | > |
189 | > |