| 194 |
|
|
| 195 |
|
void daodan_set_gamma(float gamma) |
| 196 |
|
{ |
| 197 |
< |
WORD ramp[3 * 256]; |
| 197 |
> |
WORD ramp[3][256]; |
| 198 |
|
int i; |
| 199 |
|
|
| 200 |
|
if (!gl_gamma_ramp_valid) |
| 202 |
|
|
| 203 |
|
gamma = (1.0f - gamma) * 1.2f + 0.4f; |
| 204 |
|
|
| 205 |
< |
for (i = 0; i < sizeof(ramp); i++) |
| 205 |
> |
for (i = 0; i < 256; i++) |
| 206 |
|
{ |
| 207 |
|
int value = (int)(pow(gl_gamma_ramp[i] / 65535.0f, gamma) * 65535.0f); |
| 208 |
|
|
| 211 |
|
else if (value > 65535) |
| 212 |
|
value = 65535; |
| 213 |
|
|
| 214 |
< |
ramp[i] = value; |
| 214 |
> |
ramp[0][i] = ramp[1][i] = ramp[2][i] = value; |
| 215 |
|
} |
| 216 |
|
|
| 217 |
|
if (gl_api->wglSetDeviceGammaRamp3DFX) |
| 241 |
|
Rect.top = (GetSystemMetrics(SM_CYSCREEN) / 2) - (gl->DisplayMode.Height / 2); |
| 242 |
|
Rect.right = Rect.left + gl->DisplayMode.Width; |
| 243 |
|
Rect.bottom = Rect.top + gl->DisplayMode.Height; |
| 244 |
< |
AdjustWindowRect(&Rect, WS_OVERLAPPED | WS_MAXIMIZEBOX | WS_MINIMIZEBOX, FALSE); |
| 244 |
> |
//http://msdn.microsoft.com/en-us/library/ms632665(VS.85).aspx |
| 245 |
> |
//dwStyle |
| 246 |
> |
//[in] Specifies the window style of the window whose required size is to be calculated. Note that you cannot specify the WS_OVERLAPPED style. |
| 247 |
> |
AdjustWindowRect(&Rect, WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_CAPTION, TRUE); |
| 248 |
|
|
| 249 |
|
SetWindowPos(ONgPlatformData.Window, NULL, Rect.left, Rect.top, Rect.right - Rect.left, Rect.bottom - Rect.top, SWP_NOACTIVATE | SWP_NOZORDER); |
| 250 |
|
} |
| 268 |
|
gl_gamma_ramp_valid = 1; |
| 269 |
|
} |
| 270 |
|
|
| 271 |
< |
// if (gl_gamma_ramp_valid) |
| 272 |
< |
// daodan_set_gamma(ONrPersist_GetGamma()); Its not working :( |
| 273 |
< |
// else |
| 271 |
> |
if (gl_gamma_ramp_valid) |
| 272 |
> |
//Its working now |
| 273 |
> |
daodan_set_gamma(ONrPersist_GetGamma()); |
| 274 |
> |
else |
| 275 |
|
DDrStartupMessage("gamma adjustment not supported"); |
| 276 |
|
|
| 277 |
|
if (!gl_platform_set_pixel_format(gl->HDC)) |
| 287 |
|
lastmode.Width = gl->DisplayMode.Width; |
| 288 |
|
lastmode.Height = gl->DisplayMode.Height; |
| 289 |
|
lastmode.Depth = gl->DisplayMode.Depth; |
| 290 |
< |
|
| 287 |
< |
return 0; |
| 290 |
> |
return 1; |
| 291 |
|
|
| 292 |
|
exit_err: |
| 293 |
|
AUrMessageBox(1, "Failed to initialize OpenGL contexts; Oni will now exit."); |
| 294 |
|
exit(0); |
| 295 |
< |
return 1; |
| 295 |
> |
return 0; |
| 296 |
|
} |