Skip to content

Commit

Permalink
Refactor: Switched r_data.c to C++ and began reimplementation
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Nov 26, 2012
1 parent 0999a34 commit 6b2aa30
Show file tree
Hide file tree
Showing 6 changed files with 1,289 additions and 2,051 deletions.
4 changes: 2 additions & 2 deletions doomsday/engine/engine.pro
Expand Up @@ -580,7 +580,7 @@ SOURCES += \
src/render/vignette.c \
src/render/vlight.cpp \
src/resource/animgroups.cpp \
src/resource/bitmapfont.c \
src/resource/bitmapfont.cpp \
src/resource/colorpalette.c \
src/resource/colorpalettes.cpp \
src/resource/fonts.cpp \
Expand All @@ -594,7 +594,7 @@ SOURCES += \
src/resource/patchcompositetexture.cpp \
src/resource/patchname.cpp \
src/resource/pcx.c \
src/resource/r_data.c \
src/resource/r_data.cpp \
src/resource/rawtexture.cpp \
src/resource/texture.cpp \
src/resource/textures.cpp \
Expand Down
35 changes: 33 additions & 2 deletions doomsday/engine/include/resource/r_data.h
Expand Up @@ -48,22 +48,53 @@ struct font_s;
#define PF_UPSCALE_AND_SHARPEN 0x2
///@}

typedef struct patchtex_s {
typedef struct patchtex_s
{
/// @ref patchFlags
short flags;

/// Offset to texture origin in logical pixels.
short offX, offY;
} patchtex_t;

#pragma pack(1)
typedef struct doompatch_header_s {
typedef struct doompatch_header_s
{
int16_t width; /// Bounding box size.
int16_t height;
int16_t leftOffset; /// Pixels to the left of origin.
int16_t topOffset; /// Pixels below the origin.
} doompatch_header_t;
#pragma pack()

#ifdef __cplusplus
#include <de/IReadable>
#include <de/Reader>

struct PatchHeader : public de::IReadable
{
/// Dimensions of the patch in texels.
Size2Raw dimensions;

/// Origin offset for the patch in texels.
Point2Raw origin;

/// Implements IReadable.
void operator << (de::Reader &from)
{
dint16 width, height;
from >> width >> height;
dimensions.width = width;
dimensions.height = height;

dint16 xOrigin, yOrigin;
from >> xOrigin >> yOrigin;
origin.x = xOrigin;
origin.y = yOrigin;
}
};

#endif

/**
* Textures used in the lighting system.
Expand Down
6 changes: 3 additions & 3 deletions doomsday/engine/src/dd_main.cpp
Expand Up @@ -1061,7 +1061,7 @@ static int DD_ActivateGameWorker(void* parameters)
DENG_ASSERT(p);

// Texture resources are located now, prior to initializing the game.
R_InitPatchComposites();
R_InitPatchCompositeTextures();
R_InitFlatTextures();
R_InitSpriteTextures();

Expand Down Expand Up @@ -1904,7 +1904,7 @@ boolean DD_Init(void)
initPathMappings();
App_FileSystem()->resetAllSchemes();

R_InitPatchComposites();
R_InitPatchCompositeTextures();
R_InitFlatTextures();
R_InitSpriteTextures();

Expand Down Expand Up @@ -2134,7 +2134,7 @@ void DD_UpdateEngineState(void)
// Re-build the filesystem subspace schemes as there may be new resources to be found.
App_FileSystem()->resetAllSchemes();

R_InitPatchComposites();
R_InitPatchCompositeTextures();
R_InitFlatTextures();
R_InitSpriteTextures();

Expand Down

0 comments on commit 6b2aa30

Please sign in to comment.