- Timestamp:
- 05/31/04 14:21:14 (21 years ago)
- Location:
- ps/trunk/source/lib
- Files:
-
- 3 edited
-
sdl.h (modified) (1 diff)
-
sysdep/win/wsdl.cpp (modified) (6 diffs)
-
sysdep/win/wsdl.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/source/lib/sdl.h
r216 r329 4 4 # include <SDL/SDL.h> 5 5 # include <SDL/SDL_thread.h> 6 # include <SDL/SDL_endian.h> 7 // if the compiler doesn't support inlining, this header will pull 8 // in static bswap routines. doesn't matter - modern compilers 9 // will strip them if unused, and this is more convenient than 10 // another header that toggles between wsdl and SDL_endian.h. 6 11 #endif -
ps/trunk/source/lib/sysdep/win/wsdl.cpp
r293 r329 58 58 static u16 mouse_x, mouse_y; 59 59 60 61 static void gamma_swap(bool restore_org); 62 63 60 64 /* 61 65 * shared msg handler … … 77 81 case WM_ACTIVATE: 78 82 app_active = (wParam & 0xffff) != 0; 83 84 gamma_swap(!app_active); 79 85 80 86 if(fullscreen) … … 374 380 static int wsdl_init() 375 381 { 382 // ignore BoundsChecker warnings here. subsystem is set to "Windows" 383 // to avoid the OS opening a console on startup (ugly). that means 384 // stdout isn't associated with a lowio handle; _close ends up 385 // getting called with fd = -1. oh well, nothing we can do. 376 386 FILE* const ret = freopen("stdout.txt", "w", stdout); 377 387 if(!ret) … … 489 499 490 500 501 ////////////////////////////////////////////////////////////////////////////// 502 503 504 static bool gamma_changed; 505 static u16 org_ramp[3][256]; 506 static u16 cur_ramp[3][256]; 507 508 491 509 static int calc_gamma_ramp(float gamma, u16* ramp) 492 510 { … … 495 513 496 514 // identity 497 // (special-case it to make sure we get the exact value)515 // (special-case it to make sure we get exact values) 498 516 if(gamma == 1.0f) 499 517 { … … 516 534 517 535 536 static void gamma_swap(bool restore_org) 537 { 538 if(gamma_changed) 539 { 540 void* ramp = (restore_org)? org_ramp : cur_ramp; 541 SetDeviceGammaRamp(hDC, ramp); 542 } 543 } 544 545 518 546 int SDL_SetGamma(float r, float g, float b) 519 547 { 520 u16 ramp[3][256]; 521 CHECK_ERR(calc_gamma_ramp(r, ramp[0])); 522 CHECK_ERR(calc_gamma_ramp(g, ramp[1])); 523 CHECK_ERR(calc_gamma_ramp(b, ramp[2])); 524 return SetDeviceGammaRamp(hDC, ramp)? 0 : -1; 525 } 526 548 if(!gamma_changed) 549 if(!GetDeviceGammaRamp(hDC, org_ramp)) 550 return -1; 551 552 CHECK_ERR(calc_gamma_ramp(r, cur_ramp[0])); 553 CHECK_ERR(calc_gamma_ramp(g, cur_ramp[1])); 554 CHECK_ERR(calc_gamma_ramp(b, cur_ramp[2])); 555 556 if(!SetDeviceGammaRamp(hDC, cur_ramp)) 557 return -1; 558 559 gamma_changed = true; 560 return 0; 561 } 562 563 564 ////////////////////////////////////////////////////////////////////////////// 565 566 567 // implement only if the header hasn't mapped SDL_Swap* to intrinsics 568 569 #ifndef SDL_Swap16 570 u16 SDL_Swap16(const u16 x) 571 { 572 return (u16)(((x & 0xff) << 8) | (x >> 8)); 573 } 574 #endif 575 576 #ifndef SDL_Swap32 577 u32 SDL_Swap32(const u32 x) 578 { 579 return (x << 24) | 580 (x >> 24) | 581 ((x << 8) & 0x00ff0000) | 582 ((x >> 8) & 0x0000ff00); 583 } 584 #endif 585 586 #ifndef SDL_Swap64 587 u64 SDL_Swap64(const u64 x) 588 { 589 const u32 lo = (u32)(x & 0xffffffff); 590 const u32 hi = (u32)(x >> 32); 591 u64 ret = SDL_Swap32(lo); 592 ret <<= 32; 593 // careful: must shift var of type u64, not u32 594 ret |= SDL_Swap32(hi); 595 return ret; 596 } 597 #endif 598 599 ////////////////////////////////////////////////////////////////////////////// 527 600 528 601 529 602 void SDL_Quit() 530 603 { 604 gamma_swap(true); 605 531 606 if(hDC != INVALID_HANDLE_VALUE) 532 607 { -
ps/trunk/source/lib/sysdep/win/wsdl.h
r258 r329 97 97 98 98 99 ////////////////////////////////////////////////////////////////////////////// 100 101 102 #ifdef linux 103 # include <asm/byteorder.h> 104 # ifdef __arch__swab16 105 # define SDL_Swap16 __arch__swab16 106 # endif 107 # ifdef __arch__swab32 108 # define SDL_Swap32 __arch__swab32 109 # endif 110 #endif 111 112 #ifdef _MSC_VER 113 # define SDL_Swap16 _byteswap_ushort 114 # define SDL_Swap32 _byteswap_ulong 115 # define SDL_Swap64 _byteswap_uint64 116 #endif 117 118 #ifndef SDL_Swap16 119 extern u16 SDL_Swap16(u16); 120 #endif 121 122 #ifndef SDL_Swap32 123 extern u32 SDL_Swap32(u32); 124 #endif 125 126 #ifndef SDL_Swap64 127 extern u64 SDL_Swap64(u64); 128 #endif 129 130 131 ////////////////////////////////////////////////////////////////////////////// 99 132 100 133
Note:
See TracChangeset
for help on using the changeset viewer.
