vkQuake2 doxygen  1.0 dev
rw_win.h File Reference
#include <windows.h>
#include <ddraw.h>

Go to the source code of this file.

Classes

struct  swwstate_t
 

Functions

qboolean DIB_Init (unsigned char **ppbuffer, int *ppitch)
 
void DIB_Shutdown (void)
 
void DIB_SetPalette (const unsigned char *palette)
 
qboolean DDRAW_Init (unsigned char **ppbuffer, int *ppitch)
 
void DDRAW_Shutdown (void)
 
void DDRAW_SetPalette (const unsigned char *palette)
 

Variables

swwstate_t sww_state
 

Function Documentation

◆ DDRAW_Init()

qboolean DDRAW_Init ( unsigned char **  ppbuffer,
int ppitch 
)

Definition at line 42 of file rw_ddraw.c.

43 {
44  HRESULT ddrval;
45  DDSURFACEDESC ddsd;
46  DDSCAPS ddscaps;
47  PALETTEENTRY palentries[256];
48  int i;
49  extern cvar_t *sw_allow_modex;
50 
51  HRESULT (WINAPI *QDirectDrawCreate)( GUID FAR *lpGUID, LPDIRECTDRAW FAR * lplpDDRAW, IUnknown FAR * pUnkOuter );
52 
53 ri.Con_Printf( PRINT_ALL, "Initializing DirectDraw\n");
54 
55 
56  for ( i = 0; i < 256; i++ )
57  {
58  palentries[i].peRed = ( d_8to24table[i] >> 0 ) & 0xff;
59  palentries[i].peGreen = ( d_8to24table[i] >> 8 ) & 0xff;
60  palentries[i].peBlue = ( d_8to24table[i] >> 16 ) & 0xff;
61  }
62 
63  /*
64  ** load DLL and fetch pointer to entry point
65  */
66  if ( !sww_state.hinstDDRAW )
67  {
68  ri.Con_Printf( PRINT_ALL, "...loading DDRAW.DLL: ");
69  if ( ( sww_state.hinstDDRAW = LoadLibrary( "ddraw.dll" ) ) == NULL )
70  {
71  ri.Con_Printf( PRINT_ALL, "failed\n" );
72  goto fail;
73  }
74  ri.Con_Printf( PRINT_ALL, "ok\n" );
75  }
76 
77  if ( ( QDirectDrawCreate = ( HRESULT (WINAPI *)( GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR * ) ) GetProcAddress( sww_state.hinstDDRAW, "DirectDrawCreate" ) ) == NULL )
78  {
79  ri.Con_Printf( PRINT_ALL, "*** DirectDrawCreate == NULL ***\n" );
80  goto fail;
81  }
82 
83  /*
84  ** create the direct draw object
85  */
86  ri.Con_Printf( PRINT_ALL, "...creating DirectDraw object: ");
87  if ( ( ddrval = QDirectDrawCreate( NULL, &sww_state.lpDirectDraw, NULL ) ) != DD_OK )
88  {
89  ri.Con_Printf( PRINT_ALL, "failed - %s\n", DDrawError( ddrval ) );
90  goto fail;
91  }
92  ri.Con_Printf( PRINT_ALL, "ok\n" );
93 
94  /*
95  ** see if linear modes exist first
96  */
97  sww_state.modex = false;
98 
99  ri.Con_Printf( PRINT_ALL, "...setting exclusive mode: ");
100  if ( ( ddrval = sww_state.lpDirectDraw->lpVtbl->SetCooperativeLevel( sww_state.lpDirectDraw,
101  sww_state.hWnd,
102  DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN ) ) != DD_OK )
103  {
104  ri.Con_Printf( PRINT_ALL, "failed - %s\n",DDrawError (ddrval) );
105  goto fail;
106  }
107  ri.Con_Printf( PRINT_ALL, "ok\n" );
108 
109  /*
110  ** try changing the display mode normally
111  */
112  ri.Con_Printf( PRINT_ALL, "...finding display mode\n" );
113  ri.Con_Printf( PRINT_ALL, "...setting linear mode: " );
114  if ( ( ddrval = sww_state.lpDirectDraw->lpVtbl->SetDisplayMode( sww_state.lpDirectDraw, vid.width, vid.height, 8 ) ) == DD_OK )
115  {
116  ri.Con_Printf( PRINT_ALL, "ok\n" );
117  }
118  /*
119  ** if no linear mode found, go for modex if we're trying 320x240
120  */
121  else if ( ( sw_mode->value == 0 ) && sw_allow_modex->value )
122  {
123  ri.Con_Printf( PRINT_ALL, "failed\n" );
124  ri.Con_Printf( PRINT_ALL, "...attempting ModeX 320x240: ");
125 
126  /*
127  ** reset to normal cooperative level
128  */
129  sww_state.lpDirectDraw->lpVtbl->SetCooperativeLevel( sww_state.lpDirectDraw,
130  sww_state.hWnd,
131  DDSCL_NORMAL );
132 
133  /*
134  ** set exclusive mode
135  */
136  if ( ( ddrval = sww_state.lpDirectDraw->lpVtbl->SetCooperativeLevel( sww_state.lpDirectDraw,
137  sww_state.hWnd,
138  DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_NOWINDOWCHANGES | DDSCL_ALLOWMODEX ) ) != DD_OK )
139  {
140  ri.Con_Printf( PRINT_ALL, "failed SCL - %s\n",DDrawError (ddrval) );
141  goto fail;
142  }
143 
144  /*
145  ** change our display mode
146  */
147  if ( ( ddrval = sww_state.lpDirectDraw->lpVtbl->SetDisplayMode( sww_state.lpDirectDraw, vid.width, vid.height, 8 ) ) != DD_OK )
148  {
149  ri.Con_Printf( PRINT_ALL, "failed SDM - %s\n", DDrawError( ddrval ) );
150  goto fail;
151  }
152  ri.Con_Printf( PRINT_ALL, "ok\n" );
153 
154  sww_state.modex = true;
155  }
156  else
157  {
158  ri.Con_Printf( PRINT_ALL, "failed\n" );
159  goto fail;
160  }
161 
162  /*
163  ** create our front buffer
164  */
165  memset( &ddsd, 0, sizeof( ddsd ) );
166  ddsd.dwSize = sizeof( ddsd );
167  ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
168  ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
169  ddsd.dwBackBufferCount = 1;
170 
171  ri.Con_Printf( PRINT_ALL, "...creating front buffer: ");
172  if ( ( ddrval = sww_state.lpDirectDraw->lpVtbl->CreateSurface( sww_state.lpDirectDraw, &ddsd, &sww_state.lpddsFrontBuffer, NULL ) ) != DD_OK )
173  {
174  ri.Con_Printf( PRINT_ALL, "failed - %s\n", DDrawError( ddrval ) );
175  goto fail;
176  }
177  ri.Con_Printf( PRINT_ALL, "ok\n" );
178 
179  /*
180  ** see if we're a ModeX mode
181  */
182  sww_state.lpddsFrontBuffer->lpVtbl->GetCaps( sww_state.lpddsFrontBuffer, &ddscaps );
183  if ( ddscaps.dwCaps & DDSCAPS_MODEX )
184  ri.Con_Printf( PRINT_ALL, "...using ModeX\n" );
185 
186  /*
187  ** create our back buffer
188  */
189  ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
190 
191  ri.Con_Printf( PRINT_ALL, "...creating back buffer: " );
192  if ( ( ddrval = sww_state.lpddsFrontBuffer->lpVtbl->GetAttachedSurface( sww_state.lpddsFrontBuffer, &ddsd.ddsCaps, &sww_state.lpddsBackBuffer ) ) != DD_OK )
193  {
194  ri.Con_Printf( PRINT_ALL, "failed - %s\n", DDrawError( ddrval ) );
195  goto fail;
196  }
197  ri.Con_Printf( PRINT_ALL, "ok\n" );
198 
199  /*
200  ** create our rendering buffer
201  */
202  memset( &ddsd, 0, sizeof( ddsd ) );
203  ddsd.dwSize = sizeof( ddsd );
204  ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
205  ddsd.dwHeight = vid.height;
206  ddsd.dwWidth = vid.width;
207  ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
208 
209  ri.Con_Printf( PRINT_ALL, "...creating offscreen buffer: " );
210  if ( ( ddrval = sww_state.lpDirectDraw->lpVtbl->CreateSurface( sww_state.lpDirectDraw, &ddsd, &sww_state.lpddsOffScreenBuffer, NULL ) ) != DD_OK )
211  {
212  ri.Con_Printf( PRINT_ALL, "failed - %s\n", DDrawError( ddrval ) );
213  goto fail;
214  }
215  ri.Con_Printf( PRINT_ALL, "ok\n" );
216 
217  /*
218  ** create our DIRECTDRAWPALETTE
219  */
220  ri.Con_Printf( PRINT_ALL, "...creating palette: " );
221  if ( ( ddrval = sww_state.lpDirectDraw->lpVtbl->CreatePalette( sww_state.lpDirectDraw,
222  DDPCAPS_8BIT | DDPCAPS_ALLOW256,
223  palentries,
225  NULL ) ) != DD_OK )
226  {
227  ri.Con_Printf( PRINT_ALL, "failed - %s\n", DDrawError( ddrval ) );
228  goto fail;
229  }
230  ri.Con_Printf( PRINT_ALL, "ok\n" );
231 
232  ri.Con_Printf( PRINT_ALL, "...setting palette: " );
233  if ( ( ddrval = sww_state.lpddsFrontBuffer->lpVtbl->SetPalette( sww_state.lpddsFrontBuffer,
234  sww_state.lpddpPalette ) ) != DD_OK )
235  {
236  ri.Con_Printf( PRINT_ALL, "failed - %s\n", DDrawError( ddrval ) );
237  goto fail;
238  }
239  ri.Con_Printf( PRINT_ALL, "ok\n" );
240 
241  DDRAW_SetPalette( ( const unsigned char * ) sw_state.currentpalette );
242 
243  /*
244  ** lock the back buffer
245  */
246  memset( &ddsd, 0, sizeof( ddsd ) );
247  ddsd.dwSize = sizeof( ddsd );
248 
249 ri.Con_Printf( PRINT_ALL, "...locking backbuffer: " );
250  if ( ( ddrval = sww_state.lpddsOffScreenBuffer->lpVtbl->Lock( sww_state.lpddsOffScreenBuffer, NULL, &ddsd, DDLOCK_WAIT, NULL ) ) != DD_OK )
251  {
252  ri.Con_Printf( PRINT_ALL, "failed - %s\n", DDrawError( ddrval ) );
253  goto fail;
254  }
255 ri.Con_Printf( PRINT_ALL, "ok\n" );
256 
257  *ppbuffer = ddsd.lpSurface;
258  *ppitch = ddsd.lPitch;
259 
260  for ( i = 0; i < vid.height; i++ )
261  {
262  memset( *ppbuffer + i * *ppitch, 0, *ppitch );
263  }
264 
265  sww_state.palettized = true;
266 
267  return true;
268 fail:
269  ri.Con_Printf( PRINT_ALL, "*** DDraw init failure ***\n" );
270 
271  DDRAW_Shutdown();
272  return false;
273 }

