| 212 | } |
| 213 | |
| 214 | void Director::setDefaultValues() |
| 215 | { |
| 216 | Configuration* conf = Configuration::getInstance(); |
| 217 | |
| 218 | // default FPS |
| 219 | float fps = conf->getValue("axmol.fps", Value(kDefaultFPS)).asFloat(); |
| 220 | _oldAnimationInterval = _animationInterval = 1.0f / fps; |
| 221 | |
| 222 | // Display FPS |
| 223 | _statsDisplay = conf->getValue("axmol.display_fps", Value(false)).asBool(); |
| 224 | |
| 225 | // GL projection |
| 226 | std::string projection = conf->getValue("axmol.gl.projection", Value("3d")).asString(); |
| 227 | if (projection == "3d") |
| 228 | _projection = Projection::_3D; |
| 229 | else if (projection == "2d") |
| 230 | _projection = Projection::_2D; |
| 231 | else if (projection == "custom") |
| 232 | _projection = Projection::CUSTOM; |
| 233 | else |
| 234 | AXASSERT(false, "Invalid projection value"); |
| 235 | |
| 236 | // Default pixel format for PNG images with alpha |
| 237 | std::string pixel_format = conf->getValue("axmol.texture.pixel_format_for_png", Value("rgba8888")).asString(); |
| 238 | if (pixel_format == "rgba8888") |
| 239 | Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGBA8); |
| 240 | else if (pixel_format == "rgba4444") |
| 241 | Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGBA4); |
| 242 | else if (pixel_format == "rgba5551") |
| 243 | Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGB5A1); |
| 244 | |
| 245 | /* !!!Notes |
| 246 | ** All compressed image should do PMA at texture convert tools(such as astcenc-2.2+ with -pp-premultiply) |
| 247 | ** or GPU fragment shader |
| 248 | */ |
| 249 | |
| 250 | // PVR v2 has alpha premultiplied ? |
| 251 | bool pvr_alpha_premultiplied = conf->getValue("axmol.texture.pvrv2_has_alpha_premultiplied", Value(false)).asBool(); |
| 252 | Image::setCompressedImagesHavePMA(Image::CompressedImagePMAFlag::PVR, pvr_alpha_premultiplied); |
| 253 | |
| 254 | // ASTC has alpha premultiplied ? |
| 255 | bool astc_alpha_premultiplied = conf->getValue("axmol.texture.astc_has_pma", Value{true}).asBool(); |
| 256 | Image::setCompressedImagesHavePMA(Image::CompressedImagePMAFlag::ASTC, astc_alpha_premultiplied); |
| 257 | |
| 258 | // ETC2 has alpha premultiplied ? |
| 259 | // Note: no suitable tools(etc2comp, Mali Texture Compression Tool, PVRTexTool) support do PMA currently, so set |
| 260 | // etc2 PMA default to `false` |
| 261 | bool etc2_alpha_premultiplied = conf->getValue("axmol.texture.etc2_has_pma", Value{false}).asBool(); |
| 262 | Image::setCompressedImagesHavePMA(Image::CompressedImagePMAFlag::ETC2, etc2_alpha_premultiplied); |
| 263 | } |
| 264 | |
| 265 | void Director::setRenderDefaults() |
| 266 | { |