示例#1
0
void HGE_Impl::_GfxDone()
{
	CRenderTargetList *target = pTargets, *next_target;

	while (textures) Texture_Free(textures->tex);

	while (target)
	{
		if (target->pTex) target->pTex->Release();
		if (target->pDepth) target->pDepth->Release();
		next_target = target->next;
		delete target;
		target = next_target;
	}
	pTargets = 0;

	if (m_pSwapChain)
	{
		// Release all outstanding references to the swap chain's buffers.
		if (pRTView) pRTView->Release();
		if (m_pDepthStencilState) m_pDepthStencilState->Release();
		if (m_pVertexBuf) m_pVertexBuf->Release();
		if (m_pIndexBuf) m_pIndexBuf->Release();
		if (m_pInputLayout0) m_pInputLayout0->Release();
		if (m_pInputLayout1) m_pInputLayout1->Release();

		if (m_pSwapChain) m_pSwapChain->Release();
		if (m_pD3DDevice) m_pD3DDevice->Release();
		if (m_pD3DDeviceContext) m_pD3DDeviceContext->Release();
	}

}
示例#2
0
///
//Frees resuorces allocated by an Asset Buffer
//Deletes data being held in buffer!!
//
//PArameters:
//	buffer: pointer to The buffer to free
static void AssetManager_FreeBuffer(AssetBuffer* buffer)
{
	for (unsigned int i = 0; i < buffer->meshMap->data->capacity; i++)
	{
		struct HashMap_KeyValuePair* pair = *(struct HashMap_KeyValuePair**)DynamicArray_Index(buffer->meshMap->data, i);
		if(pair != NULL)
		{
			Mesh* m = (Mesh*)pair->data;
			Mesh_Free(m);
			//Following line will be done by HashMap_Free
			//HashMap_KeyValuePair_Free(pair);
		}
	}
	printf("Meshes freed\n");
	HashMap_Free(buffer->meshMap);
	printf("MeshMap freed\n");

	for (unsigned int i = 0; i < buffer->textureMap->data->capacity; i++)
	{
		struct HashMap_KeyValuePair* pair = *(struct HashMap_KeyValuePair**)DynamicArray_Index(buffer->textureMap->data, i);
		if(pair != NULL)
		{
			Texture* t = (Texture*)pair->data;
			Texture_Free(t);
		}
	}
	printf("Textures freed.\n");
	HashMap_Free(buffer->textureMap);

	printf("Texture Map Freed.\n");
}
示例#3
0
///
//Frees resuorces allocated by an Asset Buffer
//Deletes data being held in buffer!!
//
//PArameters:
//	buffer: pointer to The buffer to free
static void AssetManager_FreeBuffer(AssetBuffer* buffer)
{
	for (int i = 0; i < buffer->meshMap->data->capacity; i++)
	{
		//Mesh_Free((Mesh*)buffer->meshMap->data[i]->data);
		Mesh* m = *(Mesh**)DynamicArray_Index(buffer->meshMap->data, i);
		if(m != NULL)
		{
			Mesh_Free(m);
		}
	}
	HashMap_Free(buffer->meshMap);

	//for (int i = 0; i < buffer->textureMap->size; i++)
	for (int i = 0; i < buffer->textureMap->data->capacity; i++)
	{
		//Texture_Free((Texture*)buffer->meshMap->data[i]->data);
		Texture* t = *(Texture**)DynamicArray_Index(buffer->textureMap->data, i);
		if(t != NULL)
		{
			Texture_Free(t);
		}
	}

	HashMap_Free(buffer->textureMap);
}
示例#4
0
bool Texture_LoadFromFile(Texture* texture, SDL_Renderer* renderer, const char* path, bool doColorManipulation)
{
	Texture_Free(texture);

	bool success = true;
	SDL_Surface* loadedSurface = IMG_Load(path);
	if (loadedSurface == nullptr)
	{
		SDL_Log("Unable to load image %s.\nIMG_Error: %s\n", path, IMG_GetError());
		success = false;
	}
	else
	{
		texture->texture = SDL_CreateTextureFromSurface(renderer, loadedSurface);
		if (texture->texture == nullptr)
		{
			SDL_Log("Unable to create texture from %s.\nSDL_Error: %s\n", path, SDL_GetError());
			success = false;
		}
		else
		{
			texture->width = loadedSurface->w;
			texture->height = loadedSurface->h;
		}
	}
	SDL_FreeSurface(loadedSurface);

	return texture->texture != nullptr;
}
示例#5
0
文件: demo_5.c 项目: master-g/kitsune
GLuint demo5_loadTexture(const char *filepath)
{
    GLuint texID;
    /* load texture */
    texture_t *tex = NULL;
    path_t texPath;
    
    filesystem_t fs;
    FileSystem_Init(&fs);
    
    Path_Init(texPath, fs.resPath);
    Path_AppendPath(texPath, filepath);
    
    tex = TextureLoader_LoadFromFile(texPath);
    Texture_Load(tex);
    Texture_SetWrapMode(tex, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
    
    texID = tex->texID;
    Texture_Free(tex);
    
    return texID;
}
示例#6
0
void BitmapFont_Free(BitmapFont* bitmapFont)
{
    Texture_UnlockTexture(bitmapFont->bitmap);
    Texture_Free(bitmapFont->bitmap);
}