◆ DDRAW_SetPalette()

void DDRAW_SetPalette ( const unsigned char *  palette)

Definition at line 288 of file rw_ddraw.c.

289 {
290  PALETTEENTRY palentries[256];
291  int i;
292 
293  if (!sww_state.lpddpPalette)
294  return;
295 
296  for ( i = 0; i < 256; i++, pal += 4 )
297  {
298  palentries[i].peRed = pal[0];
299  palentries[i].peGreen = pal[1];
300  palentries[i].peBlue = pal[2];
301  palentries[i].peFlags = PC_RESERVED | PC_NOCOLLAPSE;
302  }
303 
304  if ( sww_state.lpddpPalette->lpVtbl->SetEntries( sww_state.lpddpPalette,
305  0,
306  0,
307  256,
308  palentries ) != DD_OK )
309  {
310  ri.Con_Printf( PRINT_ALL, "DDRAW_SetPalette() - SetEntries failed\n" );
311  }
312 }

Referenced by DDRAW_Init().

◆ DDRAW_Shutdown()

void DDRAW_Shutdown ( void  )

Definition at line 317 of file rw_ddraw.c.

318 {
320  {
321  ri.Con_Printf( PRINT_ALL, "...releasing offscreen buffer\n");
325  }
326 
328  {
329  ri.Con_Printf( PRINT_ALL, "...releasing back buffer\n");
332  }
333 
335  {
336  ri.Con_Printf( PRINT_ALL, "...releasing front buffer\n");
339  }
340 
342  {
343  ri.Con_Printf( PRINT_ALL, "...releasing palette\n");
344  sww_state.lpddpPalette->lpVtbl->Release ( sww_state.lpddpPalette );
346  }
347 
348  if ( sww_state.lpDirectDraw )
349  {
350  ri.Con_Printf( PRINT_ALL, "...restoring display mode\n");
351  sww_state.lpDirectDraw->lpVtbl->RestoreDisplayMode( sww_state.lpDirectDraw );
352  ri.Con_Printf( PRINT_ALL, "...restoring normal coop mode\n");
353  sww_state.lpDirectDraw->lpVtbl->SetCooperativeLevel( sww_state.lpDirectDraw, sww_state.hWnd, DDSCL_NORMAL );
354  ri.Con_Printf( PRINT_ALL, "...releasing lpDirectDraw\n");
355  sww_state.lpDirectDraw->lpVtbl->Release( sww_state.lpDirectDraw );
357  }
358 
359  if ( sww_state.hinstDDRAW )
360  {
361  ri.Con_Printf( PRINT_ALL, "...freeing library\n");
362  FreeLibrary( sww_state.hinstDDRAW );
364  }
365 }

