| 235 | } |
| 236 | |
| 237 | PlatformWindow *PlatformWindowManagerSDL::createWindow(GFXDevice *device, const GFXVideoMode &mode) |
| 238 | { |
| 239 | // Do the allocation. |
| 240 | PlatformWindowSDL *window = new PlatformWindowSDL(); |
| 241 | U32 windowFlags = /*SDL_WINDOW_SHOWN |*/ SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN; |
| 242 | |
| 243 | if(GFX->getAdapterType() == OpenGL) |
| 244 | windowFlags |= SDL_WINDOW_OPENGL; |
| 245 | |
| 246 | window->mWindowHandle = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, mode.resolution.x, mode.resolution.y, windowFlags ); |
| 247 | window->mWindowId = SDL_GetWindowID( window->mWindowHandle ); |
| 248 | window->mOwningManager = this; |
| 249 | mWindowMap[ window->mWindowId ] = window; |
| 250 | |
| 251 | //Now, fetch our window icon, if any |
| 252 | Torque::Path iconPath = Torque::Path(Con::getVariable( "$Core::windowIcon" )); |
| 253 | |
| 254 | if (iconPath.getExtension() == String("bmp")) |
| 255 | { |
| 256 | Con::errorf("Unable to use bmp format images for the window icon. Please use a different format."); |
| 257 | } |
| 258 | else |
| 259 | { |
| 260 | Resource<GBitmap> img = GBitmap::load(iconPath); |
| 261 | if (img != NULL) |
| 262 | { |
| 263 | U32 pitch; |
| 264 | U32 width = img->getWidth(); |
| 265 | bool hasAlpha = img->getHasTransparency(); |
| 266 | U32 depth; |
| 267 | |
| 268 | if (hasAlpha) |
| 269 | { |
| 270 | pitch = 4 * width; |
| 271 | depth = 32; |
| 272 | } |
| 273 | else |
| 274 | { |
| 275 | pitch = 3 * width; |
| 276 | depth = 24; |
| 277 | } |
| 278 | |
| 279 | Uint32 rmask, gmask, bmask, amask; |
| 280 | if (SDL_BYTEORDER == SDL_BIG_ENDIAN) |
| 281 | { |
| 282 | S32 shift = hasAlpha ? 8 : 0; |
| 283 | rmask = 0xff000000 >> shift; |
| 284 | gmask = 0x00ff0000 >> shift; |
| 285 | bmask = 0x0000ff00 >> shift; |
| 286 | amask = 0x000000ff >> shift; |
| 287 | } |
| 288 | else |
| 289 | { |
| 290 | rmask = 0x000000ff; |
| 291 | gmask = 0x0000ff00; |
| 292 | bmask = 0x00ff0000; |
| 293 | amask = hasAlpha ? 0xff000000 : 0; |
| 294 | } |
no test coverage detected