I have WinQuake.exe game file which I compiled myself from source.
In software mode (without DirectX/OpenGL), what function is used to access video memory?
I know, for example, the DrawDibDraw WinAPI function; but I didn't find it in the code.
I have WinQuake.exe game file which I compiled myself from source.
In software mode (without DirectX/OpenGL), what function is used to access video memory?
I know, for example, the DrawDibDraw WinAPI function; but I didn't find it in the code.
When running in software mode, Quake uses SciTech's MGL.
The screen buffer is locked using VID_LockBuffer which calls MGL_beginDirectAccess:
void VID_LockBuffer (void) { ... MGL_beginDirectAccess(); if (memdc) { // Update surface pointer for linear access modes vid.buffer = vid.conbuffer = vid.direct = memdc->surface; vid.rowbytes = vid.conrowbytes = memdc->mi.bytesPerLine; } else if (mgldc) { // Update surface pointer for linear access modes vid.buffer = vid.conbuffer = vid.direct = mgldc->surface; vid.rowbytes = vid.conrowbytes = mgldc->mi.bytesPerLine; } ... } Screen state is then available through variable vid:
viddef_t vid; // global video state Whose definition is in vid.h:
typedef struct { pixel_t *buffer; // invisible buffer pixel_t *colormap; // 256 * VID_GRADES size unsigned short *colormap16; // 256 * VID_GRADES size int fullbright; // index of first fullbright color unsigned rowbytes; // may be > width if displayed in a window unsigned width; unsigned height; float aspect; // width / height -- < 0 is taller than wide int numpages; int recalc_refdef; // if true, recalc vid-based stuff pixel_t *conbuffer; int conrowbytes; unsigned conwidth; unsigned conheight; int maxwarpwidth; int maxwarpheight; pixel_t *direct; // direct drawing to framebuffer, if not // NULL } viddef_t; For instance, the update screen method SCR_UpdateScreen:
void SCR_UpdateScreen (void) { ... D_DisableBackBufferAccess (); // for adapters that can't stay mapped in // for linear writes all the time VID_LockBuffer (); V_RenderView (); VID_UnlockBuffer (); D_EnableBackBufferAccess (); // of all overlay stuff if drawing directly if (scr_drawdialog) { Sbar_Draw (); Draw_FadeScreen (); SCR_DrawNotifyString (); scr_copyeverything = true; } ... D_DisableBackBufferAccess (); // for adapters that can't stay mapped in // for linear writes all the time ... } If you dig deeper in the above, you will realize that:
D_DisableBackBufferAccess is an alias for VID_UnlockBufferD_EnableBackBufferAccess is an alias for VID_LockBuffermemdc is the device context for a regular in-memory back buffer, mgldc is one that’s supposed to go through an OpenGL pipeline. memdc allows blitting from a memory buffer: github.com/id-Software/Quake/blob/…