Referenced by DDRAW_Init().

◆ DIB_Init()

qboolean DIB_Init ( unsigned char **  ppbuffer,
int ppitch 
)

Definition at line 88 of file rw_dib.c.

89 {
90  dibinfo_t dibheader;
91  BITMAPINFO *pbmiDIB = ( BITMAPINFO * ) &dibheader;
92  DEVMODE gdevmode; //qb: for fullscreen
93  int i;
94 
95  memset( &dibheader, 0, sizeof( dibheader ) );
96 
97  /*
98  ** grab a DC
99  */
100  if ( !sww_state.hDC )
101  {
102  if ( ( sww_state.hDC = GetDC( sww_state.hWnd ) ) == NULL )
103  return false;
104  }
105 
106  /*
107  ** figure out if we're running in an 8-bit display mode
108  */
109  if ( GetDeviceCaps( sww_state.hDC, RASTERCAPS ) & RC_PALETTE )
110  {
111  sww_state.palettized = true;
112 
113  // save system colors
114  if ( !s_systemcolors_saved )
115  {
117  s_systemcolors_saved = true;
118  }
119  }
120  else
121  {
122  sww_state.palettized = false;
123  }
124 
125  vid.width = (int)(vid.width / 4) * 4; //qb: multiple of 4 required for DIB
126 
127  /*
128  ** fill in the BITMAPINFO struct
129  */
130  pbmiDIB->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
131  pbmiDIB->bmiHeader.biWidth = vid.width;
132  pbmiDIB->bmiHeader.biHeight = vid.height;
133  pbmiDIB->bmiHeader.biPlanes = 1;
134  pbmiDIB->bmiHeader.biBitCount = 8;
135  pbmiDIB->bmiHeader.biCompression = BI_RGB;
136  pbmiDIB->bmiHeader.biSizeImage = 0;
137  pbmiDIB->bmiHeader.biXPelsPerMeter = 0;
138  pbmiDIB->bmiHeader.biYPelsPerMeter = 0;
139  pbmiDIB->bmiHeader.biClrUsed = 256;
140  pbmiDIB->bmiHeader.biClrImportant = 256;
141 
142  /*
143  ** fill in the palette
144  */
145  for ( i = 0; i < 256; i++ )
146  {
147  dibheader.acolors[i].rgbRed = ( d_8to24table[i] >> 0 ) & 0xff;
148  dibheader.acolors[i].rgbGreen = ( d_8to24table[i] >> 8 ) & 0xff;
149  dibheader.acolors[i].rgbBlue = ( d_8to24table[i] >> 16 ) & 0xff;
150  }
151 
152  /*
153  ** create the DIB section
154  */
155  sww_state.hDIBSection = CreateDIBSection( sww_state.hDC,
156  pbmiDIB,
157  DIB_RGB_COLORS,
159  NULL,
160  0 );
161 
162  if ( sww_state.hDIBSection == NULL )
163  {
164  ri.Con_Printf( PRINT_ALL, "DIB_Init() - CreateDIBSection failed\n" );
165  goto fail;
166  }
167 
168  if ( pbmiDIB->bmiHeader.biHeight > 0 )
169  {
170  // bottom up
171  *ppbuffer = sww_state.pDIBBase + ( vid.height - 1 ) * vid.width;
172  *ppitch = -vid.width;
173  }
174  else
175  {
176  // top down
177  *ppbuffer = sww_state.pDIBBase;
178  *ppitch = vid.width;
179  }
180 
181  MONITORINFOEX monInfo;
182  memset(&monInfo, 0, sizeof(MONITORINFOEX));
183  monInfo.cbSize = sizeof(MONITORINFOEX);
184  GetMonitorInfo( MonitorFromWindow(sww_state.hWnd, MONITOR_DEFAULTTOPRIMARY), (LPMONITORINFO)&monInfo );
185 
186  ChangeDisplaySettingsEx(monInfo.szDevice, NULL, NULL, 0, NULL);
187 
188  if (vid_fullscreen->value) //qb: fullscreen dib
189  {
190 
191  RECT WindowRect;
192  DWORD WindowStyle, ExWindowStyle;
193 
194  WindowRect.top = monInfo.rcMonitor.top;
195  WindowRect.left = monInfo.rcMonitor.left;
196 
197  WindowRect.right = vid.width;
198  WindowRect.bottom = vid.height;
199  memset(&gdevmode, 0, sizeof(gdevmode));
200  gdevmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
201  gdevmode.dmPelsWidth = vid.width;
202  gdevmode.dmPelsHeight = vid.height;
203  gdevmode.dmSize = sizeof (gdevmode);
204 
205  if ( ChangeDisplaySettingsEx( monInfo.szDevice, &gdevmode, NULL, CDS_FULLSCREEN, NULL ) != DISP_CHANGE_SUCCESSFUL )
206  {
207  //ri.Sys_Error(ERR_FATAL, "Couldn't set fullscreen DIB mode");
208  goto fail; //qb: don't panic
209  }
210 
211  GetMonitorInfo( MonitorFromWindow(sww_state.hWnd, MONITOR_DEFAULTTOPRIMARY), (LPMONITORINFO)&monInfo );
212  if (!SetWindowPos(sww_state.hWnd,
213  NULL,
214  monInfo.rcMonitor.left, monInfo.rcMonitor.top,
215  WindowRect.right,
216  WindowRect.bottom,
217  SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOOWNERZORDER | SWP_NOREPOSITION | SWP_NOZORDER))
218  {
219  //ri.Sys_Error(ERR_FATAL, "Couldn't resize DIB window");
220  goto fail; //qb: don't panic
221  }
222 
223  WindowStyle = WS_POPUP | WS_SYSMENU | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
224  ExWindowStyle = 0;
225 
226  AdjustWindowRectEx(&WindowRect, WindowStyle, FALSE, 0);
227 
228  SetWindowLong(sww_state.hWnd, GWL_STYLE, WindowStyle | WS_VISIBLE);
229  SetWindowLong(sww_state.hWnd, GWL_EXSTYLE, ExWindowStyle);
230  }
231 
232  /*
233  ** clear the DIB memory buffer
234  */
235  memset(sww_state.pDIBBase, 0x00, vid.width * vid.height); //qb: do black, was 0xff
236 
237  if ( ( sww_state.hdcDIBSection = CreateCompatibleDC( sww_state.hDC ) ) == NULL )
238  {
239  ri.Con_Printf( PRINT_ALL, "DIB_Init() - CreateCompatibleDC failed\n" );
240  goto fail;
241  }
243  {
244  ri.Con_Printf( PRINT_ALL, "DIB_Init() - SelectObject failed\n" );
245  goto fail;
246  }
247 
248  return true;
249 
250 fail:
251  DIB_Shutdown();
252  return false;
253 
254 }

