6 void initSharedState(GLContext
*c
)
8 GLSharedState
*s
=&c
->shared_state
;
9 s
->lists
=gl_zalloc(sizeof(GLList
*) * MAX_DISPLAY_LISTS
);
10 s
->texture_hash_table
=
11 gl_zalloc(sizeof(GLTexture
*) * TEXTURE_HASH_TABLE_SIZE
);
16 void endSharedState(GLContext
*c
)
18 GLSharedState
*s
=&c
->shared_state
;
21 for(i
=0;i
<MAX_DISPLAY_LISTS
;i
++) {
26 gl_free(s
->texture_hash_table
);
30 void glInit(void *zbuffer1
)
32 ZBuffer
*zbuffer
=(ZBuffer
*)zbuffer1
;
37 c
=gl_zalloc(sizeof(GLContext
));
42 /* allocate GLVertex array */
43 c
->vertex_max
= POLYGON_MAX_VERTEX
;
44 c
->vertex
= gl_malloc(POLYGON_MAX_VERTEX
*sizeof(GLVertex
));
50 v
->xsize
=zbuffer
->xsize
;
51 v
->ysize
=zbuffer
->ysize
;
66 for(i
=0;i
<MAX_LIGHTS
;i
++) {
67 GLLight
*l
=&c
->lights
[i
];
68 l
->ambient
=gl_V4_New(0,0,0,1);
69 l
->diffuse
=gl_V4_New(1,1,1,1);
70 l
->specular
=gl_V4_New(1,1,1,1);
71 l
->position
=gl_V4_New(0,0,1,0);
72 l
->norm_position
=gl_V3_New(0,0,1);
73 l
->spot_direction
=gl_V3_New(0,0,-1);
74 l
->norm_spot_direction
=gl_V3_New(0,0,-1);
83 c
->ambient_light_model
=gl_V4_New(0.2,0.2,0.2,1);
84 c
->local_light_model
=0;
85 c
->lighting_enabled
=0;
86 c
->light_model_two_side
= 0;
88 /* default materials */
90 GLMaterial
*m
=&c
->materials
[i
];
91 m
->emission
=gl_V4_New(0,0,0,1);
92 m
->ambient
=gl_V4_New(0.2,0.2,0.2,1);
93 m
->diffuse
=gl_V4_New(0.8,0.8,0.8,1);
94 m
->specular
=gl_V4_New(0,0,0,1);
97 c
->current_color_material_mode
=GL_FRONT_AND_BACK
;
98 c
->current_color_material_type
=GL_AMBIENT_AND_DIFFUSE
;
99 c
->color_material_enabled
=0;
105 c
->current_color
.X
=1.0;
106 c
->current_color
.Y
=1.0;
107 c
->current_color
.Z
=1.0;
108 c
->current_color
.W
=1.0;
109 c
->longcurrent_color
[0] = 65535;
110 c
->longcurrent_color
[1] = 65535;
111 c
->longcurrent_color
[2] = 65535;
113 c
->current_normal
.X
=1.0;
114 c
->current_normal
.Y
=0.0;
115 c
->current_normal
.Z
=0.0;
116 c
->current_normal
.W
=0.0;
118 c
->current_edge_flag
=1;
120 c
->current_tex_coord
.X
=0;
121 c
->current_tex_coord
.Y
=0;
122 c
->current_tex_coord
.Z
=0;
123 c
->current_tex_coord
.W
=1;
125 c
->polygon_mode_front
=GL_FILL
;
126 c
->polygon_mode_back
=GL_FILL
;
128 c
->current_front_face
=0; /* 0 = GL_CCW 1 = GL_CW */
129 c
->current_cull_face
=GL_BACK
;
130 c
->current_shade_model
=GL_SMOOTH
;
131 c
->cull_face_enabled
=0;
134 c
->clear_color
.v
[0]=0;
135 c
->clear_color
.v
[1]=0;
136 c
->clear_color
.v
[2]=0;
137 c
->clear_color
.v
[3]=0;
141 c
->render_mode
=GL_RENDER
;
142 c
->select_buffer
=NULL
;
143 c
->name_stack_size
=0;
148 c
->matrix_stack_depth_max
[0]=MAX_MODELVIEW_STACK_DEPTH
;
149 c
->matrix_stack_depth_max
[1]=MAX_PROJECTION_STACK_DEPTH
;
150 c
->matrix_stack_depth_max
[2]=MAX_TEXTURE_STACK_DEPTH
;
153 c
->matrix_stack
[i
]=gl_zalloc(c
->matrix_stack_depth_max
[i
] * sizeof(M4
));
154 c
->matrix_stack_ptr
[i
]=c
->matrix_stack
[i
];
157 glMatrixMode(GL_PROJECTION
);
159 glMatrixMode(GL_TEXTURE
);
161 glMatrixMode(GL_MODELVIEW
);
164 c
->matrix_model_projection_updated
=1;
166 /* opengl 1.1 arrays */
167 c
->client_states
= 0;
169 /* opengl 1.1 polygon offset */
170 c
->offset_states
= 0;
172 /* clear the resize callback function pointer */
173 c
->gl_resize_viewport
= NULL
;
175 /* specular buffer */
176 c
->specbuf_first
= NULL
;
177 c
->specbuf_used_counter
= 0;
178 c
->specbuf_num_buffers
= 0;
186 GLContext
*c
=gl_get_context();