diff --git a/doomsday/engine/api/api_base.h b/doomsday/engine/api/api_base.h index 054a48716f..41024aaac2 100644 --- a/doomsday/engine/api/api_base.h +++ b/doomsday/engine/api/api_base.h @@ -23,7 +23,7 @@ #include "apis.h" #include "api_uri.h" -#include "resourceclass.h" +#include "api_resourceclass.h" /// @addtogroup game /// @{ diff --git a/doomsday/engine/api/api_render.h b/doomsday/engine/api/api_render.h new file mode 100644 index 0000000000..6a1b78653c --- /dev/null +++ b/doomsday/engine/api/api_render.h @@ -0,0 +1,160 @@ +#ifndef DOOMSDAY_API_RENDER_H +#define DOOMSDAY_API_RENDER_H + +#include "apis.h" +#include "api_gl.h" + +DENG_API_TYPEDEF(Rend) +{ + de_api_t api; + + /** + * Called by the game at various points in the map setup process. + */ + void (*SetupMap)(int mode, int flags); + void (*SetupFogDefaults)(void); + void (*SetupFog)(float start, float end, float density, float* rgb); + + /** + * Prepare all texture resources for the specified mobjtype. + */ + void (*CacheForMobjType)(int mobjtypeNum); + + void (*CacheModelsForState)(int stateIndex); + + /** + * Draw the view of the player inside the view window. + */ + void (*RenderPlayerView)(int num); + + /** + * Update the view origin position for player @a consoleNum. + * + * @param consoleNum Console number. + */ + void (*SetViewOrigin)(int player, coord_t const origin[3]); + + /** + * Update the view yaw angle for player @a consoleNum. + * + * @param consoleNum Console number. + */ + void (*SetViewAngle)(int player, angle_t angle); + + /** + * Update the view pitch angle for player @a consoleNum. + * + * @param consoleNum Console number. + */ + void (*SetViewPitch)(int player, float pitch); + + /** + * Retrieve the geometry of the specified viewwindow by console player num. + */ + int (*ViewWindowGeometry)(int player, RectRaw* geometry); + int (*ViewWindowOrigin)(int player, Point2Raw* origin); + int (*ViewWindowSize)(int player, Size2Raw* size); + + void (*SetViewWindowGeometry)(int player, const RectRaw* geometry, boolean interpolate); + + void (*SetBorderGfx)(const Uri* const* paths); + + /** + * Retrieve the geometry of the specified viewport by console player num. + */ + int (*ViewPortGeometry)(int player, RectRaw* geometry); + int (*ViewPortOrigin)(int player, Point2Raw* origin); + int (*ViewPortSize)(int player, Size2Raw* size); + + /** + * Change the view player for the specified viewport by console player num. + * + * @param consoleNum Console player number of whose viewport to change. + * @param viewPlayer Player that will be viewed by @a player. + */ + void (*SetViewPortPlayer)(int consoleNum, int viewPlayer); + + /** + * Choose an alignment mode and/or calculate the appropriate scaling factor + * for fitting an element within the bounds of the "available" region. + * The aspect ratio of the element is respected. + * + * @param scale If not @c NULL the calculated scale factor is written here. + * @param width Width of the element to fit into the available region. + * @param height Height of the element to fit into the available region. + * @param availWidth Width of the available region. + * @param availHeight Height of the available region. + * @param scaleMode @ref scaleModes + * + * @return @c true if aligning to the horizontal axis else the vertical. + */ + boolean (*ChooseAlignModeAndScaleFactor)(float* scale, int width, int height, int availWidth, int availHeight, scalemode_t scaleMode); + + /** + * Choose a scale mode by comparing the dimensions of the two, two-dimensional + * regions. The aspect ratio is respected when fitting to the bounds of the + * "available" region. + * + * @param width Width of the element to fit into the available region. + * @param height Height of the element to fit into the available region. + * @param availWidth Width of the available region. + * @param availHeight Height of the available region. + * @param overrideMode Scale mode override, for caller-convenience. @ref scaleModes + * @param stretchEpsilon Range within which aspect ratios are considered + * identical for "smart stretching". + * + * @return Chosen scale mode @ref scaleModes. + */ + scalemode_t (*ChooseScaleMode2)(int width, int height, int availWidth, int availHeight, scalemode_t overrideMode, float stretchEpsilon); + + scalemode_t (*ChooseScaleMode)(int width, int height, int availWidth, int availHeight, scalemode_t overrideMode); + + boolean (*GetSpriteInfo)(int sprite, int frame, spriteinfo_t* sprinfo); + + /** + * Alternative interface for manipulating Sky (layer) properties by name/id. + */ + void (*SkyParams)(int layer, int param, void* data); + + /** + * Grabs the current contents of the frame buffer and outputs it in a file. + * Will create/overwrite as necessary. + * + * @param filename Local file path to write to. + */ + int (*ScreenShot)(const char* filename, int bits); +} +DENG_API_T(Rend); + +#ifndef DENG_NO_API_MACROS_RENDER +#define R_SetupMap _api_Rend.SetupMap +#define R_SetupFogDefaults _api_Rend.SetupFogDefaults +#define R_SetupFog _api_Rend.SetupFog +#define Rend_CacheForMobjType _api_Rend.CacheForMobjType +#define Models_CacheForState _api_Rend.CacheModelsForState +#define R_RenderPlayerView _api_Rend.RenderPlayerView +#define R_SetViewOrigin _api_Rend.SetViewOrigin +#define R_SetViewAngle _api_Rend.SetViewAngle +#define R_SetViewPitch _api_Rend.SetViewPitch +#define R_ViewWindowGeometry _api_Rend.ViewWindowGeometry +#define R_ViewWindowOrigin _api_Rend.ViewWindowOrigin +#define R_ViewWindowSize _api_Rend.ViewWindowSize +#define R_SetViewWindowGeometry _api_Rend.SetViewWindowGeometry +#define R_SetBorderGfx _api_Rend.SetBorderGfx +#define R_ViewPortGeometry _api_Rend.ViewPortGeometry +#define R_ViewPortOrigin _api_Rend.ViewPortOrigin +#define R_ViewPortSize _api_Rend.ViewPortSize +#define R_SetViewPortPlayer _api_Rend.SetViewPortPlayer +#define R_ChooseAlignModeAndScaleFactor _api_Rend.ChooseAlignModeAndScaleFactor +#define R_ChooseScaleMode2 _api_Rend.ChooseScaleMode2 +#define R_ChooseScaleMode _api_Rend.ChooseScaleMode +#define R_GetSpriteInfo _api_Rend.GetSpriteInfo +#define R_SkyParams _api_Rend.SkyParams +#define M_ScreenShot _api_Rend.ScreenShot +#endif + +#if defined __DOOMSDAY__ && defined __CLIENT__ +DENG_USING_API(Rend); +#endif + +#endif // DOOMSDAY_API_RENDER_H diff --git a/doomsday/engine/api/api_resourceclass.h b/doomsday/engine/api/api_resourceclass.h new file mode 100644 index 0000000000..98aa99d76d --- /dev/null +++ b/doomsday/engine/api/api_resourceclass.h @@ -0,0 +1,27 @@ +#ifndef DOOMSDAY_API_RESOURCECLASS_H +#define DOOMSDAY_API_RESOURCECLASS_H + +/** + * Resource Class Identifier. + * + * @ingroup base + * + * @todo Refactor away. These identifiers are no longer needed. + */ +typedef enum resourceclassid_e { + RC_NULL = -2, ///< Not a real class. + RC_UNKNOWN = -1, ///< Attempt to guess the class through evaluation of the path. + RESOURCECLASS_FIRST = 0, + RC_PACKAGE = RESOURCECLASS_FIRST, + RC_DEFINITION, + RC_GRAPHIC, + RC_MODEL, + RC_SOUND, + RC_MUSIC, + RC_FONT, + RESOURCECLASS_COUNT +} resourceclassid_t; + +#define VALID_RESOURCECLASSID(n) ((n) >= RESOURCECLASS_FIRST && (n) < RESOURCECLASS_COUNT) + +#endif // DOOMSDAY_API_RESOURCECLASS_H diff --git a/doomsday/engine/api/api_uri.h b/doomsday/engine/api/api_uri.h index c39a78b6ed..d473207bf4 100644 --- a/doomsday/engine/api/api_uri.h +++ b/doomsday/engine/api/api_uri.h @@ -24,7 +24,7 @@ #define LIBDENG_API_URI_H #include "api_base.h" -#include "resourceclass.h" +#include "api_resourceclass.h" #include #include #include diff --git a/doomsday/engine/api/apis.h b/doomsday/engine/api/apis.h index 96205da9ca..ab67efe7c3 100644 --- a/doomsday/engine/api/apis.h +++ b/doomsday/engine/api/apis.h @@ -75,22 +75,28 @@ enum { DE_API_PLUGIN_v1 = 1600, // 1.10 DE_API_PLUGIN = DE_API_PLUGIN_v1, - DE_API_SERVER_v1 = 1700, // 1.10 + DE_API_RENDER_v1 = 1700, // 1.10 + DE_API_RENDER = DE_API_RENDER_v1, + + DE_API_RESOURCE_v1 = 1800, // 1.10 + DE_API_RESOURCE = DE_API_RESOURCE_v1, + + DE_API_SERVER_v1 = 1900, // 1.10 DE_API_SERVER = DE_API_SERVER_v1, - DE_API_SOUND_v1 = 1800, // 1.10 + DE_API_SOUND_v1 = 2000, // 1.10 DE_API_SOUND = DE_API_SOUND_v1, - DE_API_SVG_v1 = 1900, // 1.10 + DE_API_SVG_v1 = 2100, // 1.10 DE_API_SVG = DE_API_SVG_v1, - DE_API_THINKER_v1 = 2000, // 1.10 + DE_API_THINKER_v1 = 2200, // 1.10 DE_API_THINKER = DE_API_THINKER_v1, - DE_API_URI_v1 = 2100, // 1.10 + DE_API_URI_v1 = 2300, // 1.10 DE_API_URI = DE_API_URI_v1, - DE_API_WAD_v1 = 2200, // 1.10 + DE_API_WAD_v1 = 2400, // 1.10 DE_API_WAD = DE_API_WAD_v1 }; diff --git a/doomsday/engine/api/dd_types.h b/doomsday/engine/api/dd_types.h index cc70cf7b03..e861cc6990 100644 --- a/doomsday/engine/api/dd_types.h +++ b/doomsday/engine/api/dd_types.h @@ -79,8 +79,6 @@ struct material_s; #include #include -#include "resourceclass.h" -#include "filetype.h" #include "api_uri.h" #endif /* ENGINE_TYPES_H */ diff --git a/doomsday/engine/api/doomsday.h b/doomsday/engine/api/doomsday.h index aacc5a3cd5..413527256d 100644 --- a/doomsday/engine/api/doomsday.h +++ b/doomsday/engine/api/doomsday.h @@ -74,12 +74,12 @@ struct font_s; #include "api_fontrender.h" #include "api_svg.h" #include "api_sound.h" +#include "api_render.h" #include "api_map.h" #include "api_mapedit.h" #include "api_client.h" #include "api_server.h" -#include "filehandle.h" #include #include #include @@ -115,12 +115,6 @@ typedef struct material_s { int type; } material_t; extern "C" { #endif -//------------------------------------------------------------------------ -// -// Base. -// -//------------------------------------------------------------------------ - /** * @defgroup base Base */ @@ -135,24 +129,12 @@ extern "C" { * @ingroup base */ -//------------------------------------------------------------------------ -// -// System. -// -//------------------------------------------------------------------------ - /** * @defgroup system System Routines * @ingroup base * Functionality provided by or related to the operating system. */ -//------------------------------------------------------------------------ -// -// Playsim. -// -//------------------------------------------------------------------------ - /** * @defgroup playsim Playsim * @ingroup game @@ -163,61 +145,11 @@ extern "C" { * @ingroup map */ -//------------------------------------------------------------------------ -// -// Refresh. -// -//------------------------------------------------------------------------ - /** * @defgroup render Renderer */ -///@{ - -void R_SetupMap(int mode, int flags); -void R_SetupFogDefaults(void); -void R_SetupFog(float start, float end, float density, float* rgb); - -void Rend_CacheForMobjType(int mobjtypeNum); -void Models_CacheForState(int stateIndex); - -void R_RenderPlayerView(int num); - -void R_SetViewOrigin(int player, coord_t const origin[3]); -void R_SetViewAngle(int player, angle_t angle); -void R_SetViewPitch(int player, float pitch); - -/** - * Retrieve the geometry of the specified viewwindow by console player num. - */ -int R_ViewWindowGeometry(int player, RectRaw* geometry); -int R_ViewWindowOrigin(int player, Point2Raw* origin); -int R_ViewWindowSize(int player, Size2Raw* size); - -void R_SetViewWindowGeometry(int player, const RectRaw* geometry, boolean interpolate); - -void R_SetBorderGfx(const Uri* const* paths); - -/** - * Retrieve the geometry of the specified viewport by console player num. - */ -int R_ViewPortGeometry(int player, RectRaw* geometry); -int R_ViewPortOrigin(int player, Point2Raw* origin); -int R_ViewPortSize(int player, Size2Raw* size); - -/** - * Change the view player for the specified viewport by console player num. - * - * @param consoleNum Console player number of whose viewport to change. - * @param viewPlayer Player that will be viewed by @a player. - */ -void R_SetViewPortPlayer(int consoleNum, int viewPlayer); - -boolean R_ChooseAlignModeAndScaleFactor(float* scale, int width, int height, int availWidth, int availHeight, scalemode_t scaleMode); -scalemode_t R_ChooseScaleMode2(int width, int height, int availWidth, int availHeight, scalemode_t overrideMode, float stretchEpsilon); -scalemode_t R_ChooseScaleMode(int width, int height, int availWidth, int availHeight, scalemode_t overrideMode); -boolean R_GetSpriteInfo(int sprite, int frame, spriteinfo_t* sprinfo); +// R (Resource) patchid_t R_DeclarePatch(const char* name); boolean R_GetPatchInfo(patchid_t id, patchinfo_t* info); @@ -237,33 +169,6 @@ const char* R_GetColorPaletteNameForNum(colorpaletteid_t id); void R_GetColorPaletteRGBubv(colorpaletteid_t id, int colorIdx, uint8_t rgb[3], boolean applyTexGamma); void R_GetColorPaletteRGBf(colorpaletteid_t id, int colorIdx, float rgb[3], boolean applyTexGamma); -void R_HSVToRGB(float* rgb, float h, float s, float v); - -///@} - -//------------------------------------------------------------------------ -// -// Renderer. -// -//------------------------------------------------------------------------ - -/// @addtogroup render -///@{ - -void R_SkyParams(int layer, int param, void* data); - -///@} - -//------------------------------------------------------------------------ -// -// Miscellaneous. -// -//------------------------------------------------------------------------ - -/** - * @ingroup render - */ -int M_ScreenShot(const char* filename, int bits); #ifdef __cplusplus } // extern "C" diff --git a/doomsday/engine/engine.pro b/doomsday/engine/engine.pro index 84f95f9fff..7d85ba97bc 100644 --- a/doomsday/engine/engine.pro +++ b/doomsday/engine/engine.pro @@ -96,6 +96,8 @@ DENG_API_HEADERS = \ api/api_mapedit.h \ api/api_player.h \ api/api_plugin.h \ + api/api_render.h \ + api/api_resourceclass.h \ api/api_sound.h \ api/api_svg.h \ api/api_thinker.h \ @@ -108,10 +110,7 @@ DENG_API_HEADERS = \ api/dd_version.h \ api/def_share.h \ api/dengproject.h \ - api/doomsday.h \ - api/filehandle.h \ - api/filetype.h \ - api/resourceclass.h + api/doomsday.h # Convenience headers. DENG_HEADERS += \ @@ -176,6 +175,7 @@ DENG_HEADERS += \ include/edit_bias.h \ include/edit_bsp.h \ include/edit_map.h \ + include/filehandle.h \ include/filesys/file.h \ include/filesys/filehandlebuilder.h \ include/filesys/fileinfo.h \ @@ -185,6 +185,7 @@ DENG_HEADERS += \ include/filesys/manifest.h \ include/filesys/searchpath.h \ include/filesys/sys_direc.h \ + include/filetype.h \ include/game.h \ include/gl/gl_defer.h \ include/gl/gl_deferredapi.h \ @@ -310,6 +311,7 @@ DENG_HEADERS += \ include/resource/tga.h \ include/resource/wad.h \ include/resource/zip.h \ + include/resourceclass.h \ include/server/sv_def.h \ include/server/sv_frame.h \ include/server/sv_infine.h \ @@ -424,6 +426,7 @@ deng_nodisplaymode { # Platform-independent sources. SOURCES += \ src/api_material.cpp \ + src/render/api_render.c \ src/audio/audiodriver.cpp \ src/audio/audiodriver_music.c \ src/audio/m_mus2midi.c \ diff --git a/doomsday/engine/include/de_filesys.h b/doomsday/engine/include/de_filesys.h index f12118e7d8..6b7d364b77 100644 --- a/doomsday/engine/include/de_filesys.h +++ b/doomsday/engine/include/de_filesys.h @@ -25,6 +25,7 @@ #include "dd_types.h" #include "resourceclass.h" +#include "filehandle.h" #include "filetype.h" #include "filesys/filehandlebuilder.h" diff --git a/doomsday/engine/include/de_resource.h b/doomsday/engine/include/de_resource.h index aa41f7a45c..287c525297 100644 --- a/doomsday/engine/include/de_resource.h +++ b/doomsday/engine/include/de_resource.h @@ -21,6 +21,8 @@ #ifndef LIBDENG_RESOURCE_SUBSYSTEM_H #define LIBDENG_RESOURCE_SUBSYSTEM_H +#include "resourceclass.h" + #include "resource/animgroups.h" #include "resource/colorpalettes.h" #include "resource/font.h" diff --git a/doomsday/engine/api/filehandle.h b/doomsday/engine/include/filehandle.h similarity index 100% rename from doomsday/engine/api/filehandle.h rename to doomsday/engine/include/filehandle.h diff --git a/doomsday/engine/api/filetype.h b/doomsday/engine/include/filetype.h similarity index 100% rename from doomsday/engine/api/filetype.h rename to doomsday/engine/include/filetype.h diff --git a/doomsday/engine/include/m_misc.h b/doomsday/engine/include/m_misc.h index 3cf470e2a9..c126d60ae4 100644 --- a/doomsday/engine/include/m_misc.h +++ b/doomsday/engine/include/m_misc.h @@ -121,16 +121,6 @@ boolean M_RunTrigger(trigger_t* trigger, timespan_t advanceTime); */ boolean M_CheckTrigger(const trigger_t* trigger, timespan_t advanceTime); -// Other utilities: - -/** - * Grabs the current contents of the frame buffer and outputs a Targa file. - * Will create/overwrite as necessary. - * - * @param filePath Local file path to write to. - */ -int M_ScreenShot(const char* filePath, int bits); - #ifdef __cplusplus } // extern "C" #endif diff --git a/doomsday/engine/include/map/r_world.h b/doomsday/engine/include/map/r_world.h index 3692d20987..ccecc14050 100644 --- a/doomsday/engine/include/map/r_world.h +++ b/doomsday/engine/include/map/r_world.h @@ -56,14 +56,6 @@ extern boolean firstFrameAfterLoad; // Sky flags. #define SIF_DRAW_SPHERE 0x1 // Always draw the sky sphere. -/** - * Called by the game at various points in the map setup process. - */ -void R_SetupMap(int mode, int flags); - -void R_SetupFogDefaults(void); -void R_SetupFog(float start, float end, float density, float* rgb); - /** * Sector light color may be affected by the sky light color. */ diff --git a/doomsday/engine/include/r_util.h b/doomsday/engine/include/r_util.h index 14e2d2d9f0..98b2c92e30 100644 --- a/doomsday/engine/include/r_util.h +++ b/doomsday/engine/include/r_util.h @@ -76,8 +76,6 @@ void R_AmplifyColor(float color[3]); void R_ScaleAmbientRGB(float* out, const float* in, float mul); -void R_HSVToRGB(float* rgb, float h, float s, float v); - /** * Generate texcoords on the surface centered on point. * @@ -96,43 +94,6 @@ void R_HSVToRGB(float* rgb, float h, float s, float v); boolean R_GenerateTexCoords(pvec2f_t s, pvec2f_t t, const_pvec3d_t point, float xScale, float yScale, const_pvec3d_t v1, const_pvec3d_t v2, const_pvec3f_t tangent, const_pvec3f_t bitangent); -/** - * Choose an alignment mode and/or calculate the appropriate scaling factor - * for fitting an element within the bounds of the "available" region. - * The aspect ratio of the element is respected. - * - * @param scale If not @c NULL the calculated scale factor is written here. - * @param width Width of the element to fit into the available region. - * @param height Height of the element to fit into the available region. - * @param availWidth Width of the available region. - * @param availHeight Height of the available region. - * @param scaleMode @ref scaleModes - * - * @return @c true if aligning to the horizontal axis else the vertical. - */ -boolean R_ChooseAlignModeAndScaleFactor(float* scale, int width, int height, - int availWidth, int availHeight, scalemode_t scaleMode); - -/** - * Choose a scale mode by comparing the dimensions of the two, two-dimensional - * regions. The aspect ratio is respected when fitting to the bounds of the - * "available" region. - * - * @param width Width of the element to fit into the available region. - * @param height Height of the element to fit into the available region. - * @param availWidth Width of the available region. - * @param availHeight Height of the available region. - * @param overrideMode Scale mode override, for caller-convenience. @ref scaleModes - * @param stretchEpsilon Range within which aspect ratios are considered - * identical for "smart stretching". - * - * @return Chosen scale mode @ref scaleModes. - */ -scalemode_t R_ChooseScaleMode2(int width, int height, int availWidth, int availHeight, - scalemode_t overrideMode, float stretchEpsilon); -scalemode_t R_ChooseScaleMode(int width, int height, int availWidth, int availHeight, - scalemode_t overrideMode); - #ifdef __cplusplus } // extern "C" #endif diff --git a/doomsday/engine/include/render/r_draw.h b/doomsday/engine/include/render/r_draw.h index ea19e04ec9..dfcfe18aa4 100644 --- a/doomsday/engine/include/render/r_draw.h +++ b/doomsday/engine/include/render/r_draw.h @@ -32,8 +32,6 @@ extern "C" { void R_InitViewWindow(void); void R_ShutdownViewWindow(void); -void R_SetBorderGfx(Uri const *const *paths); - /** * Draws the border around the view for different size windows. */ diff --git a/doomsday/engine/include/render/r_main.h b/doomsday/engine/include/render/r_main.h index 6c22153e6e..4791d169d9 100644 --- a/doomsday/engine/include/render/r_main.h +++ b/doomsday/engine/include/render/r_main.h @@ -121,11 +121,6 @@ void R_RenderViewPorts(void); */ void R_RenderBlankView(void); -/** - * Draw the view of the player inside the view window. - */ -void R_RenderPlayerView(int num); - /** * Draw the border around the view window. */ @@ -159,48 +154,11 @@ boolean R_SetViewGrid(int numCols, int numRows); void R_SetupDefaultViewWindow(int consoleNum); -/** - * Update the view origin position for player @a consoleNum. - * - * @param consoleNum Console number. - * - * @note Part of the Doomsday public API. - */ -void R_SetViewOrigin(int consoleNum, coord_t const origin[3]); - -/** - * Update the view yaw angle for player @a consoleNum. - * - * @param consoleNum Console number. - * - * @note Part of the Doomsday public API. - */ -void R_SetViewAngle(int consoleNum, angle_t angle); - -/** - * Update the view pitch angle for player @a consoleNum. - * - * @param consoleNum Console number. - * - * @note Part of the Doomsday public API. - */ -void R_SetViewPitch(int consoleNum, float pitch); - -int R_ViewWindowGeometry(int consoleNum, RectRaw *geometry); -int R_ViewWindowOrigin(int consoleNum, Point2Raw *origin); -int R_ViewWindowSize(int consoleNum, Size2Raw *size); - -void R_SetViewWindowGeometry(int consoleNum, RectRaw const *geometry, boolean interpolate); - /** * Animates the view window towards the target values. */ void R_ViewWindowTicker(int consoleNum, timespan_t ticLength); -int R_ViewPortGeometry(int consoleNum, RectRaw *geometry); -int R_ViewPortOrigin(int consoleNum, Point2Raw *origin); -int R_ViewPortSize(int consoleNum, Size2Raw *size); - void R_SetViewPortPlayer(int consoleNum, int viewPlayer); void R_LoadSystemFonts(void); @@ -213,13 +171,6 @@ char const *R_ChooseVariableFont(fontstyle_t style, int resX, int resY); */ void Rend_CacheForMap(void); -/** - * Prepare all texture resources for the specified mobjtype. - * - * @note Part of the Doomsday public API. - */ -void Rend_CacheForMobjType(int mobjtypeNum); - #ifdef __cplusplus } // extern "C" #endif diff --git a/doomsday/engine/include/render/r_things.h b/doomsday/engine/include/render/r_things.h index 93acb3a82f..2e86485936 100644 --- a/doomsday/engine/include/render/r_things.h +++ b/doomsday/engine/include/render/r_things.h @@ -210,8 +210,6 @@ extern "C" { material_t *R_GetMaterialForSprite(int sprite, int frame); -boolean R_GetSpriteInfo(int sprite, int frame, spriteinfo_t *sprinfo); - /// @return Radius of the mobj as it would visually appear to be. coord_t R_VisualRadius(struct mobj_s *mo); diff --git a/doomsday/engine/include/render/sky.h b/doomsday/engine/include/render/sky.h index b488fd725d..bdd4894d15 100644 --- a/doomsday/engine/include/render/sky.h +++ b/doomsday/engine/include/render/sky.h @@ -124,11 +124,6 @@ void Sky_LayerSetOffset(int layerId, float offset); /// Render the current sky. void Sky_Render(void); -/** - * Alternative interface for manipulating Sky (layer) properties by name/id. - */ -void R_SkyParams(int layer, int param, void *data); - #ifdef __cplusplus } // extern "C" #endif diff --git a/doomsday/engine/include/resource/models.h b/doomsday/engine/include/resource/models.h index c43fc0ce96..dd8fe41863 100644 --- a/doomsday/engine/include/resource/models.h +++ b/doomsday/engine/include/resource/models.h @@ -174,8 +174,6 @@ void Models_Cache(modeldef_t* modef); */ int Models_CacheForMobj(thinker_t* th, void* context); -void Models_CacheForState(int stateIndex); - #endif // __CLIENT__ #ifdef __cplusplus diff --git a/doomsday/engine/api/resourceclass.h b/doomsday/engine/include/resourceclass.h similarity index 84% rename from doomsday/engine/api/resourceclass.h rename to doomsday/engine/include/resourceclass.h index 4de4f36d2e..a53bc96e62 100644 --- a/doomsday/engine/api/resourceclass.h +++ b/doomsday/engine/include/resourceclass.h @@ -24,36 +24,7 @@ #ifndef LIBDENG_RESOURCECLASS_H #define LIBDENG_RESOURCECLASS_H -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Resource Class Identifier. - * - * @ingroup base - * - * @todo Refactor away. These identifiers are no longer needed. - */ -typedef enum resourceclassid_e { - RC_NULL = -2, ///< Not a real class. - RC_UNKNOWN = -1, ///< Attempt to guess the class through evaluation of the path. - RESOURCECLASS_FIRST = 0, - RC_PACKAGE = RESOURCECLASS_FIRST, - RC_DEFINITION, - RC_GRAPHIC, - RC_MODEL, - RC_SOUND, - RC_MUSIC, - RC_FONT, - RESOURCECLASS_COUNT -} resourceclassid_t; - -#define VALID_RESOURCECLASSID(n) ((n) >= RESOURCECLASS_FIRST && (n) < RESOURCECLASS_COUNT) - -#ifdef __cplusplus -} // extern "C" -#endif +#include "api_resourceclass.h" #ifdef __cplusplus #ifndef DENG2_C_API_ONLY diff --git a/doomsday/engine/src/edit_bias.c b/doomsday/engine/src/edit_bias.c index 4c01eb1963..5958044ff4 100644 --- a/doomsday/engine/src/edit_bias.c +++ b/doomsday/engine/src/edit_bias.c @@ -33,6 +33,7 @@ #include "de_filesys.h" #include +#include D_CMD(BLEditor); @@ -182,7 +183,7 @@ static void SBE_GetHueColor(float* color, float* angle, float* sat) if(angle) *angle = 0; if(sat) *sat = 0; - R_HSVToRGB(color, 0, 0, 1); + M_HSVToRGB(color, 0, 0, 1); return; } @@ -211,7 +212,7 @@ static void SBE_GetHueColor(float* color, float* angle, float* sat) if(angle) *angle = hue; - R_HSVToRGB(color, hue, saturation, 1); + M_HSVToRGB(color, hue, saturation, 1); } void SBE_EndFrame(void) @@ -985,7 +986,7 @@ static void SBE_DrawHue(void) angle = 2*PI * i/steps; // Calculate the hue color for this angle. - R_HSVToRGB(color, i/steps, 1, 1); + M_HSVToRGB(color, i/steps, 1, 1); color[3] = .5f; SBE_HueOffset(angle, off); @@ -1027,7 +1028,7 @@ static void SBE_DrawHue(void) SBE_HueOffset(2*PI * (i + 1)/steps, off2); // Calculate the hue color for this angle. - R_HSVToRGB(color, i/steps, 1, 1); + M_HSVToRGB(color, i/steps, 1, 1); color[3] = 1; glColor4fv(color); diff --git a/doomsday/engine/src/gl/gl_draw.c b/doomsday/engine/src/gl/gl_draw.c index a55bb00eff..3e8fbd3476 100644 --- a/doomsday/engine/src/gl/gl_draw.c +++ b/doomsday/engine/src/gl/gl_draw.c @@ -40,6 +40,7 @@ #include "de_play.h" #include "gl/sys_opengl.h" +#include "api_render.h" // MACROS ------------------------------------------------------------------ diff --git a/doomsday/engine/src/gl/gl_main.cpp b/doomsday/engine/src/gl/gl_main.cpp index cb58d97a53..0400bafb90 100644 --- a/doomsday/engine/src/gl/gl_main.cpp +++ b/doomsday/engine/src/gl/gl_main.cpp @@ -41,6 +41,7 @@ #include "resource/materialvariant.h" #include "resource/texturevariant.h" #include "ui/displaymode.h" +#include "api_render.h" D_CMD(Fog); D_CMD(SetBPP); diff --git a/doomsday/engine/src/library.cpp b/doomsday/engine/src/library.cpp index b4515f650a..410b0be832 100644 --- a/doomsday/engine/src/library.cpp +++ b/doomsday/engine/src/library.cpp @@ -40,6 +40,7 @@ #include "api_svg.h" #ifdef __CLIENT__ # include "api_client.h" +# include "api_render.h" #endif #ifdef __SERVER__ # include "api_server.h" @@ -207,6 +208,7 @@ void Library_PublishAPIs(Library *lib) PUBLISH(_api_Client); PUBLISH(_api_FR); PUBLISH(_api_GL); + PUBLISH(_api_Rend); PUBLISH(_api_Svg); #endif diff --git a/doomsday/engine/src/map/r_world.cpp b/doomsday/engine/src/map/r_world.cpp index 32ebe2355f..e0df058bb4 100644 --- a/doomsday/engine/src/map/r_world.cpp +++ b/doomsday/engine/src/map/r_world.cpp @@ -801,8 +801,8 @@ lineowner_t *R_GetVtxLineOwner(Vertex const *v, LineDef const *line) return 0; } -/// @note Part of the Doomsday public API. -void R_SetupFog(float start, float end, float density, float *rgb) +#undef R_SetupFog +DENG_EXTERN_C void R_SetupFog(float start, float end, float density, float *rgb) { Con_Execute(CMDS_DDAY, "fog on", true, false); Con_Executef(CMDS_DDAY, true, "fog start %f", start); @@ -812,8 +812,8 @@ void R_SetupFog(float start, float end, float density, float *rgb) rgb[0] * 255, rgb[1] * 255, rgb[2] * 255); } -/// @note Part of the Doomsday public API. -void R_SetupFogDefaults() +#undef R_SetupFogDefaults +DENG_EXTERN_C void R_SetupFogDefaults() { // Go with the defaults. Con_Execute(CMDS_DDAY,"fog off", true, false); @@ -1311,7 +1311,8 @@ void R_MapInitSurfaceLists() } } -void R_SetupMap(int mode, int flags) +#undef R_SetupMap +DENG_EXTERN_C void R_SetupMap(int mode, int flags) { DENG_UNUSED(flags); diff --git a/doomsday/engine/src/r_util.c b/doomsday/engine/src/r_util.c index ee9e4628b0..0eca5ca78f 100644 --- a/doomsday/engine/src/r_util.c +++ b/doomsday/engine/src/r_util.c @@ -211,74 +211,6 @@ void R_ScaleAmbientRGB(float *out, const float *in, float mul) } } -/** - * Conversion from HSV to RGB. Everything is [0,1]. - */ -void R_HSVToRGB(float* rgb, float h, float s, float v) -{ - int i; - float f, p, q, t; - - if(!rgb) - return; - - if(s == 0) - { - // achromatic (grey) - rgb[0] = rgb[1] = rgb[2] = v; - return; - } - - if(h >= 1) - h -= 1; - - h *= 6; // sector 0 to 5 - i = floor(h); - f = h - i; // factorial part of h - p = v * (1 - s); - q = v * (1 - s * f); - t = v * (1 - s * (1 - f)); - - switch(i) - { - case 0: - rgb[0] = v; - rgb[1] = t; - rgb[2] = p; - break; - - case 1: - rgb[0] = q; - rgb[1] = v; - rgb[2] = p; - break; - - case 2: - rgb[0] = p; - rgb[1] = v; - rgb[2] = t; - break; - - case 3: - rgb[0] = p; - rgb[1] = q; - rgb[2] = v; - break; - - case 4: - rgb[0] = t; - rgb[1] = p; - rgb[2] = v; - break; - - default: - rgb[0] = v; - rgb[1] = p; - rgb[2] = q; - break; - } -} - boolean R_GenerateTexCoords(pvec2f_t s, pvec2f_t t, const_pvec3d_t point, float xScale, float yScale, const_pvec3d_t v1, const_pvec3d_t v2, const_pvec3f_t tangent, const_pvec3f_t bitangent) { @@ -303,8 +235,8 @@ boolean R_GenerateTexCoords(pvec2f_t s, pvec2f_t t, const_pvec3d_t point, float return true; } -/// @note Part of the Doomsday public API. -boolean R_ChooseAlignModeAndScaleFactor(float* scale, int width, int height, +#undef R_ChooseAlignModeAndScaleFactor +DENG_EXTERN_C boolean R_ChooseAlignModeAndScaleFactor(float* scale, int width, int height, int availWidth, int availHeight, scalemode_t scaleMode) { if(SCALEMODE_STRETCH == scaleMode) @@ -345,8 +277,8 @@ boolean R_ChooseAlignModeAndScaleFactor(float* scale, int width, int height, } } -/// @note Part of the Doomsday public API. -scalemode_t R_ChooseScaleMode2(int width, int height, int availWidth, int availHeight, +#undef R_ChooseScaleMode2 +DENG_EXTERN_C scalemode_t R_ChooseScaleMode2(int width, int height, int availWidth, int availHeight, scalemode_t overrideMode, float stretchEpsilon) { const float availRatio = (float)availWidth / availHeight; @@ -363,8 +295,8 @@ scalemode_t R_ChooseScaleMode2(int width, int height, int availWidth, int availH return INRANGE_OF(availRatio, origRatio, stretchEpsilon)? SCALEMODE_STRETCH : SCALEMODE_NO_STRETCH; } -/// @note Part of the Doomsday public API. -scalemode_t R_ChooseScaleMode(int width, int height, int availWidth, int availHeight, +#undef R_ChooseScaleMode +DENG_EXTERN_C scalemode_t R_ChooseScaleMode(int width, int height, int availWidth, int availHeight, scalemode_t overrideMode) { return R_ChooseScaleMode2(availWidth, availHeight, width, height, overrideMode, diff --git a/doomsday/engine/src/render/api_render.c b/doomsday/engine/src/render/api_render.c new file mode 100644 index 0000000000..de6f308fe2 --- /dev/null +++ b/doomsday/engine/src/render/api_render.c @@ -0,0 +1,71 @@ +#define DENG_NO_API_MACROS_RENDER +#include "api_render.h" + +// m_misc.c +DENG_EXTERN_C int M_ScreenShot(const char* name, int bits); + +// models.cpp +DENG_EXTERN_C void Models_CacheForState(int stateIndex); + +// r_draw.cpp +DENG_EXTERN_C void R_SetBorderGfx(struct uri_s const *const *paths); + +// r_main.cpp +DENG_EXTERN_C void Rend_CacheForMobjType(int mobjtypeNum); +DENG_EXTERN_C void R_RenderPlayerView(int num); +DENG_EXTERN_C void R_SetViewOrigin(int consoleNum, coord_t const origin[3]); +DENG_EXTERN_C void R_SetViewAngle(int consoleNum, angle_t angle); +DENG_EXTERN_C void R_SetViewPitch(int consoleNum, float pitch); +DENG_EXTERN_C int R_ViewWindowGeometry(int consoleNum, RectRaw *geometry); +DENG_EXTERN_C int R_ViewWindowOrigin(int consoleNum, Point2Raw *origin); +DENG_EXTERN_C int R_ViewWindowSize(int consoleNum, Size2Raw *size); +DENG_EXTERN_C void R_SetViewWindowGeometry(int consoleNum, RectRaw const *geometry, boolean interpolate); +DENG_EXTERN_C int R_ViewPortGeometry(int consoleNum, RectRaw *geometry); +DENG_EXTERN_C int R_ViewPortOrigin(int consoleNum, Point2Raw *origin); +DENG_EXTERN_C int R_ViewPortSize(int consoleNum, Size2Raw *size); +DENG_EXTERN_C void R_SetViewPortPlayer(int consoleNum, int viewPlayer); + +// sky.cpp +DENG_EXTERN_C void R_SkyParams(int layer, int param, void *data); + +// r_things.cpp +DENG_EXTERN_C boolean R_GetSpriteInfo(int sprite, int frame, spriteinfo_t *sprinfo); + +// r_util.c +DENG_EXTERN_C boolean R_ChooseAlignModeAndScaleFactor(float* scale, int width, int height, int availWidth, int availHeight, scalemode_t scaleMode); +DENG_EXTERN_C scalemode_t R_ChooseScaleMode2(int width, int height, int availWidth, int availHeight, scalemode_t overrideMode, float stretchEpsilon); +DENG_EXTERN_C scalemode_t R_ChooseScaleMode(int width, int height, int availWidth, int availHeight, scalemode_t overrideMode); + +// r_world.cpp +DENG_EXTERN_C void R_SetupMap(int mode, int flags); +DENG_EXTERN_C void R_SetupFogDefaults(void); +DENG_EXTERN_C void R_SetupFog(float start, float end, float density, float* rgb); + +DENG_DECLARE_API(Rend) = +{ + { DE_API_RENDER }, + R_SetupMap, + R_SetupFogDefaults, + R_SetupFog, + Rend_CacheForMobjType, + Models_CacheForState, + R_RenderPlayerView, + R_SetViewOrigin, + R_SetViewAngle, + R_SetViewPitch, + R_ViewWindowGeometry, + R_ViewWindowOrigin, + R_ViewWindowSize, + R_SetViewWindowGeometry, + R_SetBorderGfx, + R_ViewPortGeometry, + R_ViewPortOrigin, + R_ViewPortSize, + R_SetViewPortPlayer, + R_ChooseAlignModeAndScaleFactor, + R_ChooseScaleMode2, + R_ChooseScaleMode, + R_GetSpriteInfo, + R_SkyParams, + M_ScreenShot +}; diff --git a/doomsday/engine/src/render/r_draw.cpp b/doomsday/engine/src/render/r_draw.cpp index a14d71f76e..0ca223dfb9 100644 --- a/doomsday/engine/src/render/r_draw.cpp +++ b/doomsday/engine/src/render/r_draw.cpp @@ -65,7 +65,8 @@ static void loadViewBorderPatches() borderSize = info.geometry.size.height; } -void R_SetBorderGfx(struct uri_s const *const *paths) +#undef R_SetBorderGfx +DENG_EXTERN_C void R_SetBorderGfx(struct uri_s const *const *paths) { DENG_ASSERT(inited); if(!paths) Con_Error("R_SetBorderGfx: Missing argument."); diff --git a/doomsday/engine/src/render/r_main.cpp b/doomsday/engine/src/render/r_main.cpp index b97304a2ba..727cb70227 100644 --- a/doomsday/engine/src/render/r_main.cpp +++ b/doomsday/engine/src/render/r_main.cpp @@ -36,6 +36,7 @@ #include "gl/svg.h" #include "map/p_players.h" #include "render/vignette.h" +#include "api_render.h" using namespace de; @@ -193,22 +194,22 @@ void R_LoadSystemFonts() #endif } -/// @note Part of the Doomsday public API. -void R_SetViewOrigin(int consoleNum, coord_t const origin[3]) +#undef R_SetViewOrigin +DENG_EXTERN_C void R_SetViewOrigin(int consoleNum, coord_t const origin[3]) { if(consoleNum < 0 || consoleNum >= DDMAXPLAYERS) return; V3d_Copy(viewDataOfConsole[consoleNum].latest.origin, origin); } -/// @note Part of the Doomsday public API. -void R_SetViewAngle(int consoleNum, angle_t angle) +#undef R_SetViewAngle +DENG_EXTERN_C void R_SetViewAngle(int consoleNum, angle_t angle) { if(consoleNum < 0 || consoleNum >= DDMAXPLAYERS) return; viewDataOfConsole[consoleNum].latest.angle = angle; } -/// @note Part of the Doomsday public API. -void R_SetViewPitch(int consoleNum, float pitch) +#undef R_SetViewPitch +DENG_EXTERN_C void R_SetViewPitch(int consoleNum, float pitch) { if(consoleNum < 0 || consoleNum >= DDMAXPLAYERS) return; viewDataOfConsole[consoleNum].latest.pitch = pitch; @@ -253,8 +254,8 @@ void R_ViewWindowTicker(int consoleNum, timespan_t ticLength) #undef LERP } -/// @note Part of the Doomsday public API. -int R_ViewWindowGeometry(int player, RectRaw *geometry) +#undef R_ViewWindowGeometry +DENG_EXTERN_C int R_ViewWindowGeometry(int player, RectRaw *geometry) { if(!geometry) return false; if(player < 0 || player >= DDMAXPLAYERS) return false; @@ -264,8 +265,8 @@ int R_ViewWindowGeometry(int player, RectRaw *geometry) return true; } -/// @note Part of the Doomsday public API. -int R_ViewWindowOrigin(int player, Point2Raw *origin) +#undef R_ViewWindowOrigin +DENG_EXTERN_C int R_ViewWindowOrigin(int player, Point2Raw *origin) { if(!origin) return false; if(player < 0 || player >= DDMAXPLAYERS) return false; @@ -275,8 +276,8 @@ int R_ViewWindowOrigin(int player, Point2Raw *origin) return true; } -/// @note Part of the Doomsday public API. -int R_ViewWindowSize(int player, Size2Raw* size) +#undef R_ViewWindowSize +DENG_EXTERN_C int R_ViewWindowSize(int player, Size2Raw* size) { if(!size) return false; if(player < 0 || player >= DDMAXPLAYERS) return false; @@ -290,10 +291,9 @@ int R_ViewWindowSize(int player, Size2Raw* size) * @note Do not change values used during refresh here because we might be * partway through rendering a frame. Changes should take effect on next * refresh only. - * - * @note Part of the Doomsday public API. */ -void R_SetViewWindowGeometry(int player, RectRaw const *geometry, boolean interpolate) +#undef R_SetViewWindowGeometry +DENG_EXTERN_C void R_SetViewWindowGeometry(int player, RectRaw const *geometry, boolean interpolate) { int p = P_ConsoleToLocal(player); if(p < 0) return; @@ -336,8 +336,8 @@ void R_SetViewWindowGeometry(int player, RectRaw const *geometry, boolean interp } } -/// @note Part of the Doomsday public API. -int R_ViewPortGeometry(int player, RectRaw *geometry) +#undef R_ViewPortGeometry +DENG_EXTERN_C int R_ViewPortGeometry(int player, RectRaw *geometry) { if(!geometry) return false; @@ -349,8 +349,8 @@ int R_ViewPortGeometry(int player, RectRaw *geometry) return true; } -/// @note Part of the Doomsday public API. -int R_ViewPortOrigin(int player, Point2Raw *origin) +#undef R_ViewPortOrigin +DENG_EXTERN_C int R_ViewPortOrigin(int player, Point2Raw *origin) { if(!origin) return false; @@ -362,8 +362,8 @@ int R_ViewPortOrigin(int player, Point2Raw *origin) return true; } -/// @note Part of the Doomsday public API. -int R_ViewPortSize(int player, Size2Raw *size) +#undef R_ViewPortSize +DENG_EXTERN_C int R_ViewPortSize(int player, Size2Raw *size) { if(!size) return false; @@ -375,8 +375,8 @@ int R_ViewPortSize(int player, Size2Raw *size) return true; } -/// @note Part of the Doomsday public API. -void R_SetViewPortPlayer(int consoleNum, int viewPlayer) +#undef R_SetViewPortPlayer +DENG_EXTERN_C void R_SetViewPortPlayer(int consoleNum, int viewPlayer) { int p = P_ConsoleToLocal(consoleNum); if(p != -1) @@ -1016,7 +1016,8 @@ void R_SetupFrame(player_t *player) #ifdef __CLIENT__ void R_RenderPlayerViewBorder() -{ R_DrawViewBorder(); +{ + R_DrawViewBorder(); } void R_UseViewPort(viewport_t *vp) @@ -1051,7 +1052,8 @@ void R_RenderBlankView() UI_DrawDDBackground(&origin, &size, 1); } -void R_RenderPlayerView(int num) +#undef R_RenderPlayerView +DENG_EXTERN_C void R_RenderPlayerView(int num) { if(num < 0 || num >= DDMAXPLAYERS) return; // Huh? player_t *player = &ddPlayers[num]; @@ -1312,8 +1314,8 @@ static void cacheSpritesForState(int stateIndex, materialvariantspecification_t #ifdef __CLIENT__ -/// @note Part of the Doomsday public API. -void Rend_CacheForMobjType(int num) +#undef Rend_CacheForMobjType +DENG_EXTERN_C void Rend_CacheForMobjType(int num) { if(novideo || !((useModels && precacheSkins) || precacheSprites)) return; if(num < 0 || num >= defs.count.mobjs.num) return; diff --git a/doomsday/engine/src/render/r_things.cpp b/doomsday/engine/src/render/r_things.cpp index 38167c6e11..2944c9edec 100644 --- a/doomsday/engine/src/render/r_things.cpp +++ b/doomsday/engine/src/render/r_things.cpp @@ -423,7 +423,8 @@ material_t *R_GetMaterialForSprite(int sprite, int frame) return NULL; } -boolean R_GetSpriteInfo(int sprite, int frame, spriteinfo_t *info) +#undef R_GetSpriteInfo +DENG_EXTERN_C boolean R_GetSpriteInfo(int sprite, int frame, spriteinfo_t *info) { LOG_AS("R_GetSpriteInfo"); diff --git a/doomsday/engine/src/render/sky.cpp b/doomsday/engine/src/render/sky.cpp index 2a5e544a17..f3ea5d3f3b 100644 --- a/doomsday/engine/src/render/sky.cpp +++ b/doomsday/engine/src/render/sky.cpp @@ -611,7 +611,8 @@ static void internalSkyParams(int layer, int param, void *data) } } -void R_SkyParams(int layer, int param, void *data) +#undef R_SkyParams +DENG_EXTERN_C void R_SkyParams(int layer, int param, void *data) { if(layer == DD_SKY) // The whole sky? { diff --git a/doomsday/engine/src/resource/models.cpp b/doomsday/engine/src/resource/models.cpp index 12d0e02761..25d212ed81 100644 --- a/doomsday/engine/src/resource/models.cpp +++ b/doomsday/engine/src/resource/models.cpp @@ -1428,7 +1428,8 @@ void Models_Cache(modeldef_t* modef) } } -void Models_CacheForState(int stateIndex) +#undef Models_CacheForState +DENG_EXTERN_C void Models_CacheForState(int stateIndex) { if(!useModels) return; if(stateIndex <= 0 || stateIndex >= defs.count.states.num) return; diff --git a/doomsday/engine/src/ui/finaleinterpreter.c b/doomsday/engine/src/ui/finaleinterpreter.c index becfd641df..4c2aad6038 100644 --- a/doomsday/engine/src/ui/finaleinterpreter.c +++ b/doomsday/engine/src/ui/finaleinterpreter.c @@ -40,6 +40,7 @@ #include "de_resource.h" #include "api_material.h" +#include "api_render.h" #include "gl/sys_opengl.h" // TODO: get rid of this @@ -1698,10 +1699,11 @@ DEFFC(StateAnim) for(; count > 0 && stateId > 0; count--) { state_t* st = &states[stateId]; +#ifdef __CLIENT__ spriteinfo_t sinf; - R_GetSpriteInfo(st->sprite, st->frame & 0x7fff, &sinf); FIData_PicAppendFrame(obj, PFT_MATERIAL, (st->tics <= 0? 1 : st->tics), sinf.material, 0, sinf.flip); +#endif // Go to the next state. stateId = st->nextState; diff --git a/doomsday/libdeng/include/de/mathutil.h b/doomsday/libdeng/include/de/mathutil.h index ec56e6be9c..316f34f5b3 100644 --- a/doomsday/libdeng/include/de/mathutil.h +++ b/doomsday/libdeng/include/de/mathutil.h @@ -151,6 +151,11 @@ DENG_PUBLIC int Divline_PointXYOnSide(Divline const *line, coord_t x, coord_t y) */ DENG_PUBLIC fixed_t Divline_Intersection(Divline const *v1, Divline const *v2); +/** + * Conversion from HSV to RGB. All components are [0,1]. + */ +DENG_PUBLIC void M_HSVToRGB(float* rgb, float h, float s, float v); + // Bounding boxes: DENG_PUBLIC void M_ClearBox(fixed_t* box); DENG_PUBLIC void M_CopyBox(fixed_t dest[4], const fixed_t src[4]); diff --git a/doomsday/libdeng/src/mathutil.c b/doomsday/libdeng/src/mathutil.c index a405ab2257..3ba91af440 100644 --- a/doomsday/libdeng/src/mathutil.c +++ b/doomsday/libdeng/src/mathutil.c @@ -2122,3 +2122,68 @@ fixed_t Divline_Intersection(Divline const *v1, Divline const *v2) { return V2x_Intersection(v1->origin, v1->direction, v2->origin, v2->direction); } + +void M_HSVToRGB(float* rgb, float h, float s, float v) +{ + int i; + float f, p, q, t; + + if(!rgb) + return; + + if(s == 0) + { + // achromatic (grey) + rgb[0] = rgb[1] = rgb[2] = v; + return; + } + + if(h >= 1) + h -= 1; + + h *= 6; // sector 0 to 5 + i = floor(h); + f = h - i; // factorial part of h + p = v * (1 - s); + q = v * (1 - s * f); + t = v * (1 - s * (1 - f)); + + switch(i) + { + case 0: + rgb[0] = v; + rgb[1] = t; + rgb[2] = p; + break; + + case 1: + rgb[0] = q; + rgb[1] = v; + rgb[2] = p; + break; + + case 2: + rgb[0] = p; + rgb[1] = v; + rgb[2] = t; + break; + + case 3: + rgb[0] = p; + rgb[1] = q; + rgb[2] = v; + break; + + case 4: + rgb[0] = t; + rgb[1] = p; + rgb[2] = v; + break; + + default: + rgb[0] = v; + rgb[1] = p; + rgb[2] = q; + break; + } +} diff --git a/doomsday/plugins/common/src/x_hair.c b/doomsday/plugins/common/src/x_hair.c index 1b2625cb93..bb16827660 100644 --- a/doomsday/plugins/common/src/x_hair.c +++ b/doomsday/plugins/common/src/x_hair.c @@ -53,7 +53,7 @@ static boolean currentColor(player_t* player, float color[3]) #define HUE_DEAD 0.f #define HUE_LIVE .3f - R_HSVToRGB(color, HUE_DEAD + + M_HSVToRGB(color, HUE_DEAD + (HUE_LIVE - HUE_DEAD) * MINMAX_OF(0, (float) player->plr->mo->health / maxHealth, 1), 1, 1); diff --git a/doomsday/plugins/jdoom/include/d_api.h b/doomsday/plugins/jdoom/include/d_api.h index c8bd7bea21..a7b5be6e4b 100644 --- a/doomsday/plugins/jdoom/include/d_api.h +++ b/doomsday/plugins/jdoom/include/d_api.h @@ -59,6 +59,7 @@ DENG_USING_API(MaterialArchive); DENG_USING_API(MPE); DENG_USING_API(Player); DENG_USING_API(Plug); +DENG_USING_API(Rend); DENG_USING_API(S); DENG_USING_API(Server); DENG_USING_API(Svg); diff --git a/doomsday/plugins/jdoom/src/d_api.c b/doomsday/plugins/jdoom/src/d_api.c index d8a5807b40..0a0893a9ca 100644 --- a/doomsday/plugins/jdoom/src/d_api.c +++ b/doomsday/plugins/jdoom/src/d_api.c @@ -295,6 +295,7 @@ DENG_DECLARE_API(Map); DENG_DECLARE_API(MPE); DENG_DECLARE_API(Player); DENG_DECLARE_API(Plug); +DENG_DECLARE_API(Rend); DENG_DECLARE_API(S); DENG_DECLARE_API(Server); DENG_DECLARE_API(Svg); @@ -319,6 +320,7 @@ DENG_API_EXCHANGE( DENG_GET_API(DE_API_MAP_EDIT, MPE); DENG_GET_API(DE_API_PLAYER, Player); DENG_GET_API(DE_API_PLUGIN, Plug); + DENG_GET_API(DE_API_RENDER, Rend); DENG_GET_API(DE_API_SOUND, S); DENG_GET_API(DE_API_SERVER, Server); DENG_GET_API(DE_API_SVG, Svg); diff --git a/doomsday/server/server.pro b/doomsday/server/server.pro index 88cc71da30..d80e5feb76 100644 --- a/doomsday/server/server.pro +++ b/doomsday/server/server.pro @@ -89,6 +89,8 @@ DENG_API_HEADERS = \ $$SRC/api/api_mapedit.h \ $$SRC/api/api_player.h \ $$SRC/api/api_plugin.h \ + $$SRC/api/api_render.h \ + $$SRC/api/api_resourceclass.h \ $$SRC/api/api_server.h \ $$SRC/api/api_sound.h \ $$SRC/api/api_svg.h \ @@ -102,10 +104,7 @@ DENG_API_HEADERS = \ $$SRC/api/dd_version.h \ $$SRC/api/def_share.h \ $$SRC/api/dengproject.h \ - $$SRC/api/doomsday.h \ - $$SRC/api/filehandle.h \ - $$SRC/api/filetype.h \ - $$SRC/api/resourceclass.h + $$SRC/api/doomsday.h # Convenience headers. DENG_HEADERS += \ @@ -156,6 +155,7 @@ DENG_HEADERS += \ $$SRC/include/dualstring.h \ $$SRC/include/edit_bsp.h \ $$SRC/include/edit_map.h \ + $$SRC/include/filehandle.h \ $$SRC/include/filesys/file.h \ $$SRC/include/filesys/filehandlebuilder.h \ $$SRC/include/filesys/fileinfo.h \ @@ -165,6 +165,7 @@ DENG_HEADERS += \ $$SRC/include/filesys/manifest.h \ $$SRC/include/filesys/searchpath.h \ $$SRC/include/filesys/sys_direc.h \ + $$SRC/include/filetype.h \ $$SRC/include/game.h \ $$SRC/include/gl/gl_texmanager.h \ $$SRC/include/gridmap.h \ @@ -253,6 +254,7 @@ DENG_HEADERS += \ $$SRC/include/resource/tga.h \ $$SRC/include/resource/wad.h \ $$SRC/include/resource/zip.h \ + $$SRC/include/resourceclass.h \ $$SRC/include/server/sv_def.h \ $$SRC/include/server/sv_frame.h \ $$SRC/include/server/sv_infine.h \