ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/Daodan/src/Daodan_GL.c
(Generate patch)

Comparing Daodan/src/daodan_gl.c (file contents):
Revision 476 by gumby, Tue Nov 3 10:38:47 2009 UTC vs.
Revision 677 by alloc, Sat Mar 2 23:46:33 2013 UTC

# Line 4 | Line 4
4   #include "Oni.h"
5   #include "Oni_Persistence.h"
6   #include "Daodan_Utility.h"
7 <
7 > #include <GL/gl.h>
8 > #include <GL/glu.h>
9 > #include "Daodan_Win32.h"
10   #include "BFW_Utility.h"
11  
12   #include "daodan_gl.h"
# Line 44 | Line 46 | const M3tDisplayMode daodan_reslist[] =
46          { 1920, 1200, 0, 0 },
47          { 1920, 1440, 0, 0 },
48   };
49 <
50 < short daodan_resdepths[] = { 16, 32 };
51 <
49 > //Just going to always use 32 bits for now...
50 > //short daodan_resdepths[] = { 16, 32 };
51 > short daodan_resdepths[] = { 32 };
52   DEVMODE orig_devmode, cur_devmode, new_devmode;
53  
54   void init_daodan_gl()
# Line 82 | Line 84 | void update_cdmode()
84   unsigned int ONICALL daodan_enumerate_valid_display_modes(M3tDisplayMode modes[max_modes])
85   {
86          unsigned int vmodes = 0;
87 <        unsigned int screen_x = orig_devmode.dmPelsWidth;
88 <        unsigned int screen_y = orig_devmode.dmPelsHeight;
87 >        unsigned int screen_x = GetSystemMetrics(SM_CXSCREEN);
88 >        unsigned int screen_y = GetSystemMetrics(SM_CYSCREEN);
89          
90 <        int i, j;
90 >        uint16_t i, j;
91          
92          DDrStartupMessage("listing display modes");
93 <        
93 >        /*
94          if (!M3gResolutionSwitch)
95                  daodan_resdepths[0] = orig_devmode.dmBitsPerPel;
96 <        
96 >        */
97          for (i = 0; i < builtin_depths; i ++)
98          {
99                  bool scrInsert = false;
# Line 178 | Line 180 | int daodan_set_display_mode(short width,
180                          return 0;
181                  
182                  update_cdmode();
183 <                gl->DisplayMode.Width = cur_devmode.dmPelsWidth;
184 <                gl->DisplayMode.Height = cur_devmode.dmPelsHeight;
183 >                gl_eng->DisplayMode.Width = cur_devmode.dmPelsWidth;
184 >                gl_eng->DisplayMode.Height = cur_devmode.dmPelsHeight;
185                  if (cur_devmode.dmBitsPerPel > depth)
186 <                        gl->DisplayMode.Depth = cur_devmode.dmBitsPerPel;
186 >                        gl_eng->DisplayMode.Depth = cur_devmode.dmBitsPerPel;
187          }
188          else
189          {
190                  update_cdmode();
191                  if (cur_devmode.dmBitsPerPel > depth)
192 <                        gl->DisplayMode.Depth = cur_devmode.dmBitsPerPel;
192 >                        gl_eng->DisplayMode.Depth = cur_devmode.dmBitsPerPel;
193          }
194          return 1;
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        else
220                SetDeviceGammaRamp(gl->HDC, ramp);
221 }
222
196   int ONICALL daodangl_platform_initialize()
197   {
198          static M3tDisplayMode lastmode = {0, 0, 0, 0};
199          
200 <        if (lastmode.Width != gl->DisplayMode.Width || lastmode.Height != gl->DisplayMode.Height || lastmode.Depth != gl->DisplayMode.Depth)
201 <                if (!daodan_set_display_mode(gl->DisplayMode.Width, gl->DisplayMode.Height, gl->DisplayMode.Depth))
202 <                        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)
203                          {
204 <                                gl->DisplayMode.Width = 640;
205 <                                gl->DisplayMode.Height = 480;
204 >                                gl_eng->DisplayMode.Width = 640;
205 >                                gl_eng->DisplayMode.Height = 480;
206                                  if (!daodan_set_display_mode(640, 480, 16))
207                                          goto exit_err;
208                          }
209  
210 <        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)
211          {
212                  RECT Rect;
213 <                Rect.left = (GetSystemMetrics(SM_CXSCREEN) / 2) - (gl->DisplayMode.Width / 2);
214 <                Rect.top = (GetSystemMetrics(SM_CYSCREEN) / 2) - (gl->DisplayMode.Height / 2);
215 <                Rect.right = Rect.left + gl->DisplayMode.Width;
216 <                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;
217                  AdjustWindowRect(&Rect, WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_CAPTION |WS_TILEDWINDOW , FALSE);
218                  
219                  SetWindowPos(ONgPlatformData.Window, NULL, Rect.left, Rect.top, Rect.right - Rect.left, Rect.bottom - Rect.top, SWP_NOACTIVATE | SWP_NOZORDER);
220          }
221  
222 <        if (gl->HDC == NULL)
223 <                if ((gl->HDC = GetDC(ONgPlatformData.Window)) == NULL)
222 >        if (gl_eng->HDC == NULL)
223 >                if ((gl_eng->HDC = GetDC(ONgPlatformData.Window)) == NULL)
224                          goto exit_err;
225          
226          if (gl_api->wglGetDeviceGammaRamp3DFX != NULL)
227          {
228                  DDrStartupMessage("Using 3DFX gamma adjustment");
229  
230 <                if (gl_api->wglGetDeviceGammaRamp3DFX(gl->HDC, gl_gamma_ramp))
230 >                if (gl_api->wglGetDeviceGammaRamp3DFX(gl_eng->HDC, gl_gamma_ramp))
231                          gl_gamma_ramp_valid = 1;
232          }
233          else
234          {
235                  DDrStartupMessage("Using standard Windows gamma adjustment");
236  
237 <                if (GetDeviceGammaRamp(gl->HDC, gl_gamma_ramp))
237 >                if (GetDeviceGammaRamp(gl_eng->HDC, gl_gamma_ramp))
238                          gl_gamma_ramp_valid = 1;
239          }
240 <        
240 >        /*
241          if (gl_gamma_ramp_valid)
242                  daodan_set_gamma(ONrPersist_GetGamma());  
243 <        else
243 >        else*/
244                  DDrStartupMessage("gamma adjustment not supported");
245          
246 <        if (!gl_platform_set_pixel_format(gl->HDC))
247 <                if (gl->DisplayMode.Depth != 16)
246 >        if (!gl_platform_set_pixel_format(gl_eng->HDC))
247 >                if (gl_eng->DisplayMode.Depth != 16)
248                  {
249 <                        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))
250                                  goto exit_err;
251                          
252 <                        if (!gl_platform_set_pixel_format(gl->HDC))
252 >                        if (!gl_platform_set_pixel_format(gl_eng->HDC))
253                                  goto exit_err;
254                  }
255  
256 <        lastmode.Width = gl->DisplayMode.Width;
257 <        lastmode.Height = gl->DisplayMode.Height;
258 <        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;
259          return 1;
260  
261   exit_err:

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)