Texture2DSP Texture2DManager::createTexture(const string& key, GLint internalFormat, int32_t width, int32_t height, GLenum format, GLenum type, const uint8_t* pixels, uint32_t sizeOfData, bool mipMap, GLint minFilter, GLint magFilter, GLint wrapS, GLint wrapT, float anisotropic)
{
	TextureFactory textureFactory;

	if (!allTextures.contains(key))
	{
		allTextures[key] = textureFactory.createTexture2D(key, internalFormat, width, height, format, type, pixels, sizeOfData, mipMap, minFilter, magFilter, wrapS, wrapT, anisotropic);

		return allTextures[key];
	}

	return allTextures[key];
}
Texture2DSP Texture2DManager::createTexture(const string& filename, bool mipMap, GLint minFilter, GLint magFilter, GLint wrapS, GLint wrapT, float anisotropic)
{
	TextureFactory textureFactory;

	if (!allTextures.contains(filename))
	{
		allTextures[filename] = textureFactory.loadTexture2D(filename, mipMap, minFilter, magFilter, wrapS, wrapT, anisotropic);

		return allTextures[filename];
	}

	return allTextures[filename];
}
Example #3
0
vector<KeyFrame> ModelLoaderMD3::buildKeyFrame(Surface * surfaces,
  const FileName &fileName,
  const FileName &skinName,
  const Header &header,
  TextureFactory &textureFactory) {
	vector<KeyFrame> keyFrames;
	
	const FileName directory = fileName.getPath();
	
	/*
	Only the first frame loads texture files.
	The other frames use a copy of the handles and that copy is stored in here.
	*/
	Material md3Material;
	
	// Take the all the surfaces and push each frame into the mesh manager
	for (int i=0; i<surfaces[0].header.numFrames; ++i) {
		string name = fileName.str() + "#" + itos(i);
		
		// Create a mesh from the surface
		Mesh *mesh = surfaces[0].getObject(i);
		
		// Load a material for the first mesh in the first model.
		// First model only! Ignored for subsequent models
		if (i==0) {
			if (header.numSurfaces > 0) {
				mesh->material.clear();
				
#if 0
				if (surfaces[0].header.numShaders > 0) {
					const char *shaderName=(char*)surfaces[0].shaders[0].name;
					FileName skin = directory.append(FileName(shaderName));
					mesh->material.setTexture(textureFactory.load(skin));
				} else {
					mesh->material.setTexture(textureFactory.load(skinName));
				}
#else
				mesh->material.setTexture(textureFactory.load(skinName));
#endif
				// Keep a copy of the material to propagate to the subsequent frames
				md3Material = mesh->material;
			}
		} else {
			mesh->material = md3Material; // shallow copy
		}
		
		keyFrames.push_back(KeyFrame(mesh));
	}
	
	return keyFrames;
}
Example #4
0
SkyBox::SkyBox(TextureFactory &textureFactory,
               FileName _top,
               FileName _bottom,
               FileName _east,
               FileName _west,
               FileName _north,
               FileName _south) {
	// Texture clamp on these ones
	top.setTexture(textureFactory.load(_top, false));
	bottom.setTexture(textureFactory.load(_bottom, false));
	east.setTexture(textureFactory.load(_east, false));
	west.setTexture(textureFactory.load(_west, false));
	north.setTexture(textureFactory.load(_north, false));
	south.setTexture(textureFactory.load(_south, false));
}
Texture1DArraySP Texture1DArrayManager::createTexture(const string& key, GLint internalFormat, int32_t width, GLenum format, GLenum type, bool mipMap, GLint minFilter, GLint magFilter, GLint wrapS, GLint wrapT)
{
	auto walker = allTextures.find(key);

	TextureFactory textureFactory;

	if (walker == allTextures.end())
	{
		allTextures[key] = textureFactory.createTexture1DArray(internalFormat, width, format, type, mipMap, minFilter, magFilter, wrapS, wrapT);

		return allTextures[key];
	}

	return allTextures[key];
}
Example #6
0
Texture* TextureFactory::Load(const char* url)
{
	for (LinkedList<TextureFactory*>::Iterator iter = m_factories.Begin(); iter != m_factories.End(); iter++)
	{
		TextureFactory* factory = *iter;
		Texture* result = factory->Try_Load(url);
		if (result != NULL)
		{
			DBG_LOG("Loaded texture: %s", url);
			return result;
		}
	}

	DBG_LOG("Failed to load texture: %s", url);
	return NULL;
}
Example #7
0
vector<KeyFrame>
ModelLoaderMD2::loadKeyFrames(const FileName &fileName,
                              const FileName &skinName,
                              TextureFactory &textureFactory) const {
	FILE *stream=0;
	
//	fopen_s(&stream, fileName.c_str(), "rb");
	stream = fopen(fileName.c_str(), "rb");
	
	VERIFY(stream && !ferror(stream), "MD2 failed to open: "+fileName.str());
	
	Header header = readHeader(stream);
	Skin *skins = readSkins(stream, header);
	TexCoord *texCoords = readTexCoords(stream, header);
	Triangle *triangles = readTriangles(stream, header);
	Frame *frames = readFrames(stream, header);
	
	fclose(stream);
	
	Material skin;
	
	if (header.numOfSkins>0) {
		skin.setTexture(textureFactory.load(FileName((const char*)skins[0].name)));
	} else {
		skin.setTexture(textureFactory.load(skinName));
	}
	
	vector<KeyFrame> keyFrames = buildKeyFrames(fileName,
	                             skin,
	                             header,
	                             texCoords,
	                             triangles,
	                             frames);
	                             
	delete [] skins;
	delete [] texCoords;
	delete [] triangles;
	delete [] frames;
	
	return keyFrames;
}
Example #8
0
void ParticleSystem::loadParticleMaterials(const PropertyBag &data,
										   TextureFactory &textureFactory)
{
	const size_t nMaterials = data.getNumInstances("material");
	ASSERT(nMaterials>0, "particle system does not specify any materials");
	for(size_t i=0; i<nMaterials; ++i)
	{
		PropertyBag MatBag = data.getBag("material", i);
		Material material;
		const string name = MatBag.getString("name");
		const FileName fileName = MatBag.getString("image");
		material.setTexture(textureFactory.load(fileName, false));
		material.glow = MatBag.getBool("glow");
		materials.insert(make_pair(name, material));
	}
	ASSERT(!materials.empty(),
		   "after loading, there are no particle materials in system");
}
Example #9
0
			void reloadObject(LoadableObject::Pointer o, ObjectsCache& c)
				{ owner->reloadObject(o, c); }