Commits

Alex Szpakowski committed 5cb3fa5

Renamed CompressedData:getType to CompressedData:getFormat

  • Participants
  • Parent commits 68d0b44

Comments (0)

Files changed (10)

File src/modules/graphics/opengl/Image.cpp

 
 void Image::uploadCompressedMipmaps()
 {
-	if (!isCompressed() || !cdata || !hasCompressedTextureSupport(cdata->getType()))
+	if (!isCompressed() || !cdata || !hasCompressedTextureSupport(cdata->getFormat()))
 		return;
 
 	bind();
 	{
 		glCompressedTexImage2DARB(GL_TEXTURE_2D,
 		                          i,
-		                          getCompressedFormat(cdata->getType()),
+		                          getCompressedFormat(cdata->getFormat()),
 		                          cdata->getWidth(i),
 		                          cdata->getHeight(i),
 		                          0,
 	if (mipmapsCreated || filter.mipmap == FILTER_NONE || usingDefaultTexture)
 		return;
 
-	if (isCompressed() && cdata && hasCompressedTextureSupport(cdata->getType()))
+	if (isCompressed() && cdata && hasCompressedTextureSupport(cdata->getFormat()))
 		uploadCompressedMipmaps();
 	else if (data)
 		createMipmaps();
 
 bool Image::loadVolatile()
 {
-	if (isCompressed() && cdata && !hasCompressedTextureSupport(cdata->getType()))
+	if (isCompressed() && cdata && !hasCompressedTextureSupport(cdata->getFormat()))
 	{
 		const char *str;
-		if (image::CompressedData::getConstant(cdata->getType(), str))
+		if (image::CompressedData::getConstant(cdata->getFormat(), str))
 		{
 			throw love::Exception("Cannot create image: "
 			      "%s compressed images are not supported on this system.", str);
 
 		glCompressedTexImage2DARB(GL_TEXTURE_2D,
 		                          0,
-		                          getCompressedFormat(cdata->getType()),
+		                          getCompressedFormat(cdata->getFormat()),
 		                          cdata->getWidth(0),
 		                          cdata->getHeight(0),
 		                          0,
 
 	if (isCompressed() && cdata)
 	{
-		GLenum format = getCompressedFormat(cdata->getType());
+		GLenum format = getCompressedFormat(cdata->getFormat());
 		glCompressedTexImage2DARB(GL_TEXTURE_2D,
 		                          0,
 		                          format,
 
 	if (isCompressed() && cdata)
 	{
-		GLenum format = getCompressedFormat(cdata->getType());
+		GLenum format = getCompressedFormat(cdata->getFormat());
 		glCompressedTexSubImage2DARB(GL_TEXTURE_2D,
 		                             0,
 		                             0, 0,
 	return compressed;
 }
 
-GLenum Image::getCompressedFormat(image::CompressedData::TextureType type) const
+GLenum Image::getCompressedFormat(image::CompressedData::Format format) const
 {
-	switch (type)
+	switch (format)
 	{
-	case image::CompressedData::TYPE_DXT1:
+	case image::CompressedData::FORMAT_DXT1:
 		return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
-	case image::CompressedData::TYPE_DXT3:
+	case image::CompressedData::FORMAT_DXT3:
 		return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
-	case image::CompressedData::TYPE_DXT5:
+	case image::CompressedData::FORMAT_DXT5:
 		return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
-	case image::CompressedData::TYPE_BC4:
+	case image::CompressedData::FORMAT_BC4:
 		return GL_COMPRESSED_RED_RGTC1;
-	case image::CompressedData::TYPE_BC4s:
+	case image::CompressedData::FORMAT_BC4s:
 		return GL_COMPRESSED_SIGNED_RED_RGTC1;
-	case image::CompressedData::TYPE_BC5:
+	case image::CompressedData::FORMAT_BC5:
 		return GL_COMPRESSED_RG_RGTC2;
-	case image::CompressedData::TYPE_BC5s:
+	case image::CompressedData::FORMAT_BC5s:
 		return GL_COMPRESSED_SIGNED_RG_RGTC2;
 	default:
 		return GL_RGBA8;
 	return GLEE_VERSION_1_3 || GLEE_ARB_texture_compression;
 }
 
-bool Image::hasCompressedTextureSupport(image::CompressedData::TextureType type)
+bool Image::hasCompressedTextureSupport(image::CompressedData::Format format)
 {
 	if (!hasCompressedTextureSupport())
 		return false;
 
-	switch (type)
+	switch (format)
 	{
-	case image::CompressedData::TYPE_DXT1:
-	case image::CompressedData::TYPE_DXT3:
-	case image::CompressedData::TYPE_DXT5:
+	case image::CompressedData::FORMAT_DXT1:
+	case image::CompressedData::FORMAT_DXT3:
+	case image::CompressedData::FORMAT_DXT5:
 		return GLEE_EXT_texture_compression_s3tc;
-	case image::CompressedData::TYPE_BC4:
-	case image::CompressedData::TYPE_BC4s:
-	case image::CompressedData::TYPE_BC5:
-	case image::CompressedData::TYPE_BC5s:
+	case image::CompressedData::FORMAT_BC4:
+	case image::CompressedData::FORMAT_BC4s:
+	case image::CompressedData::FORMAT_BC5:
+	case image::CompressedData::FORMAT_BC5s:
 		return (GLEE_VERSION_3_0 || GLEE_ARB_texture_compression_rgtc || GLEE_EXT_texture_compression_rgtc);
 	default:
 		break;

File src/modules/graphics/opengl/Image.h

 	static bool hasMipmapSharpnessSupport();
 
 	static bool hasCompressedTextureSupport();
-	static bool hasCompressedTextureSupport(image::CompressedData::TextureType type);
+	static bool hasCompressedTextureSupport(image::CompressedData::Format format);
 
 private:
 
 	static FilterMode defaultMipmapFilter;
 	static float defaultMipmapSharpness;
 
-	GLenum getCompressedFormat(image::CompressedData::TextureType type) const;
+	GLenum getCompressedFormat(image::CompressedData::Format format) const;
 
 }; // Image
 

File src/modules/graphics/opengl/wrap_Graphics.cpp

 				supported = false;
 			break;
 		case Graphics::SUPPORT_DXT:
-			if (!Image::hasCompressedTextureSupport(image::CompressedData::TYPE_DXT5))
+			if (!Image::hasCompressedTextureSupport(image::CompressedData::FORMAT_DXT5))
 				supported = false;
 			break;
 		case Graphics::SUPPORT_BC5:
-			if (!Image::hasCompressedTextureSupport(image::CompressedData::TYPE_BC5))
+			if (!Image::hasCompressedTextureSupport(image::CompressedData::FORMAT_BC5))
 				supported = false;
 			break;
 		default:

File src/modules/image/CompressedData.cpp

 {
 
 CompressedData::CompressedData()
-	: type(TYPE_UNKNOWN)
+	: format(FORMAT_UNKNOWN)
 {
 }
 
 	return dataImages[miplevel].height;
 }
 
-CompressedData::TextureType CompressedData::getType() const
+CompressedData::Format CompressedData::getFormat() const
 {
-	return type;
+	return format;
 }
 
 void CompressedData::checkMipmapLevelExists(int miplevel) const
 		throw love::Exception("Mipmap level %d does not exist", miplevel);
 }
 
-bool CompressedData::getConstant(const char *in, CompressedData::TextureType &out)
+bool CompressedData::getConstant(const char *in, CompressedData::Format &out)
 {
-	return types.find(in, out);
+	return formats.find(in, out);
 }
 
-bool CompressedData::getConstant(CompressedData::TextureType in, const char *&out)
+bool CompressedData::getConstant(CompressedData::Format in, const char *&out)
 {
-	return types.find(in, out);
+	return formats.find(in, out);
 }
 
-StringMap<CompressedData::TextureType, CompressedData::TYPE_MAX_ENUM>::Entry CompressedData::typeEntries[] =
+StringMap<CompressedData::Format, CompressedData::FORMAT_MAX_ENUM>::Entry CompressedData::formatEntries[] =
 {
-	{"unknown", CompressedData::TYPE_UNKNOWN},
-	{"dxt1", CompressedData::TYPE_DXT1},
-	{"dxt3", CompressedData::TYPE_DXT3},
-	{"dxt5", CompressedData::TYPE_DXT5},
-	{"bc4", CompressedData::TYPE_BC4},
-	{"bc4s", CompressedData::TYPE_BC4s},
-	{"bc5", CompressedData::TYPE_BC5},
-	{"bc5s", CompressedData::TYPE_BC5s},
+	{"unknown", CompressedData::FORMAT_UNKNOWN},
+	{"dxt1", CompressedData::FORMAT_DXT1},
+	{"dxt3", CompressedData::FORMAT_DXT3},
+	{"dxt5", CompressedData::FORMAT_DXT5},
+	{"bc4", CompressedData::FORMAT_BC4},
+	{"bc4s", CompressedData::FORMAT_BC4s},
+	{"bc5", CompressedData::FORMAT_BC5},
+	{"bc5s", CompressedData::FORMAT_BC5s},
 };
 
-StringMap<CompressedData::TextureType, CompressedData::TYPE_MAX_ENUM> CompressedData::types(CompressedData::typeEntries, sizeof(CompressedData::typeEntries));
+StringMap<CompressedData::Format, CompressedData::FORMAT_MAX_ENUM> CompressedData::formats(CompressedData::formatEntries, sizeof(CompressedData::formatEntries));
 
 } // image
 } // love

File src/modules/image/CompressedData.h

 {
 public:
 
-	// Types of compressed image data.
-	enum TextureType
+	// Recognized compressed image data formats.
+	enum Format
 	{
-		TYPE_UNKNOWN,
-		TYPE_DXT1,
-		TYPE_DXT3,
-		TYPE_DXT5,
-		TYPE_BC4,
-		TYPE_BC4s,
-		TYPE_BC5,
-		TYPE_BC5s,
-		TYPE_MAX_ENUM
+		FORMAT_UNKNOWN,
+		FORMAT_DXT1,
+		FORMAT_DXT3,
+		FORMAT_DXT5,
+		FORMAT_BC4,
+		FORMAT_BC4s,
+		FORMAT_BC5,
+		FORMAT_BC5s,
+		FORMAT_MAX_ENUM
 	};
 
 	// Compressed image data can have multiple mipmap levels, each represented
 	int getHeight(int miplevel) const;
 
 	/**
-	 * Gets the type of the compressed data.
+	 * Gets the format of the compressed data.
 	 **/
-	TextureType getType() const;
+	Format getFormat() const;
 
-	static bool getConstant(const char *in, TextureType &out);
-	static bool getConstant(TextureType in, const char *&out);
+	static bool getConstant(const char *in, Format &out);
+	static bool getConstant(Format in, const char *&out);
 
 protected:
 
-	TextureType type;
+	Format format;
 
 	// Texture info for each mipmap level.
 	std::vector<SubImage> dataImages;
 
 private:
 
-	static StringMap<TextureType, TYPE_MAX_ENUM>::Entry typeEntries[];
-	static StringMap<TextureType, TYPE_MAX_ENUM> types;
+	static StringMap<Format, FORMAT_MAX_ENUM>::Entry formatEntries[];
+	static StringMap<Format, FORMAT_MAX_ENUM> formats;
 
 }; // CompressedData
 

File src/modules/image/magpie/CompressedData.cpp

 {
 	// SubImage vector will be populated by a parser.
 	std::vector<SubImage> parsedimages;
-	TextureType textype = TYPE_UNKNOWN;
+	Format texformat = FORMAT_UNKNOWN;
 
 	if (ddsHandler::canParse(data))
-		textype = ddsHandler::parse(data, parsedimages);
+		texformat = ddsHandler::parse(data, parsedimages);
 
-	if (textype == TYPE_UNKNOWN)
+	if (texformat == FORMAT_UNKNOWN)
 		throw love::Exception("Could not parse compressed data: Unknown format.");
 
 	if (parsedimages.size() == 0)
 	}
 
 	dataImages = parsedimages;
-	type = textype;
+	format = texformat;
 }
 
 bool CompressedData::isCompressed(love::filesystem::FileData *data)

File src/modules/image/magpie/ddsHandler.cpp

 	return dds::isCompressedDDS(data->getData(), data->getSize());
 }
 
-CompressedData::TextureType ddsHandler::parse(filesystem::FileData *data, std::vector<CompressedData::SubImage> &images)
+CompressedData::Format ddsHandler::parse(filesystem::FileData *data, std::vector<CompressedData::SubImage> &images)
 {
 	if (!dds::isDDS(data->getData(), data->getSize()))
 		throw love::Exception("Could not decode compressed data (not a DDS file?)");
 
-	CompressedData::TextureType textype = CompressedData::TYPE_UNKNOWN;
+	CompressedData::Format texformat = CompressedData::FORMAT_UNKNOWN;
 
 	try
 	{
 		// Attempt to parse the dds file.
 		dds::Parser parser(data->getData(), data->getSize());
 
-		textype = convertFormat(parser.getFormat());
+		texformat = convertFormat(parser.getFormat());
 
-		if (textype == CompressedData::TYPE_UNKNOWN)
+		if (texformat == CompressedData::FORMAT_UNKNOWN)
 			throw love::Exception("Could not parse compressed data: Unsupported format.");
 
 		if (parser.getMipmapCount() == 0)
 		throw love::Exception(e.what());
 	}
 
-	return textype;
+	return texformat;
 }
 
-CompressedData::TextureType ddsHandler::convertFormat(dds::Format ddsformat)
+CompressedData::Format ddsHandler::convertFormat(dds::Format ddsformat)
 {
 	switch (ddsformat)
 	{
 	case dds::FORMAT_DXT1:
-		return CompressedData::TYPE_DXT1;
+		return CompressedData::FORMAT_DXT1;
 	case dds::FORMAT_DXT3:
-		return CompressedData::TYPE_DXT3;
+		return CompressedData::FORMAT_DXT3;
 	case dds::FORMAT_DXT5:
-		return CompressedData::TYPE_DXT5;
+		return CompressedData::FORMAT_DXT5;
 	case dds::FORMAT_BC4:
-		return CompressedData::TYPE_BC4;
+		return CompressedData::FORMAT_BC4;
 	case dds::FORMAT_BC4s:
-		return CompressedData::TYPE_BC4s;
+		return CompressedData::FORMAT_BC4s;
 	case dds::FORMAT_BC5:
-		return CompressedData::TYPE_BC5;
+		return CompressedData::FORMAT_BC5;
 	case dds::FORMAT_BC5s:
-		return CompressedData::TYPE_BC5s;
+		return CompressedData::FORMAT_BC5s;
 	default:
-		return CompressedData::TYPE_UNKNOWN;
+		return CompressedData::FORMAT_UNKNOWN;
 	}
 
-	return CompressedData::TYPE_UNKNOWN;
+	return CompressedData::FORMAT_UNKNOWN;
 }
 
 } // magpie

File src/modules/image/magpie/ddsHandler.h

 	 * @param[in]  data The data to parse.
 	 * @param[out] images The list of sub-images (including byte data for each)
 	 *             parsed from the file data.
-	 * @return The type of CompressedData.
+	 * @return The format of the CompressedData.
 	 **/
-	static CompressedData::TextureType parse(filesystem::FileData *data, std::vector<CompressedData::SubImage> &images);
+	static CompressedData::Format parse(filesystem::FileData *data, std::vector<CompressedData::SubImage> &images);
 
 private:
 
-	static CompressedData::TextureType convertFormat(dds::Format ddsformat);
+	static CompressedData::Format convertFormat(dds::Format ddsformat);
 
 }; // ddsHandler
 

File src/modules/image/wrap_CompressedData.cpp

 	return 1;
 }
 
-int w_CompressedData_getType(lua_State *L)
+int w_CompressedData_getFormat(lua_State *L)
 {
 	CompressedData *t = luax_checkcompresseddata(L, 1);
 
-	image::CompressedData::TextureType type = t->getType();
+	image::CompressedData::Format format = t->getFormat();
 	const char *str;
 
-	if (image::CompressedData::getConstant(type, str))
+	if (image::CompressedData::getConstant(format, str))
 		lua_pushstring(L, str);
 	else
 		lua_pushstring(L, "unknown");
 	{ "getHeight", w_CompressedData_getHeight },
 	{ "getDimensions", w_CompressedData_getDimensions },
 	{ "getMipmapCount", w_CompressedData_getMipmapCount },
-	{ "getType", w_CompressedData_getType },
+	{ "getFormat", w_CompressedData_getFormat },
 	{ 0, 0 },
 };
 

File src/modules/image/wrap_CompressedData.h

 int w_CompressedData_getHeight(lua_State *L);
 int w_CompressedData_getDimensions(lua_State *L);
 int w_CompressedData_getMipmapCount(lua_State *L);
-int w_CompressedData_getType(lua_State *L);
+int w_CompressedData_getFormat(lua_State *L);
 extern "C" int luaopen_compresseddata(lua_State *L);
 
 } // image