vx_object_t * _vxo_rect_private(vx_style_t * style, ...) { // Make sure the static geometry is initialized safely, correctly, and quickly if (points == NULL) { vx_global_lock(); if (points == NULL) { vxo_rect_init(); vx_global_register_destroy(vxo_rect_destroy, NULL); } vx_global_unlock(); } vx_object_t * vc = vxo_chain_create(); va_list va; va_start(va, style); for (vx_style_t * sty = style; sty != NULL; sty = va_arg(va, vx_style_t *)) { switch(sty->type) { case VXO_POINTS_STYLE: vxo_chain_add(vc, vxo_points(points, NVERTS, sty)); break; case VXO_LINES_STYLE: vxo_chain_add(vc, vxo_lines(points, NVERTS, GL_LINE_LOOP, sty)); break; case VXO_MESH_STYLE: vxo_chain_add(vc, vxo_mesh_indexed(points, NVERTS, normals, indices, GL_TRIANGLES, sty)); break; } } va_end(va); return vc; }
static void gl_init(void * unused) { if (verbose) printf("Creating GL context\n"); glc = glcontext_X11_create(); checkVersions(); // check version after we got a gl context vx_global_register_destroy(gl_destroy, NULL); }
// 1M grid by default vx_object_t * vxo_grid_colored(vx_style_t * style) { // Make sure the static geometry is initialized safely, correctly, and quickly if (grid_vertices == NULL) { pthread_mutex_lock(&vx_convenience_mutex); if (grid_vertices == NULL) { vxo_grid_init(N_AXES_LINES); vx_global_register_destroy(vxo_grid_destroy, NULL); } pthread_mutex_unlock(&vx_convenience_mutex); } return vxo_lines(grid_vertices, N_AXES_LINES*4, GL_LINES, style); }
vx_object_t * _vxo_box_private(vx_style_t * style, ...) { // Make sure the static geometry is initialized safely, correctly, and quickly if (vertex_points == NULL) { pthread_mutex_lock(&vx_convenience_mutex); if (vertex_points == NULL) { vxo_box_init(); vx_global_register_destroy(vxo_box_destroy, NULL); } pthread_mutex_unlock(&vx_convenience_mutex); } vx_object_t * vc = vxo_chain_create(); va_list va; va_start(va, style); for (vx_style_t * sty = style; sty != NULL; sty = va_arg(va, vx_style_t *)) { switch(sty->type) { case VXO_POINTS_STYLE: vxo_chain_add(vc, vxo_points(vertex_points, NVERTS, sty)); break; case VXO_LINES_STYLE: vxo_chain_add(vc, vxo_lines_indexed(vertex_points, NVERTS, line_indices, GL_LINES, sty)); break; case VXO_MESH_STYLE: // XXX always pass normals? vxo_chain_add(vc, vxo_mesh(tri_points, N_TRI_VERT, tri_normals, GL_TRIANGLES, sty)); break; } } va_end(va); return vc; }