Changeset 677 for Daodan/src/daodan_gl.c
- Timestamp:
- Mar 3, 2013, 12:46:33 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Daodan/src/daodan_gl.c
r476 r677 5 5 #include "Oni_Persistence.h" 6 6 #include "Daodan_Utility.h" 7 7 #include <GL/gl.h> 8 #include <GL/glu.h> 9 #include "Daodan_Win32.h" 8 10 #include "BFW_Utility.h" 9 11 … … 45 47 { 1920, 1440, 0, 0 }, 46 48 }; 47 48 short daodan_resdepths[] = { 16, 32 };49 49 //Just going to always use 32 bits for now... 50 //short daodan_resdepths[] = { 16, 32 }; 51 short daodan_resdepths[] = { 32 }; 50 52 DEVMODE orig_devmode, cur_devmode, new_devmode; 51 53 … … 83 85 { 84 86 unsigned int vmodes = 0; 85 unsigned int screen_x = orig_devmode.dmPelsWidth;86 unsigned int screen_y = orig_devmode.dmPelsHeight;87 88 int i, j;87 unsigned int screen_x = GetSystemMetrics(SM_CXSCREEN); 88 unsigned int screen_y = GetSystemMetrics(SM_CYSCREEN); 89 90 uint16_t i, j; 89 91 90 92 DDrStartupMessage("listing display modes"); 91 93 /* 92 94 if (!M3gResolutionSwitch) 93 95 daodan_resdepths[0] = orig_devmode.dmBitsPerPel; 94 96 */ 95 97 for (i = 0; i < builtin_depths; i ++) 96 98 { … … 179 181 180 182 update_cdmode(); 181 gl ->DisplayMode.Width = cur_devmode.dmPelsWidth;182 gl ->DisplayMode.Height = cur_devmode.dmPelsHeight;183 gl_eng->DisplayMode.Width = cur_devmode.dmPelsWidth; 184 gl_eng->DisplayMode.Height = cur_devmode.dmPelsHeight; 183 185 if (cur_devmode.dmBitsPerPel > depth) 184 gl ->DisplayMode.Depth = cur_devmode.dmBitsPerPel;186 gl_eng->DisplayMode.Depth = cur_devmode.dmBitsPerPel; 185 187 } 186 188 else … … 188 190 update_cdmode(); 189 191 if (cur_devmode.dmBitsPerPel > depth) 190 gl ->DisplayMode.Depth = cur_devmode.dmBitsPerPel;192 gl_eng->DisplayMode.Depth = cur_devmode.dmBitsPerPel; 191 193 } 192 194 return 1; 193 195 } 194 195 void daodan_set_gamma(float gamma)196 {197 WORD ramp[3][256];198 int i;199 200 if (!gl_gamma_ramp_valid)201 return;202 203 gamma = (1.0f - gamma) * 1.2f + 0.4f;204 205 for (i = 0; i < 256; i++)206 {207 int value = (int)(pow(gl_gamma_ramp[i] / 65535.0f, gamma) * 65535.0f);208 209 if (value < 0)210 value = 0;211 else if (value > 65535)212 value = 65535;213 214 ramp[0][i] = ramp[1][i] = ramp[2][i] = value;215 }216 217 if (gl_api->wglSetDeviceGammaRamp3DFX)218 gl_api->wglSetDeviceGammaRamp3DFX(gl->HDC, ramp);219 else220 SetDeviceGammaRamp(gl->HDC, ramp);221 }222 223 196 int ONICALL daodangl_platform_initialize() 224 197 { 225 198 static M3tDisplayMode lastmode = {0, 0, 0, 0}; 226 199 227 if (lastmode.Width != gl ->DisplayMode.Width || lastmode.Height != gl->DisplayMode.Height || lastmode.Depth != gl->DisplayMode.Depth)228 if (!daodan_set_display_mode(gl ->DisplayMode.Width, gl->DisplayMode.Height, gl->DisplayMode.Depth))229 if (gl ->DisplayMode.Width != 640 || gl->DisplayMode.Height != 480 || gl->DisplayMode.Depth != 16)200 if (lastmode.Width != gl_eng->DisplayMode.Width || lastmode.Height != gl_eng->DisplayMode.Height || lastmode.Depth != gl_eng->DisplayMode.Depth) 201 if (!daodan_set_display_mode(gl_eng->DisplayMode.Width, gl_eng->DisplayMode.Height, gl_eng->DisplayMode.Depth)) 202 if (gl_eng->DisplayMode.Width != 640 || gl_eng->DisplayMode.Height != 480 || gl_eng->DisplayMode.Depth != 16) 230 203 { 231 gl ->DisplayMode.Width = 640;232 gl ->DisplayMode.Height = 480;204 gl_eng->DisplayMode.Width = 640; 205 gl_eng->DisplayMode.Height = 480; 233 206 if (!daodan_set_display_mode(640, 480, 16)) 234 207 goto exit_err; 235 208 } 236 209 237 if (lastmode.Width != gl ->DisplayMode.Width || lastmode.Height != gl->DisplayMode.Height)210 if (lastmode.Width != gl_eng->DisplayMode.Width || lastmode.Height != gl_eng->DisplayMode.Height) 238 211 { 239 212 RECT Rect; 240 Rect.left = (GetSystemMetrics(SM_CXSCREEN) / 2) - (gl ->DisplayMode.Width / 2);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;213 Rect.left = (GetSystemMetrics(SM_CXSCREEN) / 2) - (gl_eng->DisplayMode.Width / 2); 214 Rect.top = (GetSystemMetrics(SM_CYSCREEN) / 2) - (gl_eng->DisplayMode.Height / 2); 215 Rect.right = Rect.left + gl_eng->DisplayMode.Width; 216 Rect.bottom = Rect.top + gl_eng->DisplayMode.Height; 244 217 AdjustWindowRect(&Rect, WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_CAPTION |WS_TILEDWINDOW , FALSE); 245 218 … … 247 220 } 248 221 249 if (gl ->HDC == NULL)250 if ((gl ->HDC = GetDC(ONgPlatformData.Window)) == NULL)222 if (gl_eng->HDC == NULL) 223 if ((gl_eng->HDC = GetDC(ONgPlatformData.Window)) == NULL) 251 224 goto exit_err; 252 225 … … 255 228 DDrStartupMessage("Using 3DFX gamma adjustment"); 256 229 257 if (gl_api->wglGetDeviceGammaRamp3DFX(gl ->HDC, gl_gamma_ramp))230 if (gl_api->wglGetDeviceGammaRamp3DFX(gl_eng->HDC, gl_gamma_ramp)) 258 231 gl_gamma_ramp_valid = 1; 259 232 } … … 262 235 DDrStartupMessage("Using standard Windows gamma adjustment"); 263 236 264 if (GetDeviceGammaRamp(gl ->HDC, gl_gamma_ramp))237 if (GetDeviceGammaRamp(gl_eng->HDC, gl_gamma_ramp)) 265 238 gl_gamma_ramp_valid = 1; 266 239 } 267 240 /* 268 241 if (gl_gamma_ramp_valid) 269 242 daodan_set_gamma(ONrPersist_GetGamma()); 270 else 243 else*/ 271 244 DDrStartupMessage("gamma adjustment not supported"); 272 245 273 if (!gl_platform_set_pixel_format(gl ->HDC))274 if (gl ->DisplayMode.Depth != 16)246 if (!gl_platform_set_pixel_format(gl_eng->HDC)) 247 if (gl_eng->DisplayMode.Depth != 16) 275 248 { 276 if (!daodan_set_display_mode(gl ->DisplayMode.Width, gl->DisplayMode.Height, 16))249 if (!daodan_set_display_mode(gl_eng->DisplayMode.Width, gl_eng->DisplayMode.Height, 16)) 277 250 goto exit_err; 278 251 279 if (!gl_platform_set_pixel_format(gl ->HDC))252 if (!gl_platform_set_pixel_format(gl_eng->HDC)) 280 253 goto exit_err; 281 254 } 282 255 283 lastmode.Width = gl ->DisplayMode.Width;284 lastmode.Height = gl ->DisplayMode.Height;285 lastmode.Depth = gl ->DisplayMode.Depth;256 lastmode.Width = gl_eng->DisplayMode.Width; 257 lastmode.Height = gl_eng->DisplayMode.Height; 258 lastmode.Depth = gl_eng->DisplayMode.Depth; 286 259 return 1; 287 260
Note:
See TracChangeset
for help on using the changeset viewer.