context.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910
  1. #ifndef _context_h_
  2. #define _context_h_
  3. //////////////////////////////////////////////////////////////////////////////
  4. //
  5. // Plane
  6. //
  7. //////////////////////////////////////////////////////////////////////////////
  8. class Plane {
  9. private:
  10. HVector m_hvec;
  11. public:
  12. Plane()
  13. {
  14. }
  15. Plane(const Vector& normal, const Vector& position) :
  16. m_hvec(
  17. normal.X(),
  18. normal.Y(),
  19. normal.Z(),
  20. - (normal * position)
  21. )
  22. {
  23. }
  24. Plane(const HVector& vec) :
  25. m_hvec(vec)
  26. {
  27. }
  28. Plane(const Plane& plane) :
  29. m_hvec(plane.m_hvec)
  30. {
  31. }
  32. const HVector& GetHVector() const
  33. {
  34. return m_hvec;
  35. }
  36. float Distance(const HVector& vec) const;
  37. float Intersect(const HVector& v0, const HVector& v1) const;
  38. };
  39. //////////////////////////////////////////////////////////////////////////////
  40. //
  41. // Index into an array or vercies
  42. //
  43. //////////////////////////////////////////////////////////////////////////////
  44. typedef WORD MeshIndex;
  45. //////////////////////////////////////////////////////////////////////////////
  46. //
  47. // Vertex
  48. //
  49. //////////////////////////////////////////////////////////////////////////////
  50. class Vertex {
  51. public:
  52. float x, y, z;
  53. float u, v;
  54. float nx, ny, nz;
  55. Vertex()
  56. {
  57. }
  58. Vertex(
  59. float xArg,
  60. float yArg,
  61. float zArg,
  62. float nxArg,
  63. float nyArg,
  64. float nzArg,
  65. float uArg = 0,
  66. float vArg = 0
  67. ) :
  68. x(xArg),
  69. y(yArg),
  70. z(zArg),
  71. nx(nxArg),
  72. ny(nyArg),
  73. nz(nzArg),
  74. u(uArg),
  75. v(vArg)
  76. {
  77. }
  78. Vertex(
  79. const Vector& vec,
  80. const Vector& vecNormal,
  81. const Point& pointTexture = Point(0, 0)
  82. ) {
  83. x = vec.X();
  84. y = vec.Y();
  85. z = vec.Z();
  86. nx = vecNormal.X();
  87. ny = vecNormal.Y();
  88. nz = vecNormal.Z();
  89. u = pointTexture.X();
  90. v = pointTexture.Y();
  91. }
  92. Vertex(const Vertex& vertex)
  93. {
  94. memcpy(this, &vertex, sizeof(Vertex));
  95. }
  96. void SetPosition(const Vector& vec)
  97. {
  98. x = vec.X();
  99. y = vec.Y();
  100. z = vec.Z();
  101. }
  102. Vector GetPosition() const
  103. {
  104. return Vector(x, y, z);
  105. }
  106. void SetNormal(const Vector& vec)
  107. {
  108. nx = vec.X();
  109. ny = vec.Y();
  110. nz = vec.Z();
  111. }
  112. Vector GetNormal() const
  113. {
  114. return Vector(nx, ny, nz);
  115. }
  116. Point GetTextureCoordinate()
  117. {
  118. return Point(u, v);
  119. }
  120. friend operator==(const Vertex& v0, const Vertex& v1)
  121. {
  122. return
  123. v0.x == v1.x
  124. && v0.y == v1.y
  125. && v0.z == v1.z
  126. && v0.nx == v1.nx
  127. && v0.ny == v1.ny
  128. && v0.nz == v1.nz
  129. && v0.u == v1.u
  130. && v0.v == v1.v;
  131. }
  132. };
  133. class VertexL {
  134. public:
  135. float x, y, z;
  136. float u, v;
  137. float r, g, b, a;
  138. VertexL()
  139. {
  140. }
  141. VertexL(
  142. float xArg,
  143. float yArg,
  144. float zArg,
  145. float rArg,
  146. float gArg,
  147. float bArg,
  148. float aArg,
  149. float uArg,
  150. float vArg
  151. ) :
  152. x(xArg),
  153. y(yArg),
  154. z(zArg),
  155. r(rArg),
  156. g(gArg),
  157. b(bArg),
  158. a(aArg),
  159. u(uArg),
  160. v(vArg)
  161. {
  162. }
  163. VertexL(
  164. const Vector& vec,
  165. const Color& color = Color::White(),
  166. const Point& point = Point::GetZero()
  167. ) :
  168. x(vec.X()),
  169. y(vec.Y()),
  170. z(vec.Z()),
  171. r(color.R()),
  172. g(color.G()),
  173. b(color.B()),
  174. a(color.A()),
  175. u(point.X()),
  176. v(point.Y())
  177. {
  178. }
  179. VertexL(const VertexL& vertex)
  180. {
  181. memcpy(this, &vertex, sizeof(VertexL));
  182. }
  183. void SetPosition(const Vector& vec)
  184. {
  185. x = vec.X();
  186. y = vec.Y();
  187. z = vec.Z();
  188. }
  189. Vector GetPosition() const
  190. {
  191. return Vector(x, y, z);
  192. }
  193. void SetTextureCoordinate(const Point& point)
  194. {
  195. u = point.X();
  196. v = point.Y();
  197. }
  198. Point GetTextureCoordinate()
  199. {
  200. return Point(u, v);
  201. }
  202. void SetNormal(const Vector& vec)
  203. {
  204. }
  205. Vector GetNormal() const
  206. {
  207. return Vector(1, 0, 0);
  208. }
  209. void SetColor(const Color& color)
  210. {
  211. r = color.R();
  212. g = color.G();
  213. b = color.B();
  214. a = color.A();
  215. }
  216. Color GetColor() const
  217. {
  218. return Color(r, g, b, a);
  219. }
  220. friend operator==(const VertexL& v0, const VertexL& v1)
  221. {
  222. return
  223. v0.x == v1.x
  224. && v0.y == v1.y
  225. && v0.z == v1.z
  226. && v0.r == v1.r
  227. && v0.g == v1.g
  228. && v0.b == v1.b
  229. && v0.a == v1.a
  230. && v0.u == v1.u
  231. && v0.v == v1.v;
  232. }
  233. };
  234. //////////////////////////////////////////////////////////////////////////////
  235. //
  236. // D3D
  237. //
  238. //////////////////////////////////////////////////////////////////////////////
  239. #ifdef FLOATASM
  240. inline D3DCOLOR MakeD3DCOLOR(const Color& color)
  241. {
  242. DWORD r, g, b, a;
  243. __asm {
  244. mov ecx, color
  245. fld [ecx]Color.m_r
  246. fmul g_255 // r
  247. fld [ecx]Color.m_g
  248. fmul g_255 // g r
  249. fld [ecx]Color.m_b
  250. fmul g_255 // b g r
  251. fld [ecx]Color.m_a
  252. fmul g_255 // a b g r
  253. fxch st(3) // r b g a
  254. fistp r // b g a
  255. fistp b
  256. fistp g
  257. fistp a
  258. }
  259. return
  260. (a << 24)
  261. | (r << 16)
  262. | (g << 8)
  263. | (b );
  264. }
  265. #else
  266. inline D3DCOLOR MakeD3DCOLOR(const Color& color)
  267. {
  268. return
  269. (MakeInt(255.0f * color.GetAlpha()) << 24)
  270. | (MakeInt(255.0f * color.GetRed() ) << 16)
  271. | (MakeInt(255.0f * color.GetGreen()) << 8)
  272. | (MakeInt(255.0f * color.GetBlue() ) );
  273. }
  274. #endif
  275. inline Color MakeColor(const D3DCOLORVALUE& color)
  276. {
  277. return
  278. Color(
  279. (float)color.r,
  280. (float)color.g,
  281. (float)color.b,
  282. (float)color.a
  283. );
  284. }
  285. inline Color MakeColor(D3DCOLOR color)
  286. {
  287. return
  288. Color(
  289. (float)((color >> 24) & 0xff) / 255.0f,
  290. (float)((color >> 16) & 0xff) / 255.0f,
  291. (float)((color >> 8) & 0xff) / 255.0f,
  292. (float)((color >> 0) & 0xff) / 255.0f
  293. );
  294. }
  295. class D3DVector : public D3DVECTOR {
  296. public:
  297. D3DVector() {}
  298. D3DVector(float xArg, float yArg, float zArg)
  299. {
  300. x = xArg;
  301. y = yArg;
  302. z = zArg;
  303. }
  304. D3DVector(const Vector& vec)
  305. {
  306. x = vec.X();
  307. y = vec.Y();
  308. z = vec.Z();
  309. }
  310. };
  311. class D3DVertex : public D3DVERTEX {
  312. public:
  313. D3DVertex() {}
  314. D3DVertex(
  315. const Vector& vec,
  316. const Vector& vecNormal,
  317. const Point& pointTexture = Point(0, 0)
  318. ) {
  319. x = vec.X();
  320. y = vec.Y();
  321. z = vec.Z();
  322. nx = vecNormal.X();
  323. ny = vecNormal.Y();
  324. nz = vecNormal.Z();
  325. tu = pointTexture.X();
  326. tv = pointTexture.Y();
  327. }
  328. D3DVertex(
  329. float xArg,
  330. float yArg,
  331. float zArg,
  332. float nxArg,
  333. float nyArg,
  334. float nzArg,
  335. float uArg = 0,
  336. float vArg = 0
  337. ) {
  338. x = xArg;
  339. y = yArg;
  340. z = zArg;
  341. nx = nxArg;
  342. ny = nyArg;
  343. nz = nzArg;
  344. tu = uArg;
  345. tv = vArg;
  346. }
  347. float X() const { return x; }
  348. float Y() const { return y; }
  349. float Z() const { return z; }
  350. Vector GetPosition() const { return Vector(x, y, z); }
  351. Vector GetNormal() const { return Vector(nx, ny, nz); }
  352. Point GetTextureCoordinate() const { return Point(tu, tv); }
  353. void SetPosition(const Vector& vec)
  354. {
  355. x = vec.X();
  356. y = vec.Y();
  357. z = vec.Z();
  358. }
  359. void SetNormal(const Vector& vec)
  360. {
  361. nx = vec.X();
  362. ny = vec.Y();
  363. nz = vec.Z();
  364. }
  365. void SetTextureCoordinate(const Point& point)
  366. {
  367. tu = point.X();
  368. tv = point.Y();
  369. }
  370. friend bool operator==(const D3DVertex& v1, const D3DVertex& v2)
  371. {
  372. return
  373. v1.x == v2.x
  374. && v1.y == v2.y
  375. && v1.z == v2.z
  376. && v1.nx == v2.nx
  377. && v1.ny == v2.ny
  378. && v1.nz == v2.nz
  379. && v1.tu == v2.tu
  380. && v1.tv == v2.tv;
  381. }
  382. };
  383. class D3DLVertex : public D3DLVERTEX {
  384. public:
  385. D3DLVertex() {}
  386. D3DLVertex(
  387. const Vector& vec,
  388. const Color& colorArg,
  389. const Color& colorSpecular = Color(0, 0, 0),
  390. const Point& pointTexture = Point(0, 0)
  391. ) {
  392. dwReserved = 0;
  393. x = vec.X();
  394. y = vec.Y();
  395. z = vec.Z();
  396. color = MakeD3DCOLOR(colorArg);
  397. specular = MakeD3DCOLOR(colorSpecular);
  398. tu = pointTexture.X();
  399. tv = pointTexture.Y();
  400. }
  401. float X() const { return x; }
  402. float Y() const { return y; }
  403. float Z() const { return z; }
  404. Vector GetPosition() const { return Vector(x, y, z); }
  405. Point GetTextureCoordinate() const { return Point(tu, tv); }
  406. Color GetColor() const { return MakeColor(color); }
  407. Color GetSpecularColor() const { return MakeColor(specular); }
  408. void SetPosition(const Vector& vec)
  409. {
  410. x = vec.X();
  411. y = vec.Y();
  412. z = vec.Z();
  413. }
  414. void SetNormal(const Vector& vec)
  415. {
  416. }
  417. Vector GetNormal() const
  418. {
  419. return Vector(1, 0, 0);
  420. }
  421. void SetTextureCoordinate(const Point& point)
  422. {
  423. tu = point.X();
  424. tv = point.Y();
  425. }
  426. void SetColor(const Color& colorArg)
  427. {
  428. color = MakeD3DCOLOR(colorArg);
  429. }
  430. void SetSpecularColor(const Color& colorArg)
  431. {
  432. specular = MakeD3DCOLOR(colorArg);
  433. }
  434. friend bool operator==(const D3DLVertex& v1, const D3DLVertex& v2)
  435. {
  436. return
  437. v1.x == v2.x
  438. && v1.y == v2.y
  439. && v1.z == v2.z
  440. && v1.color == v2.color
  441. && v1.specular == v2.specular
  442. && v1.tu == v2.tu
  443. && v1.tv == v2.tv;
  444. }
  445. };
  446. class D3DTLVertex : public D3DTLVERTEX {
  447. public:
  448. D3DTLVertex() {}
  449. D3DTLVertex(
  450. const Point& point,
  451. float z,
  452. float rhwArg,
  453. const Color& colorArg,
  454. const Color& colorSpecular = Color::Black(),
  455. const Point& pointTexture = Point(0, 0)
  456. ) {
  457. sx = point.X();
  458. sy = point.Y();
  459. sz = z;
  460. rhw = rhwArg;
  461. color = MakeD3DCOLOR(colorArg);
  462. specular = MakeD3DCOLOR(colorSpecular);
  463. tu = pointTexture.X();
  464. tv = pointTexture.Y();
  465. }
  466. float X() const { return sx; }
  467. float Y() const { return sy; }
  468. float Z() const { return sz; }
  469. float RHW() const { return rhw; }
  470. Point GetPosition() const { return Point(sx, sy); }
  471. Point GetTextureCoordinate() const { return Point(tu, tv); }
  472. Color GetColor() const { return MakeColor(color); }
  473. Color GetSpecularColor() const { return MakeColor(specular); }
  474. void SetPosition(const Point& point)
  475. {
  476. sx = point.X();
  477. sy = point.Y();
  478. }
  479. void SetX(float xArg)
  480. {
  481. sx = xArg;
  482. }
  483. void SetY(float yArg)
  484. {
  485. sy = yArg;
  486. }
  487. void SetZ(float zArg)
  488. {
  489. sz = zArg;
  490. }
  491. void SetRHW(float rhwArg)
  492. {
  493. rhw = rhwArg;
  494. }
  495. void SetTextureCoordinate(const Point& point)
  496. {
  497. tu = point.X();
  498. tv = point.Y();
  499. }
  500. void SetColor(const Color& colorArg)
  501. {
  502. color = MakeD3DCOLOR(colorArg);
  503. }
  504. void SetSpecularColor(const Color& colorArg)
  505. {
  506. specular = MakeD3DCOLOR(colorArg);
  507. }
  508. friend bool operator==(const D3DTLVertex& v1, const D3DTLVertex& v2)
  509. {
  510. return
  511. v1.sx == v2.sx
  512. && v1.sy == v2.sy
  513. && v1.sz == v2.sz
  514. && v1.rhw == v2.rhw
  515. && v1.color == v2.color
  516. && v1.specular == v2.specular
  517. && v1.tu == v2.tu
  518. && v1.tv == v2.tv;
  519. }
  520. };
  521. inline ZString GetString(const D3DLVertex& v)
  522. {
  523. return
  524. ZString(v.x) + ", "
  525. + ZString(v.y) + ", "
  526. + ZString(v.z) + ", "
  527. + ZString(v.tu) + ", "
  528. + ZString(v.tv);
  529. }
  530. inline ZString GetString(const D3DVertex& v)
  531. {
  532. return
  533. ZString(v.x) + ", "
  534. + ZString(v.y) + ", "
  535. + ZString(v.z) + ", "
  536. + ZString(v.tu) + ", "
  537. + ZString(v.tv);
  538. }
  539. struct VertexScreen {
  540. float x;
  541. float y;
  542. float z;
  543. float qw;
  544. D3DCOLOR color;
  545. D3DCOLOR specular;
  546. float u;
  547. float v;
  548. };
  549. //////////////////////////////////////////////////////////////////////////////
  550. //
  551. // Forward Declarations
  552. //
  553. //////////////////////////////////////////////////////////////////////////////
  554. enum ShadeMode {
  555. ShadeModeNone,
  556. ShadeModeCopy,
  557. ShadeModeFlat,
  558. ShadeModeGouraud,
  559. ShadeModeGlobalColor
  560. };
  561. enum BlendMode {
  562. BlendModeSource,
  563. BlendModeAdd,
  564. BlendModeSourceAlpha
  565. };
  566. enum WrapMode {
  567. WrapModeNone,
  568. WrapModeUCylinder,
  569. WrapModeVCylinder,
  570. WrapModeTorus
  571. };
  572. enum CullMode {
  573. CullModeNone,
  574. CullModeCW,
  575. CullModeCCW,
  576. CullModeBoth
  577. };
  578. enum Counter {
  579. CounterPoints,
  580. CounterLines,
  581. CounterTriangles,
  582. CounterMeshes,
  583. CounterObjects,
  584. CounterObjectsRendered,
  585. CounterMatrixLoads,
  586. CounterDrawStrings,
  587. CounterDrawStringChars
  588. };
  589. //////////////////////////////////////////////////////////////////////////////
  590. //
  591. // Geo Callback
  592. //
  593. //////////////////////////////////////////////////////////////////////////////
  594. class IGeoCallback : public IObject {
  595. public:
  596. virtual void RenderCallback(Context* pcontext) = 0;
  597. };
  598. //////////////////////////////////////////////////////////////////////////////
  599. //
  600. // Deformation
  601. //
  602. //////////////////////////////////////////////////////////////////////////////
  603. class Deformation : public IObject {
  604. public:
  605. virtual Vector Deform(const Vector& vec) = 0;
  606. };
  607. //////////////////////////////////////////////////////////////////////////////
  608. //
  609. // Real coordinate system drawing context.
  610. //
  611. //////////////////////////////////////////////////////////////////////////////
  612. class Context : public IObject {
  613. public:
  614. //
  615. // Capabilities
  616. //
  617. virtual bool Has3DAcceleration() = 0;
  618. //
  619. // 3D Layers
  620. //
  621. virtual void Begin3DLayer(Camera* pcamera, bool bZBuffer) = 0;
  622. virtual void End3DLayer() = 0;
  623. //
  624. // Level of Detail
  625. //
  626. virtual void SetLOD(float lod) = 0;
  627. virtual float GetLOD() = 0;
  628. //
  629. // These states are maintained in the attibutes stack.
  630. //
  631. virtual void PushState() = 0;
  632. virtual void PopState() = 0;
  633. virtual void SetGlobalColor(const Color& color, bool bOverride = false) = 0;
  634. virtual void SetZTest(bool b, bool bOverride = false) = 0;
  635. virtual void SetZWrite(bool b, bool bOverride = false) = 0;
  636. virtual void SetPerspectiveCorrection(bool b, bool bOverride = false) = 0;
  637. virtual void SetDither(bool b, bool bOverride = false) = 0;
  638. virtual void SetColorKey(bool b, bool bOverride = false) = 0;
  639. virtual void SetLinearFilter(bool b, bool bOverride = false) = 0;
  640. virtual void SetShadeMode(ShadeMode shadeMode, bool bOverride = false) = 0;
  641. virtual void SetBlendMode(BlendMode blendMode, bool bOverride = false) = 0;
  642. virtual void SetWrapMode(WrapMode wrapMode, bool bOverride = false) = 0;
  643. virtual void SetCullMode(CullMode cullMode, bool bOverride = false) = 0;
  644. virtual void SetMaterial(Material* pmaterial, bool bOverride = false) = 0;
  645. virtual void SetTexture(Surface* psurface, bool bOverride = false) = 0;
  646. virtual void SetLineWidth(float width, bool bOverride = false) = 0;
  647. virtual void SetDeformation(Deformation* pdeform, bool bOverride = false) = 0;
  648. virtual const Color& GetGlobalColor() const = 0;
  649. virtual bool GetZTest() const = 0;
  650. virtual bool GetZWrite() const = 0;
  651. virtual bool GetPerspectiveCorrection() const = 0;
  652. virtual bool GetDither() const = 0;
  653. virtual bool GetColorKey() const = 0;
  654. virtual bool GetLinearFilter() const = 0;
  655. virtual ShadeMode GetShadeMode() const = 0;
  656. virtual BlendMode GetBlendMode() const = 0;
  657. virtual CullMode GetCullMode() const = 0;
  658. virtual Material* GetMaterial() const = 0;
  659. virtual Surface* GetTexture() const = 0;
  660. virtual Deformation* GetDeformation() const = 0;
  661. //
  662. // Lighting
  663. //
  664. virtual void DirectionalLight(const Vector& direction, const Color& color) = 0;
  665. virtual void BidirectionalLight(const Vector& direction, const Color& color, const Color& colorAlt) = 0;
  666. virtual void SetAmbientLevel(float ambientLevel) = 0;
  667. //
  668. // 3D Transforms
  669. //
  670. virtual void SetTransform(const Matrix& mat) = 0;
  671. virtual void Multiply(const Matrix& mat) = 0;
  672. virtual void Rotate(const Vector& vec, float angle) = 0;
  673. virtual void Translate(const Vector& vec) = 0;
  674. virtual void Scale(const Vector& vec) = 0;
  675. virtual void Scale3(float scale) = 0;
  676. //
  677. // 2D Transforms
  678. //
  679. virtual void SetMatrix(const Matrix2& mat) = 0;
  680. virtual void Multiply(const Matrix2& mat) = 0;
  681. virtual void Rotate(float angle) = 0;
  682. virtual void Translate(const Point& vec) = 0;
  683. virtual void Scale(const Point& point) = 0;
  684. virtual void Scale2(float scale) = 0;
  685. //
  686. // Transforms Applications
  687. //
  688. virtual const Matrix& GetLocalToEyeMatrix() = 0;
  689. virtual Vector TransformDirectionToEye(const Vector& vec) = 0;
  690. virtual bool TransformDirectionToImage(const Vector& vec, Point& point) = 0;
  691. virtual Vector TransformLocalToEye(const Vector& vec) = 0;
  692. virtual bool TransformLocalToImage(const Vector& vec, Point& point) = 0;
  693. virtual bool TransformEyeToImage(const Vector& vec, Point& point) = 0;
  694. virtual float GetImageRadius(const Vector& vec, float radius) = 0;
  695. virtual Vector TransformEyeToLocal(const Vector& vec) = 0;
  696. //
  697. // 3D Clipping
  698. //
  699. virtual void Clip(const Rect& rect) = 0;
  700. virtual void AddClipPlane(const Plane& plane) = 0;
  701. virtual bool IsCulled(const Vector& vecEye, float radius, bool& bOnScreen) = 0;
  702. virtual bool GetClipping() = 0;
  703. virtual void SetClipping(bool bClip) = 0;
  704. //
  705. // Vertex Buffers
  706. //
  707. virtual Vertex* GetVertexBuffer(int count) = 0;
  708. virtual VertexL* GetVertexLBuffer(int count) = 0;
  709. virtual VertexScreen* GetVertexScreenBuffer(int count) = 0;
  710. virtual MeshIndex* GetIndexBuffer(int count) = 0;
  711. //
  712. // 2D Rendering
  713. //
  714. virtual void DrawImage(Surface* psurface, const Rect& rect, bool bCentered = false, const Point& point = Point(0, 0)) = 0;
  715. virtual void DrawImage(Surface* psurface, bool bCentered = false, const Point& point = Point(0, 0)) = 0;
  716. virtual void DrawImage3D(Surface* psurface, const Rect& rect, const Color& color, bool bCentered = false, const Point& point = Point(0, 0)) = 0;
  717. virtual void DrawImage3D(Surface* psurface, const Color& color, bool bCentered = false, const Point& point = Point(0, 0)) = 0;
  718. virtual void DrawString(
  719. IEngineFont* pfont,
  720. const Color& color,
  721. const Point& point,
  722. const ZString& str
  723. ) = 0;
  724. virtual void DrawRectangle(const Rect& rect, const Color& color) = 0;
  725. virtual void FillRect(const Rect& rect, const Color& color) = 0;
  726. virtual void FillInfinite(const Color& color) = 0;
  727. //
  728. // 3D Rendering
  729. //
  730. virtual void DrawCallbackGeo(IGeoCallback* pgeo, bool bSortObject) = 0;
  731. virtual void DrawPoints(const D3DVertex* pvertex, int vcount) = 0;
  732. virtual void DrawPoints(const Vertex* pvertex, int vcount) = 0;
  733. virtual void DrawPoints(const VertexL* pvertex, int vcount) = 0;
  734. virtual void DrawPoints(const VertexScreen* pvertex, int vcount) = 0;
  735. virtual void DrawLineStrip(const D3DVertex* pvertex, int vcount) = 0;
  736. virtual void DrawLineStrip(const Vertex* pvertex, int vcount) = 0;
  737. virtual void DrawLineStrip(const VertexL* pvertex, int vcount) = 0;
  738. virtual void DrawLineStrip(const VertexScreen* pvertex, int vcount) = 0;
  739. virtual void DrawLines(const D3DVertex* pvertex, int vcount, const MeshIndex* pindex, int icount) = 0;
  740. virtual void DrawLines(const Vertex* pvertex, int vcount, const MeshIndex* pindex, int icount) = 0;
  741. virtual void DrawLines(const VertexL* pvertex, int vcount, const MeshIndex* pindex, int icount) = 0;
  742. virtual void DrawLines(const VertexScreen* pvertex, int vcount, const MeshIndex* pindex, int icount) = 0;
  743. virtual void DrawTriangles(const D3DVertex* pvertex, int vcount, const MeshIndex* pindex, int icount) = 0;
  744. virtual void DrawTriangles(const Vertex* pvertex, int vcount, const MeshIndex* pindex, int icount) = 0;
  745. virtual void DrawTriangles(const VertexL* pvertex, int vcount, const MeshIndex* pindex, int icount) = 0;
  746. virtual void DrawTriangles(const VertexScreen* pvertex, int vcount, const MeshIndex* pindex, int icount) = 0;
  747. //
  748. // Rendering with TVectors
  749. //
  750. virtual void DrawPoints(const TVector<VertexL>& vertices) = 0;
  751. virtual void DrawLines(const TVector<D3DVertex>& vertices, const TVector<MeshIndex>& indices) = 0;
  752. virtual void DrawLines(const TVector<Vertex>& vertices, const TVector<MeshIndex>& indices) = 0;
  753. virtual void DrawLines(const TVector<VertexL>& vertices, const TVector<MeshIndex>& indices) = 0;
  754. virtual void DrawTriangles(const TVector<D3DVertex>& vertices, const TVector<MeshIndex>& indices) = 0;
  755. virtual void DrawTriangles(const TVector<Vertex>& vertices, const TVector<MeshIndex>& indices) = 0;
  756. virtual void DrawTriangles(const TVector<VertexL>& vertices, const TVector<MeshIndex>& indices) = 0;
  757. //
  758. // Decals
  759. //
  760. virtual float DrawDecal(
  761. Surface* psurface,
  762. const Color& color,
  763. const Vector& position,
  764. const Vector& forward,
  765. const Vector& right,
  766. float scale,
  767. float angle,
  768. BlendMode blendMode = BlendModeAdd
  769. ) = 0;
  770. //
  771. // Performance Counters
  772. //
  773. #ifdef EnablePerformanceCounters
  774. virtual int GetPerformanceCounter(Counter counter) = 0;
  775. virtual void ResetPerformanceCounters() = 0;
  776. #endif
  777. };
  778. #endif