Ejemplo n.º 1
0
Archivo: mesh.c Proyecto: Ckef/Groufix
GFXMesh* gfx_mesh_create(void)
{
	/* Allocate mesh */
	GFX_Mesh* mesh = malloc(sizeof(GFX_Mesh));
	if(!mesh)
	{
		/* Out of memory error */
		gfx_errors_push(
			GFX_ERROR_OUT_OF_MEMORY,
			"Mesh could not be allocated."
		);
		return NULL;
	}

	/* Initialize */
	_gfx_lod_map_init(
		(GFX_LodMap*)mesh,
		0,
		sizeof(GFX_SourceData),
		sizeof(GFX_SourceData)
	);

	gfx_vector_init(&mesh->layouts, sizeof(GFXVertexLayout*));
	gfx_vector_init(&mesh->buckets, 1);
	gfx_vector_init(&mesh->buffers, sizeof(GFXSharedBuffer));

	return (GFXMesh*)mesh;
}
Ejemplo n.º 2
0
void _gfx_render_objects_init(

		GFX_RenderObjects* cont)
{
	gfx_vector_init(&cont->objects, sizeof(GFX_Object));
	gfx_deque_init(&cont->empties, sizeof(unsigned int));
	gfx_vector_init(&cont->saved, sizeof(GFX_Object));
}
Ejemplo n.º 3
0
void _gfx_lod_map_init(

		GFX_LodMap*  map,
		GFXLodFlags  flags,
		size_t       dataSize,
		size_t       compSize)
{
	map->map.flags = flags;
	map->map.levels = 0;
	map->map.compSize = (compSize > dataSize) ? dataSize : compSize;

	gfx_vector_init(&map->data, dataSize);
	gfx_vector_init(&map->levels, sizeof(unsigned int));
}
Ejemplo n.º 4
0
int _gfx_platform_init(void)
{
	/* Connect to X Server */
	_gfx_x11.display = XOpenDisplay(NULL);
	if(!_gfx_x11.display) return 0;

	XSetErrorHandler(_gfx_x11_error_handler);
	_gfx_x11.errors = 1;

	/* Setup memory */
	gfx_vector_init(&_gfx_x11.monitors, sizeof(GFX_X11_Monitor));
	gfx_vector_init(&_gfx_x11.modes, sizeof(GFX_X11_Mode));
	gfx_vector_init(&_gfx_x11.windows, sizeof(GFX_X11_Window));

	/* Load extensions and init monitors */
	int major;
	int minor;

	if(
		!_gfx_x11_load_extensions(&major, &minor) ||
		!_gfx_x11_init_monitors(major, minor))
	{
		_gfx_platform_terminate();
		return 0;
	}

	/* Load atoms */
	_gfx_x11.MOTIF_WM_HINTS =
		XInternAtom(_gfx_x11.display, "_MOTIF_WM_HINTS", False);
	_gfx_x11.NET_WM_BYPASS_COMPOSITOR =
		XInternAtom(_gfx_x11.display, "_NET_WM_BYPASS_COMPOSITOR", False);
	_gfx_x11.NET_WM_STATE =
		XInternAtom(_gfx_x11.display, "_NET_WM_STATE", False);
	_gfx_x11.NET_WM_STATE_ABOVE =
		XInternAtom(_gfx_x11.display, "_NET_WM_STATE_ABOVE", False);
	_gfx_x11.WM_DELETE_WINDOW =
		XInternAtom(_gfx_x11.display, "WM_DELETE_WINDOW", False);

	/* Construct a keycode lookup */
	_gfx_x11_create_key_table();

	return 1;
}
Ejemplo n.º 5
0
GFXThreadPool* gfx_thread_pool_create(

		GFXThreadPoolInit       init,
		GFXThreadPoolTerminate  terminate,
		int                     suspend)
{
	/* Create a new thread pool */
	GFX_Pool* pool = malloc(sizeof(GFX_Pool));
	if(!pool)
	{
		/* Out of memory error */
		gfx_errors_push(
			GFX_ERROR_OUT_OF_MEMORY,
			"Thread pool could not be allocated."
		);
		return NULL;
	}

	/* Create mutex */
	if(_gfx_platform_mutex_init(&pool->mutex))
	{
		/* Create condition variable */
		if(_gfx_platform_cond_init(&pool->assign))
		{
			if(_gfx_platform_cond_init(&pool->flush))
			{
				/* Initialize */
				pool->status = suspend ?
					GFX_INT_POOL_SUSPENDED :
					GFX_INT_POOL_RESUMED;

				pool->pool.size = 0;
				pool->pool.init = init;
				pool->pool.terminate = terminate;

				gfx_vector_init(&pool->tasks, sizeof(GFX_Task));

				pool->threads = NULL;
				pool->deads = NULL;

				return (GFXThreadPool*)pool;
			}

			_gfx_platform_cond_clear(&pool->assign);
		}

		_gfx_platform_mutex_clear(&pool->mutex);
	}

	/* Nevermind */
	free(pool);

	return NULL;
}