mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Embedded nogame screen into binary and exposed version info.
This commit is contained in:
@@ -53,6 +53,13 @@ namespace image
|
||||
**/
|
||||
virtual ImageData * newImageData(love::filesystem::File * file) = 0;
|
||||
|
||||
/**
|
||||
* Creates new ImageData from a raw Data.
|
||||
* @param data The object containing encoded pixel data.
|
||||
* @return The new ImageData.
|
||||
**/
|
||||
virtual ImageData * newImageData(Data * data) = 0;
|
||||
|
||||
/**
|
||||
* Creates empty ImageData with the given size.
|
||||
* @param The width of the ImageData.
|
||||
|
||||
@@ -51,6 +51,11 @@ namespace devil
|
||||
return new ImageData(file);
|
||||
}
|
||||
|
||||
love::image::ImageData * Image::newImageData(Data * data)
|
||||
{
|
||||
return new ImageData(data);
|
||||
}
|
||||
|
||||
love::image::ImageData * Image::newImageData(int width, int height)
|
||||
{
|
||||
return new ImageData(width, height);
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace devil
|
||||
const char * getName() const;
|
||||
|
||||
love::image::ImageData * newImageData(love::filesystem::File * file);
|
||||
love::image::ImageData * newImageData(Data * data);
|
||||
love::image::ImageData * newImageData(int width, int height);
|
||||
|
||||
}; // Image
|
||||
|
||||
@@ -29,11 +29,8 @@ namespace image
|
||||
{
|
||||
namespace devil
|
||||
{
|
||||
ImageData::ImageData(filesystem::File * file)
|
||||
void ImageData::load(Data * data)
|
||||
{
|
||||
// Read the data.
|
||||
Data * data = file->read();
|
||||
|
||||
// Generate DevIL image.
|
||||
ilGenImages(1, &image);
|
||||
|
||||
@@ -43,9 +40,6 @@ namespace devil
|
||||
// Try to load the image.
|
||||
ILboolean success = ilLoadL(IL_TYPE_UNKNOWN, (void*)data->getData(), data->getSize());
|
||||
|
||||
// Free local image data.
|
||||
data->release();
|
||||
|
||||
// Check for errors
|
||||
if(!success)
|
||||
{
|
||||
@@ -70,6 +64,18 @@ namespace devil
|
||||
}
|
||||
}
|
||||
|
||||
ImageData::ImageData(Data * data)
|
||||
{
|
||||
load(data);
|
||||
}
|
||||
|
||||
ImageData::ImageData(filesystem::File * file)
|
||||
{
|
||||
Data * data = file->read();
|
||||
load(data);
|
||||
data->release();
|
||||
}
|
||||
|
||||
ImageData::ImageData(int width, int height)
|
||||
: width(width), height(height), origin(IL_ORIGIN_UPPER_LEFT), bpp(4)
|
||||
{
|
||||
|
||||
@@ -53,8 +53,11 @@ namespace devil
|
||||
// DevIL image identifier.
|
||||
ILuint image;
|
||||
|
||||
void load(Data * data);
|
||||
|
||||
public:
|
||||
|
||||
ImageData(Data * data);
|
||||
ImageData(love::filesystem::File * file);
|
||||
ImageData(int width, int height);
|
||||
virtual ~ImageData();
|
||||
|
||||
@@ -41,11 +41,21 @@ namespace image
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Case 2: Data
|
||||
if(luax_istype(L, 1, DATA_T))
|
||||
{
|
||||
Data * d = luax_checktype<Data>(L, 1, "Data", DATA_T);
|
||||
ImageData * t = instance->newImageData(d);
|
||||
luax_newtype(L, "ImageData", IMAGE_IMAGE_DATA_T, (void*)t);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Case 3: String/File.
|
||||
|
||||
// Convert to File, if necessary.
|
||||
if(lua_isstring(L, 1))
|
||||
luax_convobj(L, 1, "filesystem", "newFile");
|
||||
|
||||
// Case 2: String/File.
|
||||
love::filesystem::File * file = luax_checktype<love::filesystem::File>(L, 1, "File", FILESYSTEM_FILE_T);
|
||||
ImageData * t = instance->newImageData(file);
|
||||
luax_newtype(L, "ImageData", IMAGE_IMAGE_DATA_T, (void*)t);
|
||||
|
||||
Reference in New Issue
Block a user