26 m_stopRendering =
FALSE;
27 m_isInitialized =
FALSE;
64 memset(&pixelFormat, 0,
sizeof(pixelFormat));
65 pixelFormat.
dwSize =
sizeof(pixelFormat);
67 result = pSurface->GetPixelFormat(&pixelFormat);
68 assert(result ==
DD_OK);
85 int textureShadeCount = -1;
86 int textureColorCount = -1;
89 m_pRenderer = pRenderer;
100 if (bitsPerPixel == 1) {
102 textureShadeCount = 4;
104 else if (bitsPerPixel == 8) {
108 textureShadeCount = shadeCount;
109 textureColorCount = 256;
111 else if (bitsPerPixel == 16) {
114 textureShadeCount = shadeCount;
115 textureColorCount = 256;
117 else if (bitsPerPixel >= 24) {
120 textureShadeCount = 256;
121 textureColorCount = 64;
127 if (textureShadeCount != -1) {
131 if (textureColorCount != -1) {
157 m_frameRateMeter.
Reset();
158 m_renderingRateMeter.
Reset();
160 m_triangleRateMeter.Reset();
164 m_isInitialized =
TRUE;
183 if (m_isInitialized && !m_stopRendering) {
187 m_triangleRateMeter.StartOperation();
192 result = m_pView->
Render(m_pScene);
198 m_triangleRateMeter.EndOperation();
207 unsigned long triangleCount = m_pDevice->GetDrawnTriangleCount();
209 unsigned long triangleCount = 0;
212 m_triangleRateMeter.IncreaseOperationCount(triangleCount - m_triangleCount - 1);
213 m_triangleCount = triangleCount;
219 if ((++m_frameCount % 20) == 0)
225 m_frameRateMeter.
Reset();
226 m_renderingRateMeter.
Reset();
228 m_triangleRateMeter.Reset();
void EndOperation()
Marks the end of a measured operation and increments the count.
void Reset()
Resets the operation counter and stopwatch to zero.
void StartOperation()
Marks the beginning of a measured operation.
double ElapsedSeconds() const
Returns the total elapsed seconds since the last Reset().
Measures elapsed wall clock time using high resolution performance counters.
void Stop()
Stops timing and accumulates the elapsed interval to m_elapsedSeconds.
double ElapsedSeconds() const
Returns the total accumulated elapsed time in seconds.
void Start()
Starts (or resumes) timing from the current moment.
[AI] Encapsulates a rendering surface, its associated hardware device, renderer, and view.
virtual Tgl::View * CreateView(Tgl::Renderer *, Tgl::Device *)=0
[AI] Abstract view creation.
virtual BOOL Create(const CreateStruct &, Tgl::Renderer *, Tgl::Group *pScene)
[AI] Creates and initializes the surface, rendering device, and optionally installs scene graph.
virtual void Destroy()
[AI] Destroys all resources (view, device), releasing scene and renderer references.
virtual ~TglSurface()
[AI] Virtual destructor also triggers Destroy().
virtual double Render()
[AI] Renders a single frame and returns the render time for that frame.
TglSurface()
[AI] Constructs a new TglSurface instance with members initialized to their default state.
virtual void DestroyView()
[AI] Destroys (deletes) the surface's view/camera, and resets the pointer to null.
virtual Result SetShadeCount(unsigned long)=0
[AI] Specifies the number of shades for rendering (possibly for palette/ramp mode).
virtual Result SetDither(int)=0
[AI] Enables/disables dithering in the renderer.
virtual Result SetColorModel(ColorModel)=0
[AI] Sets the color model for rendering.
virtual unsigned long GetWidth()=0
[AI] Gets the output width in pixels.
virtual Result SetShadingModel(ShadingModel)=0
[AI] Sets the shading model (e.g., Gouraud, flat).
virtual unsigned long GetHeight()=0
[AI] Gets the output height in pixels.
[AI] Scene graph node for parental transforms/color/material/texture; can hold meshes or other groups...
[AI] Main interface/factory for rendering resources and scene graphs.
virtual Device * CreateDevice(const DeviceDirectDrawCreateData &)=0
[AI] Creates a rendering device using DirectDraw parameters.
virtual Result SetTextureDefaultShadeCount(unsigned long)=0
[AI] Sets the default number of shades to generate for textures.
virtual Result SetTextureDefaultColorCount(unsigned long)=0
[AI] Sets the default number of colors to use for textures (likely palette size).
virtual Result Render(const Group *)=0
[AI] Renders a group hierarchy to the view.
#define DECOMP_SIZE_ASSERT(T, S)
[AI] Namespace containing all classes related to the 3D graphics abstraction/rendering engine.
int Succeeded(Result result)
[AI] Returns whether a Tgl::Result indicates success.
ShadingModel
[AI] Represents shading models available for rendering geometry.
@ Gouraud
[AI] Gouraud (vertex-interpolated) shading. [AI]
Result
[AI] Result type used throughout the Tgl API to report operation success or failure.
ColorModel
[AI] Represents available color models for rendering.
@ Ramp
[AI] Uses a color ramp (palette/indexed color). [AI]
[AI] Contains initialization parameters for creating a TglSurface and its underlying DDraw/D3D resour...
IDirectDrawSurface * m_pFrontBuffer
[AI] DirectDraw primary/front buffer surface.
IDirect3D2 * m_direct3d
[AI] Direct3D2 interface pointer for 3D initialization.
IDirect3DDevice2 * m_d3dDevice
[AI] Direct3D2 device interface (hardware or emulated).
[AI] Contains Direct3D-specific data needed to create a rendering device.
int GetBitsPerPixel(IDirectDrawSurface *pSurface)