Esempio n. 1
0
	void Texture::initialise(const TextureResource* init_data /* = nullptr */)
	{
		GLenum tex_type = toTextureType(type());
		GLenum colour_fmt = toSurfaceFormat(format());

#	if defined(VCL_GL_ARB_direct_state_access)
		glCreateTextures(tex_type, 1, &_glId);
		allocImpl(colour_fmt);

		// Configure texture
		glTextureParameteri(_glId, GL_TEXTURE_BASE_LEVEL, firstMipMapLevel());
		glTextureParameteri(_glId, GL_TEXTURE_MAX_LEVEL, firstMipMapLevel() + mipMapLevels() - 1);
#	elif defined(VCL_GL_EXT_direct_state_access)
		glGenTextures(1, &_glId);
		allocImpl(colour_fmt);

		// Configure texture
		glTextureParameteriEXT(_glId, tex_type, GL_TEXTURE_BASE_LEVEL, firstMipMapLevel());
		glTextureParameteriEXT(_glId, tex_type, GL_TEXTURE_MAX_LEVEL, firstMipMapLevel() + mipMapLevels() - 1);
#	else
		glCreateTextures(tex_type, 1, &_glId);
		TextureBindPoint bp(tex_type, _glId);
		allocImpl(colour_fmt);

		// Configure texture
		glTexParameteri(tex_type, GL_TEXTURE_BASE_LEVEL, firstMipMapLevel());
		glTexParameteri(tex_type, GL_TEXTURE_MAX_LEVEL, firstMipMapLevel() + mipMapLevels() - 1);
#	endif

		if (init_data)
			updateImpl(*init_data);
	}
void LinearAllocator::addToDestructionList(Destructor dtor, void* addr) {
    static_assert(std::is_standard_layout<DestructorNode>::value,
                  "DestructorNode must have standard layout");
    static_assert(std::is_trivially_destructible<DestructorNode>::value,
                  "DestructorNode must be trivially destructable");
    auto node = new (allocImpl(sizeof(DestructorNode))) DestructorNode();
    node->dtor = dtor;
    node->addr = addr;
    node->next = mDtorList;
    mDtorList = node;
}
void MemoryInstrumenter::freeImpl(mem_t size, char type) {
    allocImpl(-size, type);
}