more software renderer code removal

This commit is contained in:
Edu García 2024-05-09 12:11:49 +01:00
parent 7d38dde25d
commit fbd6350917
11 changed files with 3 additions and 328 deletions

View File

@ -266,11 +266,8 @@ void grSurface::load(char *data, int w, int h, char *pal) {
switch (ddsfObj.bpp) { switch (ddsfObj.bpp) {
case BPP_16: case BPP_16:
if (Renderer_type == RENDERER_SOFTWARE_8BIT) // TODO: This is probably software renderer only?
xlat8_16(data, w, h, pal); xlat16_16(data, w, h);
else
xlat16_16(data, w, h);
break;
default: default:
Int3(); // NOT SUPPORTED YET Int3(); // NOT SUPPORTED YET
} }

View File

@ -1233,25 +1233,13 @@ void StartFrame(int x, int y, int x2, int y2, bool clear, bool push_on_stack) {
last_fov = Render_FOV; last_fov = Render_FOV;
} }
// for software renderers perform frame buffer lock.
if (Renderer_type == RENDERER_SOFTWARE_16BIT) {
int w, h, color_depth, pitch;
ubyte *data;
ddvid_GetVideoProperties(&w, &h, &color_depth);
ddvid_LockFrameBuffer(&data, &pitch);
rend_SetSoftwareParameters(ddvid_GetAspectRatio(), w, h, pitch, data);
}
if (push_on_stack) { if (push_on_stack) {
// push this frame onto the stack // push this frame onto the stack
FramePush(x, y, x2, y2, clear); FramePush(x, y, x2, y2, clear);
} }
rend_StartFrame(x, y, x2, y2); rend_StartFrame(x, y, x2, y2);
if (Renderer_type == RENDERER_SOFTWARE_16BIT && clear) {
rend_FillRect(GR_RGB(0, 0, 0), x, y, x2, y2);
}
grtext_SetParameters(0, 0, (x2 - x), (y2 - y)); grtext_SetParameters(0, 0, (x2 - x), (y2 - y));
} }
@ -1273,11 +1261,6 @@ void EndFrame() {
//@@Frame_inside = false; //@@Frame_inside = false;
rend_EndFrame(); rend_EndFrame();
// for software renderers perform unlock on frame buffer.
if (Renderer_type == RENDERER_SOFTWARE_16BIT) {
ddvid_UnlockFrameBuffer();
}
// pop off frame // pop off frame
int x1, x2, y1, y2; int x1, x2, y1, y2;
bool clear; bool clear;

View File

@ -1484,12 +1484,6 @@ void LoadGameSettings() {
int len = _MAX_PATH; int len = _MAX_PATH;
Database->read("Default_pilot", Default_pilot, &len); Database->read("Default_pilot", Default_pilot, &len);
// If preferred renderer set to software, force it to be glide
if ((PreferredRenderer == RENDERER_SOFTWARE_8BIT) || (PreferredRenderer == RENDERER_SOFTWARE_16BIT)) {
Int3(); // Warning: rederer was set to Software. Ok to ignore this.
PreferredRenderer = RENDERER_OPENGL;
}
// Now that we have read in all the data, set the detail level if it is a predef setting (custom is ignored in // Now that we have read in all the data, set the detail level if it is a predef setting (custom is ignored in
// function) // function)

View File

@ -322,69 +322,6 @@ int bm_tga_read_outrage_compressed16(CFILE *infile, int n, int num_mips, int typ
return 1; return 1;
} }
// Reads a 8bit bitmap into memory
// Note: Even if we're are not using an 8bit renderer this routine still needs
// to be called due to the fact that we need to 'move' our position in the file
// We also need to extract the palette number
/*int bm_tga_read_outrage_compressed8 (CFILE *infile,int n)
{
ubyte pal_num=tga_read_byte ();
ubyte num_mips=tga_read_byte ();
ASSERT (pal_num>=0 && pal_num<=MAX_BITMAP_PALETTES);
if (num_mips>1)
GameBitmaps[n].mipmapped=1;
GameBitmaps[n].palette_num=pal_num;
for (int m=0;m<num_mips;m++)
{
int width=bm_w(n,m);
int height=bm_h(n,m);
int total=height * width;
int count=0;
ubyte *data;
if (Renderer_type==RENDERER_SOFTWARE_8BIT)
data=bm_data8 (n,m);
else
data=NULL;
while (count!=total)
{
ASSERT (count<total);
ubyte command=tga_read_byte ();
if (command==0) // next pixel is raw
{
ubyte pixel=tga_read_byte ();
int i=count/width;
int t=count%width;
if (Renderer_type==RENDERER_SOFTWARE_8BIT)
data[i*256+t]=pixel;
count++;
}
else if (command>=2 && command<=250) // next pixel is run of pixels
{
ubyte pixel=tga_read_byte ();
for (int k=0;k<command;k++)
{
int i=count/width;
int t=count%width;
if (Renderer_type==RENDERER_SOFTWARE_8BIT)
data[i*256+t]=pixel;
count++;
}
}
else Int3(); // bad compression run
}
}
return 1;
}*/
// Loads a tga or ogf file into a bitmap...returns handle to bm or -1 on error // Loads a tga or ogf file into a bitmap...returns handle to bm or -1 on error
int bm_tga_alloc_file(CFILE *infile, char *name, int format) { int bm_tga_alloc_file(CFILE *infile, char *name, int format) {
ubyte image_id_len, color_map_type, image_type, pixsize, descriptor; ubyte image_id_len, color_map_type, image_type, pixsize, descriptor;

View File

@ -100,9 +100,6 @@ bool ddvidfs_SetVideoMode(int w, int h, int color_depth, bool paged);
// closes video mode for fs // closes video mode for fs
void ddvidfs_CloseVideo(); void ddvidfs_CloseVideo();
// retrieves screen information for fullscreen version
void ddvidfs_GetVideoProperties(int *w, int *h, int *color_depth);
// flips screen if there's a back buffer // flips screen if there's a back buffer
void ddvidfs_VideoFlip(); void ddvidfs_VideoFlip();
@ -121,9 +118,6 @@ bool ddvidwin_SetVideoMode(int w, int h, int color_depth, bool paged, bool resch
// closes video mode for fs // closes video mode for fs
void ddvidwin_CloseVideo(); void ddvidwin_CloseVideo();
// retrieves screen information for windowed version
void ddvidwin_GetVideoProperties(int *w, int *h, int *color_depth);
// flips screen if there's a back buffer // flips screen if there's a back buffer
void ddvidwin_VideoFlip(); void ddvidwin_VideoFlip();

View File

@ -192,15 +192,6 @@ void ddvidfs_CloseVideo() {
} }
} }
// retrieves screen information for fullscreen version
void ddvidfs_GetVideoProperties(int *w, int *h, int *color_depth) {
ASSERT(DDVideo_info.curmode > -1);
*w = DDVideo_info.DDModes[DDVideo_info.curmode].dwWidth;
*h = DDVideo_info.DDModes[DDVideo_info.curmode].dwHeight;
*color_depth = (int)DDVideo_info.DDModes[DDVideo_info.curmode].ddpfPixelFormat.dwRGBBitCount;
}
// flips screen if there's a back buffer // flips screen if there's a back buffer
void ddvidfs_VideoFlip() { void ddvidfs_VideoFlip() {
if (DDVideo_info.lpDDSBack) if (DDVideo_info.lpDDSBack)

View File

@ -188,126 +188,3 @@ bool ddvid_SetVideoMode(int w, int h, int color_depth, bool paged) {
// sets screen handle // sets screen handle
void ddvid_SetVideoHandle(unsigned handle) { DDVideo_info.hVidWnd = (HWND)handle; } void ddvid_SetVideoHandle(unsigned handle) { DDVideo_info.hVidWnd = (HWND)handle; }
// retrieves screen information
void ddvid_GetVideoProperties(int *w, int *h, int *color_depth) {
ASSERT(DDVideo_init);
switch (DDVideo_info.subsystem) {
case VID_GDIF_SUBSYSTEM:
case VID_GDI_SUBSYSTEM:
ddvidwin_GetVideoProperties(w, h, color_depth);
break;
case VID_GDIX_SUBSYSTEM:
ddvidfs_GetVideoProperties(w, h, color_depth);
break;
case VID_DX_SUBSYSTEM:
ddvidfs_GetVideoProperties(w, h, color_depth);
break;
default:
Int3();
}
}
// retrieves screen aspect ratio.
float ddvid_GetAspectRatio() {
float aspect_ratio = (float)((3.0 * GetSystemMetrics(SM_CXSCREEN)) / (4.0 * GetSystemMetrics(SM_CYSCREEN)));
return aspect_ratio;
}
// only available to DD_ACCESS libraries.
// dd_obj is the DIRECTDRAW OBJECT for the system.
// dds_obj is the DIRECTDRAWSURFACE OBJECT for the screen
void ddvid_GetVideoDDrawProps(uint *dd_obj, uint *dds_obj) {
switch (DDVideo_info.subsystem) {
case VID_GDIX_SUBSYSTEM:
*dd_obj = NULL;
break;
case VID_DX_SUBSYSTEM:
*dd_obj = ddvidfs_GetDirectDrawObject();
break;
}
*dds_obj = NULL;
}
// flips screen if there's a back buffer
void ddvid_VideoFlip() {
switch (DDVideo_info.subsystem) {
case VID_GDIF_SUBSYSTEM:
case VID_GDI_SUBSYSTEM:
ddvidwin_VideoFlip();
break;
case VID_GDIX_SUBSYSTEM:
ddvidwin_VideoFlip();
break;
case VID_DX_SUBSYSTEM:
ddvidfs_VideoFlip();
break;
default:
Int3();
}
}
// retreives frame buffer info for a video mode.
void ddvid_LockFrameBuffer(ubyte **data, int *pitch) {
// locks a direct draw paged surface or a paged window. unpaged buffers won't lock.
ASSERT(DDVideo_init);
switch (DDVideo_info.subsystem) {
case VID_GDIF_SUBSYSTEM:
case VID_GDI_SUBSYSTEM: {
*data = (ubyte *)DDVideo_info.gdi.data;
*pitch = DDVideo_info.gdi.pitch;
} break;
case VID_GDIX_SUBSYSTEM: {
*data = (ubyte *)DDVideo_info.gdi.data;
*pitch = DDVideo_info.gdi.pitch;
} break;
case VID_DX_SUBSYSTEM: {
HRESULT hres;
DDSURFACEDESC ddsd;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
if (DDVideo_info.lpDDSBack) {
hres = DDVideo_info.lpDDSBack->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
if (hres != DD_OK) {
Error("Unable to set lock DirectDraw surface(%d)\n", LOWORD(hres));
}
*pitch = (int)ddsd.lPitch;
*data = (ubyte *)ddsd.lpSurface;
DDVideo_info.surf_data = (char *)(*data);
} else {
*data = NULL;
*pitch = 0;
}
} break;
default:
Int3();
}
}
void ddvid_UnlockFrameBuffer() {
ASSERT(DDVideo_init);
switch (DDVideo_info.subsystem) {
case VID_GDIF_SUBSYSTEM:
case VID_GDI_SUBSYSTEM:
case VID_GDIX_SUBSYSTEM:
break;
case VID_DX_SUBSYSTEM: {
HRESULT hres;
if (DDVideo_info.lpDDSBack) {
hres = DDVideo_info.lpDDSBack->Unlock(DDVideo_info.surf_data);
if (hres != DD_OK)
Error("Unable to unlock DirectDraw surface(%d)\n", LOWORD(hres));
DDVideo_info.surf_data = NULL;
}
} break;
default:
Int3();
}
}

View File

@ -153,59 +153,3 @@ bool ddvid_SetVideoMode(int w, int h, int color_depth, bool paged) {
// sets screen handle // sets screen handle
void ddvid_SetVideoHandle(unsigned handle) {} void ddvid_SetVideoHandle(unsigned handle) {}
// retrieves screen information
void ddvid_GetVideoProperties(int *w, int *h, int *color_depth) {
*w = 640;
*h = 480;
*color_depth = 16;
/*
ASSERT(DDVideo_init);
if(!DDVideo_info.info){
*w = *h = *color_depth = 0;
return;
}
*w = DDVideo_info.info->width;
*h = DDVideo_info.info->height;
*color_depth = DDVideo_info.info->bytesperpixel;
*/
}
// retrieves screen aspect ratio.
float ddvid_GetAspectRatio() {
/*
float aspect_ratio = (float)((3.0 * vga_getxdim())/(4.0 * vga_getydim()));
return aspect_ratio;
*/
return 0.75f;
}
// flips screen if there's a back buffer
void ddvid_VideoFlip() {
if (!DDVideo_info.paged)
return;
// vga_flip();
}
// retreives frame buffer info for a video mode.
void ddvid_LockFrameBuffer(ubyte **data, int *pitch) {
*data = NULL;
*pitch = 0;
/*
ASSERT(DDVideo_init);
if(!DDVideo_info.info){
*data = NULL;
*pitch = 0;
return;
}
// *data = vga_getgraphmem();
*pitch = DDVideo_info.info->linewidth;
*/
}
void ddvid_UnlockFrameBuffer() {
// ASSERT(DDVideo_init);
}

View File

@ -59,29 +59,4 @@ bool ddvid_SetVideoMode(int w, int h, int color_depth, bool paged);
// sets screen handle // sets screen handle
void ddvid_SetVideoHandle(unsigned handle); void ddvid_SetVideoHandle(unsigned handle);
// retrieves screen information
void ddvid_GetVideoProperties(int *w, int *h, int *color_depth);
// retrieves screen aspect ratio.
float ddvid_GetAspectRatio();
// retreives frame buffer info for a video mode.
void ddvid_LockFrameBuffer(ubyte **data, int *pitch);
void ddvid_UnlockFrameBuffer();
// flips screen if there's a back buffer
void ddvid_VideoFlip();
// only available to DD_ACCESS libraries.
#if defined(DD_ACCESS_RING)
#if defined(WIN32)
// dd_obj is the DIRECTDRAW OBJECT for the system.
// dds_obj is the DIRECTDRAWSURFACE OBJECT for the screen
void ddvid_GetVideoDDrawProps(uint *dd_obj, uint *dds_obj);
#endif // WIN32
#endif // DD_ACCESS
#endif #endif

View File

@ -316,8 +316,6 @@ extern int Triangles_drawn;
// Is this hardware or software rendered? // Is this hardware or software rendered?
typedef enum { typedef enum {
RENDERER_SOFTWARE_8BIT,
RENDERER_SOFTWARE_16BIT,
RENDERER_OPENGL, RENDERER_OPENGL,
RENDERER_DIRECT3D, RENDERER_DIRECT3D,
RENDERER_GLIDE, RENDERER_GLIDE,

View File

@ -100,16 +100,6 @@ static int m_UITextFlags = 0;
// DRAWING PRIMATIVE FUNCTIONS // DRAWING PRIMATIVE FUNCTIONS
void ui_StartDraw(int left, int top, int right, int bottom) { void ui_StartDraw(int left, int top, int right, int bottom) {
// for software renderers perform frame buffer lock.
if (Renderer_type == RENDERER_SOFTWARE_16BIT) {
int w, h, color_depth, pitch;
ubyte *data;
ddvid_GetVideoProperties(&w, &h, &color_depth);
ddvid_LockFrameBuffer(&data, &pitch);
rend_SetSoftwareParameters(ddvid_GetAspectRatio(), w, h, pitch, data);
}
m_UIDrawLeft = left; m_UIDrawLeft = left;
m_UIDrawTop = top; m_UIDrawTop = top;
m_UIDrawRight = right; m_UIDrawRight = right;
@ -123,11 +113,6 @@ void ui_StartDraw(int left, int top, int right, int bottom) {
void ui_EndDraw() { void ui_EndDraw() {
grtext_Flush(); grtext_Flush();
rend_EndFrame(); rend_EndFrame();
// for software renderers perform unlock on frame buffer.
if (Renderer_type == RENDERER_SOFTWARE_16BIT) {
ddvid_UnlockFrameBuffer();
}
} }
// sets text clipping within the startdraw region // sets text clipping within the startdraw region