Referenced by SWimp_InitGraphics().

◆ DIB_SetPalette()

void DIB_SetPalette ( const unsigned char *  palette)

Definition at line 269 of file rw_dib.c.

270 {
271  const unsigned char *pal = _pal;
272  LOGPALETTE *pLogPal = ( LOGPALETTE * ) &s_ipal;
273  RGBQUAD colors[256];
274  int i;
275  int ret;
276  HDC hDC = sww_state.hDC;
277 
278  /*
279  ** set the DIB color table
280  */
281  if ( sww_state.hdcDIBSection )
282  {
283  for ( i = 0; i < 256; i++, pal += 4 )
284  {
285  colors[i].rgbRed = pal[0];
286  colors[i].rgbGreen = pal[1];
287  colors[i].rgbBlue = pal[2];
288  colors[i].rgbReserved = 0;
289  }
290 
291  colors[0].rgbRed = 0;
292  colors[0].rgbGreen = 0;
293  colors[0].rgbBlue = 0;
294 
295  colors[255].rgbRed = 0xff;
296  colors[255].rgbGreen = 0xff;
297  colors[255].rgbBlue = 0xff;
298 
299  if ( SetDIBColorTable( sww_state.hdcDIBSection, 0, 256, colors ) == 0 )
300  {
301  ri.Con_Printf( PRINT_ALL, "DIB_SetPalette() - SetDIBColorTable failed\n" );
302  }
303  }
304 
305  /*
306  ** for 8-bit color desktop modes we set up the palette for maximum
307  ** speed by going into an identity palette mode.
308  */
309  if ( sww_state.palettized )
310  {
311  int i;
312  HPALETTE hpalOld;
313 
314  if ( SetSystemPaletteUse( hDC, SYSPAL_NOSTATIC ) == SYSPAL_ERROR )
315  {
316  ri.Sys_Error( ERR_FATAL, "DIB_SetPalette() - SetSystemPaletteUse() failed\n" );
317  }
318 
319  /*
320  ** destroy our old palette
321  */
322  if ( sww_state.hPal )
323  {
324  DeleteObject( sww_state.hPal );
325  sww_state.hPal = 0;
326  }
327 
328  /*
329  ** take up all physical palette entries to flush out anything that's currently
330  ** in the palette
331  */
332  pLogPal->palVersion = 0x300;
333  pLogPal->palNumEntries = 256;
334 
335  for ( i = 0, pal = _pal; i < 256; i++, pal += 4 )
336  {
337  pLogPal->palPalEntry[i].peRed = pal[0];
338  pLogPal->palPalEntry[i].peGreen = pal[1];
339  pLogPal->palPalEntry[i].peBlue = pal[2];
340  pLogPal->palPalEntry[i].peFlags = PC_RESERVED | PC_NOCOLLAPSE;
341  }
342  pLogPal->palPalEntry[0].peRed = 0;
343  pLogPal->palPalEntry[0].peGreen = 0;
344  pLogPal->palPalEntry[0].peBlue = 0;
345  pLogPal->palPalEntry[0].peFlags = 0;
346  pLogPal->palPalEntry[255].peRed = 0xff;
347  pLogPal->palPalEntry[255].peGreen = 0xff;
348  pLogPal->palPalEntry[255].peBlue = 0xff;
349  pLogPal->palPalEntry[255].peFlags = 0;
350 
351  if ( ( sww_state.hPal = CreatePalette( pLogPal ) ) == NULL )
352  {
353  ri.Sys_Error( ERR_FATAL, "DIB_SetPalette() - CreatePalette failed(%x)\n", GetLastError() );
354  }
355 
356  if ( ( hpalOld = SelectPalette( hDC, sww_state.hPal, FALSE ) ) == NULL )
357  {
358  ri.Sys_Error( ERR_FATAL, "DIB_SetPalette() - SelectPalette failed(%x)\n",GetLastError() );
359  }
360 
361  if ( sww_state.hpalOld == NULL )
362  sww_state.hpalOld = hpalOld;
363 
364  if ( ( ret = RealizePalette( hDC ) ) != pLogPal->palNumEntries )
365  {
366  ri.Sys_Error( ERR_FATAL, "DIB_SetPalette() - RealizePalette set %d entries\n", ret );
367  }
368  }
369 }

