CmRenderSystem.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. /*
  2. -----------------------------------------------------------------------------
  3. This source file is part of OGRE
  4. (Object-oriented Graphics Rendering Engine)
  5. For the latest info, see http://www.ogre3d.org/
  6. Copyright (c) 2000-2011 Torus Knot Software Ltd
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. -----------------------------------------------------------------------------
  23. */
  24. // RenderSystem implementation
  25. // Note that most of this class is abstract since
  26. // we cannot know how to implement the behaviour without
  27. // being aware of the 3D API. However there are a few
  28. // simple functions which can have a base implementation
  29. #include "CmRenderSystem.h"
  30. #include "CmViewport.h"
  31. #include "CmException.h"
  32. #include "CmRenderTarget.h"
  33. #include "CmRenderWindow.h"
  34. #include "CmHardwarePixelBuffer.h"
  35. #include "CmHardwareOcclusionQuery.h"
  36. namespace CamelotEngine {
  37. static const TexturePtr sNullTexPtr;
  38. //-----------------------------------------------------------------------
  39. RenderSystem::RenderSystem()
  40. : mActiveRenderTarget(0)
  41. , mActiveViewport(0)
  42. // This means CULL clockwise vertices, i.e. front of poly is counter-clockwise
  43. // This makes it the same as OpenGL and other right-handed systems
  44. , mCullingMode(CULL_CLOCKWISE)
  45. , mVSync(true)
  46. , mVSyncInterval(1)
  47. , mWBuffer(false)
  48. , mInvertVertexWinding(false)
  49. , mDisabledTexUnitsFrom(0)
  50. , mCurrentPassIterationCount(0)
  51. , mDerivedDepthBias(false)
  52. , mVertexProgramBound(false)
  53. , mGeometryProgramBound(false)
  54. , mFragmentProgramBound(false)
  55. , mClipPlanesDirty(true)
  56. , mRealCapabilities(0)
  57. , mCurrentCapabilities(0)
  58. , mUseCustomCapabilities(false)
  59. , mTexProjRelative(false)
  60. , mTexProjRelativeOrigin(Vector3::ZERO)
  61. {
  62. }
  63. //-----------------------------------------------------------------------
  64. RenderSystem::~RenderSystem()
  65. {
  66. shutdown();
  67. delete mRealCapabilities;
  68. mRealCapabilities = 0;
  69. // Current capabilities managed externally
  70. mCurrentCapabilities = 0;
  71. }
  72. //-----------------------------------------------------------------------
  73. void RenderSystem::_initRenderTargets(void)
  74. {
  75. }
  76. //-----------------------------------------------------------------------
  77. void RenderSystem::_updateAllRenderTargets(bool swapBuffers)
  78. {
  79. // Update all in order of priority
  80. // This ensures render-to-texture targets get updated before render windows
  81. RenderTargetPriorityMap::iterator itarg, itargend;
  82. itargend = mPrioritisedRenderTargets.end();
  83. for( itarg = mPrioritisedRenderTargets.begin(); itarg != itargend; ++itarg )
  84. {
  85. if( itarg->second->isActive())
  86. itarg->second->update(swapBuffers);
  87. }
  88. }
  89. //-----------------------------------------------------------------------
  90. void RenderSystem::_swapAllRenderTargetBuffers(bool waitForVSync)
  91. {
  92. // Update all in order of priority
  93. // This ensures render-to-texture targets get updated before render windows
  94. RenderTargetPriorityMap::iterator itarg, itargend;
  95. itargend = mPrioritisedRenderTargets.end();
  96. for( itarg = mPrioritisedRenderTargets.begin(); itarg != itargend; ++itarg )
  97. {
  98. if( itarg->second->isActive())
  99. itarg->second->swapBuffers(waitForVSync);
  100. }
  101. }
  102. //-----------------------------------------------------------------------
  103. RenderWindow* RenderSystem::_initialise(bool autoCreateWindow, const String& windowTitle)
  104. {
  105. // Have I been registered by call to Root::setRenderSystem?
  106. /** Don't do this anymore, just allow via Root
  107. RenderSystem* regPtr = Root::getSingleton().getRenderSystem();
  108. if (!regPtr || regPtr != this)
  109. // Register self - library user has come to me direct
  110. Root::getSingleton().setRenderSystem(this);
  111. */
  112. // Subclasses should take it from here
  113. // They should ALL call this superclass method from
  114. // their own initialise() implementations.
  115. mVertexProgramBound = false;
  116. mGeometryProgramBound = false;
  117. mFragmentProgramBound = false;
  118. return 0;
  119. }
  120. //---------------------------------------------------------------------------------------------
  121. void RenderSystem::useCustomRenderSystemCapabilities(RenderSystemCapabilities* capabilities)
  122. {
  123. if (mRealCapabilities != 0)
  124. {
  125. CM_EXCEPT(InternalErrorException,
  126. "Custom render capabilities must be set before the RenderSystem is initialised.");
  127. }
  128. mCurrentCapabilities = capabilities;
  129. mUseCustomCapabilities = true;
  130. }
  131. //---------------------------------------------------------------------------------------------
  132. bool RenderSystem::_createRenderWindows(const RenderWindowDescriptionList& renderWindowDescriptions,
  133. RenderWindowList& createdWindows)
  134. {
  135. unsigned int fullscreenWindowsCount = 0;
  136. // Grab some information and avoid duplicate render windows.
  137. for (unsigned int nWindow=0; nWindow < renderWindowDescriptions.size(); ++nWindow)
  138. {
  139. const RenderWindowDescription* curDesc = &renderWindowDescriptions[nWindow];
  140. // Count full screen windows.
  141. if (curDesc->useFullScreen)
  142. fullscreenWindowsCount++;
  143. bool renderWindowFound = false;
  144. if (mRenderTargets.find(curDesc->name) != mRenderTargets.end())
  145. renderWindowFound = true;
  146. else
  147. {
  148. for (unsigned int nSecWindow = nWindow + 1 ; nSecWindow < renderWindowDescriptions.size(); ++nSecWindow)
  149. {
  150. if (curDesc->name == renderWindowDescriptions[nSecWindow].name)
  151. {
  152. renderWindowFound = true;
  153. break;
  154. }
  155. }
  156. }
  157. // Make sure we don't already have a render target of the
  158. // same name as the one supplied
  159. if(renderWindowFound)
  160. {
  161. String msg;
  162. msg = "A render target of the same name '" + String(curDesc->name) + "' already "
  163. "exists. You cannot create a new window with this name.";
  164. CM_EXCEPT(InternalErrorException, msg);
  165. }
  166. }
  167. // Case we have to create some full screen rendering windows.
  168. if (fullscreenWindowsCount > 0)
  169. {
  170. // Can not mix full screen and windowed rendering windows.
  171. if (fullscreenWindowsCount != renderWindowDescriptions.size())
  172. {
  173. CM_EXCEPT(InvalidParametersException,
  174. "Can not create mix of full screen and windowed rendering windows");
  175. }
  176. }
  177. return true;
  178. }
  179. //---------------------------------------------------------------------------------------------
  180. void RenderSystem::destroyRenderWindow(const String& name)
  181. {
  182. destroyRenderTarget(name);
  183. }
  184. //---------------------------------------------------------------------------------------------
  185. void RenderSystem::destroyRenderTexture(const String& name)
  186. {
  187. destroyRenderTarget(name);
  188. }
  189. //---------------------------------------------------------------------------------------------
  190. void RenderSystem::destroyRenderTarget(const String& name)
  191. {
  192. RenderTarget* rt = detachRenderTarget(name);
  193. delete rt;
  194. }
  195. //---------------------------------------------------------------------------------------------
  196. void RenderSystem::attachRenderTarget( RenderTarget &target )
  197. {
  198. assert( target.getPriority() < OGRE_NUM_RENDERTARGET_GROUPS );
  199. mRenderTargets.insert( RenderTargetMap::value_type( target.getName(), &target ) );
  200. mPrioritisedRenderTargets.insert(
  201. RenderTargetPriorityMap::value_type(target.getPriority(), &target ));
  202. }
  203. //---------------------------------------------------------------------------------------------
  204. RenderTarget * RenderSystem::getRenderTarget( const String &name )
  205. {
  206. RenderTargetMap::iterator it = mRenderTargets.find( name );
  207. RenderTarget *ret = NULL;
  208. if( it != mRenderTargets.end() )
  209. {
  210. ret = it->second;
  211. }
  212. return ret;
  213. }
  214. //---------------------------------------------------------------------------------------------
  215. RenderTarget * RenderSystem::detachRenderTarget( const String &name )
  216. {
  217. RenderTargetMap::iterator it = mRenderTargets.find( name );
  218. RenderTarget *ret = NULL;
  219. if( it != mRenderTargets.end() )
  220. {
  221. ret = it->second;
  222. /* Remove the render target from the priority groups. */
  223. RenderTargetPriorityMap::iterator itarg, itargend;
  224. itargend = mPrioritisedRenderTargets.end();
  225. for( itarg = mPrioritisedRenderTargets.begin(); itarg != itargend; ++itarg )
  226. {
  227. if( itarg->second == ret ) {
  228. mPrioritisedRenderTargets.erase( itarg );
  229. break;
  230. }
  231. }
  232. mRenderTargets.erase( it );
  233. }
  234. /// If detached render target is the active render target, reset active render target
  235. if(ret == mActiveRenderTarget)
  236. mActiveRenderTarget = 0;
  237. return ret;
  238. }
  239. //-----------------------------------------------------------------------
  240. Viewport* RenderSystem::_getViewport(void)
  241. {
  242. return mActiveViewport;
  243. }
  244. //-----------------------------------------------------------------------
  245. void RenderSystem::_setTextureUnitSettings(size_t texUnit, const TexturePtr& tex, TextureState& tl)
  246. {
  247. // This method is only ever called to set a texture unit to valid details
  248. // The method _disableTextureUnit is called to turn a unit off
  249. // Vertex texture binding?
  250. if (mCurrentCapabilities->hasCapability(RSC_VERTEX_TEXTURE_FETCH) &&
  251. !mCurrentCapabilities->getVertexTextureUnitsShared())
  252. {
  253. if (tl.getBindingType() == TextureState::BT_VERTEX)
  254. {
  255. // Bind vertex texture
  256. _setVertexTexture(texUnit, tex);
  257. // bind nothing to fragment unit (hardware isn't shared but fragment
  258. // unit can't be using the same index
  259. _setTexture(texUnit, true, sNullTexPtr);
  260. }
  261. else
  262. {
  263. // vice versa
  264. _setVertexTexture(texUnit, sNullTexPtr);
  265. _setTexture(texUnit, true, tex);
  266. }
  267. }
  268. else
  269. {
  270. // Shared vertex / fragment textures or no vertex texture support
  271. // Bind texture (may be blank)
  272. _setTexture(texUnit, true, tex);
  273. }
  274. // Set texture layer filtering
  275. _setTextureUnitFiltering(texUnit,
  276. tl.getTextureFiltering(FT_MIN),
  277. tl.getTextureFiltering(FT_MAG),
  278. tl.getTextureFiltering(FT_MIP));
  279. // Set texture layer filtering
  280. _setTextureLayerAnisotropy(texUnit, tl.getTextureAnisotropy());
  281. // Set mipmap biasing
  282. _setTextureMipmapBias(texUnit, tl.getTextureMipmapBias());
  283. // Texture addressing mode
  284. const TextureState::UVWAddressingMode& uvw = tl.getTextureAddressingMode();
  285. _setTextureAddressingMode(texUnit, uvw);
  286. }
  287. //-----------------------------------------------------------------------
  288. void RenderSystem::_setVertexTexture(size_t unit, const TexturePtr& tex)
  289. {
  290. CM_EXCEPT(NotImplementedException,
  291. "This rendersystem does not support separate vertex texture samplers, "
  292. "you should use the regular texture samplers which are shared between "
  293. "the vertex and fragment units.");
  294. }
  295. //-----------------------------------------------------------------------
  296. void RenderSystem::_disableTextureUnit(size_t texUnit)
  297. {
  298. _setTexture(texUnit, false, sNullTexPtr);
  299. }
  300. //---------------------------------------------------------------------
  301. void RenderSystem::_disableTextureUnitsFrom(size_t texUnit)
  302. {
  303. size_t disableTo = CM_MAX_TEXTURE_LAYERS;
  304. if (disableTo > mDisabledTexUnitsFrom)
  305. disableTo = mDisabledTexUnitsFrom;
  306. mDisabledTexUnitsFrom = texUnit;
  307. for (size_t i = texUnit; i < disableTo; ++i)
  308. {
  309. _disableTextureUnit(i);
  310. }
  311. }
  312. //-----------------------------------------------------------------------
  313. void RenderSystem::_setTextureUnitFiltering(size_t unit, FilterOptions minFilter,
  314. FilterOptions magFilter, FilterOptions mipFilter)
  315. {
  316. _setTextureUnitFiltering(unit, FT_MIN, minFilter);
  317. _setTextureUnitFiltering(unit, FT_MAG, magFilter);
  318. _setTextureUnitFiltering(unit, FT_MIP, mipFilter);
  319. }
  320. //-----------------------------------------------------------------------
  321. CullingMode RenderSystem::_getCullingMode(void) const
  322. {
  323. return mCullingMode;
  324. }
  325. //-----------------------------------------------------------------------
  326. bool RenderSystem::getWaitForVerticalBlank(void) const
  327. {
  328. return mVSync;
  329. }
  330. //-----------------------------------------------------------------------
  331. void RenderSystem::setWaitForVerticalBlank(bool enabled)
  332. {
  333. mVSync = enabled;
  334. }
  335. bool RenderSystem::getWBufferEnabled(void) const
  336. {
  337. return mWBuffer;
  338. }
  339. //-----------------------------------------------------------------------
  340. void RenderSystem::setWBufferEnabled(bool enabled)
  341. {
  342. mWBuffer = enabled;
  343. }
  344. //-----------------------------------------------------------------------
  345. void RenderSystem::shutdown(void)
  346. {
  347. // Remove occlusion queries
  348. for (HardwareOcclusionQueryList::iterator i = mHwOcclusionQueries.begin();
  349. i != mHwOcclusionQueries.end(); ++i)
  350. {
  351. delete *i;
  352. }
  353. mHwOcclusionQueries.clear();
  354. // Remove all the render targets.
  355. // (destroy primary target last since others may depend on it)
  356. RenderTarget* primary = 0;
  357. for (RenderTargetMap::iterator it = mRenderTargets.begin(); it != mRenderTargets.end(); ++it)
  358. {
  359. if (!primary && it->second->isPrimary())
  360. primary = it->second;
  361. else
  362. delete it->second;
  363. }
  364. delete primary;
  365. mRenderTargets.clear();
  366. mPrioritisedRenderTargets.clear();
  367. }
  368. //-----------------------------------------------------------------------
  369. void RenderSystem::_beginGeometryCount(void)
  370. {
  371. mBatchCount = mFaceCount = mVertexCount = 0;
  372. }
  373. //-----------------------------------------------------------------------
  374. unsigned int RenderSystem::_getFaceCount(void) const
  375. {
  376. return static_cast< unsigned int >( mFaceCount );
  377. }
  378. //-----------------------------------------------------------------------
  379. unsigned int RenderSystem::_getBatchCount(void) const
  380. {
  381. return static_cast< unsigned int >( mBatchCount );
  382. }
  383. //-----------------------------------------------------------------------
  384. unsigned int RenderSystem::_getVertexCount(void) const
  385. {
  386. return static_cast< unsigned int >( mVertexCount );
  387. }
  388. //-----------------------------------------------------------------------
  389. void RenderSystem::convertColourValue(const Color& colour, UINT32* pDest)
  390. {
  391. *pDest = VertexElement::convertColourValue(colour, getColourVertexElementType());
  392. }
  393. //-----------------------------------------------------------------------
  394. void RenderSystem::_setWorldMatrices(const Matrix4* m, unsigned short count)
  395. {
  396. // Do nothing with these matrices here, it never used for now,
  397. // derived class should take care with them if required.
  398. // Set hardware matrix to nothing
  399. _setWorldMatrix(Matrix4::IDENTITY);
  400. }
  401. //-----------------------------------------------------------------------
  402. void RenderSystem::_render(const RenderOperation& op)
  403. {
  404. // Update stats
  405. size_t val;
  406. if (op.useIndexes)
  407. val = op.indexData->indexCount;
  408. else
  409. val = op.vertexData->vertexCount;
  410. // account for a pass having multiple iterations
  411. if (mCurrentPassIterationCount > 1)
  412. val *= mCurrentPassIterationCount;
  413. mCurrentPassIterationNum = 0;
  414. switch(op.operationType)
  415. {
  416. case RenderOperation::OT_TRIANGLE_LIST:
  417. mFaceCount += val / 3;
  418. break;
  419. case RenderOperation::OT_TRIANGLE_STRIP:
  420. case RenderOperation::OT_TRIANGLE_FAN:
  421. mFaceCount += val - 2;
  422. break;
  423. case RenderOperation::OT_POINT_LIST:
  424. case RenderOperation::OT_LINE_LIST:
  425. case RenderOperation::OT_LINE_STRIP:
  426. break;
  427. }
  428. mVertexCount += op.vertexData->vertexCount;
  429. mBatchCount += mCurrentPassIterationCount;
  430. // sort out clip planes
  431. // have to do it here in case of matrix issues
  432. if (mClipPlanesDirty)
  433. {
  434. setClipPlanesImpl(mClipPlanes);
  435. mClipPlanesDirty = false;
  436. }
  437. }
  438. //-----------------------------------------------------------------------
  439. void RenderSystem::setInvertVertexWinding(bool invert)
  440. {
  441. mInvertVertexWinding = invert;
  442. }
  443. //-----------------------------------------------------------------------
  444. bool RenderSystem::getInvertVertexWinding(void) const
  445. {
  446. return mInvertVertexWinding;
  447. }
  448. //---------------------------------------------------------------------
  449. void RenderSystem::addClipPlane (const Plane &p)
  450. {
  451. mClipPlanes.push_back(p);
  452. mClipPlanesDirty = true;
  453. }
  454. //---------------------------------------------------------------------
  455. void RenderSystem::addClipPlane (float A, float B, float C, float D)
  456. {
  457. addClipPlane(Plane(A, B, C, D));
  458. }
  459. //---------------------------------------------------------------------
  460. void RenderSystem::setClipPlanes(const PlaneList& clipPlanes)
  461. {
  462. if (clipPlanes != mClipPlanes)
  463. {
  464. mClipPlanes = clipPlanes;
  465. mClipPlanesDirty = true;
  466. }
  467. }
  468. //---------------------------------------------------------------------
  469. void RenderSystem::resetClipPlanes()
  470. {
  471. if (!mClipPlanes.empty())
  472. {
  473. mClipPlanes.clear();
  474. mClipPlanesDirty = true;
  475. }
  476. }
  477. //-----------------------------------------------------------------------
  478. void RenderSystem::_notifyCameraRemoved(const Camera* cam)
  479. {
  480. // TODO PORT - Not used in the port. Should probably be removed
  481. }
  482. //---------------------------------------------------------------------
  483. bool RenderSystem::updatePassIterationRenderState(void)
  484. {
  485. if (mCurrentPassIterationCount <= 1)
  486. return false;
  487. --mCurrentPassIterationCount;
  488. ++mCurrentPassIterationNum;
  489. if (mActiveVertexGpuProgramParameters != nullptr)
  490. {
  491. mActiveVertexGpuProgramParameters->incPassIterationNumber();
  492. bindGpuProgramPassIterationParameters(GPT_VERTEX_PROGRAM);
  493. }
  494. if (mActiveGeometryGpuProgramParameters != nullptr)
  495. {
  496. mActiveGeometryGpuProgramParameters->incPassIterationNumber();
  497. bindGpuProgramPassIterationParameters(GPT_GEOMETRY_PROGRAM);
  498. }
  499. if (mActiveFragmentGpuProgramParameters != nullptr)
  500. {
  501. mActiveFragmentGpuProgramParameters->incPassIterationNumber();
  502. bindGpuProgramPassIterationParameters(GPT_FRAGMENT_PROGRAM);
  503. }
  504. return true;
  505. }
  506. //-----------------------------------------------------------------------
  507. void RenderSystem::addListener(Listener* l)
  508. {
  509. mEventListeners.push_back(l);
  510. }
  511. //-----------------------------------------------------------------------
  512. void RenderSystem::removeListener(Listener* l)
  513. {
  514. mEventListeners.remove(l);
  515. }
  516. //-----------------------------------------------------------------------
  517. void RenderSystem::fireEvent(const String& name, const NameValuePairList* params)
  518. {
  519. for(ListenerList::iterator i = mEventListeners.begin();
  520. i != mEventListeners.end(); ++i)
  521. {
  522. (*i)->eventOccurred(name, params);
  523. }
  524. }
  525. //-----------------------------------------------------------------------
  526. void RenderSystem::destroyHardwareOcclusionQuery( HardwareOcclusionQuery *hq)
  527. {
  528. HardwareOcclusionQueryList::iterator i =
  529. std::find(mHwOcclusionQueries.begin(), mHwOcclusionQueries.end(), hq);
  530. if (i != mHwOcclusionQueries.end())
  531. {
  532. mHwOcclusionQueries.erase(i);
  533. delete hq;
  534. }
  535. }
  536. //-----------------------------------------------------------------------
  537. void RenderSystem::bindGpuProgram(GpuProgram* prg)
  538. {
  539. switch(prg->getType())
  540. {
  541. case GPT_VERTEX_PROGRAM:
  542. // mark clip planes dirty if changed (programmable can change space)
  543. if (!mVertexProgramBound && !mClipPlanes.empty())
  544. mClipPlanesDirty = true;
  545. mVertexProgramBound = true;
  546. break;
  547. case GPT_GEOMETRY_PROGRAM:
  548. mGeometryProgramBound = true;
  549. break;
  550. case GPT_FRAGMENT_PROGRAM:
  551. mFragmentProgramBound = true;
  552. break;
  553. }
  554. }
  555. //-----------------------------------------------------------------------
  556. void RenderSystem::unbindGpuProgram(GpuProgramType gptype)
  557. {
  558. switch(gptype)
  559. {
  560. case GPT_VERTEX_PROGRAM:
  561. // mark clip planes dirty if changed (programmable can change space)
  562. if (mVertexProgramBound && !mClipPlanes.empty())
  563. mClipPlanesDirty = true;
  564. mVertexProgramBound = false;
  565. break;
  566. case GPT_GEOMETRY_PROGRAM:
  567. mGeometryProgramBound = false;
  568. break;
  569. case GPT_FRAGMENT_PROGRAM:
  570. mFragmentProgramBound = false;
  571. break;
  572. }
  573. }
  574. //-----------------------------------------------------------------------
  575. bool RenderSystem::isGpuProgramBound(GpuProgramType gptype)
  576. {
  577. switch(gptype)
  578. {
  579. case GPT_VERTEX_PROGRAM:
  580. return mVertexProgramBound;
  581. case GPT_GEOMETRY_PROGRAM:
  582. return mGeometryProgramBound;
  583. case GPT_FRAGMENT_PROGRAM:
  584. return mFragmentProgramBound;
  585. }
  586. // Make compiler happy
  587. return false;
  588. }
  589. //---------------------------------------------------------------------
  590. void RenderSystem::_setTextureProjectionRelativeTo(bool enabled, const Vector3& pos)
  591. {
  592. mTexProjRelative = enabled;
  593. mTexProjRelativeOrigin = pos;
  594. }
  595. //---------------------------------------------------------------------
  596. RenderSystem::RenderSystemContext* RenderSystem::_pauseFrame(void)
  597. {
  598. _endFrame();
  599. return new RenderSystem::RenderSystemContext;
  600. }
  601. //---------------------------------------------------------------------
  602. void RenderSystem::_resumeFrame(RenderSystemContext* context)
  603. {
  604. _beginFrame();
  605. delete context;
  606. }
  607. }