mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-22 11:28:56 +00:00
Isolate 2dlib submodule
Isolate 2dlib from rest of the project, minor cleanups
This commit is contained in:
parent
d3659bb56b
commit
506521695a
@ -1,4 +1,3 @@
|
||||
set(HEADERS lib2d.h)
|
||||
set(CPPS
|
||||
font.cpp
|
||||
hardsurf.cpp
|
||||
@ -7,11 +6,17 @@ set(CPPS
|
||||
pentext.cpp
|
||||
screen.cpp
|
||||
surface.cpp
|
||||
viewport.cpp)
|
||||
viewport.cpp
|
||||
)
|
||||
|
||||
add_library(2dlib STATIC ${HEADERS} ${CPPS})
|
||||
add_library(2dlib STATIC ${CPPS})
|
||||
target_link_libraries(2dlib PRIVATE
|
||||
cfile
|
||||
mem
|
||||
misc
|
||||
)
|
||||
target_include_directories(2dlib PUBLIC
|
||||
$<BUILD_INTERFACE:
|
||||
${PROJECT_SOURCE_DIR}/2dlib
|
||||
>
|
||||
)
|
||||
|
@ -116,16 +116,16 @@
|
||||
* $NoKeywords: $
|
||||
*/
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "bitmap.h"
|
||||
#include "cfile.h"
|
||||
#include "gr.h"
|
||||
#include "mem.h"
|
||||
#include "mono.h"
|
||||
#include "pserror.h"
|
||||
#include "renderer.h"
|
||||
#include "gr.h"
|
||||
#include "mono.h"
|
||||
#include "cfile.h"
|
||||
#include "bitmap.h"
|
||||
#include "mem.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FT_COLOR 1
|
||||
#define FT_PROPORTIONAL 2
|
||||
|
@ -107,7 +107,6 @@
|
||||
#include "Ddgr.h"
|
||||
#include "fix.h"
|
||||
#include "pserror.h"
|
||||
#include "pstypes.h"
|
||||
|
||||
class grMemorySurface;
|
||||
class grViewport;
|
@ -55,5 +55,5 @@ grHardwareSurface::~grHardwareSurface() {}
|
||||
|
||||
bool grHardwareSurface::create(int w, int h, int bpp, unsigned flags, const char *name) {
|
||||
grSurface::create(w, h, bpp, SURFTYPE_GENERIC, flags, name);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
@ -68,12 +68,11 @@
|
||||
* $NoKeywords: $
|
||||
*/
|
||||
|
||||
#include "lib2d.h"
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "bitmap.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "lib2d.h"
|
||||
#include "mem.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -81,19 +80,19 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
grMemorySurface::grMemorySurface() : grSurface() {
|
||||
m_FirstTimeInit = 1;
|
||||
m_AllowInit = 1;
|
||||
m_FirstTimeInit = true;
|
||||
m_AllowInit = true;
|
||||
}
|
||||
|
||||
grMemorySurface::grMemorySurface(int w, int h, int bpp, unsigned flags, const char *name)
|
||||
: grSurface(w, h, bpp, SURFTYPE_MEMORY, flags, name) {
|
||||
m_FirstTimeInit = 0;
|
||||
m_AllowInit = 0;
|
||||
m_FirstTimeInit = false;
|
||||
m_AllowInit = false;
|
||||
}
|
||||
|
||||
grMemorySurface::grMemorySurface(int bm) {
|
||||
m_FirstTimeInit = 1;
|
||||
m_AllowInit = 1;
|
||||
m_FirstTimeInit = true;
|
||||
m_AllowInit = true;
|
||||
|
||||
grMemorySurface::init(bm_w(bm, 0), bm_h(bm, 0), bm_bpp(bm), (char *)bm_data(bm, 0), bm_rowsize(bm, 0),
|
||||
SURFFLAG_COLORKEY);
|
||||
@ -115,7 +114,7 @@ bool grMemorySurface::init(int w, int h, int bpp, char *data, int rowsize, unsig
|
||||
if (m_FirstTimeInit) {
|
||||
// add to list ONLY ONCE!
|
||||
add_to_list(&ddsfObj);
|
||||
m_FirstTimeInit = 0;
|
||||
m_FirstTimeInit = false;
|
||||
}
|
||||
|
||||
ddsfObj.w = w;
|
||||
@ -127,7 +126,7 @@ bool grMemorySurface::init(int w, int h, int bpp, char *data, int rowsize, unsig
|
||||
strncpy(ddsfObj.name, name, 15);
|
||||
|
||||
if (!gr_mem_surf_Init(&ddsfObj, data, rowsize))
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
surf_init(1);
|
||||
|
||||
|
@ -83,9 +83,8 @@
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdarg>
|
||||
#include <cstring>
|
||||
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "gr.h"
|
||||
#include "mono.h"
|
||||
#include "renderer.h"
|
||||
|
@ -45,8 +45,6 @@
|
||||
* $NoKeywords: $
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "gr.h"
|
||||
#include "pserror.h"
|
||||
#include "renderer.h"
|
||||
|
@ -86,15 +86,14 @@
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "bitmap.h"
|
||||
#include "lib2d.h"
|
||||
#include "pserror.h"
|
||||
#include "bitmap.h"
|
||||
#include "texture.h"
|
||||
#include "renderer.h"
|
||||
#include "texture.h"
|
||||
|
||||
static inline unsigned XLAT_RGB_TO_16(ddgr_color c) {
|
||||
uint8_t r, g, b;
|
||||
@ -105,9 +104,9 @@ static inline unsigned XLAT_RGB_TO_16(ddgr_color c) {
|
||||
return (((r >> 3) << 10) + ((g >> 3) << 5) + (b >> 3));
|
||||
}
|
||||
|
||||
ddgr_surface_node *grSurface::surf_list = NULL; // the surface list
|
||||
ddgr_surface_node *grSurface::surf_list_cur = NULL; // current node on list.
|
||||
ddgr_surface *grSurface::scratch_mem_surf = NULL;
|
||||
ddgr_surface_node *grSurface::surf_list = nullptr; // the surface list
|
||||
ddgr_surface_node *grSurface::surf_list_cur = nullptr; // current node on list.
|
||||
ddgr_surface *grSurface::scratch_mem_surf = nullptr;
|
||||
|
||||
void grSurface::init_system() {
|
||||
// allocate our scratch memory surface used in uniblt
|
||||
@ -122,11 +121,11 @@ void grSurface::init_system() {
|
||||
void grSurface::close_system() {
|
||||
// cleanup our scratch memory surface for blt
|
||||
if (grSurface::scratch_mem_surf) {
|
||||
if (grSurface::scratch_mem_surf->obj != NULL)
|
||||
if (grSurface::scratch_mem_surf->obj != nullptr)
|
||||
gr_mem_surf_Destroy(grSurface::scratch_mem_surf);
|
||||
|
||||
delete grSurface::scratch_mem_surf;
|
||||
grSurface::scratch_mem_surf = NULL;
|
||||
grSurface::scratch_mem_surf = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -458,7 +457,7 @@ char *grSurface::lock(int *rowsize) {
|
||||
*rowsize = m_DataRowsize;
|
||||
|
||||
if (!grerr)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
surf_Locked++; // increment lock counter for this surface
|
||||
|
||||
@ -487,7 +486,7 @@ char *grSurface::lock(int x, int y, int *rowsize) {
|
||||
|
||||
*rowsize = m_DataRowsize;
|
||||
if (!grerr)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
/* calculate the adjusted data pointer based off of x,y,bpp */
|
||||
char *data = m_OrigDataPtr;
|
||||
@ -732,13 +731,13 @@ void grSurface::xlat32_16(char *data, int w, int h) {
|
||||
void grSurface::add_to_list(ddgr_surface *sf) {
|
||||
ddgr_surface_node *node;
|
||||
|
||||
ASSERT(sf != NULL);
|
||||
ASSERT(sf != nullptr);
|
||||
|
||||
if (!grSurface::surf_list_cur) {
|
||||
// first surface on list
|
||||
node = new ddgr_surface_node;
|
||||
node->sf = sf;
|
||||
node->prev = NULL;
|
||||
node->prev = nullptr;
|
||||
grSurface::surf_list = grSurface::surf_list_cur = node;
|
||||
} else {
|
||||
// next surface on list.
|
||||
@ -755,12 +754,12 @@ void grSurface::remove_from_list(ddgr_surface *sf) {
|
||||
ddgr_surface_node *node, *next_node;
|
||||
|
||||
ASSERT(grSurface::surf_list_cur);
|
||||
ASSERT(sf != NULL);
|
||||
ASSERT(sf != nullptr);
|
||||
|
||||
// node is current node. next node is node after it on the list. since we are
|
||||
// going from end to beginning, this may confuse you.
|
||||
node = grSurface::surf_list_cur;
|
||||
next_node = NULL; // grSurface::surf_list_cur should be at end of list, so no next node
|
||||
next_node = nullptr; // grSurface::surf_list_cur should be at end of list, so no next node
|
||||
|
||||
while (node) {
|
||||
if (node->sf == sf) {
|
||||
@ -771,7 +770,7 @@ void grSurface::remove_from_list(ddgr_surface *sf) {
|
||||
}
|
||||
delete node;
|
||||
|
||||
node = NULL; // break out of loop
|
||||
node = nullptr; // break out of loop
|
||||
} else {
|
||||
// go down one node.
|
||||
next_node = node;
|
||||
|
@ -118,14 +118,14 @@
|
||||
#define CLIP_BOTTOM (vp_InitTop + vp_Bottom)
|
||||
|
||||
int grViewport::vp_Locked = 0;
|
||||
grViewport *grViewport::vp_Current_VP = NULL;
|
||||
grViewport *grViewport::vp_Current_VP = nullptr;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// grViewport constructor and destructor
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
grViewport::grViewport(grScreen *scr_parent) {
|
||||
ASSERT(scr_parent != NULL);
|
||||
ASSERT(scr_parent != nullptr);
|
||||
|
||||
sf_Parent = scr_parent; // screen is a child of grSurface, so we
|
||||
// can do this.
|
||||
@ -148,7 +148,7 @@ grViewport::grViewport(grScreen *scr_parent) {
|
||||
}
|
||||
|
||||
grViewport::grViewport(grSurface *sf_parent) {
|
||||
ASSERT(sf_parent != NULL);
|
||||
ASSERT(sf_parent != nullptr);
|
||||
|
||||
sf_Parent = sf_parent;
|
||||
|
||||
@ -288,11 +288,11 @@ void grViewport::unlock() {
|
||||
sf_Parent->unlock();
|
||||
vp_Locked = 0;
|
||||
|
||||
grViewport::vp_Current_VP = NULL;
|
||||
grViewport::vp_Current_VP = nullptr;
|
||||
|
||||
pen_Obj.data = NULL;
|
||||
pen_Obj.data = nullptr;
|
||||
pen_Obj.rowsize = 0;
|
||||
pen_Obj.sf = NULL;
|
||||
pen_Obj.sf = nullptr;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@ -10,6 +10,7 @@ set(CPPS
|
||||
|
||||
add_library(dd_grwin32 STATIC ${HEADERS} ${CPPS})
|
||||
target_link_libraries(dd_grwin32 PRIVATE
|
||||
2dlib
|
||||
misc
|
||||
)
|
||||
target_compile_definitions(dd_grwin32 PRIVATE DX_APP)
|
||||
|
@ -19,7 +19,7 @@
|
||||
// WorldObjectsRobotDialog.h : header file
|
||||
//
|
||||
|
||||
#include "../lib/gr.h"
|
||||
#include "gr.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CWorldObjectsRobotDialog dialog
|
||||
|
Loading…
Reference in New Issue
Block a user