| 91 | // *********************************************************************** |
| 92 | |
| 93 | UserData* AllocUserData(lua_State* L, Type type, i32 width, i32 height) { |
| 94 | i32 typeSize = 0; |
| 95 | switch (type) { |
| 96 | case Type::Float32: typeSize = sizeof(f32); break; |
| 97 | case Type::Int32: typeSize = sizeof(i32); break; |
| 98 | case Type::Int16: typeSize = sizeof(i16); break; |
| 99 | case Type::Uint8: typeSize = sizeof(u8); break; |
| 100 | } |
| 101 | |
| 102 | i32 bufSize = width * height * typeSize; |
| 103 | UserData* pUserData = (UserData*)lua_newuserdata(L, sizeof(UserData) + bufSize); |
| 104 | memset(pUserData, 0, sizeof(UserData) + bufSize); |
| 105 | pUserData->pData = (u8*)pUserData + sizeof(UserData); |
| 106 | pUserData->width = width; |
| 107 | pUserData->height = height; |
| 108 | pUserData->type = type; |
| 109 | pUserData->img.id = SG_INVALID_ID; |
| 110 | pUserData->dirty = false; |
| 111 | pUserData->dynamic = false; |
| 112 | |
| 113 | luaL_getmetatable(L, "UserData"); |
| 114 | lua_setmetatable(L, -2); |
| 115 | return pUserData; |
| 116 | } |
| 117 | |
| 118 | // *********************************************************************** |
| 119 |
no outgoing calls
no test coverage detected