u16 ckLowLevelAPI::getValidTextureLength(u16 length) { if (length >= getMaxTextureLength()) { return getMaxTextureLength(); } u16 valid_length = 8; while (length > valid_length) { valid_length *= 2; } return valid_length; }
fsTex* fsDrawMgr::newTexture(fsID tex_id, u16 width, u16 height, fsTex::TexFormat format) { fsDrawMgr* ins = instance(); if (tex_id == fsID::ZERO || width == 0 || height == 0 || width > getMaxTextureLength() || height > getMaxTextureLength() || // (format != fsTex::FORMAT_RGB && format != fsTex::FORMAT_RGBA && format != fsTex::FORMAT_ALPHA)) { fsThrow(ExceptionInvalidArgument); } if (ins->m_tex_map.getN(tex_id)) { fsThrow(ExceptionSameIDExists); } return fsNew(fsTex)(tex_id, width, height, format, fsTex::MODE_READ_WRITE, NULL, 0); }
fsTex* fsDrawMgr::newTexture(fsID tex_id, u16 width, u16 height, fsTex::TexFormat format, const void* image, u32 image_size) { fsDrawMgr* ins = instance(); if (tex_id == fsID::ZERO || width == 0 || height == 0 || width > getMaxTextureLength() || height > getMaxTextureLength() || // format == fsTex::FORMAT_PNG_RGB || format == fsTex::FORMAT_PNG_RGBA || format == fsTex::FORMAT_PNG_ALPHA || // !image || image_size != static_cast<u32>(getTexturePixelSize(format) * width * height)) { fsThrow(ExceptionInvalidArgument); } if (ins->m_tex_map.getN(tex_id)) { fsThrow(ExceptionSameIDExists); } return fsNew(fsTex)(tex_id, width, height, format, fsTex::MODE_READ_ONLY, image, image_size); }