Esempio n. 1
0
File: tr_vbo.c Progetto: UniQP/ioq3
/*
============
R_ShutdownVaos
============
*/
void R_ShutdownVaos(void)
{
	int             i;
	vao_t          *vao;

	ri.Printf(PRINT_ALL, "------- R_ShutdownVaos -------\n");

	R_BindNullVao();

	for(i = 0; i < tr.numVaos; i++)
	{
		vao = tr.vaos[i];

		if(vao->vao)
			qglDeleteVertexArrays(1, &vao->vao);

		if(vao->vertexesVBO)
		{
			qglDeleteBuffers(1, &vao->vertexesVBO);
		}

		if(vao->indexesIBO)
		{
			qglDeleteBuffers(1, &vao->indexesIBO);
		}
	}

	tr.numVaos = 0;
}
Esempio n. 2
0
/*
 * R_FreeModels
 */
static void R_FreeModels(void) {
	int i;

	for (i = 0; i < r_num_models; i++) {
		r_model_t *mod = &r_models[i];

		if (mod->vertex_buffer)
			qglDeleteBuffers(1, &mod->vertex_buffer);
		if (mod->texcoord_buffer)
			qglDeleteBuffers(1, &mod->texcoord_buffer);
		if (mod->lmtexcoord_buffer)
			qglDeleteBuffers(1, &mod->lmtexcoord_buffer);
		if (mod->normal_buffer)
			qglDeleteBuffers(1, &mod->normal_buffer);
	}

	r_world_model = NULL;

	// reset the models array
	memset(r_models, 0, sizeof(r_models));
	r_num_models = 0;

	// reset inline models
	memset(r_inline_models, 0, sizeof(r_inline_models));

	// reset the hunk
	memset(r_hunk.base, 0, r_hunk.size);
	r_hunk.offset = 0;
}
Esempio n. 3
0
/**
 * @brief Frees the model pool
 * @param complete If this is true the static mesh models are freed, too
 * @sa R_SwitchModelMemPoolTag
 */
void R_ShutdownModels (bool complete)
{
	int i;
	const int start = complete ? 0 : r_numModelsStatic;

	/* free the vertex buffer - but not for the static models
	 * the world, the submodels and all the misc_models are located in the
	 * r_models array */
	for (i = start; i < r_numModels; i++) {
		model_t *mod = &r_models[i];
		mBspModel_t *bsp = &mod->bsp;

		if (bsp->vertex_buffer)
			qglDeleteBuffers(1, &bsp->vertex_buffer);
		if (bsp->texcoord_buffer)
			qglDeleteBuffers(1, &bsp->texcoord_buffer);
		if (bsp->lmtexcoord_buffer)
			qglDeleteBuffers(1, &bsp->lmtexcoord_buffer);
		if (bsp->normal_buffer)
			qglDeleteBuffers(1, &bsp->normal_buffer);
		if (bsp->tangent_buffer)
			qglDeleteBuffers(1, &bsp->tangent_buffer);
	}

	/* don't free the static models with the tag MEM_TAG_STATIC_MODELS */
	if (complete) {
		if (vid_modelPool)
			Mem_FreePool(vid_modelPool);
		if (vid_lightPool)
			Mem_FreePool(vid_lightPool);
		r_numModels = 0;
		r_numModelsInline = 0;
		r_numMapTiles = 0;
		OBJZERO(r_models);
	} else {
		if (vid_modelPool)
			Mem_FreeTag(vid_modelPool, 0);
		if (vid_lightPool)
			Mem_FreeTag(vid_lightPool, 0);
		r_numModels = r_numModelsStatic;
	}
}
Esempio n. 4
0
/*
 * @brief Free event listener for models.
 */
static void R_FreeModel(r_media_t *self) {
	r_model_t *mod = (r_model_t *) self;

	if (mod->vertex_buffer)
		qglDeleteBuffers(1, &mod->vertex_buffer);

	if (mod->texcoord_buffer)
		qglDeleteBuffers(1, &mod->texcoord_buffer);

	if (mod->lightmap_texcoord_buffer)
		qglDeleteBuffers(1, &mod->lightmap_texcoord_buffer);

	if (mod->normal_buffer)
		qglDeleteBuffers(1, &mod->normal_buffer);

	if (mod->tangent_buffer)
		qglDeleteBuffers(1, &mod->tangent_buffer);

	R_GetError(mod->media.name);
}