Referenced by SWimp_SetPalette().

◆ DIB_Shutdown()

void DIB_Shutdown ( void  )

Definition at line 374 of file rw_dib.c.

375 {
378 
379  if ( sww_state.hPal )
380  {
381  DeleteObject( sww_state.hPal );
382  sww_state.hPal = 0;
383  }
384 
385  if ( sww_state.hpalOld )
386  {
387  SelectPalette( sww_state.hDC, sww_state.hpalOld, FALSE );
388  RealizePalette( sww_state.hDC );
390  }
391 
392  if ( sww_state.hdcDIBSection )
393  {
395  DeleteDC( sww_state.hdcDIBSection );
397  }
398 
399  if ( sww_state.hDIBSection )
400  {
401  DeleteObject( sww_state.hDIBSection );
404  }
405 
406  if ( sww_state.hDC )
407  {
408  ReleaseDC( sww_state.hWnd, sww_state.hDC );
409  sww_state.hDC = 0;
410  }
411 }

Referenced by DIB_Init(), and SWimp_Shutdown().

Variable Documentation

◆ sww_state

vid_fullscreen
cvar_t * vid_fullscreen
Definition: vid_dll.c:47
DDrawError
static const char * DDrawError(int code)
Definition: rw_ddraw.c:367
int
CONST PIXELFORMATDESCRIPTOR int
Definition: qgl_win.c:35
viddef_t::buffer
pixel_t * buffer
Definition: r_local.h:94
s_ipal
static identitypalette_t s_ipal
Definition: rw_dib.c:78
ri
refimport_t ri
Definition: r_main.c:25
DDRAW_Shutdown
void DDRAW_Shutdown(void)
Definition: rw_ddraw.c:317
swwstate_t::lpddsFrontBuffer
LPDIRECTDRAWSURFACE lpddsFrontBuffer
Definition: rw_win.h:44
i
int i
Definition: q_shared.c:305
previously_selected_GDI_obj
static HGDIOBJ previously_selected_GDI_obj
Definition: rw_dib.c:35
swwstate_t::pDIBBase
unsigned char * pDIBBase
Definition: rw_win.h:35
swwstate_t::lpddsOffScreenBuffer
LPDIRECTDRAWSURFACE lpddsOffScreenBuffer
Definition: rw_win.h:46
cvar_s
Definition: q_shared.h:324
swwstate_t::hinstDDRAW
HINSTANCE hinstDDRAW
Definition: rw_win.h:41
refimport_t::Con_Printf
void(* Con_Printf)(int print_level, char *str,...)
Definition: ref.h:202
PRINT_ALL
#define PRINT_ALL
Definition: qcommon.h:751
swwstate_t::hPal
HPALETTE hPal
Definition: rw_win.h:37
swwstate_t::palettized
qboolean palettized
Definition: rw_win.h:49
viddef_t::width
unsigned width
Definition: vid.h:29
HDC
HDC(WINAPI *qwglGetCurrentDC)(VOID)
refimport_t::Sys_Error
void(* Sys_Error)(int err_level, char *str,...)
Definition: ref.h:194
DDRAW_SetPalette
void DDRAW_SetPalette(const unsigned char *pal)
Definition: rw_ddraw.c:288
viddef_t::height
unsigned height
Definition: vid.h:29
DIB_SaveSystemColors
static void DIB_SaveSystemColors(void)
Definition: rw_dib.c:423
cvar_s::value
float value
Definition: q_shared.h:331
swwstate_t::modex
qboolean modex
Definition: rw_win.h:50
NULL
#define NULL
Definition: q_shared.h:67
DIB_Shutdown
void DIB_Shutdown(void)
Definition: rw_dib.c:374
DIB_RestoreSystemColors
static void DIB_RestoreSystemColors(void)
Definition: rw_dib.c:417
ERR_FATAL
#define ERR_FATAL
Definition: qcommon.h:743
dibinfo::acolors
RGBQUAD acolors[256]
Definition: rw_dib.c:68
swwstate_t::lpddpPalette
LPDIRECTDRAWPALETTE lpddpPalette
Definition: rw_win.h:47
d_8to24table
unsigned d_8to24table[256]
Definition: r_main.c:27
sw_allow_modex
cvar_t * sw_allow_modex
Definition: r_main.c:119
swwstate_t::hpalOld
HPALETTE hpalOld
Definition: rw_win.h:38
swwstate_t::hdcDIBSection
HDC hdcDIBSection
Definition: rw_win.h:33
DWORD
DWORD
Definition: qgl_win.c:49
dibinfo
Definition: rw_dib.c:65
FALSE
#define FALSE
Definition: stb_vorbis.c:618
swwstate_t::lpDirectDraw
LPDIRECTDRAW lpDirectDraw
Definition: rw_win.h:42
sww_state
swwstate_t sww_state
Definition: rw_imp.c:38
swwstate_t::hWnd
HWND hWnd
Definition: rw_win.h:31
swwstate_t::hDC
HDC hDC
Definition: rw_win.h:30
swstate_s::currentpalette
byte currentpalette[1024]
Definition: r_local.h:884
sw_state
swstate_t sw_state
Definition: r_main.c:49
s_systemcolors_saved
static qboolean s_systemcolors_saved
Definition: rw_dib.c:33
HRESULT
HRESULT(WINAPI *pDirectSoundCreate)(GUID FAR *lpGUID
pUnkOuter
LPDIRECTSOUND FAR IUnknown FAR * pUnkOuter
Definition: snd_win.c:28
swwstate_t::lpddsBackBuffer
LPDIRECTDRAWSURFACE lpddsBackBuffer
Definition: rw_win.h:45
sw_mode
static cvar_t * sw_mode
Definition: vid_menu.c:52
swwstate_t::hDIBSection
HBITMAP hDIBSection
Definition: rw_win.h:34
vid
viddef_t vid
Definition: r_main.c:24