Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added public API for Rend (renderer) module
Moved R_HSVToRGB() to libdeng1, and split "resourceclass.h" into
internal and public parts.
  • Loading branch information
skyjake committed Jan 4, 2013
1 parent 4cffa77 commit bd814ed
Show file tree
Hide file tree
Showing 40 changed files with 426 additions and 378 deletions.
2 changes: 1 addition & 1 deletion doomsday/engine/api/api_base.h
Expand Up @@ -23,7 +23,7 @@

#include "apis.h"
#include "api_uri.h"
#include "resourceclass.h"
#include "api_resourceclass.h"

/// @addtogroup game
/// @{
Expand Down
160 changes: 160 additions & 0 deletions 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
27 changes: 27 additions & 0 deletions 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
2 changes: 1 addition & 1 deletion doomsday/engine/api/api_uri.h
Expand Up @@ -24,7 +24,7 @@
#define LIBDENG_API_URI_H

#include "api_base.h"
#include "resourceclass.h"
#include "api_resourceclass.h"
#include <de/str.h>
#include <de/reader.h>
#include <de/writer.h>
Expand Down
18 changes: 12 additions & 6 deletions doomsday/engine/api/apis.h
Expand Up @@ -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
};

Expand Down
2 changes: 0 additions & 2 deletions doomsday/engine/api/dd_types.h
Expand Up @@ -79,8 +79,6 @@ struct material_s;

#include <de/str.h>
#include <de/fixedpoint.h>
#include "resourceclass.h"
#include "filetype.h"
#include "api_uri.h"

#endif /* ENGINE_TYPES_H */
99 changes: 2 additions & 97 deletions doomsday/engine/api/doomsday.h
Expand Up @@ -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 <de/memoryzone.h>
#include <de/point.h>
#include <de/reader.h>
Expand Down Expand Up @@ -115,12 +115,6 @@ typedef struct material_s { int type; } material_t;
extern "C" {
#endif

//------------------------------------------------------------------------
//
// Base.
//
//------------------------------------------------------------------------

/**
* @defgroup base Base
*/
Expand All @@ -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
Expand All @@ -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);
Expand All @@ -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"
Expand Down

0 comments on commit bd814ed

Please sign in to comment.