Isle
Loading...
Searching...
No Matches
tglsurface.h
Go to the documentation of this file.
1#ifndef _TglSurface_h
2#define _TglSurface_h
3
5#include "tgl/tgl.h"
6
12namespace Tgl
13{
14class Renderer;
15class Device;
16class View;
17class Group;
18} // namespace Tgl
19
21// TglSurface
22
33public:
40 struct CreateStruct {
41 const GUID* m_pDriverGUID;
42 HWND m_hWnd;
43 IDirectDraw* m_pDirectDraw;
44 IDirectDrawSurface* m_pFrontBuffer;
45 IDirectDrawSurface* m_pBackBuffer;
46 IDirectDrawPalette* m_pPalette;
49 IDirect3D2* m_direct3d;
50 IDirect3DDevice2* m_d3dDevice;
51 };
52
53public:
57 TglSurface();
58
62 virtual ~TglSurface();
63
76 virtual BOOL Create(const CreateStruct&, Tgl::Renderer*, Tgl::Group* pScene); // vtable+0x04
77
82 virtual void Destroy(); // vtable+0x08
83
90 virtual double Render(); // vtable+0x0c
91
96 Tgl::Renderer* GetRenderer() const { return m_pRenderer; }
97
102 Tgl::Device* GetDevice() const { return m_pDevice; }
103
108 Tgl::View* GetView() const { return m_pView; }
109
114 Tgl::Group* GetScene() const { return m_pScene; }
115
120 unsigned long GetWidth() const { return m_width; }
121
126 unsigned long GetHeight() const { return m_height; }
127
132 double GetRenderingRate() const { return m_renderingRateMeter.Frequency(); }
133
138 double GetFrameRate() const { return m_frameRateMeter.Frequency(); }
139
144 unsigned long GetFrameCount() const { return m_frameCount; }
145
146#ifdef _DEBUG
151 double GetTriangleRate() const { return m_triangleRateMeter.Frequency(); }
152#endif
153
154protected:
161 virtual Tgl::View* CreateView(Tgl::Renderer*, Tgl::Device*) = 0; // vtable+0x10
162
167 virtual void DestroyView(); // vtable+0x14
168
169private:
170 Tgl::Renderer* m_pRenderer;
171 Tgl::Device* m_pDevice;
172 Tgl::View* m_pView;
173 Tgl::Group* m_pScene;
174
175 unsigned long m_width;
176 unsigned long m_height;
177
178 BOOL m_isInitialized;
179 BOOL m_stopRendering;
180
181 // statistics
182 MxFrequencyMeter m_renderingRateMeter;
183 MxFrequencyMeter m_frameRateMeter;
184 unsigned long m_frameCount;
185#ifdef _DEBUG
186 MxFrequencyMeter m_triangleRateMeter;
187 unsigned long m_triangleCount;
188#endif
189};
190
192
197// SYNTHETIC: LEGO1 0x100abcf0
198// SYNTHETIC: BETA10 0x1017de00
199// TglSurface::`scalar deleting destructor'
200
201#endif /* _TglSurface_h */
Utility for measuring the frequency (operations per second) of a repeated operation.
Definition: mxstopwatch.h:91
double Frequency() const
Returns the measured frequency (operations per elapsed second).
[AI] Encapsulates a rendering surface, its associated hardware device, renderer, and view.
Definition: tglsurface.h:32
Tgl::View * GetView() const
[AI] Gets the current view/camera for this surface.
Definition: tglsurface.h:108
Tgl::Device * GetDevice() const
[AI] Returns the graphics device used by this surface, e.g.
Definition: tglsurface.h:102
Tgl::Group * GetScene() const
[AI] Returns the currently attached 3D scene root/group.
Definition: tglsurface.h:114
Tgl::Renderer * GetRenderer() const
[AI] Gets the active renderer for this surface.
Definition: tglsurface.h:96
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.
Definition: tglsurface.cpp:76
virtual void Destroy()
[AI] Destroys all resources (view, device), releasing scene and renderer references.
Definition: tglsurface.cpp:45
unsigned long GetFrameCount() const
[AI] Returns the frame count since creation or since last meter reset.
Definition: tglsurface.h:144
virtual ~TglSurface()
[AI] Virtual destructor also triggers Destroy().
Definition: tglsurface.cpp:38
double GetFrameRate() const
[AI] Returns the measured frame rate (frames per second) for the current surface.
Definition: tglsurface.h:138
double GetRenderingRate() const
[AI] Returns the measured rendering rate (frames per second) for the rendering routine.
Definition: tglsurface.h:132
virtual double Render()
[AI] Renders a single frame and returns the render time for that frame.
Definition: tglsurface.cpp:179
TglSurface()
[AI] Constructs a new TglSurface instance with members initialized to their default state.
Definition: tglsurface.cpp:16
virtual void DestroyView()
[AI] Destroys (deletes) the surface's view/camera, and resets the pointer to null.
Definition: tglsurface.cpp:171
unsigned long GetWidth() const
[AI] Returns the width (in pixels) of the rendered surface.
Definition: tglsurface.h:120
unsigned long GetHeight() const
[AI] Returns the height (in pixels) of the rendered surface.
Definition: tglsurface.h:126
[AI] Represents a rendering device/context for the Tgl renderer.
Definition: tgl.h:318
[AI] Scene graph node for parental transforms/color/material/texture; can hold meshes or other groups...
Definition: tgl.h:669
[AI] Main interface/factory for rendering resources and scene graphs.
Definition: tgl.h:188
[AI] Represents a rendering viewport and drawing context.
Definition: tgl.h:397
typedef BOOL(FAR PASCAL *LPDIENUMDEVICEOBJECTSCALLBACKA)(LPCDIDEVICEOBJECTINSTANCEA
[AI] Namespace containing all classes related to the 3D graphics abstraction/rendering engine.
[AI] Contains initialization parameters for creating a TglSurface and its underlying DDraw/D3D resour...
Definition: tglsurface.h:40
BOOL m_isWideViewAngle
[AI] Enables wide or default field-of-view projection.
Definition: tglsurface.h:48
BOOL m_isFullScreen
[AI] TRUE to use fullscreen mode, FALSE for windowed rendering.
Definition: tglsurface.h:47
HWND m_hWnd
[AI] Handle to the window to be associated with this surface.
Definition: tglsurface.h:42
IDirectDraw * m_pDirectDraw
[AI] DirectDraw interface pointer for low-level surface management.
Definition: tglsurface.h:43
IDirectDrawSurface * m_pFrontBuffer
[AI] DirectDraw primary/front buffer surface.
Definition: tglsurface.h:44
IDirect3D2 * m_direct3d
[AI] Direct3D2 interface pointer for 3D initialization.
Definition: tglsurface.h:49
const GUID * m_pDriverGUID
[AI] DirectDraw driver GUID to use or NULL for primary display.
Definition: tglsurface.h:41
IDirect3DDevice2 * m_d3dDevice
[AI] Direct3D2 device interface (hardware or emulated).
Definition: tglsurface.h:50
IDirectDrawPalette * m_pPalette
[AI] Optional palette for indexed color surfaces.
Definition: tglsurface.h:46
IDirectDrawSurface * m_pBackBuffer
[AI] Optional DirectDraw back buffer for double buffering.
Definition: tglsurface.h:45