annotate src/modules/image/wrap_Image.cpp @ 1448:108ee2e81f65 default tip

Fix a case typo, imageData.h -> ImageData.h
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Sat, 18 Jan 2014 13:57:44 +0100
parents 5b9ebe6a9a7e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1096
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
1 /**
1282
b7f097053d74 Updated copyright text for the new year
Alex Szpakowski <slime73@gmail.com>
parents: 1096
diff changeset
2 * Copyright (c) 2006-2013 LOVE Development Team
1096
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
3 *
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
4 * This software is provided 'as-is', without any express or implied
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
5 * warranty. In no event will the authors be held liable for any damages
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
6 * arising from the use of this software.
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
7 *
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
8 * Permission is granted to anyone to use this software for any purpose,
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
9 * including commercial applications, and to alter it and redistribute it
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
10 * freely, subject to the following restrictions:
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
11 *
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
12 * 1. The origin of this software must not be misrepresented; you must not
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
13 * claim that you wrote the original software. If you use this software
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
14 * in a product, an acknowledgment in the product documentation would be
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
15 * appreciated but is not required.
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
16 * 2. Altered source versions must be plainly marked as such, and must not be
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
17 * misrepresented as being the original software.
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
18 * 3. This notice may not be removed or altered from any source distribution.
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
19 **/
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
20
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
21 #include "wrap_Image.h"
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
22
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
23 #include "common/Data.h"
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
24 #include "common/StringMap.h"
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
25
1422
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
26 #include "magpie/Image.h"
1096
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
27
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
28 namespace love
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
29 {
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
30 namespace image
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
31 {
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
32
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
33 static Image *instance = 0;
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
34
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
35 int w_newImageData(lua_State *L)
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
36 {
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
37 // Case 1: Integers.
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
38 if (lua_isnumber(L, 1))
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
39 {
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
40 int w = luaL_checkint(L, 1);
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
41 int h = luaL_checkint(L, 2);
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
42 if (w <= 0 || h <= 0)
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
43 return luaL_error(L, "Invalid image size.");
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
44
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
45 ImageData *t = 0;
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
46 try
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
47 {
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
48 t = instance->newImageData(w, h);
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
49 }
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
50 catch(love::Exception &e)
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
51 {
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
52 return luaL_error(L, "%s", e.what());
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
53 }
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
54 luax_newtype(L, "ImageData", IMAGE_IMAGE_DATA_T, (void *)t);
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
55 return 1;
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
56 }
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
57
1422
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
58 // Case 2: File(Data).
1096
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
59
1422
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
60 // Convert to FileData, if necessary.
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
61 if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_T))
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
62 luax_convobj(L, 1, "filesystem", "newFileData");
1096
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
63
1422
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
64 love::filesystem::FileData *data = luax_checktype<love::filesystem::FileData>(L, 1, "FileData", FILESYSTEM_FILE_DATA_T);
1096
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
65
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
66 ImageData *t = 0;
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
67 try
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
68 {
1422
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
69 t = instance->newImageData(data);
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
70 }
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
71 catch (love::Exception &e)
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
72 {
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
73 return luaL_error(L, "%s", e.what());
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
74 }
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
75
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
76 luax_newtype(L, "ImageData", IMAGE_IMAGE_DATA_T, (void *) t);
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
77
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
78 return 1;
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
79 }
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
80
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
81 int w_newCompressedData(lua_State *L)
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
82 {
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
83 // Convert to FileData, if necessary.
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
84 if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_T))
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
85 luax_convobj(L, 1, "filesystem", "newFileData");
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
86
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
87 love::filesystem::FileData *data = luax_checktype<love::filesystem::FileData>(L, 1, "FileData", FILESYSTEM_FILE_DATA_T);
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
88
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
89 CompressedData *t = 0;
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
90 try
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
91 {
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
92 t = instance->newCompressedData(data);
1096
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
93 }
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
94 catch(love::Exception &e)
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
95 {
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
96 return luaL_error(L, "%s", e.what());
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
97 }
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
98
1420
2a5ef265e040 Added support for DXT1/3/5 and BC5/7 compressed textures via love.image.CompressedData. Some internals are still iffy.
Alex Szpakowski <slime73@gmail.com>
parents: 1282
diff changeset
99 luax_newtype(L, "CompressedData", IMAGE_COMPRESSED_DATA_T, (void *) t);
2a5ef265e040 Added support for DXT1/3/5 and BC5/7 compressed textures via love.image.CompressedData. Some internals are still iffy.
Alex Szpakowski <slime73@gmail.com>
parents: 1282
diff changeset
100
2a5ef265e040 Added support for DXT1/3/5 and BC5/7 compressed textures via love.image.CompressedData. Some internals are still iffy.
Alex Szpakowski <slime73@gmail.com>
parents: 1282
diff changeset
101 return 1;
2a5ef265e040 Added support for DXT1/3/5 and BC5/7 compressed textures via love.image.CompressedData. Some internals are still iffy.
Alex Szpakowski <slime73@gmail.com>
parents: 1282
diff changeset
102 }
2a5ef265e040 Added support for DXT1/3/5 and BC5/7 compressed textures via love.image.CompressedData. Some internals are still iffy.
Alex Szpakowski <slime73@gmail.com>
parents: 1282
diff changeset
103
2a5ef265e040 Added support for DXT1/3/5 and BC5/7 compressed textures via love.image.CompressedData. Some internals are still iffy.
Alex Szpakowski <slime73@gmail.com>
parents: 1282
diff changeset
104 int w_isCompressed(lua_State *L)
2a5ef265e040 Added support for DXT1/3/5 and BC5/7 compressed textures via love.image.CompressedData. Some internals are still iffy.
Alex Szpakowski <slime73@gmail.com>
parents: 1282
diff changeset
105 {
1422
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
106 // Convert to FileData, if necessary.
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
107 if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_T))
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
108 luax_convobj(L, 1, "filesystem", "newFileData");
1420
2a5ef265e040 Added support for DXT1/3/5 and BC5/7 compressed textures via love.image.CompressedData. Some internals are still iffy.
Alex Szpakowski <slime73@gmail.com>
parents: 1282
diff changeset
109
1422
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
110 love::filesystem::FileData *data = luax_checktype<love::filesystem::FileData>(L, 1, "FileData", FILESYSTEM_FILE_DATA_T);
1420
2a5ef265e040 Added support for DXT1/3/5 and BC5/7 compressed textures via love.image.CompressedData. Some internals are still iffy.
Alex Szpakowski <slime73@gmail.com>
parents: 1282
diff changeset
111
1422
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
112 bool compressed = false;
1420
2a5ef265e040 Added support for DXT1/3/5 and BC5/7 compressed textures via love.image.CompressedData. Some internals are still iffy.
Alex Szpakowski <slime73@gmail.com>
parents: 1282
diff changeset
113 try
2a5ef265e040 Added support for DXT1/3/5 and BC5/7 compressed textures via love.image.CompressedData. Some internals are still iffy.
Alex Szpakowski <slime73@gmail.com>
parents: 1282
diff changeset
114 {
1422
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
115 compressed = instance->isCompressed(data);
1420
2a5ef265e040 Added support for DXT1/3/5 and BC5/7 compressed textures via love.image.CompressedData. Some internals are still iffy.
Alex Szpakowski <slime73@gmail.com>
parents: 1282
diff changeset
116 }
2a5ef265e040 Added support for DXT1/3/5 and BC5/7 compressed textures via love.image.CompressedData. Some internals are still iffy.
Alex Szpakowski <slime73@gmail.com>
parents: 1282
diff changeset
117 catch (love::Exception &e)
2a5ef265e040 Added support for DXT1/3/5 and BC5/7 compressed textures via love.image.CompressedData. Some internals are still iffy.
Alex Szpakowski <slime73@gmail.com>
parents: 1282
diff changeset
118 {
2a5ef265e040 Added support for DXT1/3/5 and BC5/7 compressed textures via love.image.CompressedData. Some internals are still iffy.
Alex Szpakowski <slime73@gmail.com>
parents: 1282
diff changeset
119 return luaL_error(L, "%s", e.what());
2a5ef265e040 Added support for DXT1/3/5 and BC5/7 compressed textures via love.image.CompressedData. Some internals are still iffy.
Alex Szpakowski <slime73@gmail.com>
parents: 1282
diff changeset
120 }
1423
5b9ebe6a9a7e Cosmetic code improvements
Alex Szpakowski <slime73@gmail.com>
parents: 1422
diff changeset
121 luax_pushboolean(L, compressed);
1420
2a5ef265e040 Added support for DXT1/3/5 and BC5/7 compressed textures via love.image.CompressedData. Some internals are still iffy.
Alex Szpakowski <slime73@gmail.com>
parents: 1282
diff changeset
122 return 1;
2a5ef265e040 Added support for DXT1/3/5 and BC5/7 compressed textures via love.image.CompressedData. Some internals are still iffy.
Alex Szpakowski <slime73@gmail.com>
parents: 1282
diff changeset
123 }
2a5ef265e040 Added support for DXT1/3/5 and BC5/7 compressed textures via love.image.CompressedData. Some internals are still iffy.
Alex Szpakowski <slime73@gmail.com>
parents: 1282
diff changeset
124
1096
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
125 // List of functions to wrap.
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
126 static const luaL_Reg functions[] =
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
127 {
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
128 { "newImageData", w_newImageData },
1420
2a5ef265e040 Added support for DXT1/3/5 and BC5/7 compressed textures via love.image.CompressedData. Some internals are still iffy.
Alex Szpakowski <slime73@gmail.com>
parents: 1282
diff changeset
129 { "newCompressedData", w_newCompressedData },
2a5ef265e040 Added support for DXT1/3/5 and BC5/7 compressed textures via love.image.CompressedData. Some internals are still iffy.
Alex Szpakowski <slime73@gmail.com>
parents: 1282
diff changeset
130 { "isCompressed", w_isCompressed },
1096
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
131 { 0, 0 }
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
132 };
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
133
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
134 static const lua_CFunction types[] =
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
135 {
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
136 luaopen_imagedata,
1420
2a5ef265e040 Added support for DXT1/3/5 and BC5/7 compressed textures via love.image.CompressedData. Some internals are still iffy.
Alex Szpakowski <slime73@gmail.com>
parents: 1282
diff changeset
137 luaopen_compresseddata,
1096
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
138 0
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
139 };
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
140
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
141 extern "C" int luaopen_love_image(lua_State *L)
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
142 {
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
143 if (instance == 0)
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
144 {
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
145 try
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
146 {
1422
377f9dad7a2d Replaced the devil love.image module with love.image.magpie, which can decide which image library to use in a similar manner to love.sound.lullaby. Some rough edges still exist.
Alex Szpakowski <slime73@gmail.com>
parents: 1420
diff changeset
147 instance = new love::image::magpie::Image();
1096
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
148 }
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
149 catch(Exception &e)
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
150 {
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
151 return luaL_error(L, "%s", e.what());
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
152 }
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
153 }
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
154 else
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
155 instance->retain();
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
156
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
157 WrappedModule w;
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
158 w.module = instance;
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
159 w.name = "image";
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
160 w.flags = MODULE_IMAGE_T;
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
161 w.functions = functions;
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
162 w.types = types;
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
163
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
164 return luax_register_module(L, w);
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
165 }
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
166
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
167 } // image
86a44f2bc38f CRLF to LF
Bart van Strien <bart.bes+projects@gmail.com>
parents: 1086
diff changeset
168 } // love