15struct IDirect3DRMDevice2;
16struct IDirect3DRMViewport;
17struct IDirect3DRMFrame2;
18struct IDirect3DRMMesh;
19struct IDirect3DRMMeshBuilder;
20struct IDirect3DRMTexture;
150 int pTexelsArePersistent,
151 int paletteEntryCount,
182 return m_data->CreateTextureFromSurface(pSurface, pTexture2);
234 unsigned long height,
269 int texelsArePersistent,
270 int paletteEntryCount,
299 int refCount = pRenderer->Release();
494 Result SetFrustrum(
float frontClippingDistance,
float backClippingDistance,
float degrees)
override;
531 Result ForceUpdate(
unsigned long x,
unsigned long y,
unsigned long width,
unsigned long height)
override;
560 const Group** ppGroupsToPickFrom,
561 int groupsToPickFromCount,
562 const Group**& rppPickedGroups,
563 int& rPickedGroupCount
629 int groupsToPickFromCount,
630 const Group**& rppPickedGroups,
631 int& rPickedGroupCount
1108 unsigned long faceCount,
1109 unsigned long vertexCount,
1110 float (*pPositions)[3],
1111 float (*pNormals)[3],
1112 float (*pTextureCoordinates)[2],
1113 unsigned long (*pFaceIndices)[3],
1114 unsigned long (*pTextureIndices)[3],
1166 inline Result CreateMeshImpl(
1168 unsigned long faceCount,
1169 unsigned long vertexCount,
1170 float (*pPositions)[3],
1171 float (*pNormals)[3],
1172 float (*pTextureCoordinates)[2],
1173 unsigned long (*pFaceIndices)[3],
1174 unsigned long (*pTextureIndices)[3],
1188 pMeshBuilder->Release();
1289 Result SetTexels(
int width,
int height,
int bitsPerTexel,
void* pTexels)
override;
1305 Result Changed(
int texelsChanged,
int paletteChanged)
override;
1376 pTexture->Release();
1402 switch (tglShadingModel) {
1423 return renderQuality;
1435 switch (tglProjectionType) {
1446 return projectionType;
1460 for (
int i = 0; i < (
sizeof(rD3DRMMatrix4x4) /
sizeof(rD3DRMMatrix4x4[0])); i++) {
1461 for (
int j = 0; j < (
sizeof(rD3DRMMatrix4x4[0]) /
sizeof(rD3DRMMatrix4x4[0][0])); j++) {
1462 rD3DRMMatrix4x4[i][j] =
D3DVAL(tglMatrix4x4[i][j]);
1465 return &rD3DRMMatrix4x4;
1477 rD3DVector.
x =
D3DVAL(tglVector[0]);
1478 rD3DVector.
y =
D3DVAL(tglVector[1]);
1479 rD3DVector.
z =
D3DVAL(tglVector[2]);
1495 switch (tglLightType) {
[AI] Implementation of Tgl::Camera, wraps a Direct3DRMFrame2 and provides transformation management [...
~CameraImpl() override
[AI] Cleans up frame on destruction [AI]
CameraDataType & ImplementationData()
Retrieves camera pointer (mutable) [AI].
Result SetTransformation(FloatMatrix4 &) override
Sets the camera transformation matrix [AI].
void Destroy()
Frees the camera/frame resources [AI].
CameraImpl()
[AI] Initializes frame pointer [AI]
IDirect3DRMFrame2 * CameraDataType
[AI] Internal pointer to Direct3DRMFrame2 [AI]
const CameraDataType & ImplementationData() const
Retrieves camera pointer (const) [AI].
void * ImplementationDataPtr() override
Returns Direct3DRMFrame2 implementation pointer [AI].
[AI] Implements the Tgl::Device interface, encapsulates Direct3DRMDevice2 and provides rendering devi...
DeviceDataType & ImplementationData()
Retrieves the device pointer (mutable) [AI].
void HandleActivate(WORD) override
Handles application/window activation event [AI].
void SetImplementationData(IDirect3DRMDevice2 *device)
Replaces the implementation pointer [AI].
void * ImplementationDataPtr() override
Returns Direct3DRMDevice2 pointer as a generic implementation data pointer [AI].
unsigned long GetHeight() override
Returns the current device height in pixels [AI].
IDirect3DRMDevice2 * DeviceDataType
[AI] Internal data type for device (Direct3DRMDevice2*) [AI]
Result Update() override
Submits any pending updates to the device [AI].
~DeviceImpl() override
[AI] Destructor releases resources [AI]
Result SetDither(int) override
Enables or disables dithering [AI].
void Destroy()
Frees device resources [AI].
const DeviceDataType & ImplementationData() const
Retrieves the device pointer (const) [AI].
void HandlePaint(HDC) override
Handles window paint event [AI].
unsigned long GetWidth() override
Returns the current device width in pixels [AI].
Result SetShadingModel(ShadingModel) override
Sets the shading model (flat, Gouraud, etc.) [AI].
DeviceImpl()
[AI] Initializes device data to null [AI]
Result SetShadeCount(unsigned long) override
Sets number of shades [AI].
Result SetColorModel(ColorModel) override
Sets the color model used for rendering [AI].
[AI] Implementation of Tgl::Group, wraps a Direct3DRMFrame2 and provides scene graph and transformati...
Result SetTransformation(FloatMatrix4 &) override
Sets transformation matrix for group [AI].
GroupDataType & ImplementationData()
Gets internal group/frame pointer, mutable [AI].
Result Add(const Group *) override
Adds a child group [AI].
Result Bounds(D3DVECTOR *p_min, D3DVECTOR *p_max) override
Returns bounding box in world space [AI].
const GroupDataType & ImplementationData() const
Gets internal group/frame pointer, const [AI].
Result GetTexture(Texture *&) override
Gets texture from group [AI].
~GroupImpl() override
[AI] Cleanly releases resources on destruction [AI]
void Destroy()
Frees resources for group, such as child groups and geometry [AI].
Result SetTexture(const Texture *) override
Sets texture for all group geometry [AI].
IDirect3DRMFrame2 * GroupDataType
[AI] Internal pointer to Direct3DRMFrame2 [AI]
Result SetMaterialMode(MaterialMode) override
Sets usage/staging of group as a material [AI].
Result Remove(const Group *) override
Removes a child group [AI].
Result SetColor(float r, float g, float b, float a) override
Sets color and alpha for the group [AI].
GroupImpl()
[AI] Initializes frame/group to null [AI]
Result RemoveAll() override
Removes all contained groups and meshes [AI].
void * ImplementationDataPtr() override
Returns group implementation pointer [AI].
[AI] Implementation of Tgl::Light, wraps a Direct3DRMFrame2 and color data [AI]
Result SetTransformation(FloatMatrix4 &) override
Sets transformation matrix for the light [AI].
Result SetColor(float r, float g, float b) override
Sets color for the light [AI].
void Destroy()
Frees resources for the light [AI].
const LightDataType & ImplementationData() const
Retrieves light pointer (const) [AI].
void * ImplementationDataPtr() override
Returns Direct3DRMFrame2 implementation pointer [AI].
LightDataType & ImplementationData()
Retrieves light pointer (mutable) [AI].
LightImpl()
[AI] Initializes light frame pointer [AI]
~LightImpl() override
[AI] Frees resources on destruction [AI]
IDirect3DRMFrame2 * LightDataType
[AI] Internal pointer to Direct3DRMFrame2 [AI]
[AI] Implements Tgl::MeshBuilder, manages mesh construction and provides the interface for creating g...
Mesh * CreateMesh(unsigned long faceCount, unsigned long vertexCount, float(*pPositions)[3], float(*pNormals)[3], float(*pTextureCoordinates)[2], unsigned long(*pFaceIndices)[3], unsigned long(*pTextureIndices)[3], ShadingModel shadingModel) override
Creates a mesh from arrays of data (positions, normals, etc.) [AI].
Result GetBoundingBox(float min[3], float max[3]) const override
Gets the bounding box of the constructed mesh [AI].
MeshBuilderDataType & ImplementationData()
Gets mesh builder pointer (mutable) [AI].
MeshBuilder * Clone() override
Clones the mesh builder [AI].
const MeshBuilderDataType & ImplementationData() const
Gets mesh builder pointer (const) [AI].
~MeshBuilderImpl() override
[AI] Frees mesh building resources on destruction [AI]
void Destroy()
Frees mesh builder resources [AI].
IDirect3DRMMesh * MeshBuilderDataType
[AI] Internal pointer to Direct3DRMMesh [AI]
void * ImplementationDataPtr() override
Returns mesh builder implementation pointer [AI].
MeshBuilderImpl()
[AI] Initializes mesh builder to null [AI]
[AI] Implementation of Tgl::Mesh, manages a mesh object and geometry data with group index [AI]
Result SetColor(float r, float g, float b, float a) override
Sets the color for this mesh [AI].
Result SetTextureMappingMode(TextureMappingMode) override
Sets the mesh texturing mode (UV/cylindrical/etc.) [AI].
void * ImplementationDataPtr() override
Returns pointer to mesh implementation data [AI].
MeshDataType & ImplementationData()
Gets mesh implementation data (mutable) [AI].
Result GetTexture(Texture *&) override
Retrieves the texture currently assigned to this mesh [AI].
void Destroy()
Frees mesh and associated data [AI].
MeshData * MeshDataType
[AI] Pointer to mesh data struct [AI]
~MeshImpl() override
[AI] Frees resources on destruction [AI]
const MeshDataType & ImplementationData() const
Gets mesh implementation data (const) [AI].
MeshImpl()
[AI] Initializes mesh data pointer [AI]
Mesh * ShallowClone(MeshBuilder *) override
Creates a shallow copy of this mesh using a mesh builder [AI].
Mesh * DeepClone(MeshBuilder *) override
Creates a deep copy of this mesh using a mesh builder [AI].
Result SetTexture(const Texture *) override
Assigns a texture to this mesh [AI].
Result SetShadingModel(ShadingModel) override
Sets mesh shading model (flat, Gouraud, etc.) [AI].
[AI] Implements Tgl::MeshBuilder; facilitates mesh construction [AI]
Device * CreateDevice(const DeviceDirectDrawCreateData &) override
Creates a device from DirectDraw configuration [AI].
Result SetTextureDefaultShadeCount(unsigned long) override
Sets the number of default texture shades used [AI].
Camera * CreateCamera() override
Creates a camera object [AI].
MeshBuilder * CreateMeshBuilder() override
Creates a mesh builder for assembling geometry [AI].
Light * CreateLight(LightType, float r, float g, float b) override
Creates a light source with color and type [AI].
Texture * CreateTexture() override
Creates an empty texture [AI].
IDirect3DRM2 * RendererDataType
[AI] Internal data type for renderer (Direct3DRM2*) [AI]
HRESULT CreateTextureFromSurface(LPDIRECTDRAWSURFACE pSurface, LPDIRECT3DRMTEXTURE2 *pTexture2)
Creates a Direct3DRM texture from a DirectDraw surface [AI].
RendererDataType & ImplementationData()
Retrieves the Direct3DRM2 pointer (mutable) [AI].
void * ImplementationDataPtr() override
Returns implementation-specific data pointer (Direct3DRM2) [AI].
View * CreateView(const Device *, const Camera *, unsigned long x, unsigned long y, unsigned long width, unsigned long height) override
Creates a view using provided device and camera [AI].
~RendererImpl() override
[AI] Destructor ensures Direct3DRM2 resources are freed. [AI]
Group * CreateGroup(const Group *pParent) override
Creates a new group under parent group [AI].
const RendererDataType & ImplementationData() const
Retrieves the Direct3DRM2 pointer (const) [AI].
void Destroy()
Frees Direct3DRM2 resources [AI].
Result SetTextureDefaultColorCount(unsigned long) override
Sets the number of default texture colors used [AI].
Result Create()
Initializes Direct3DRM2 [AI].
RendererImpl()
[AI] Initializes renderer data to null. [AI]
[AI] Implements Tgl::Texture using a Direct3DRMTexture; provides upload and palette control [AI]
void Destroy()
Frees the texture [AI].
static Result SetImage(IDirect3DRMTexture *pSelf, TglD3DRMIMAGE *pImage)
Copies palette/texel data from TglD3DRMIMAGE to Direct3DRMTexture [AI].
TextureDataType & ImplementationData()
Gets Direct3DRMTexture pointer (mutable) [AI].
void FillRowsOfTexture(int y, int height, void *pBuffer) override
Fills rows of the texture [AI].
const TextureDataType & ImplementationData() const
Gets Direct3DRMTexture pointer (const) [AI].
~TextureImpl() override
[AI] Releases on destruction [AI]
void * ImplementationDataPtr() override
Returns implementation pointer for texture [AI].
TextureImpl()
[AI] Initializes texture pointer [AI]
Result GetBufferAndPalette(int *pWidth, int *pHeight, int *pDepth, void **ppBuffer, int *ppPaletteSize, PaletteEntry **ppPalette) override
Returns current buffer and palette [AI].
Result SetPalette(int entryCount, PaletteEntry *entries) override
Sets the palette entries for the texture [AI].
Result Changed(int texelsChanged, int paletteChanged) override
Notifies that texels or palette have changed [AI].
void SetImplementation(IDirect3DRMTexture *pData)
Replaces implementation pointer [AI].
Result SetTexels(int width, int height, int bitsPerTexel, void *pTexels) override
Sets texel data for the texture [AI].
IDirect3DRMTexture * TextureDataType
[AI] Internal type for Direct3DRMTexture pointer [AI]
[AI] Simple wrapper for D3DRMIMAGE; manages pixel buffer and palette for Direct3DRM textures [AI]
void Destroy()
Destroys any buffers/palette managed by the image [AI].
D3DRMIMAGE m_image
[AI] Underlying D3DRM image struct [AI]
Result FillRowsOfTexture(int y, int height, char *content)
Writes pixel rows into texture [AI].
Result InitializePalette(int paletteSize, PaletteEntry *pEntries)
Initializes palette for image [AI].
~TglD3DRMIMAGE()
[AI] Destroys and frees buffer/palette if needed [AI]
int m_texelsAllocatedByClient
[AI] Flag for texel memory ownership (by client) [AI]
Result CreateBuffer(int width, int height, int depth, void *pBuffer, int useBuffer)
Creates or reallocates image buffer as necessary [AI].
[AI] Implementation of Tgl::View backed by Direct3DRMViewport, handles scene rendering,...
Result Add(const Light *) override
Adds a light to this view [AI].
static Result ViewportCreateAppData(IDirect3DRM2 *, IDirect3DRMViewport *, IDirect3DRMFrame2 *)
Associates user app data with a viewport/frame [AI].
void * ImplementationDataPtr() override
Returns Direct3DRMViewport implementation pointer [AI].
Result Render(const Group *) override
Renders the provided scene/group [AI].
Result GetBackgroundColor(float *r, float *g, float *b) override
Gets the background color [AI].
Result SetFrustrum(float frontClippingDistance, float backClippingDistance, float degrees) override
Sets the view frustum parameters [AI].
Result Pick(unsigned long x, unsigned long y, const Group **ppGroupsToPickFrom, int groupsToPickFromCount, const Group **&rppPickedGroups, int &rPickedGroupCount) override
Picks objects in the view by screen coordinate [AI].
const ViewDataType & ImplementationData() const
Gets internal viewport pointer, const [AI].
Result SetBackgroundColor(float r, float g, float b) override
Sets background color [AI].
IDirect3DRMViewport * ViewDataType
[AI] Internal pointer to Direct3DRMViewport [AI]
Result TransformWorldToScreen(const float world[3], float screen[4]) override
Converts a world coordinate to screen space [AI].
Result SetCamera(const Camera *) override
Sets the active camera for this view [AI].
Result Clear() override
Clears the view [AI].
Result ForceUpdate(unsigned long x, unsigned long y, unsigned long width, unsigned long height) override
Forces an update/redraw of specified rectangle [AI].
void SetImplementationData(IDirect3DRMViewport *viewport)
Sets internal viewport pointer [AI].
Result Remove(const Light *) override
Removes a light from this view [AI].
Result SetProjection(ProjectionType) override
Sets the camera projection type (perspective/orthographic) [AI].
ViewDataType & ImplementationData()
Gets internal viewport pointer, mutable [AI].
void Destroy()
Frees viewport resources [AI].
~ViewImpl() override
[AI] Cleans up viewport on destruction [AI]
Result TransformScreenToWorld(const float screen[4], float world[3]) override
Converts screen coordinates to world space [AI].
ViewImpl()
[AI] Initializes viewport pointer [AI]
[AI] Represents a viewpoint in the 3D scene.
[AI] Represents a rendering device/context for the Tgl renderer.
[AI] Scene graph node for parental transforms/color/material/texture; can hold meshes or other groups...
[AI] Represents a source of lighting in the 3D scene.
[AI] Builder class for assembling mesh data and extracting mesh objects.
[AI] Represents a renderable 3D mesh.
[AI] Main interface/factory for rendering resources and scene graphs.
[AI] Represents a GPU or system memory texture for use in rendering.
[AI] Represents a rendering viewport and drawing context.
@ D3DRMLIGHT_PARALLELPOINT
#define D3DRMRENDER_GOURAUD
D3DVALUE D3DRMMATRIX4D[4][4]
@ D3DRMPROJECT_ORTHOGRAPHIC
@ D3DRMPROJECT_PERSPECTIVE
enum _D3DRMLIGHTTYPE D3DRMLIGHTTYPE
#define D3DRMRENDER_WIREFRAME
#define D3DRMRENDER_PHONG
enum _D3DRMPROJECTIONTYPE D3DRMPROJECTIONTYPE
#define D3DRMRENDER_UNLITFLAT
struct IDirectDrawSurface FAR * LPDIRECTDRAWSURFACE
typedef DWORD(FAR PASCAL *LPCLIPPERCALLBACK)(LPDIRECTDRAWCLIPPER lpDDClipper
LPVOID LPD3DRM_APPDATA
[AI] Application data type varies by DirectX version [AI]
#define NULL
[AI] Null pointer value (C/C++ semantics).
[AI] Forward declaration for Direct3DRMTexture interface [AI]
void RendererDestroy(IDirect3DRM2 *pRenderer)
Destroys a Direct3DRM2 renderer object, manages global pointer [AI].
Result ResultVal(HRESULT result)
Returns a Tgl Result value for HRESULT [AI].
D3DRMRENDERQUALITY Translate(ShadingModel tglShadingModel)
Converts Tgl shading model enum to D3DRM enum [AI].
void MeshBuilderDestroy(IDirect3DRMMesh *pMeshBuilder)
Releases a Direct3DRMMesh [AI].
IDirect3DRM2 * g_pD3DRM
[AI] Global pointer to Direct3DRM2, used to manage lifecycle [AI]
void TextureDestroy(IDirect3DRMTexture *pTexture)
Releases texture and manages memory [AI].
void MeshDestroy(MeshImpl::MeshDataType pMesh)
Destroys mesh data object [AI].
void ViewDestroy(IDirect3DRMViewport *pView)
Releases a Direct3DRMViewport [AI].
void CameraDestroy(IDirect3DRMFrame2 *pFrame)
Releases (decreases ref count) for a Direct3DRMFrame2 [AI].
void DeviceDestroy(IDirect3DRMDevice2 *pDevice)
Releases (decreases ref count of) a Direct3DRMDevice2 [AI].
void LightDestroy(IDirect3DRMFrame2 *pLight)
Releases a Direct3DRMFrame2 used as light [AI].
void GroupDestroy(IDirect3DRMFrame2 *pGroup)
Releases group/frame resource from Direct3DRM [AI].
[AI] Namespace containing all classes related to the 3D graphics abstraction/rendering engine.
ShadingModel
[AI] Represents shading models available for rendering geometry.
@ UnlitFlat
[AI] Flat shading without lighting calculations. [AI]
@ Flat
[AI] Flat shaded, possibly single color per polygon with lighting. [AI]
@ Phong
[AI] Phong (pixel-level) shading, if supported. [AI]
@ Gouraud
[AI] Gouraud (vertex-interpolated) shading. [AI]
@ Wireframe
[AI] No shading; renders only mesh edges. [AI]
TextureMappingMode
[AI] Methods for mapping textures onto geometry.
ProjectionType
[AI] Projection modes for camera/view transforms.
@ Perspective
[AI] Distant objects appear smaller. [AI]
@ Orthographic
[AI] Objects keep constant size regardless of distance. [AI]
Result
[AI] Result type used throughout the Tgl API to report operation success or failure.
@ Success
[AI] Operation succeeded. [AI]
@ Error
[AI] Operation failed. [AI]
ColorModel
[AI] Represents available color models for rendering.
float FloatMatrix4[4][4]
[AI] Represents a 4x4 matrix of single-precision floating point values.
LightType
[AI] Types of lights supported in the renderer.
@ Point
[AI] Light emitted from a point in all directions. [AI]
@ ParallelPoint
[AI] Similar to point, but with parallel rays. [AI]
@ Directional
[AI] Parallel light rays, such as sunlight. [AI]
@ Ambient
[AI] Non-directional lighting applied equally everywhere. [AI]
@ Spot
[AI] Light that emits a cone-shaped beam from a point. [AI]
MaterialMode
[AI] Determines how material properties are sourced for a group/mesh.
[AI] Holds D3DRMMesh pointer and group index for referencing geometry [AI]
D3DRMGROUPINDEX groupIndex
[AI] Index within mesh group [AI]
IDirect3DRMMesh * groupMesh
[AI] D3DRM mesh pointer [AI]
[AI] Contains Direct3D-specific data needed to create a rendering device.
[AI] Contains DirectDraw-specific params for creating a rendering device.
[AI] Represents a single color entry in a palette.