- Timestamp:
- 08/03/05 14:12:41 (19 years ago)
- Location:
- trunk/VUT/work
- Files:
-
- 1 added
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/work/IVReader/include/ivmanualmeshloader.h
r183 r193 3 3 4 4 5 #include " ogre.h"5 #include "Ogre.h" 6 6 #include "ivmeshdata.h" 7 7 -
trunk/VUT/work/iv/Demo_IV.vcproj
r187 r193 46 46 LinkIncremental="1" 47 47 SuppressStartupBanner="TRUE" 48 AdditionalLibraryDirectories=""$(OGRE_PATH)\OgreMain\Lib\$(ConfigurationName)";" ..\IVReader\Lib\$(ConfigurationName)";"$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib";"$(OGRE_PATH)\Dependencies\Lib\$(ConfigurationName)";"$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)";"$(GAMETOOLS_PATH)\trunk\VUT\Ogre\lib\$(ConfigurationName)""48 AdditionalLibraryDirectories=""$(OGRE_PATH)\OgreMain\Lib\$(ConfigurationName)";"$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib";"..\IVReader\Lib\$(ConfigurationName)";"$(OGRE_PATH)\Dependencies\Lib\$(ConfigurationName)";"$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)";"$(GAMETOOLS_PATH)\trunk\VUT\Ogre\lib\$(ConfigurationName)"" 49 49 ProgramDatabaseFile=".\..\bin\Release/Demo_IV.pdb" 50 50 SubSystem="2" -
trunk/VUT/work/iv/TestCullingIVApplication.cpp
r187 r193 91 91 Real scale = 1; 92 92 mSceneMgr->setOption("NodeVizScale", &scale); 93 94 String path = " E:/gametools/trunk/VUT/Ogre/resources/";93 // HACK: change this to relative path 94 String path = "D:/gametools/trunk/VUT/Ogre/resources/"; 95 95 96 96 SceneNode *node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node1"); -
trunk/VUT/work/ogre_changes/OgreMain/include/OgreRenderQueueSortingGrouping.h
r139 r193 48 48 objects. 49 49 */ 50 class RenderPriorityGroup 50 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 51 class _OgreExport RenderPriorityGroup 52 #else 53 class _OgrePrivate RenderPriorityGroup 54 #endif // GTP_VISIBILITY_MODIFIED_OGRE 51 55 { 52 56 /** Internal struct reflecting a single Pass for a Renderable. … … 247 251 This is an internal OGRE class, not intended for apps to use. 248 252 */ 249 class RenderQueueGroup253 class _OgrePrivate RenderQueueGroup 250 254 { 251 255 public: -
trunk/VUT/work/ogre_changes/OgreMain/include/OgreRenderSystem.h
r150 r193 318 318 Values: true, false 319 319 Default: 0 320 ** 321 Key: "border" 322 Description: The type of window border (in windowed mode) 323 Values: none, fixed, resize 324 Default: resize 325 ** 326 Key: "outerDimensions" 327 Description: Whether the width/height is expressed as the size of the 328 outer window, rather than the content area 329 Values: true, false 330 Default: false 320 331 */ 321 332 virtual RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height, … … 980 991 bool mInvertVertexWinding; 981 992 993 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 982 994 int mColour[4]; 995 #endif // GTP_VISIBILITY_MODIFIED_OGRE 983 996 }; 984 997 } -
trunk/VUT/work/ogre_changes/OgreMain/include/OgreRenderable.h
r158 r193 53 53 { 54 54 public: 55 Renderable() {mId = -1;} 55 Renderable() : mRenderDetailOverrideable(true) 56 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 57 , mId(-1) 58 #endif // GTP_VISIBILITY_MODIFIED_OGRE 59 {} 60 56 61 /** Virtual destructor needed as class has virtual methods. */ 57 62 virtual ~Renderable() { } … … 227 232 } 228 233 } 234 235 /** Sets whether this renderable's chosen detail level can be 236 overridden (downgraded) by the camera setting. 237 @param override true means that a lower camera detail will override this 238 renderables detail level, false means it won't. 239 */ 240 virtual void setRenderDetailOverrideable(bool override) 241 { 242 mRenderDetailOverrideable = override; 243 } 244 245 /** Gets whether this renderable's chosen detail level can be 246 overridden (downgraded) by the camera setting. 247 */ 248 virtual bool getRenderDetailOverrideable(void) const 249 { 250 return mRenderDetailOverrideable; 251 } 252 253 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 229 254 /** Sets an id for this renderable. 230 255 */ … … 233 258 */ 234 259 int getId() {return mId;} 235 260 #endif // GTP_VISIBILITY_MODIFIED_OGRE 236 261 protected: 237 262 static const PlaneList msDummyPlaneList; 238 263 typedef std::map<size_t, Vector4> CustomParameterMap; 239 264 CustomParameterMap mCustomParameters; 265 bool mRenderDetailOverrideable; 266 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 240 267 int mId; 268 #endif // GTP_VISIBILITY_MODIFIED_OGRE 241 269 }; 242 270 -
trunk/VUT/work/ogre_changes/OgreMain/src/OgreFrustum.cpp
r61 r193 496 496 updateFrustum(); 497 497 498 Vector3 newpos = position; 499 if (mReflect) 500 { 501 newpos = mReflectMatrix * newpos; 502 } 498 503 Matrix4 combo = mStandardProjMatrix * mViewMatrix; 499 504 mFrustumPlanes[FRUSTUM_PLANE_LEFT].normal.x = combo[3][0] + combo[0][0]; … … 520 525 mFrustumPlanes[FRUSTUM_PLANE_NEAR].normal.y = combo[3][1] + combo[2][1]; 521 526 mFrustumPlanes[FRUSTUM_PLANE_NEAR].normal.z = combo[3][2] + combo[2][2]; 522 mFrustumPlanes[FRUSTUM_PLANE_NEAR].d = combo[3][3] + combo[2][3]; 527 mFrustumPlanes[FRUSTUM_PLANE_NEAR].normal.normalise(); 528 mFrustumPlanes[FRUSTUM_PLANE_NEAR].d = 529 -(mFrustumPlanes[FRUSTUM_PLANE_NEAR].normal.dotProduct(newpos) + mNearDist); 523 530 524 531 mFrustumPlanes[FRUSTUM_PLANE_FAR].normal.x = combo[3][0] - combo[2][0]; 525 532 mFrustumPlanes[FRUSTUM_PLANE_FAR].normal.y = combo[3][1] - combo[2][1]; 526 533 mFrustumPlanes[FRUSTUM_PLANE_FAR].normal.z = combo[3][2] - combo[2][2]; 527 mFrustumPlanes[FRUSTUM_PLANE_FAR].d = combo[3][3] - combo[2][3]; 528 529 // Renormalise any normals which were not unit length 530 for(int i=0; i<6; i++ ) 534 mFrustumPlanes[FRUSTUM_PLANE_FAR].normal.normalise(); 535 mFrustumPlanes[FRUSTUM_PLANE_FAR].d = 536 -(mFrustumPlanes[FRUSTUM_PLANE_FAR].normal.dotProduct(newpos) - mFarDist); 537 538 // Renormalise any normals which were not unit length (not near & far) 539 for(int i=2; i<6; i++ ) 531 540 { 532 541 float length = mFrustumPlanes[i].normal.normalise(); -
trunk/VUT/work/ogre_changes/OgreMain/src/OgreSceneManager.cpp
r183 r193 130 130 mShadowCasterQueryListener = new ShadowCasterSceneQueryListener(this); 131 131 132 132 Root *root = Root::getSingletonPtr(); 133 if (root) 134 _setDestinationRenderSystem(root->getRenderSystem()); 133 135 } 134 136 //----------------------------------------------------------------------- … … 392 394 // Calc squared distance 393 395 lt->tempSquareDist = (lt->getDerivedPosition() - position).squaredLength(); 394 lt->tempSquareDist -= squaredRadius;395 396 // only add in-range lights 396 397 Real range = lt->getAttenuationRange(); 397 if ( lt->tempSquareDist<= (range * range))398 if ((lt->tempSquareDist - squaredRadius) <= (range * range)) 398 399 { 399 400 destList.push_back(lt); … … 403 404 } 404 405 405 // Sort 406 std::s ort(destList.begin(), destList.end(), lightLess());406 // Sort (stable to guarantee ordering on directional lights) 407 std::stable_sort(destList.begin(), destList.end(), lightLess()); 407 408 408 409 … … 527 528 { 528 529 removeAllStaticGeometry(); 530 removeAllEntities(); 531 removeAllBillboardSets(); 532 removeAllLights(); 533 534 // Clear root node of all children 535 mSceneRoot->removeAllChildren(); 536 mSceneRoot->detachAllObjects(); 537 529 538 // Delete all SceneNodes, except root that is 530 539 for (SceneNodeList::iterator i = mSceneNodes.begin(); … … 536 545 mAutoTrackingSceneNodes.clear(); 537 546 538 // Clear root node of all children 539 mSceneRoot->removeAllChildren(); 540 mSceneRoot->detachAllObjects(); 541 542 removeAllEntities(); 543 removeAllBillboardSets(); 544 removeAllLights(); 547 545 548 546 549 // Clear animations … … 607 610 } 608 611 612 // detach from parent (don't do this in destructor since bulk destruction 613 // behaves differently) 614 Node* parentNode = i->second->getParent(); 615 if (parentNode) 616 { 617 parentNode->removeChild(i->second); 618 } 609 619 delete i->second; 610 620 mSceneNodes.erase(i); … … 646 656 647 657 // TEST 648 649 //LogManager::getSingleton().logMessage("BEGIN PASS " + StringConverter::toString(pass->getIndex()) +650 //" of " + pass->getParent()->getParent()->getName() + "\n");651 658 /* 659 LogManager::getSingleton().logMessage("BEGIN PASS " + StringConverter::toString(pass->getIndex()) + 660 " of " + pass->getParent()->getParent()->getName()); 661 */ 652 662 bool passSurfaceAndLightParams = true; 653 663 … … 868 878 // Tell params about current ambient light 869 879 mAutoParamDataSource.setAmbientLightColour(mAmbientLight); 880 // Tell rendersystem 881 mDestRenderSystem->setAmbientLight(mAmbientLight.r, mAmbientLight.g, mAmbientLight.b); 870 882 871 883 // Tell params about render target … … 1540 1552 renderShadowVolumesToStencil(l, mCameraInProgress); 1541 1553 // render full-screen shadow modulator for all lights 1542 //LogManager::getSingleton().logMessage("setting shadow modulative pass");1543 1554 setPass(mShadowModulativePass); 1544 1555 // turn stencil check on … … 1801 1812 continue; 1802 1813 1803 //LogManager::getSingleton().logMessage("setting solid pass");1804 1814 // For solids, we try to do each pass in turn 1805 1815 Pass* usedPass = setPass(ipass->first); … … 1832 1842 itrans != itransend; ++itrans) 1833 1843 { 1834 //LogManager::getSingleton().logMessage("setting transparent pass");1835 1844 // For transparents, we have to accept that we can't sort entirely by pass 1836 1845 setPass(itrans->pass); … … 1909 1918 1910 1919 itransend = objs.end(); 1911 for (itrans = objs.begin(); itrans != itransend; ++itrans) 1920 for (itrans = objs.begin(); 1921 itrans != itransend; ++itrans) 1912 1922 { 1913 1923 Renderable *r = itrans->renderable; … … 1917 1927 if (p->getParent()->getParent()->getTransparencyCastsShadows()) 1918 1928 { 1919 //LogManager::getSingleton().logMessage("setting transparent shadow pass");1920 1929 setPass(p); 1921 1930 renderSingleObject(itrans->renderable, p, doLightIteration, manualLightList); … … 1930 1939 unsigned short numMatrices; 1931 1940 static bool normalisedNormals = false; 1932 staticSceneDetailLevel camDetailLevel = mCameraInProgress->getDetailLevel();1941 SceneDetailLevel camDetailLevel = mCameraInProgress->getDetailLevel(); 1933 1942 static SceneDetailLevel lastDetailLevel = camDetailLevel; 1934 1943 static RenderOperation ro; … … 1981 1990 // Set up the solid / wireframe override 1982 1991 SceneDetailLevel reqDetail = rend->getRenderDetail(); 1983 if (reqDetail != lastDetailLevel || reqDetail != camDetailLevel) 1984 { 1992 if (rend->getRenderDetailOverrideable()) 1993 { 1994 // check camera detial only when render detail is overridable 1985 1995 if (reqDetail > camDetailLevel) 1986 1996 { … … 1988 1998 reqDetail = camDetailLevel; 1989 1999 } 2000 } 2001 if (reqDetail != lastDetailLevel) 2002 { 1990 2003 mDestRenderSystem->_setRasterisationMode(reqDetail); 1991 2004 lastDetailLevel = reqDetail; … … 2416 2429 mDestRenderSystem->_beginFrame(); 2417 2430 2418 //LogManager::getSingleton().logMessage("setting manual pass");2419 2431 setPass(pass); 2420 2432 mDestRenderSystem->_render(*rend); … … 2814 2826 void SceneManager::initShadowVolumeMaterials(void) 2815 2827 { 2828 /* This should have been set in the SceneManager constructor, but if you 2829 created the SceneManager BEFORE the Root object, you will need to call 2830 SceneManager::_setDestinationRenderSystem manually. 2831 */ 2832 assert( mDestRenderSystem ); 2816 2833 2817 2834 if (mShadowMaterialInitDone) … … 3012 3029 Pass* SceneManager::deriveShadowCasterPass(Pass* pass) 3013 3030 { 3014 //LogManager::getSingleton().logMessage("*********derive shadow caster pass*********");3015 3031 switch (mShadowTechnique) 3016 3032 { … … 3018 3034 if (mShadowTextureCustomCasterPass) 3019 3035 { 3020 //LogManager::getSingleton().logMessage("custom caster pass");3021 3036 // Caster pass has been customised 3022 3037 3023 3038 if (!pass->getShadowCasterVertexProgramName().empty()) 3024 3039 { 3025 //LogManager::getSingleton().logMessage("custom caster pass has vertex program");3026 3040 // Have to merge the shadow caster vertex program in 3027 3041 mShadowTextureCustomCasterPass->setVertexProgram( … … 3040 3054 else if (mShadowTextureCasterVPDirty) 3041 3055 { 3042 //LogManager::getSingleton().logMessage("caster pass dirty");3043 3056 // reset 3044 3057 mShadowTextureCustomCasterPass->setVertexProgram( … … 3056 3069 else 3057 3070 { 3058 //LogManager::getSingleton().logMessage("standard caster pass");3059 3071 // Standard pass 3060 3072 if (pass->hasVertexProgram()) 3061 3073 { 3062 //LogManager::getSingleton().logMessage("standard caster pass has vertex program");3063 3074 // Have to merge the shadow caster vertex program in 3064 3075 // This may in fact be blank, in which case it falls back on … … 3081 3092 else if (mShadowCasterPlainBlackPass->hasVertexProgram()) 3082 3093 { 3083 //LogManager::getSingleton().logMessage("standard caster pass no vertex program");3084 3094 // reset 3085 3095 mShadowCasterPlainBlackPass->setVertexProgram(""); … … 3095 3105 Pass* SceneManager::deriveShadowReceiverPass(Pass* pass) 3096 3106 { 3097 //LogManager::getSingleton().logMessage("*********derive shadow receiver pass*********"); 3107 3098 3108 switch (mShadowTechnique) 3099 3109 { … … 3102 3112 { 3103 3113 // Receiver pass has been customised 3104 //LogManager::getSingleton().logMessage("custom receiver pass"); 3114 3105 3115 if (!pass->getShadowReceiverVertexProgramName().empty()) 3106 3116 { 3107 //LogManager::getSingleton().logMessage("merge receiver pass shadow vertex program");3108 3117 // Have to merge the shadow Receiver vertex program in 3109 3118 mShadowTextureCustomReceiverPass->setVertexProgram( … … 3122 3131 else if (mShadowTextureReceiverVPDirty) 3123 3132 { 3124 //LogManager::getSingleton().logMessage("receiver pass dirty");3125 3133 // reset 3126 3134 mShadowTextureCustomReceiverPass->setVertexProgram( … … 3138 3146 else 3139 3147 { 3140 //LogManager::getSingleton().logMessage("no custom receiver pass");3141 3148 if (pass->hasVertexProgram()) 3142 3149 { 3143 //LogManager::getSingleton().logMessage("standard receiver pass has vertex program");3144 3150 // Have to merge the receiver vertex program in 3145 3151 // This may return "" which means fixed function will be used … … 3161 3167 else if (mShadowReceiverPass->hasVertexProgram()) 3162 3168 { 3163 //LogManager::getSingleton().logMessage("standard receiver pass no vertex program");3164 3169 // reset 3165 3170 mShadowReceiverPass->setVertexProgram(""); … … 3383 3388 setColourOperationEx(LBX_MODULATE, LBS_MANUAL, LBS_CURRENT, 3384 3389 zfailAlgo ? ColourValue(0.7, 0.0, 0.2) : ColourValue(0.0, 0.7, 0.2)); 3385 //LogManager::getSingleton().logMessage("setting shadow debug pass");3386 3390 setPass(mShadowDebugPass); 3387 3391 renderShadowVolumeObjects(iShadowRenderables, mShadowDebugPass, &lightList, flags, -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/include/OgreOctree.h
r158 r193 36 36 #define OCTREE_H 37 37 38 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 38 39 #include "OgreTerrainPrerequisites.h" 40 #endif 39 41 #include <OgreAxisAlignedBox.h> 40 42 #include <OgreWireBoundingBox.h> … … 58 60 */ 59 61 62 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 60 63 class _OgreTerrainExport Octree 64 #else 65 class Octree 66 #endif // GTP_VISIBILITY_MODIFIED_OGRE 61 67 { 62 68 public: -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/include/OgreOctreeCamera.h
r61 r193 59 59 than the default. 60 60 */ 61 61 62 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 62 63 class _OgreTerrainExport OctreeCamera : public Camera -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/include/OgreOctreeNode.h
r187 r193 47 47 * 48 48 */ 49 49 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 50 50 class _OgreTerrainExport OctreeNode : public SceneNode 51 #else 52 class OctreeNode : public SceneNode 53 #endif // GTP_VISIBILITY_MODIFIED_OGRE 51 54 { 52 55 public: … … 104 107 }; 105 108 109 110 106 111 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 107 112 /// scale for node visualization -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/include/OgreOctreeSceneManager.h
r139 r193 35 35 #define OCTREESCENEMANAGER_H 36 36 37 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 37 38 #include "OgreTerrainPrerequisites.h" 39 #endif // GTP_VISIBILITY_MODIFIED_OGRE 38 40 #include "OgreSceneManager.h" 39 41 #include "OgreRenderOperation.h" … … 71 73 */ 72 74 75 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 73 76 class _OgreTerrainExport OctreeSceneManager : public SceneManager 77 #else 78 class OctreeSceneManager : public SceneManager 79 #endif GTP_VISIBILITY_MODIFIED_OGRE 74 80 { 75 81 friend class OctreeIntersectionSceneQuery; -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/include/OgreTerrainRenderable.h
r159 r193 231 231 inline int getRenderLevel() const 232 232 { 233 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 233 234 return mRenderLevel[msCurrentRenderLevelIndex]; 235 #else 236 return mRenderLevel; 237 #endif // GTP_VISIBILITY_MODIFIED_OGRE 234 238 }; 235 239 -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctree.cpp
r160 r193 36 36 #include <OgreOctree.h> 37 37 #include <OgreOctreeNode.h> 38 #include <OgreLogManager.h>39 38 40 39 namespace Ogre … … 174 173 if(mWireBoundingBox == 0) 175 174 mWireBoundingBox = new WireBoundingBox(); 176 177 //mWireBoundingBox->setupBoundingBox(mBox); 175 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 178 176 mWireBoundingBox->setupBoundingBox(mWorldAABB); 177 #else 178 mWireBoundingBox->setupBoundingBox(mBox); 179 #endif 179 180 180 181 return mWireBoundingBox; -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctreeNode.cpp
r187 r193 38 38 #include <OgreOctreeNode.h> 39 39 #include <OgreOctreeSceneManager.h> 40 #include <OgreLogManager.h>41 40 #include <OgreMeshManager.h> 42 41 #include <OgreSubMesh.h> … … 157 156 MovableObject * mo = mit->second; 158 157 159 //LogManager::getSingleton().logMessage("notify");160 158 mo->_notifyCurrentCamera(cam); 161 159 if ( mo->isVisible() && 162 160 (!onlyShadowCasters || mo->getCastShadows())) 163 161 { 164 //LogManager::getSingleton().logMessage("update queue");165 162 mo -> _updateRenderQueue( queue ); 166 163 } -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreTerrainRenderable.cpp
r159 r193 67 67 //----------------------------------------------------------------------- 68 68 TerrainRenderable::TerrainRenderable(const String& name) 69 : mTerrain(0), mName(name), mDeltaBuffers(0), mPositionBuffer(0)69 : Renderable(), mTerrain(0), mName(name), mDeltaBuffers(0), mPositionBuffer(0) 70 70 { 71 71 mForcedRenderLevel = -1; … … 220 220 *pSysPos++ = *pPos++ = ( float ) j * msOptions->scale.z; //z 221 221 222 *pTex0++ = ( float ) i / ( float ) msOptions->pageSize;223 *pTex0++ = ( float ) ( float ) j / ( float ) msOptions->pageSize;224 225 *pTex1++ = ( ( float ) i / ( float ) msOptions->tileSize) * msOptions->detailTile;226 *pTex1++ = ( ( float ) ( float ) j / ( float ) msOptions->tileSize) * msOptions->detailTile;222 *pTex0++ = ( float ) i / ( float ) ( msOptions->pageSize - 1 ); 223 *pTex0++ = ( float ) j / ( float ) ( msOptions->pageSize - 1 ); 224 225 *pTex1++ = ( ( float ) i / ( float ) ( msOptions->tileSize - 1 ) ) * msOptions->detailTile; 226 *pTex1++ = ( ( float ) j / ( float ) ( msOptions->tileSize - 1 ) ) * msOptions->detailTile; 227 227 228 228 if ( height < min ) … … 261 261 262 262 _calculateMinLevelDist2( C ); 263 if (msOptions->lit)264 _calculateNormals();265 263 266 264 } … … 301 299 void TerrainRenderable::_calculateNormals() 302 300 { 301 303 302 Vector3 norm; 304 303 … … 342 341 return ; 343 342 } 343 344 344 345 345 Vector3 cpos = cam -> getDerivedPosition(); … … 381 381 int nextLevel = mNextLevelDown[getRenderLevel()]; 382 382 #else 383 int nextLevel = mNextLevelDown ;383 int nextLevel = mNextLevelDown[mRenderLevel]; 384 384 #endif // GTP_VISIBILITY_MODIFIED_OGRE 385 385 … … 393 393 // Set the morph such that the morph happens in the last 0.25 of 394 394 // the distance range 395 Real range = mMinLevelDistSqr[nextLevel] - mMinLevelDistSqr[getRenderLevel()]; 395 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 396 Real range = mMinLevelDistSqr[nextLevel] - mMinLevelDistSqr[getRenderLevel()]; 397 #else 398 Real range = mMinLevelDistSqr[nextLevel] - mMinLevelDistSqr[mRenderLevel]; 399 #endif // GTP_VISIBILITY_MODIFIED_OGRE 396 400 if (range) 397 401 { 398 Real percent = (L - mMinLevelDistSqr[getRenderLevel()]) / range; 402 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 403 Real percent = (L - mMinLevelDistSqr[getRenderLevel()]) / range; 404 #else 405 Real percent = (L - mMinLevelDistSqr[mRenderLevel]) / range; 406 #endif // GTP_VISIBILITY_MODIFIED_OGRE 399 407 // scale result so that msLODMorphStart == 0, 1 == 1, clamp to 0 below that 400 408 Real rescale = 1.0f / (1.0f - msOptions->lodMorphStart); … … 430 438 431 439 } 440 432 441 } 433 442 //----------------------------------------------------------------------- … … 668 677 return ; 669 678 679 670 680 if ( mLevelIndex.size() == 0 ) 671 681 { 672 682 for ( int i = 0; i < 16; i++ ) 673 683 { 684 674 685 mLevelIndex.push_back( new IndexMap() ); 686 675 687 } 676 688 … … 695 707 void TerrainRenderable::_adjustRenderLevel( int i ) 696 708 { 709 697 710 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 698 711 mRenderLevel[msCurrentRenderLevelIndex] = i; -
trunk/VUT/work/ogre_changes/RenderSystems/Direct3D9/include/OgreD3D9RenderWindow.h
r153 r193 46 46 bool fullScreen, const NameValuePairList *miscParams); 47 47 void destroy(void); 48 bool is Active() const { return mActive; }48 bool isVisible() const; 49 49 bool isClosed() const { return mClosed; } 50 void reposition( int left, int top ) {}50 void reposition(int left, int top); 51 51 void resize( unsigned int width, unsigned int height ); 52 52 void swapBuffers( bool waitForVSync = true ); … … 61 61 */ 62 62 void writeContentsToFile(const String& filename); 63 bool requiresTextureFlipping() const { return false; } 63 64 65 // Method for dealing with resize / move & 3d library 66 void windowMovedOrResized(); 64 67 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 65 68 uchar *getBufferContents(int &dimx, int &dimy); 66 69 #endif // GTP_VISIBILITY_MODIFIED_OGRE 67 70 68 bool requiresTextureFlipping() const { return false; }69 70 // Method for dealing with resize / move & 3d library71 virtual void WindowMovedOrResized(void);72 73 bool isReady() const { return mReady; }74 void setReady(bool set) { mReady = set; }75 void setActive(bool set) { mActive = set; }76 71 /// Get the presentation parameters used with this window 77 72 D3DPRESENT_PARAMETERS* getPresentationParameters(void) 78 73 { return &md3dpp; } 74 79 75 /// @copydoc RenderTarget::update 80 void update( void);76 void update(); 81 77 82 78 /** Create (or recreate) the D3D device or SwapChain for this window. 83 79 */ 84 void createD3DResources(void); 80 void createD3DResources(); 81 82 /** Destroy the D3D device or SwapChain for this window. 83 */ 84 void destroyD3DResources(); 85 85 86 86 protected: … … 88 88 D3D9Driver *mDriver; // D3D9 driver 89 89 HWND mHWnd; // Win32 Window handle 90 bool m Active; // Is active i.e. visible91 bool m Ready; // Is ready i.e. available for update90 bool mIsExternal; // window not created by Ogre 91 bool mSizing; 92 92 bool mClosed; 93 93 bool mIsSwapChain; // Is this a secondary window? -
trunk/VUT/work/ogre_changes/RenderSystems/Direct3D9/include/OgreD3D9Texture.h
r154 r193 161 161 static PixelFormat _getClosestSupportedPF(PixelFormat ogrePF); 162 162 163 /// For dealing with lost devices - release the resource if in the default pool 164 voidreleaseIfDefaultPool(void);165 /// For dealing with lost devices - recreate the resource if in the default pool 166 voidrecreateIfDefaultPool(LPDIRECT3DDEVICE9 pDev);163 /// For dealing with lost devices - release the resource if in the default pool (and return true) 164 bool releaseIfDefaultPool(void); 165 /// For dealing with lost devices - recreate the resource if in the default pool (and return true) 166 bool recreateIfDefaultPool(LPDIRECT3DDEVICE9 pDev); 167 167 168 168 }; … … 243 243 (mName + "_PRIVATE##", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, 244 244 texType, mWidth, mHeight, 0, internalFormat, TU_RENDERTARGET ); 245 mPrivateTex->load(); 245 246 } 246 247 -
trunk/VUT/work/ogre_changes/RenderSystems/Direct3D9/src/OgreD3D9HardwareOcclusionQuery.cpp
r115 r193 87 87 mSkipCounter = 0; 88 88 } 89 //std::stringstream d; d << "count: " << mSkipCounter;90 //LogManager::getSingleton().logMessage(d.str());91 89 if (mSkipCounter == 0) 92 90 { -
trunk/VUT/work/ogre_changes/RenderSystems/Direct3D9/src/OgreD3D9RenderWindow.cpp
r183 r193 45 45 LRESULT D3D9RenderWindow::WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) 46 46 { 47 LPCREATESTRUCT lpcs; 48 D3D9RenderWindow* win; 49 50 // look up window instance 51 if( WM_CREATE != uMsg ) 52 // Get window pointer 53 win = (D3D9RenderWindow*)GetWindowLong( hWnd, 0 ); 47 if (uMsg == WM_CREATE) 48 { 49 // copy D3D9RenderWindow* from createwindow param to userdata slot 50 SetWindowLong(hWnd, GWL_USERDATA, 51 (LONG)(((LPCREATESTRUCT)lParam)->lpCreateParams)); 52 return 0; 53 } 54 55 D3D9RenderWindow* win = 56 (D3D9RenderWindow*)GetWindowLong(hWnd, GWL_USERDATA); 57 58 if (!win) 59 return DefWindowProc(hWnd, uMsg, wParam, lParam); 54 60 55 61 switch( uMsg ) 56 62 { 57 63 case WM_ACTIVATE: 58 if( WA_INACTIVE == LOWORD( wParam ) ) 59 win->mActive = false; 60 else 61 win->mActive = true; 64 win->mActive = (LOWORD(wParam) != WA_INACTIVE); 62 65 break; 63 66 64 case WM_CREATE: 65 // Log the new window 66 // Get CREATESTRUCT 67 lpcs = (LPCREATESTRUCT)lParam; 68 win = (D3D9RenderWindow*)(lpcs->lpCreateParams); 69 // Store pointer in window user data area 70 SetWindowLong( hWnd, 0, (long)win ); 71 win->mActive = true; 72 73 return 0; 67 case WM_ENTERSIZEMOVE: 68 win->mSizing = true; 74 69 break; 75 70 76 case WM_KEYDOWN: 77 // TEMPORARY CODE 78 // TODO - queue up keydown / keyup events with 79 // window name and timestamp to be processed 80 // by main loop 81 82 // ESCAPE closes window 83 /* 84 if (wParam == VK_ESCAPE) 85 { 86 win->mClosed = true; 87 return 0L; 88 } 89 */ 71 case WM_EXITSIZEMOVE: 72 win->windowMovedOrResized(); 73 win->mSizing = false; 90 74 break; 91 75 92 case WM_PAINT:93 // If we get WM_PAINT messges, it usually means our window was94 // comvered up, so we need to refresh it by re-showing the contents95 // of the current frame.96 if( win->mActive && win->mReady )97 win->update();98 break;99 100 76 case WM_MOVE: 101 // Move messages need to be tracked to update the screen rects102 // used for blitting the backbuffer to the primary103 // *** This doesn't need to be used to Direct3D9 ***104 break;105 106 case WM_ENTERSIZEMOVE:107 // Previent rendering while moving / sizing108 win->mReady = false;109 break;110 111 case WM_EXITSIZEMOVE:112 win->WindowMovedOrResized();113 win->mReady = true;114 break;115 116 77 case WM_SIZE: 117 // Check to see if we are losing or gaining our window. Set the 118 // active flag to match 119 if( SIZE_MAXHIDE == wParam || SIZE_MINIMIZED == wParam ) 120 win->mActive = false; 121 else 122 { 123 win->mActive = true; 124 if( win->mReady ) 125 win->WindowMovedOrResized(); 126 } 78 if (!win->mSizing) 79 win->windowMovedOrResized(); 127 80 break; 128 81 … … 134 87 135 88 case WM_CLOSE: 136 DestroyWindow( win->mHWnd );89 win->destroy(); // cleanup and call DestroyWindow 137 90 win->mClosed = true; 138 91 return 0; … … 147 100 { 148 101 mIsFullScreen = false; 149 mIsSwapChain = deviceIfSwapChain != NULL; 102 mIsSwapChain = (deviceIfSwapChain != NULL); 103 mIsExternal = false; 150 104 mHWnd = 0; 151 105 mActive = false; 152 m Ready= false;106 mSizing = false; 153 107 mClosed = false; 154 108 } … … 161 115 LPDIRECT3DDEVICE9 mpD3DDevice = mDriver->getD3DDevice(); 162 116 SAFE_RELEASE( mpD3DDevice ); 163 mDriver->setD3DDevice( mpD3DDevice);117 mDriver->setD3DDevice( NULL ); 164 118 } 165 119 } … … 192 146 String title = name; 193 147 unsigned int colourDepth = 32; 194 unsigned int left = 0; // Defaults to screen center195 unsigned int top = 0; // Defaults to screen center148 int left = -1; // Defaults to screen center 149 int top = -1; // Defaults to screen center 196 150 bool depthBuffer = true; 151 String border = ""; 152 bool outerSize = false; 197 153 198 154 if(miscParams) … … 203 159 opt = miscParams->find("left"); 204 160 if(opt != miscParams->end()) 205 left = StringConverter::parse UnsignedInt(opt->second);161 left = StringConverter::parseInt(opt->second); 206 162 // top (y) 207 163 opt = miscParams->find("top"); 208 164 if(opt != miscParams->end()) 209 top = StringConverter::parse UnsignedInt(opt->second);165 top = StringConverter::parseInt(opt->second); 210 166 // Window title 211 167 opt = miscParams->find("title"); 212 168 if(opt != miscParams->end()) 213 169 title = opt->second; 170 // parentWindowHandle -> parentHWnd 171 opt = miscParams->find("parentWindowHandle"); 172 if(opt != miscParams->end()) 173 parentHWnd = (HWND)StringConverter::parseUnsignedInt(opt->second); 214 174 // externalWindowHandle -> externalHandle 215 175 opt = miscParams->find("externalWindowHandle"); … … 240 200 if(opt != miscParams->end()) 241 201 mFSAAQuality = StringConverter::parseUnsignedInt(opt->second); 202 // window border style 203 opt = miscParams->find("border"); 204 if(opt != miscParams->end()) 205 border = opt->second; 206 // set outer dimensions? 207 opt = miscParams->find("outerDimensions"); 208 if(opt != miscParams->end()) 209 outerSize = StringConverter::parseBool(opt->second); 242 210 } 243 211 … … 249 217 if (!externalHandle) 250 218 { 251 DWORD dwStyle = (fullScreen ? WS_POPUP : WS_OVERLAPPEDWINDOW)| WS_CLIPCHILDREN | WS_CLIPSIBLINGS;219 DWORD dwStyle = WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; 252 220 RECT rc; 253 221 254 222 mWidth = width; 255 223 mHeight = height; 224 mTop = top; 225 mLeft = left; 256 226 257 227 if (!fullScreen) 258 228 { 259 // Calculate window dimensions required to get the requested client area 229 if (parentHWnd) 230 { 231 dwStyle |= WS_CHILD; 232 } 233 else 234 { 235 if (border == "none") 236 dwStyle |= WS_POPUP; 237 else if (border == "fixed") 238 dwStyle |= WS_OVERLAPPED | WS_BORDER | WS_CAPTION | 239 WS_SYSMENU | WS_MINIMIZEBOX; 240 else 241 dwStyle |= WS_OVERLAPPEDWINDOW; 242 } 243 244 if (!outerSize) 245 { 246 // Calculate window dimensions required 247 // to get the requested client area 260 248 SetRect(&rc, 0, 0, mWidth, mHeight); 261 249 AdjustWindowRect(&rc, dwStyle, false); … … 264 252 265 253 // Clamp width and height to the desktop dimensions 266 if (mWidth > (unsigned)GetSystemMetrics(SM_CXSCREEN)) 267 mWidth = (unsigned)GetSystemMetrics(SM_CXSCREEN); 268 if (mHeight > (unsigned)GetSystemMetrics(SM_CYSCREEN)) 269 mHeight = (unsigned)GetSystemMetrics(SM_CYSCREEN); 270 271 if (!left) 272 mLeft = (GetSystemMetrics(SM_CXSCREEN) / 2) - (mWidth / 2); 273 else 274 mLeft = left; 275 if (!top) 276 mTop = (GetSystemMetrics(SM_CYSCREEN) / 2) - (mHeight / 2); 277 else 278 mTop = top; 254 int screenw = GetSystemMetrics(SM_CXSCREEN); 255 int screenh = GetSystemMetrics(SM_CYSCREEN); 256 if ((int)mWidth > screenw) 257 mWidth = screenw; 258 if ((int)mHeight > screenh) 259 mHeight = screenh; 260 if (mLeft < 0) 261 mLeft = (screenw - mWidth) / 2; 262 if (mTop < 0) 263 mTop = (screenh - mHeight) / 2; 264 } 279 265 } 280 266 else 267 { 268 dwStyle |= WS_POPUP; 281 269 mTop = mLeft = 0; 270 } 282 271 283 272 // Register the window class 284 273 // NB allow 4 bytes of window data for D3D9RenderWindow pointer 285 WNDCLASS wndClass = { CS_HREDRAW | CS_VREDRAW, WndProc, 0, 4, hInst, 286 LoadIcon( NULL, IDI_APPLICATION ), 287 LoadCursor( NULL, IDC_ARROW ), 288 (HBRUSH)GetStockObject( BLACK_BRUSH ), NULL, 289 TEXT(title.c_str()) }; 290 RegisterClass( &wndClass ); 274 WNDCLASS wc = { 0, WndProc, 0, 0, hInst, 275 LoadIcon(0, IDI_APPLICATION), LoadCursor(NULL, IDC_ARROW), 276 (HBRUSH)GetStockObject(BLACK_BRUSH), 0, "OgreD3D9Wnd" }; 277 RegisterClass(&wc); 291 278 292 279 // Create our main window 293 280 // Pass pointer to self 294 HWND hWnd = CreateWindow(TEXT(title.c_str()), 295 TEXT(title.c_str()), 296 dwStyle, mLeft, mTop, 297 mWidth, mHeight, 0L, 0L, hInst, this); 298 GetClientRect(hWnd,&rc); 281 mIsExternal = false; 282 mHWnd = CreateWindow("OgreD3D9Wnd", title.c_str(), dwStyle, 283 mLeft, mTop, mWidth, mHeight, parentHWnd, 0, hInst, this); 284 } 285 else 286 { 287 mHWnd = externalHandle; 288 mIsExternal = true; 289 } 290 291 RECT rc; 292 // top and left represent outer window coordinates 293 GetWindowRect(mHWnd, &rc); 294 mTop = rc.top; 295 mLeft = rc.left; 296 // width and height represent interior drawable area 297 GetClientRect(mHWnd,&rc); 299 298 mWidth = rc.right; 300 299 mHeight = rc.bottom; 301 300 302 ShowWindow(hWnd, SW_SHOWNORMAL);303 UpdateWindow(hWnd);304 305 mHWnd = hWnd;306 // Store info307 301 mName = name; 308 302 mIsDepthBuffered = depthBuffer; 309 303 mIsFullScreen = fullScreen; 310 }311 else312 {313 mHWnd = externalHandle;314 ShowWindow(mHWnd, SW_SHOWNORMAL);315 UpdateWindow(mHWnd);316 RECT rc;317 GetClientRect(mHWnd,&rc);318 mWidth = rc.right;319 mHeight = rc.bottom;320 mLeft = rc.left;321 mTop = rc.top;322 mName = name;323 mIsDepthBuffered = depthBuffer;324 mIsFullScreen = fullScreen;325 }326 327 // track colour depth328 304 mColourDepth = colourDepth; 329 305 … … 337 313 createD3DResources(); 338 314 339 m Ready= true;315 mActive = true; 340 316 } 341 317 … … 365 341 md3dpp.BackBufferWidth = mWidth; 366 342 md3dpp.BackBufferHeight = mHeight; 343 367 344 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 368 345 //md3dpp.Flags |= D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; … … 504 481 } 505 482 506 507 void D3D9RenderWindow::destroy() 483 void D3D9RenderWindow::destroyD3DResources() 508 484 { 509 485 mpRenderSurface = 0; … … 515 491 else 516 492 { 517 // ignore dept zh buffer, access device through driver493 // ignore depth buffer, access device through driver 518 494 mpRenderZBuffer = 0; 519 495 LPDIRECT3DDEVICE9 mpD3DDevice = mDriver->getD3DDevice(); 520 496 SAFE_RELEASE(mpD3DDevice); 521 mDriver->setD3DDevice( mpD3DDevice ); 497 mDriver->setD3DDevice(NULL); 498 } 499 } 500 501 void D3D9RenderWindow::destroy() 502 { 503 if (mHWnd && !mIsExternal) 522 504 DestroyWindow( mHWnd ); 523 }524 505 mHWnd = 0; 506 mActive = false; 507 } 508 509 bool D3D9RenderWindow::isVisible() const 510 { 511 return (mHWnd && !IsIconic(mHWnd)); 512 } 513 514 void D3D9RenderWindow::reposition(int top, int left) 515 { 516 if (mHWnd && !mIsFullScreen) 517 { 518 SetWindowPos(mHWnd, 0, top, left, 0, 0, 519 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); 520 } 525 521 } 526 522 527 523 void D3D9RenderWindow::resize( unsigned int width, unsigned int height ) 528 524 { 525 if (mHWnd && !mIsFullScreen) 526 { 527 RECT rc = { 0, 0, width, height }; 528 AdjustWindowRect(&rc, GetWindowLong(mHWnd, GWL_STYLE), false); 529 width = rc.right - rc.left; 530 height = rc.bottom - rc.top; 531 SetWindowPos(mHWnd, 0, 0, 0, width, height, 532 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); 533 } 534 } 535 536 void D3D9RenderWindow::windowMovedOrResized() 537 { 538 if (!mHWnd || IsIconic(mHWnd)) 539 return; 540 541 RECT rc; 542 // top and left represent outer window position 543 GetWindowRect(mHWnd, &rc); 544 mTop = rc.top; 545 mLeft = rc.left; 546 // width and height represent drawable area only 547 GetClientRect(mHWnd, &rc); 548 unsigned int width = rc.right; 549 unsigned int height = rc.bottom; 550 if (mWidth == width && mHeight == height) 551 return; 529 552 530 553 if (mIsSwapChain) … … 584 607 } 585 608 } 586 // primary windows would reset the device - not implemented yet.609 // primary windows must reset the device 587 610 else 588 611 { 589 mWidth = width; 590 mHeight = height; 612 md3dpp.BackBufferWidth = mWidth = width; 613 md3dpp.BackBufferHeight = mHeight = height; 614 static_cast<D3D9RenderSystem*>( 615 Root::getSingleton().getRenderSystem())->_notifyDeviceLost(); 591 616 } 592 617 … … 595 620 while( it != mViewportList.end() ) 596 621 (*it++).second->_updateDimensions(); 597 // TODO - resize window598 622 } 599 623 … … 617 641 static_cast<D3D9RenderSystem*>( 618 642 Root::getSingleton().getRenderSystem())->_notifyDeviceLost(); 619 Sleep(500);620 621 643 } 622 644 else if( FAILED(hr) ) … … 668 690 return; 669 691 } 670 }671 672 void D3D9RenderWindow::WindowMovedOrResized()673 {674 // TODO675 692 } 676 693 … … 863 880 else 864 881 SAFE_RELEASE (mpRenderZBuffer); 865 Sleep(50 0);882 Sleep(50); 866 883 return; 867 884 } 868 else if (hr == D3DERR_DEVICENOTRESET)885 else 869 886 { 870 887 // device lost, and we can reset … … 875 892 { 876 893 // Wait a while 877 Sleep(50 0);894 Sleep(50); 878 895 return; 879 896 } -
trunk/VUT/work/ogre_changes/RenderSystems/GL/include/OgreGLPrerequisites.h
r115 r193 52 52 # define APIENTRY 53 53 # endif 54 # define GL_GLEXT_LEGACY 54 55 # include <OpenGL/gl.h> 55 56 # include <OpenGL/glu.h> … … 270 271 if (errCode != GL_NO_ERROR) { \ 271 272 errString = gluErrorString (errCode); \ 272 LogManager::getSingleton().logMessage ("[GL] :" + ERROR_MSG+ \273 LogManager::getSingleton().logMessage ("[GL] :" + Ogre::String(ERROR_MSG) + \ 273 274 " : " + Ogre::String( (const char*) errString)); \ 274 275 } \ … … 282 283 errString = gluErrorString (errCode); \ 283 284 OGRE_EXCEPT (Exception::ERR_INTERNAL_ERROR, \ 284 ERROR_MSG+ \285 Ogre::String(ERROR_MSG) + \ 285 286 " : " + Ogre::String( (const char*) errString), String("")); \ 286 287 } \ -
trunk/VUT/work/ogre_changes/RenderSystems/GL/include/OgreWin32Window.h
r153 r193 40 40 bool fullScreen, const NameValuePairList *miscParams); 41 41 void destroy(void); 42 bool is Active(void) const;42 bool isVisible() const; 43 43 bool isClosed(void) const; 44 44 void reposition(int left, int top); … … 61 61 // Method for dealing with resize / move & 3d library 62 62 virtual void windowMovedOrResized(void); 63 bool isReady() const { return mReady; }64 void setReady(bool set) { mReady = set; }65 void setActive(bool set) { mActive = set; }66 63 67 64 void getCustomAttribute( const String& name, void* pData ); … … 72 69 HDC mHDC; 73 70 HGLRC mGlrc; 74 int mOldSwapIntervall; 75 bool mActive; // Is active i.e. visible 76 bool mReady; // Is ready i.e. available for update 71 bool mIsExternal; 72 bool mSizing; 77 73 bool mClosed; 74 int mDisplayFrequency; // fullscreen only, to restore display 78 75 Win32Context *mContext; 79 76 -
trunk/VUT/work/ogre_changes/RenderSystems/GL/src/OgreGLHardwareOcclusionQuery.cpp
r115 r193 27 27 #include "OgreException.h" 28 28 29 30 29 namespace Ogre { 31 30 … … 52 51 // Check for hardware occlusion support 53 52 // This is a hack to see if hw occlusion is supported. pointer is 0 if it's not supported. 54 //if (glGenQueriesARB_ptr != 0) 53 #ifdef GTP_VISIBILITY_USE_ARB_QUERIES 54 if (glGenQueriesARB_ptr != 0) 55 #else 55 56 if (glGenOcclusionQueriesNV_ptr != 0) 57 #endif 56 58 { 57 59 mHasOcclusionSupport = true; … … 64 66 if(mHasOcclusionSupport) 65 67 { 66 //glGenQueriesARB_ptr(1, &mQueryID ); 68 #ifdef GTP_VISIBILITY_USE_ARB_QUERIES 69 glGenQueriesARB_ptr(1, &mQueryID ); 70 #else 67 71 glGenOcclusionQueriesNV_ptr(1, &mQueryID); 72 #endif 68 73 } 69 74 } … … 76 81 if( mHasOcclusionSupport ) 77 82 { 78 //glDeleteQueriesARB_ptr(1, &mQueryID); 83 #ifdef GTP_VISIBILITY_USE_ARB_QUERIES 84 glDeleteQueriesARB_ptr(1, &mQueryID); 85 #else 79 86 glDeleteOcclusionQueriesNV_ptr(1, &mQueryID); 87 #endif 80 88 } 81 89 } … … 101 109 if (mSkipCounter == 0) 102 110 { 103 //glBeginQueryARB_ptr(GL_SAMPLES_PASSED_ARB, mQueryID); 111 #ifdef GTP_VISIBILITY_USE_ARB_QUERIES 112 glBeginQueryARB_ptr(GL_SAMPLES_PASSED_ARB, mQueryID); 113 #else 104 114 glBeginOcclusionQueryNV_ptr(mQueryID); 115 #endif 105 116 } 106 117 } … … 114 125 if( mSkipCounter == 0) 115 126 { 116 //glEndQueryARB_ptr(GL_SAMPLES_PASSED_ARB); 127 #ifdef GTP_VISIBILITY_USE_ARB_QUERIES 128 glEndQueryARB_ptr(GL_SAMPLES_PASSED_ARB); 129 #else 117 130 glEndOcclusionQueryNV_ptr(); 131 #endif 118 132 } 119 133 … … 129 143 if( mHasOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 130 144 { 131 //glGetQueryObjectuivARB_ptr(mQueryID, GL_QUERY_RESULT_ARB, NumOfFragments); 145 #ifdef GTP_VISIBILITY_USE_ARB_QUERIES 146 glGetQueryObjectuivARB_ptr(mQueryID, GL_QUERY_RESULT_ARB, NumOfFragments); 147 #else 132 148 glGetOcclusionQueryuivNV_ptr(mQueryID, GL_PIXEL_COUNT_NV, NumOfFragments); 149 #endif 133 150 } 134 151 else -
trunk/VUT/work/ogre_changes/RenderSystems/GL/src/OgreGLRenderSystem.cpp
r150 r193 149 149 150 150 GLRenderSystem::GLRenderSystem() 151 : m ExternalWindowHandle(0), mDepthWrite(true), mHardwareBufferManager(0),151 : mDepthWrite(true), mHardwareBufferManager(0), 152 152 mGpuProgramManager(0) 153 153 { … … 173 173 for (i = 0; i < OGRE_MAX_TEXTURE_COORD_SETS; i++) 174 174 { 175 mTextureCoordIndex[i] = 0; 175 // Dummy value 176 mTextureCoordIndex[i] = 99; 176 177 } 177 178 … … 334 335 GLint units; 335 336 glGetIntegerv( GL_MAX_TEXTURE_UNITS, &units ); 337 mFixedFunctionTextureUnits = units; 338 339 if (mGLSupport->checkExtension("GL_ARB_fragment_program")) 340 { 341 // Also check GL_MAX_TEXTURE_IMAGE_UNITS_ARB since NV at least 342 // only increased this on the FX/6x00 series 343 GLint arbUnits; 344 glGetIntegerv( GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &arbUnits ); 345 if (arbUnits > units) 346 units = arbUnits; 347 } 336 348 337 349 mCapabilities->setNumTextureUnits(units); 350 338 351 } 339 352 else … … 405 418 mGpuProgramManager->_pushSyntaxCode("arbvp1"); 406 419 mGpuProgramManager->registerProgramFactory("arbvp1", createGLArbGpuProgram); 420 if (mGLSupport->checkExtension("GL_NV_vertex_program2_option")) 421 { 422 mCapabilities->setMaxVertexProgramVersion("vp30"); 423 mGpuProgramManager->_pushSyntaxCode("vp30"); 424 mGpuProgramManager->registerProgramFactory("vp30", createGLArbGpuProgram); 425 } 426 427 if (mGLSupport->checkExtension("GL_NV_vertex_program3")) 428 { 429 mCapabilities->setMaxVertexProgramVersion("vp40"); 430 mGpuProgramManager->_pushSyntaxCode("vp40"); 431 mGpuProgramManager->registerProgramFactory("vp40", createGLArbGpuProgram); 432 } 407 433 } 408 434 … … 455 481 mGpuProgramManager->_pushSyntaxCode("arbfp1"); 456 482 mGpuProgramManager->registerProgramFactory("arbfp1", createGLArbGpuProgram); 483 if (mGLSupport->checkExtension("GL_NV_fragment_program_option")) 484 { 485 mCapabilities->setMaxFragmentProgramVersion("fp30"); 486 mGpuProgramManager->_pushSyntaxCode("fp30"); 487 mGpuProgramManager->registerProgramFactory("fp30", createGLArbGpuProgram); 488 } 489 490 if (mGLSupport->checkExtension("GL_NV_fragment_program2")) 491 { 492 mCapabilities->setMaxFragmentProgramVersion("fp40"); 493 mGpuProgramManager->_pushSyntaxCode("fp40"); 494 mGpuProgramManager->registerProgramFactory("fp40", createGLArbGpuProgram); 495 } 457 496 } 458 497 … … 911 950 912 951 GLfloat mat[16]; 913 makeGLMatrix(mat, mViewMatrix);952 makeGLMatrix( mat, mViewMatrix * mWorldMatrix ); 914 953 glMatrixMode(GL_MODELVIEW); 915 954 glLoadMatrixf(mat); 916 917 makeGLMatrix(mat, mWorldMatrix);918 glMultMatrixf(mat);919 955 920 956 setGLClipPlanes(); … … 1025 1061 if(lastTextureType != mTextureTypes[stage] && lastTextureType != 0) 1026 1062 { 1063 if (stage < mFixedFunctionTextureUnits) 1064 { 1027 1065 glDisable( lastTextureType ); 1028 1066 } 1029 1067 } 1068 1069 if (stage < mFixedFunctionTextureUnits) 1070 { 1030 1071 glEnable( mTextureTypes[stage] ); 1072 } 1073 1031 1074 if(!tex.isNull()) 1032 1075 glBindTexture( mTextureTypes[stage], tex->getGLID() ); 1076 1033 1077 } 1034 1078 else 1035 1079 { 1080 if (stage < mFixedFunctionTextureUnits) 1081 { 1036 1082 if (lastTextureType != 0) 1037 1083 { … … 1040 1086 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 1041 1087 } 1088 } 1042 1089 1043 1090 glActiveTextureARB_ptr( GL_TEXTURE0 ); 1091 1044 1092 } 1045 1093 … … 1053 1101 const Frustum* frustum) 1054 1102 { 1103 if (stage >= mFixedFunctionTextureUnits) 1104 { 1105 // Can't do this 1106 return; 1107 } 1108 1109 1055 1110 GLfloat M[16]; 1056 1111 Matrix4 projectionBias; … … 1209 1264 void GLRenderSystem::_setTextureMatrix(size_t stage, const Matrix4& xform) 1210 1265 { 1266 if (stage >= mFixedFunctionTextureUnits) 1267 { 1268 // Can't do this 1269 return; 1270 } 1271 1211 1272 GLfloat mat[16]; 1212 1273 makeGLMatrix(mat, xform); … … 1286 1347 GLint sourceBlend = getBlendMode(sourceFactor); 1287 1348 GLint destBlend = getBlendMode(destFactor); 1288 1349 if(sourceFactor == SBF_ONE && destFactor == SBF_ZERO) 1350 { 1351 glDisable(GL_BLEND); 1352 } 1353 else 1354 { 1289 1355 glEnable(GL_BLEND); 1290 1356 glBlendFunc(sourceBlend, destBlend); 1291 1357 } 1358 } 1292 1359 //----------------------------------------------------------------------------- 1293 1360 void GLRenderSystem::_setAlphaRejectSettings(CompareFunction func, unsigned char value) 1294 1361 { 1362 if(func == CMPF_ALWAYS_PASS) 1363 { 1364 glDisable(GL_ALPHA_TEST); 1365 } 1366 else 1367 { 1295 1368 glEnable(GL_ALPHA_TEST); 1296 1369 glAlphaFunc(convertCompareFunction(func), value / 255.0f); 1370 } 1297 1371 } 1298 1372 //----------------------------------------------------------------------------- … … 1345 1419 "GLRenderSystem::_beginFrame"); 1346 1420 1421 // Activate the viewport clipping 1422 glEnable(GL_SCISSOR_TEST); 1347 1423 // Clear the viewport if required 1348 1424 if (mActiveViewport->getClearEveryFrame()) 1349 1425 { 1350 // Activate the viewport clipping1351 glEnable(GL_SCISSOR_TEST);1352 1353 1426 clearFrameBuffer(FBT_COLOUR | FBT_DEPTH, 1354 1427 mActiveViewport->getBackgroundColour()); … … 1839 1912 void GLRenderSystem::_setTextureBlendMode(size_t stage, const LayerBlendModeEx& bm) 1840 1913 { 1914 if (stage >= mFixedFunctionTextureUnits) 1915 { 1916 // Can't do this 1917 return; 1918 } 1919 1841 1920 // Check to see if blending is supported 1842 1921 if(!mCapabilities->hasCapability(RSC_BLENDING)) … … 2095 2174 { 2096 2175 pBufferData = static_cast<const GLDefaultHardwareVertexBuffer*>(vertexBuffer.get())->getDataPtr(elem->getOffset()); 2176 } 2177 if (op.vertexData->vertexStart) 2178 { 2179 pBufferData = static_cast<char*>(pBufferData) + op.vertexData->vertexStart * vertexBuffer->getVertexSize(); 2097 2180 } 2098 2181 … … 2132 2215 case VES_TEXTURE_COORDINATES: 2133 2216 2134 for (i = 0; i < mCapabilities->getNumTextureUnits(); i++)2217 for (i = 0; i < OGRE_MAX_TEXTURE_COORD_SETS; i++) 2135 2218 { 2136 2219 // Only set this texture unit's texcoord pointer if it … … 2227 2310 else 2228 2311 { 2229 glDrawArrays(primType, op.vertexData->vertexStart, 2230 op.vertexData->vertexCount); 2312 glDrawArrays(primType, 0, op.vertexData->vertexCount); 2231 2313 } 2232 2314 2233 2315 glDisableClientState( GL_VERTEX_ARRAY ); 2234 for (int i = 0; i < mCapabilities->getNumTextureUnits(); i++)2316 for (int i = 0; i < OGRE_MAX_TEXTURE_COORD_SETS; i++) 2235 2317 { 2236 2318 glClientActiveTextureARB_ptr(GL_TEXTURE0 + i); … … 2451 2533 dest[3][2] = -1; 2452 2534 } 2535 2453 2536 // ------------------------------------------------------------------ 2454 2537 void GLRenderSystem::setClipPlane (ushort index, Real A, Real B, Real C, Real D) … … 2496 2579 } 2497 2580 //--------------------------------------------------------------------- 2498 void GLRenderSystem::resizeRepositionWindow(void* wich)2499 {2500 mGLSupport->resizeRepositionWindow(wich);2501 for (RenderTargetMap::iterator it = mRenderTargets.begin(); it != mRenderTargets.end(); ++it)2502 {2503 if (it->second->isActive())2504 {2505 mGLSupport->resizeReposition(it->second);2506 }2507 }2508 }2509 //---------------------------------------------------------------------2510 2581 void GLRenderSystem::_applyObliqueDepthProjection(Matrix4& matrix, const Plane& plane, 2511 2582 bool forGpuProgram) … … 2541 2612 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); 2542 2613 glEnable(GL_COLOR_SUM); 2614 glDisable(GL_DITHER); 2543 2615 2544 2616 // Check for FSAA -
trunk/VUT/work/ogre_changes/RenderSystems/GL/src/OgreGLTexture.cpp
r156 r193 37 37 #include "OgreCodec.h" 38 38 #include "OgreImageCodec.h" 39 39 #include "OgreStringConverter.h" 40 40 41 41 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 … … 200 200 if(depth>1) depth = depth/2; 201 201 } 202 delete tmpdata;202 delete [] tmpdata; 203 203 } 204 204 else … … 355 355 for(int mip=0; mip<=getNumMipmaps(); mip++) 356 356 { 357 mSurfaceList.push_back(HardwarePixelBufferSharedPtr( 358 new GLHardwarePixelBuffer(getGLTextureTarget(), mTextureID, face, mip, 359 static_cast<HardwareBuffer::Usage>(mUsage), doSoftware && mip==0) 360 )); 357 GLHardwarePixelBuffer *buf = new GLHardwarePixelBuffer(getGLTextureTarget(), mTextureID, face, mip, 358 static_cast<HardwareBuffer::Usage>(mUsage), doSoftware && mip==0); 359 mSurfaceList.push_back(HardwarePixelBufferSharedPtr(buf)); 360 361 /// Check for error 362 if(buf->getWidth()==0 || buf->getHeight()==0 || buf->getDepth()==0) 363 { 364 OGRE_EXCEPT( 365 Exception::ERR_RENDERINGAPI_ERROR, 366 "Zero sized texture surface on texture "+getName()+ 367 " face "+StringConverter::toString(face)+ 368 " mipmap "+StringConverter::toString(mip)+ 369 ". Probably, the GL driver refused to create the texture.", 370 "GLTexture::_createSurfaceList"); 371 } 361 372 } 362 373 } -
trunk/VUT/work/ogre_changes/RenderSystems/GL/src/OgreWin32Window.cpp
r156 r193 42 42 mIsFullScreen = false; 43 43 mHWnd = 0; 44 mIsExternal = false; 45 mSizing = false; 46 mClosed = false; 47 mDisplayFrequency = 0; 44 48 mActive = false; 45 mReady = false;46 mClosed = false;47 49 } 48 50 … … 55 57 bool fullScreen, const NameValuePairList *miscParams) 56 58 { 57 HWND parentHWnd = 0; 58 HWND externalHandle = 0; 59 // destroy current window, if any 60 if (mHWnd) 61 destroy(); 62 59 63 HINSTANCE hInst = GetModuleHandle("RenderSystem_GL.dll"); 64 65 mHWnd = 0; 66 mName = name; 67 mIsFullScreen = fullScreen; 68 mClosed = false; 69 70 // load window defaults 71 mLeft = mTop = -1; // centered 72 mWidth = width; 73 mHeight = height; 74 mDisplayFrequency = 0; 75 mIsDepthBuffered = true; 76 mColourDepth = mIsFullScreen? 32 : GetDeviceCaps(GetDC(0), BITSPIXEL); 77 78 HWND parent = 0; 79 String title = name; 60 80 bool vsync = false; 61 unsigned int displayFrequency = 0; 62 String title = name; 63 unsigned int colourDepth = 32; 64 unsigned int left = 0; // Defaults to screen center 65 unsigned int top = 0; // Defaults to screen center 66 bool depthBuffer = true; 67 int multisample = 0; 81 int fsaa = 0; 82 String border = ""; 83 bool outerSize = false; 68 84 69 85 if(miscParams) … … 71 87 // Get variable-length params 72 88 NameValuePairList::const_iterator opt; 73 // left (x) 74 opt = miscParams->find("left"); 89 NameValuePairList::const_iterator end = miscParams->end(); 90 91 if ((opt = miscParams->find("title")) != end) 92 title = opt->second; 93 94 if ((opt = miscParams->find("left")) != end) 95 mLeft = StringConverter::parseInt(opt->second); 96 97 if ((opt = miscParams->find("top")) != end) 98 mTop = StringConverter::parseInt(opt->second); 99 100 if ((opt = miscParams->find("depthBuffer")) != end) 101 mIsDepthBuffered = StringConverter::parseBool(opt->second); 102 103 if ((opt = miscParams->find("vsync")) != end) 104 vsync = StringConverter::parseBool(opt->second); 105 106 if ((opt = miscParams->find("FSAA")) != end) 107 fsaa = StringConverter::parseUnsignedInt(opt->second); 108 109 if ((opt = miscParams->find("externalWindowHandle")) != end) 110 { 111 mHWnd = (HWND)StringConverter::parseUnsignedInt(opt->second); 112 if (mHWnd) 113 { 114 mIsExternal = true; 115 mIsFullScreen = false; 116 } 117 } 118 // window border style 119 opt = miscParams->find("border"); 75 120 if(opt != miscParams->end()) 76 left = StringConverter::parseUnsignedInt(opt->second);77 // top (y)78 opt = miscParams->find(" top");121 border = opt->second; 122 // set outer dimensions? 123 opt = miscParams->find("outerDimensions"); 79 124 if(opt != miscParams->end()) 80 top = StringConverter::parseUnsignedInt(opt->second); 81 // Window title 82 opt = miscParams->find("title"); 83 if(opt != miscParams->end()) 84 title = opt->second; 85 // externalWindowHandle -> externalHandle 86 opt = miscParams->find("externalWindowHandle"); 87 if(opt != miscParams->end()) 88 externalHandle = (HWND)StringConverter::parseUnsignedInt(opt->second); 89 // parentWindowHandle -> parentHWnd 90 opt = miscParams->find("parentWindowHandle"); 91 if(opt != miscParams->end()) 92 parentHWnd = (HWND)StringConverter::parseUnsignedInt(opt->second); 93 // vsync [parseBool] 94 opt = miscParams->find("vsync"); 95 if(opt != miscParams->end()) 96 vsync = StringConverter::parseBool(opt->second); 97 // displayFrequency 98 opt = miscParams->find("displayFrequency"); 99 if(opt != miscParams->end()) 100 displayFrequency = StringConverter::parseUnsignedInt(opt->second); 101 // colourDepth 102 opt = miscParams->find("colourDepth"); 103 if(opt != miscParams->end()) 104 colourDepth = StringConverter::parseUnsignedInt(opt->second); 105 // depthBuffer [parseBool] 106 opt = miscParams->find("depthBuffer"); 107 if(opt != miscParams->end()) 108 depthBuffer = StringConverter::parseBool(opt->second); 109 // FSAA 110 opt = miscParams->find("FSAA"); 111 if(opt != miscParams->end()) 112 multisample = StringConverter::parseUnsignedInt(opt->second); 113 } 125 outerSize = StringConverter::parseBool(opt->second); 114 126 115 // Destroy current window if any 116 if( mHWnd ) 117 destroy(); 118 119 if (fullScreen) 127 if (mIsFullScreen) 120 128 { 121 mColourDepth = colourDepth; 129 // only available with fullscreen 130 if ((opt = miscParams->find("displayFrequency")) != end) 131 mDisplayFrequency = StringConverter::parseUnsignedInt(opt->second); 132 if ((opt = miscParams->find("colourDepth")) != end) 133 mColourDepth = StringConverter::parseUnsignedInt(opt->second); 122 134 } 123 135 else 124 136 { 125 // Get colour depth from display 126 mColourDepth = GetDeviceCaps(GetDC(0), BITSPIXEL); 127 } 128 129 if (!externalHandle) { 130 DWORD dwStyle = (fullScreen ? WS_POPUP : WS_OVERLAPPEDWINDOW) | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; 131 RECT rc; 132 133 mWidth = width; 134 mHeight = height; 135 136 if (!fullScreen) 137 // incompatible with fullscreen 138 if ((opt = miscParams->find("parentWindowHandle")) != end) 139 parent = (HWND)StringConverter::parseUnsignedInt(opt->second); 140 } 141 } 142 143 if (!mIsExternal) 137 144 { 138 // Calculate window dimensions required to get the requested client area 139 SetRect(&rc, 0, 0, mWidth, mHeight); 140 AdjustWindowRect(&rc, dwStyle, false); 141 mWidth = rc.right - rc.left; 142 mHeight = rc.bottom - rc.top; 143 144 // Clamp width and height to the desktop dimensions 145 if (mWidth > (unsigned)GetSystemMetrics(SM_CXSCREEN)) 146 mWidth = (unsigned)GetSystemMetrics(SM_CXSCREEN); 147 if (mHeight > (unsigned)GetSystemMetrics(SM_CYSCREEN)) 148 mHeight = (unsigned)GetSystemMetrics(SM_CYSCREEN); 149 150 if (!left) 145 DWORD dwStyle = WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; 146 DWORD dwStyleEx = 0; 147 int outerw, outerh; 148 149 if (mIsFullScreen) 151 150 { 152 mLeft = (GetSystemMetrics(SM_CXSCREEN) / 2) - (mWidth / 2); 151 dwStyle |= WS_POPUP; 152 dwStyleEx |= WS_EX_TOPMOST; 153 outerw = mWidth; 154 outerh = mHeight; 155 mLeft = mTop = 0; 153 156 } 154 157 else 155 158 { 156 mLeft = left; 157 } 158 if (!top) 159 if (border == "none") 160 dwStyle |= WS_POPUP; 161 else if (border == "fixed") 162 dwStyle |= WS_OVERLAPPED | WS_BORDER | WS_CAPTION | 163 WS_SYSMENU | WS_MINIMIZEBOX; 164 else 165 dwStyle |= WS_OVERLAPPEDWINDOW; 166 167 int screenw = GetSystemMetrics(SM_CXSCREEN); 168 int screenh = GetSystemMetrics(SM_CYSCREEN); 169 170 if (!outerSize) 159 171 { 160 mTop = (GetSystemMetrics(SM_CYSCREEN) / 2) - (mHeight / 2); 161 } 162 else 163 { 164 mTop = top; 165 } 172 // calculate overall dimensions for requested client area 173 RECT rc = { 0, 0, mWidth, mHeight }; 174 AdjustWindowRect(&rc, dwStyle, false); 175 176 // clamp window dimensions to screen size 177 outerw = (rc.right-rc.left < screenw)? rc.right-rc.left : screenw; 178 outerh = (rc.bottom-rc.top < screenh)? rc.bottom-rc.top : screenh; 179 } 180 181 // center window if given negative coordinates 182 if (mLeft < 0) 183 mLeft = (screenw - outerw) / 2; 184 if (mTop < 0) 185 mTop = (screenh - outerh) / 2; 186 187 // keep window contained in visible screen area 188 if (mLeft > screenw - outerw) 189 mLeft = screenw - outerw; 190 if (mTop > screenh - outerh) 191 mTop = screenh - outerh; 166 192 } 167 else 168 { 169 mTop = mLeft = 0; 170 } 171 172 // Register the window class 173 174 WNDCLASS wndClass = { CS_HREDRAW | CS_VREDRAW | CS_OWNDC, 175 WndProc, 0, 4, hInst, 176 LoadIcon( NULL, IDI_APPLICATION ), 177 LoadCursor( NULL, IDC_ARROW ), 178 (HBRUSH)GetStockObject( BLACK_BRUSH ), NULL, 179 TEXT(title.c_str()) }; 180 RegisterClass( &wndClass ); 181 182 // Create our main window 183 // Pass pointer to self 184 HWND hWnd = CreateWindowEx(fullScreen?WS_EX_TOPMOST:0, TEXT(title.c_str()), TEXT(title.c_str()), 185 dwStyle, mLeft, mTop, mWidth, mHeight, 0L, 0L, hInst, this); 186 mHWnd = hWnd; 187 188 GetClientRect(mHWnd,&rc); 189 mWidth = rc.right; 190 mHeight = rc.bottom; 191 192 if (fullScreen) { 193 DEVMODE DevMode; 194 DevMode.dmSize = sizeof(DevMode); 195 DevMode.dmBitsPerPel = mColourDepth; 196 DevMode.dmPelsWidth = mWidth; 197 DevMode.dmPelsHeight = mHeight; 198 DevMode.dmDisplayFrequency = displayFrequency; 199 DevMode.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT|DM_DISPLAYFREQUENCY; 200 if (ChangeDisplaySettings(&DevMode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) 201 LogManager::getSingleton().logMessage(LML_CRITICAL, "ChangeDisplaySettingsEx"); 202 193 194 // register class and create window 195 WNDCLASS wc = { CS_OWNDC, WndProc, 0, 0, hInst, 196 LoadIcon(NULL, IDI_APPLICATION), LoadCursor(NULL, IDC_ARROW), 197 (HBRUSH)GetStockObject(BLACK_BRUSH), NULL, "OgreGLWindow" }; 198 RegisterClass(&wc); 199 200 // Pass pointer to self as WM_CREATE parameter 201 mHWnd = CreateWindowEx(dwStyleEx, "OgreGLWindow", title.c_str(), 202 dwStyle, mLeft, mTop, outerw, outerh, parent, 0, hInst, this); 203 204 StringUtil::StrStreamType str; 205 str << "Created Win32Window '" 206 << mName << "' : " << mWidth << "x" << mHeight 207 << ", " << mColourDepth << "bpp"; 208 LogManager::getSingleton().logMessage(LML_NORMAL, str.str()); 209 210 if (mIsFullScreen) 211 { 212 DEVMODE dm; 213 dm.dmSize = sizeof(DEVMODE); 214 dm.dmBitsPerPel = mColourDepth; 215 dm.dmPelsWidth = mWidth; 216 dm.dmPelsHeight = mHeight; 217 dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; 218 if (mDisplayFrequency) 219 { 220 dm.dmDisplayFrequency = mDisplayFrequency; 221 dm.dmFields |= DM_DISPLAYFREQUENCY; 222 } 223 if (ChangeDisplaySettings(&dm, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) 224 LogManager::getSingleton().logMessage(LML_CRITICAL, "ChangeDisplaySettings failed"); 225 } 203 226 } 204 227 205 }206 else {207 mHWnd = externalHandle;208 228 RECT rc; 229 // top and left represent outer window position 230 GetWindowRect(mHWnd, &rc); 231 mTop = rc.top; 232 mLeft = rc.left; 233 // width and height represent drawable area only 209 234 GetClientRect(mHWnd, &rc); 210 235 mWidth = rc.right; 211 236 mHeight = rc.bottom; 212 mLeft = rc.left;213 mTop = rc.top;214 }215 ShowWindow(mHWnd, SW_SHOWNORMAL);216 UpdateWindow(mHWnd);217 mName = name;218 mIsDepthBuffered = depthBuffer;219 mIsFullScreen = fullScreen;220 221 237 222 HDC hdc = GetDC(mHWnd); 223 224 StringUtil::StrStreamType str; 225 str << "Created Win32Window '" 226 << mName << "' : " << mWidth << "x" << mHeight 227 << ", " << mColourDepth << "bpp"; 228 LogManager::getSingleton().logMessage(LML_NORMAL, str.str()); 229 230 if (!mGLSupport.selectPixelFormat(hdc, mColourDepth, multisample)) 231 { 232 if (multisample == 0) 238 mHDC = GetDC(mHWnd); 239 240 if (!mGLSupport.selectPixelFormat(mHDC, mColourDepth, fsaa)) 241 { 242 if (fsaa == 0) 233 243 OGRE_EXCEPT(0, "selectPixelFormat failed", "Win32Window::create"); 234 244 235 245 LogManager::getSingleton().logMessage(LML_NORMAL, "FSAA level not supported, falling back"); 236 if (!mGLSupport.selectPixelFormat( hdc, mColourDepth, 0))246 if (!mGLSupport.selectPixelFormat(mHDC, mColourDepth, 0)) 237 247 OGRE_EXCEPT(0, "selectPixelFormat failed", "Win32Window::create"); 238 248 } 239 249 240 HGLRC glrc = wglCreateContext(hdc);241 if (! glrc)250 mGlrc = wglCreateContext(mHDC); 251 if (!mGlrc) 242 252 OGRE_EXCEPT(0, "wglCreateContext", "Win32Window::create"); 243 if (!wglMakeCurrent( hdc, glrc))253 if (!wglMakeCurrent(mHDC, mGlrc)) 244 254 OGRE_EXCEPT(0, "wglMakeCurrent", "Win32Window::create"); 245 255 246 mGlrc = glrc; 247 mHDC = hdc; 248 249 mOldSwapIntervall = wglGetSwapIntervalEXT(); 250 if (vsync) 251 wglSwapIntervalEXT(1); 252 else 253 wglSwapIntervalEXT(0); 254 255 mReady = true; 256 wglSwapIntervalEXT(vsync? 1 : 0); 256 257 257 258 // Create RenderSystem context … … 260 261 GLRenderSystem *rs = static_cast<GLRenderSystem*>(Root::getSingleton().getRenderSystem()); 261 262 rs->_registerContext(this, mContext); 263 264 mActive = true; 262 265 } 263 266 264 267 void Win32Window::destroy(void) 265 268 { 269 if (!mHWnd) 270 return; 271 266 272 // Unregister and destroy OGRE GLContext 267 273 if (mContext) … … 270 276 rs->_unregisterContext(this); 271 277 delete mContext; 272 mContext = NULL; 273 274 wglSwapIntervalEXT(mOldSwapIntervall); 278 mContext = 0; 275 279 } 276 if (mGlrc) {277 wglMakeCurrent(NULL, NULL);280 if (mGlrc) 281 { 278 282 wglDeleteContext(mGlrc); 279 mGlrc = NULL; 280 } 281 if (mHDC) { 282 ReleaseDC(mHWnd, mHDC); 283 mHDC = NULL; 284 } 283 mGlrc = 0; 284 } 285 if (!mIsExternal) 286 { 285 287 if (mIsFullScreen) 286 {287 288 ChangeDisplaySettings(NULL, 0); 288 }289 if (mHWnd)290 {291 289 DestroyWindow(mHWnd); 292 mHWnd = 0;293 290 } 294 291 mActive = false; 295 } 296 297 bool Win32Window::isActive() const 298 { 299 return mActive; 292 mHDC = 0; // no release thanks to CS_OWNDC wndclass style 293 mHWnd = 0; 294 } 295 296 bool Win32Window::isVisible() const 297 { 298 return (mHWnd && !IsIconic(mHWnd)); 300 299 } 301 300 … … 307 306 void Win32Window::reposition(int left, int top) 308 307 { 309 // XXX FIXME 308 if (mHWnd && !mIsFullScreen) 309 { 310 SetWindowPos(mHWnd, 0, left, top, 0, 0, 311 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); 312 } 310 313 } 311 314 312 315 void Win32Window::resize(unsigned int width, unsigned int height) 313 316 { 314 315 mWidth = width; 316 mHeight = height; 317 if (mHWnd && !mIsFullScreen) 318 { 319 RECT rc = { 0, 0, width, height }; 320 AdjustWindowRect(&rc, GetWindowLong(mHWnd, GWL_STYLE), false); 321 width = rc.right - rc.left; 322 height = rc.bottom - rc.top; 323 SetWindowPos(mHWnd, 0, 0, 0, width, height, 324 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); 325 } 326 } 327 328 void Win32Window::windowMovedOrResized() 329 { 330 if (!isVisible()) 331 return; 332 333 RECT rc; 334 // top and left represent outer window position 335 GetWindowRect(mHWnd, &rc); 336 mTop = rc.top; 337 mLeft = rc.left; 338 // width and height represent drawable area only 339 GetClientRect(mHWnd, &rc); 340 341 if (mWidth == rc.right && mHeight == rc.bottom) 342 return; 343 344 mWidth = rc.right; 345 mHeight = rc.bottom; 317 346 318 347 // Notify viewports of resize … … 321 350 for( it = mViewportList.begin(); it != itend; ++it ) 322 351 (*it).second->_updateDimensions(); 323 // TODO - resize window324 }325 326 void Win32Window::windowMovedOrResized()327 {328 RECT temprect;329 ::GetClientRect(getWindowHandle(),&temprect);330 resize(temprect.right-temprect.left,temprect.bottom-temprect.top);331 // TODO332 352 } 333 353 … … 406 426 LRESULT Win32Window::WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) 407 427 { 408 Win32Window* win; 428 429 if (uMsg == WM_CREATE) 430 { 431 // Store pointer to Win32Window in user data area 432 SetWindowLong(hWnd, GWL_USERDATA, 433 (LONG)(((LPCREATESTRUCT)lParam)->lpCreateParams)); 434 return 0; 435 } 409 436 410 437 // look up window instance 411 if( WM_CREATE != uMsg ) 412 win = (Win32Window*)GetWindowLong( hWnd, 0 ); 438 // note: it is possible to get a WM_SIZE before WM_CREATE 439 Win32Window* win = (Win32Window*)GetWindowLong(hWnd, GWL_USERDATA); 440 if (!win) 441 return DefWindowProc(hWnd, uMsg, wParam, lParam); 413 442 414 443 switch( uMsg ) 415 444 { 416 445 case WM_ACTIVATE: 417 if( WA_INACTIVE == LOWORD( wParam ) ) 446 if (win->mIsFullScreen) 447 { 448 if (LOWORD(wParam) == WA_INACTIVE) 449 { 418 450 win->mActive = false; 451 ChangeDisplaySettings(NULL, 0); 452 ShowWindow(hWnd, SW_SHOWMINNOACTIVE); 453 } 419 454 else 455 { 420 456 win->mActive = true; 457 ShowWindow(hWnd, SW_SHOWNORMAL); 458 459 DEVMODE dm; 460 dm.dmSize = sizeof(DEVMODE); 461 dm.dmBitsPerPel = win->mColourDepth; 462 dm.dmPelsWidth = win->mWidth; 463 dm.dmPelsHeight = win->mHeight; 464 dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; 465 if (win->mDisplayFrequency) 466 { 467 dm.dmDisplayFrequency = win->mDisplayFrequency; 468 dm.dmFields |= DM_DISPLAYFREQUENCY; 469 } 470 ChangeDisplaySettings(&dm, CDS_FULLSCREEN); 471 } 472 } 421 473 break; 422 474 423 case WM_CREATE: {424 // Log the new window425 // Get CREATESTRUCT426 LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;427 win = (Win32Window*)(lpcs->lpCreateParams);428 // Store pointer in window user data area429 SetWindowLong( hWnd, 0, (long)win );430 win->mActive = true;431 432 return 0; }433 break;434 435 case WM_PAINT:436 // If we get WM_PAINT messges, it usually means our window was437 // comvered up, so we need to refresh it by re-showing the contents438 // of the current frame.439 if( win->mActive && win->mReady )440 win->update();441 break;442 443 case WM_MOVE:444 // Move messages need to be tracked to update the screen rects445 // used for blitting the backbuffer to the primary446 // *** This doesn't need to be used to Direct3D9 ***447 break;448 449 475 case WM_ENTERSIZEMOVE: 450 // Previent rendering while moving / sizing 451 win->mReady = false; 476 win->mSizing = true; 452 477 break; 453 478 454 479 case WM_EXITSIZEMOVE: 455 480 win->windowMovedOrResized(); 456 win->m Ready = true;481 win->mSizing = false; 457 482 break; 458 483 484 case WM_MOVE: 459 485 case WM_SIZE: 460 // Check to see if we are losing or gaining our window. Set the 461 // active flag to match 462 if( SIZE_MAXHIDE == wParam || SIZE_MINIMIZED == wParam ) 463 win->mActive = false; 464 else 465 { 466 win->mActive = true; 467 if( win->mReady ) 486 if (!win->mSizing) 468 487 win->windowMovedOrResized(); 469 }470 488 break; 471 489 … … 477 495 478 496 case WM_CLOSE: 479 DestroyWindow( win->mHWnd );497 win->destroy(); // will call DestroyWindow 480 498 win->mClosed = true; 481 499 return 0;
Note: See TracChangeset
for help on using the changeset viewer.