src/video/windx5/SDL_dx5video.c
changeset 453 a6fa62b1be09
parent 448 323c766f5a46
child 468 0b0c2e63eb27
     1.1 --- a/src/video/windx5/SDL_dx5video.c	Mon Aug 19 18:33:29 2002 +0000
     1.2 +++ b/src/video/windx5/SDL_dx5video.c	Tue Aug 20 00:20:06 2002 +0000
     1.3 @@ -51,10 +51,23 @@
     1.4  #include "SDL_dx5yuv_c.h"
     1.5  #include "SDL_wingl_c.h"
     1.6  
     1.7 +#ifdef _WIN32_WCE
     1.8 +#define NO_CHANGEDISPLAYSETTINGS
     1.9 +#endif
    1.10 +#ifndef WS_MAXIMIZE
    1.11 +#define WS_MAXIMIZE		0
    1.12 +#endif
    1.13 +#ifndef SWP_NOCOPYBITS
    1.14 +#define SWP_NOCOPYBITS	0
    1.15 +#endif
    1.16 +#ifndef PC_NOCOLLAPSE
    1.17 +#define PC_NOCOLLAPSE	0
    1.18 +#endif
    1.19 +
    1.20  
    1.21  /* DirectX function pointers for video and events */
    1.22  HRESULT (WINAPI *DDrawCreate)( GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter );
    1.23 -HRESULT (WINAPI *DInputCreate)(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter);
    1.24 +HRESULT (WINAPI *DInputCreate)(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUT *ppDI, LPUNKNOWN punkOuter);
    1.25  
    1.26  /* This is the rect EnumModes2 uses */
    1.27  struct DX5EnumRect {
    1.28 @@ -443,19 +456,19 @@
    1.29  
    1.30  	/* Version check DINPUT.DLL and DDRAW.DLL (Is DirectX okay?) */
    1.31  	dinput_ok = 0;
    1.32 -	DInputDLL = LoadLibrary("DINPUT.DLL");
    1.33 +	DInputDLL = LoadLibrary(TEXT("DINPUT.DLL"));
    1.34  	if ( DInputDLL != NULL ) {
    1.35  		dinput_ok = 1;
    1.36  	  	FreeLibrary(DInputDLL);
    1.37  	}
    1.38  	ddraw_ok = 0;
    1.39 -	DDrawDLL = LoadLibrary("DDRAW.DLL");
    1.40 +	DDrawDLL = LoadLibrary(TEXT("DDRAW.DLL"));
    1.41  	if ( DDrawDLL != NULL ) {
    1.42  	  HRESULT (WINAPI *DDrawCreate)(GUID *,LPDIRECTDRAW *,IUnknown *);
    1.43  	  LPDIRECTDRAW DDraw;
    1.44  
    1.45  	  /* Try to create a valid DirectDraw object */
    1.46 -	  DDrawCreate = (void *)GetProcAddress(DDrawDLL, "DirectDrawCreate");
    1.47 +	  DDrawCreate = (void *)GetProcAddress(DDrawDLL, TEXT("DirectDrawCreate"));
    1.48  	  if ( (DDrawCreate != NULL)
    1.49  			&& !FAILED(DDrawCreate(NULL, &DDraw, NULL)) ) {
    1.50  	    if ( !FAILED(IDirectDraw_SetCooperativeLevel(DDraw,
    1.51 @@ -511,15 +524,15 @@
    1.52  	int status;
    1.53  
    1.54  	DX5_Unload();
    1.55 -	DDrawDLL = LoadLibrary("DDRAW.DLL");
    1.56 +	DDrawDLL = LoadLibrary(TEXT("DDRAW.DLL"));
    1.57  	if ( DDrawDLL != NULL ) {
    1.58  		DDrawCreate = (void *)GetProcAddress(DDrawDLL,
    1.59 -					"DirectDrawCreate");
    1.60 +					TEXT("DirectDrawCreate"));
    1.61  	}
    1.62 -	DInputDLL = LoadLibrary("DINPUT.DLL");
    1.63 +	DInputDLL = LoadLibrary(TEXT("DINPUT.DLL"));
    1.64  	if ( DInputDLL != NULL ) {
    1.65  		DInputCreate = (void *)GetProcAddress(DInputDLL,
    1.66 -					"DirectInputCreateA");
    1.67 +					TEXT("DirectInputCreateA"));
    1.68  	}
    1.69  	if ( DDrawDLL && DDrawCreate && DInputDLL && DInputCreate ) {
    1.70  		status = 0;
    1.71 @@ -596,11 +609,11 @@
    1.72  	device->SetGammaRamp = DX5_SetGammaRamp;
    1.73  	device->GetGammaRamp = DX5_GetGammaRamp;
    1.74  #ifdef HAVE_OPENGL
    1.75 -        device->GL_LoadLibrary = WIN_GL_LoadLibrary;
    1.76 -        device->GL_GetProcAddress = WIN_GL_GetProcAddress;
    1.77 -        device->GL_GetAttribute = WIN_GL_GetAttribute;
    1.78 -        device->GL_MakeCurrent = WIN_GL_MakeCurrent;
    1.79 -        device->GL_SwapBuffers = WIN_GL_SwapBuffers;
    1.80 +	device->GL_LoadLibrary = WIN_GL_LoadLibrary;
    1.81 +	device->GL_GetProcAddress = WIN_GL_GetProcAddress;
    1.82 +	device->GL_GetAttribute = WIN_GL_GetAttribute;
    1.83 +	device->GL_MakeCurrent = WIN_GL_MakeCurrent;
    1.84 +	device->GL_SwapBuffers = WIN_GL_SwapBuffers;
    1.85  #endif
    1.86  	device->SetCaption = WIN_SetWMCaption;
    1.87  	device->SetIcon = WIN_SetWMIcon;
    1.88 @@ -670,7 +683,7 @@
    1.89  void SetDDerror(const char *function, int code)
    1.90  {
    1.91  	static char *error;
    1.92 -	static char  errbuf[BUFSIZ];
    1.93 +	static char  errbuf[1024];
    1.94  
    1.95  	errbuf[0] = 0;
    1.96  	switch (code) {
    1.97 @@ -994,11 +1007,13 @@
    1.98  		SDL_primary = NULL;
    1.99  	}
   1.100  
   1.101 +#ifndef NO_CHANGEDISPLAYSETTINGS
   1.102  	/* Unset any previous OpenGL fullscreen mode */
   1.103  	if ( (current->flags & (SDL_OPENGL|SDL_FULLSCREEN)) ==
   1.104  	                       (SDL_OPENGL|SDL_FULLSCREEN) ) {
   1.105  		ChangeDisplaySettings(NULL, 0);
   1.106  	}
   1.107 +#endif
   1.108  
   1.109  	/* Clean up any GL context that may be hanging around */
   1.110  	if ( current->flags & SDL_OPENGL ) {
   1.111 @@ -1057,6 +1072,7 @@
   1.112  		video->h = height;
   1.113  		video->pitch = SDL_CalculatePitch(video);
   1.114  
   1.115 +#ifndef NO_CHANGEDISPLAYSETTINGS
   1.116  		/* Set fullscreen mode if appropriate.
   1.117  		   Ugh, since our list of valid video modes comes from
   1.118  		   the DirectX driver, we may not actually be able to
   1.119 @@ -1077,6 +1093,7 @@
   1.120  				SDL_fullscreen_mode = settings;
   1.121  			}
   1.122  		}
   1.123 +#endif /* !NO_CHANGEDISPLAYSETTINGS */
   1.124  
   1.125  		style = GetWindowLong(SDL_Window, GWL_STYLE);
   1.126  		style &= ~(resizestyle|WS_MAXIMIZE);
   1.127 @@ -1096,7 +1113,9 @@
   1.128  					video->flags |= SDL_RESIZABLE;
   1.129  				}
   1.130  			}
   1.131 +#if WS_MAXIMIZE
   1.132  			if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE;
   1.133 +#endif
   1.134  		}
   1.135  		SetWindowLong(SDL_Window, GWL_STYLE, style);
   1.136  
   1.137 @@ -1110,7 +1129,7 @@
   1.138  			bounds.top = 0;
   1.139  			bounds.right = video->w;
   1.140  			bounds.bottom = video->h;
   1.141 -			AdjustWindowRect(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE);
   1.142 +			AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE, 0);
   1.143  			width = bounds.right-bounds.left;
   1.144  			height = bounds.bottom-bounds.top;
   1.145  			x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
   1.146 @@ -1157,7 +1176,9 @@
   1.147  				style |= resizestyle;
   1.148  			}
   1.149  		}
   1.150 +#if WS_MAXIMIZE
   1.151  		if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE;
   1.152 +#endif
   1.153  	}
   1.154  	SetWindowLong(SDL_Window, GWL_STYLE, style);
   1.155  
   1.156 @@ -1466,8 +1487,7 @@
   1.157  		bounds.top = 0;
   1.158  		bounds.right = video->w;
   1.159  		bounds.bottom = video->h;
   1.160 -		AdjustWindowRect(&bounds, GetWindowLong(SDL_Window, GWL_STYLE),
   1.161 -									FALSE);
   1.162 +		AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE, 0);
   1.163  		width = bounds.right-bounds.left;
   1.164  		height = bounds.bottom-bounds.top;
   1.165  		x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
   1.166 @@ -2235,11 +2255,13 @@
   1.167  
   1.168  	/* If we're fullscreen GL, we need to reset the display */
   1.169  	if ( this->screen != NULL ) {
   1.170 +#ifndef NO_CHANGEDISPLAYSETTINGS
   1.171  		if ( (this->screen->flags & (SDL_OPENGL|SDL_FULLSCREEN)) ==
   1.172  		                            (SDL_OPENGL|SDL_FULLSCREEN) ) {
   1.173  			ChangeDisplaySettings(NULL, 0);
   1.174  			ShowWindow(SDL_Window, SW_HIDE);
   1.175  		}
   1.176 +#endif
   1.177  		if ( this->screen->flags & SDL_OPENGL ) {
   1.178  			WIN_GL_ShutDown(this);
   1.179  		}