Quake II RTX doxygen  1.0 dev
swimp.c File Reference
#include "client.h"

Go to the source code of this file.

Classes

struct  sww_t
 

Functions

void VID_Shutdown (void)
 
void SWimp_ModeChanged (void)
 
qboolean VID_Init (void)
 
void VID_VideoWait (void)
 
qboolean VID_VideoSync (void)
 
void VID_BeginFrame (void)
 
void VID_EndFrame (void)
 

Variables

static sww_t sww
 

Function Documentation

◆ SWimp_ModeChanged()

void SWimp_ModeChanged ( void  )

Definition at line 65 of file swimp.c.

66 {
67  BITMAPINFO info;
68 
69  if (!sww.dibdc) {
70  return;
71  }
72 
73  // destroy previous DIB section
74  if (sww.dibsect) {
75  SelectObject(sww.dibdc, sww.prevobj);
76  DeleteObject(sww.dibsect);
77  }
78 
79  // fill in the BITMAPINFO struct
80  memset(&info, 0, sizeof(info));
81 
82  info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
83  info.bmiHeader.biWidth = win.rc.width;
84  info.bmiHeader.biHeight = win.rc.height;
85  info.bmiHeader.biPlanes = 1;
86  info.bmiHeader.biCompression = BI_RGB;
87  info.bmiHeader.biBitCount = 32;
88 
89  // create the DIB section
90  sww.dibsect = CreateDIBSection(win.dc,
91  &info,
92  DIB_RGB_COLORS,
93  (void **)&sww.pixels,
94  NULL,
95  0);
96 
97  if (!sww.dibsect) {
98  Com_Error(ERR_FATAL, "DIB_Init: CreateDIBSection failed");
99  }
100 
101  if (info.bmiHeader.biHeight > 0) {
102  // bottom up
103  win.buffer = sww.pixels + (win.rc.height - 1) * win.rc.width * 4;
104  win.pitch = -win.rc.width * 4;
105  } else {
106  // top down
107  win.buffer = sww.pixels;
108  win.pitch = win.rc.width * 4;
109  }
110 
111  // clear the DIB memory buffer
112  memset(sww.pixels, 0, win.rc.width * win.rc.height * 4);
113 
114  sww.prevobj = SelectObject(sww.dibdc, sww.dibsect);
115  if (!sww.prevobj) {
116  Com_Error(ERR_FATAL, "DIB_Init: SelectObject failed\n");
117  }
118 }

Referenced by Win_ModeChanged().

◆ VID_BeginFrame()

void VID_BeginFrame ( void  )

Definition at line 157 of file swimp.c.

158 {
159 }

◆ VID_EndFrame()

void VID_EndFrame ( void  )

Definition at line 167 of file swimp.c.

168 {
169  BitBlt(win.dc, 0, 0, win.rc.width, win.rc.height, sww.dibdc, 0, 0, SRCCOPY);
170 }

◆ VID_Init()

qboolean VID_Init ( void  )

Definition at line 127 of file swimp.c.

128 {
129  // create the window
130  Win_Init();
131 
132  // set display mode
133  Win_SetMode();
134 
135  // create logical DC
136  sww.dibdc = CreateCompatibleDC(win.dc);
137  if (!sww.dibdc) {
138  Com_EPrintf("DIB_Init: CreateCompatibleDC failed with error %lu\n", GetLastError());
139  Win_Shutdown();
140  return qfalse;
141  }
142 
143  // call SWimp_ModeChanged and friends
144  Win_ModeChanged();
145  return qtrue;
146 }

◆ VID_Shutdown()

void VID_Shutdown ( void  )

Definition at line 49 of file swimp.c.

50 {
51  if (sww.dibdc) {
52  SelectObject(sww.dibdc, sww.prevobj);
53  DeleteDC(sww.dibdc);
54  }
55 
56  if (sww.dibsect) {
57  DeleteObject(sww.dibsect);
58  }
59 
60  memset(&sww, 0, sizeof(sww));
61 
62  Win_Shutdown();
63 }

◆ VID_VideoSync()

qboolean VID_VideoSync ( void  )

Definition at line 152 of file swimp.c.

153 {
154  return qtrue;
155 }

◆ VID_VideoWait()

void VID_VideoWait ( void  )

Definition at line 148 of file swimp.c.

149 {
150 }

Variable Documentation

◆ sww

sww_t sww
static

Definition at line 41 of file swimp.c.

Referenced by SWimp_ModeChanged(), VID_EndFrame(), VID_Init(), and VID_Shutdown().

Win_Init
void Win_Init(void)
Definition: client.c:1014
Win_ModeChanged
void Win_ModeChanged(void)
Definition: client.c:123
sww_t::prevobj
HGDIOBJ prevobj
Definition: swimp.c:38
Win_SetMode
void Win_SetMode(void)
Definition: client.c:358
sww_t::pixels
byte * pixels
Definition: swimp.c:37
sww_t::dibdc
HDC dibdc
Definition: swimp.c:35
Com_Error
void Com_Error(error_type_t type, const char *fmt,...)
Definition: g_main.c:258
Win_Shutdown
void Win_Shutdown(void)
Definition: client.c:1091
sww_t::dibsect
HBITMAP dibsect
Definition: swimp.c:36
win
win_state_t win
Definition: client.c:33
sww
static sww_t sww
Definition: swimp.c:41