Пример #1
0
	//---------------------------------------------------------------------
    void Profiler::initialize() 
	{


        // create a new overlay to hold our Profiler display
        mOverlay = OverlayManager::getSingleton().create("Profiler");
        mOverlay->setZOrder(500);

        // this panel will be the main container for our profile bars
        mProfileGui = createContainer();

        OverlayElement* element;

        // we create an initial pool of 50 profile bars
        for (uint i = 0; i < mMaxDisplayProfiles; ++i) {

            // this is for the profile name and the number of times it was called in a frame
            element = createTextArea("profileText" + StringConverter::toString(i), 90, mBarHeight, mGuiBorderWidth + (mBarHeight + mBarSpacing) * i, 0, 14, "", false);
            mProfileGui->addChild(element);
            mProfileBars.push_back(element);

            // this indicates the current frame time
            element = createPanel("currBar" + StringConverter::toString(i), 0, mBarHeight, mGuiBorderWidth + (mBarHeight + mBarSpacing) * i, mBarIndent, "Core/ProfilerCurrent", false);
            mProfileGui->addChild(element);
            mProfileBars.push_back(element);

            // this indicates the minimum frame time
            element = createPanel("minBar" + StringConverter::toString(i), mBarLineWidth, mBarHeight, mGuiBorderWidth + (mBarHeight + mBarSpacing) * i, 0, "Core/ProfilerMin", false);
            mProfileGui->addChild(element);
            mProfileBars.push_back(element);

            // this indicates the maximum frame time
            element = createPanel("maxBar" + StringConverter::toString(i), mBarLineWidth, mBarHeight, mGuiBorderWidth + (mBarHeight + mBarSpacing) * i, 0, "Core/ProfilerMax", false);
            mProfileGui->addChild(element);
            mProfileBars.push_back(element);

            // this indicates the average frame time
            element = createPanel("avgBar" + StringConverter::toString(i), mBarLineWidth, mBarHeight, mGuiBorderWidth + (mBarHeight + mBarSpacing) * i, 0, "Core/ProfilerAvg", false);
            mProfileGui->addChild(element);
            mProfileBars.push_back(element);

			// this indicates the text of the frame time
			element = createTextArea("statText" + StringConverter::toString(i), 20, mBarHeight, mGuiBorderWidth + (mBarHeight + mBarSpacing) * i, 0, 14, "", false);
			mProfileGui->addChild(element);
			mProfileBars.push_back(element);
        }

        // throw everything all the GUI stuff into the overlay and display it
        mOverlay->add2D(mProfileGui);
        mOverlay->show();

    }
Пример #2
0
int openFile(){
	OPENFILENAME ofn;
    char szFileName[MAX_PATH] = "";
    FILE * fp;
    char * buffer = 0;
    long length;

    ZeroMemory(&ofn, sizeof(ofn));

    ofn.lStructSize = sizeof(ofn); // SEE NOTE BELOW
    ofn.hwndOwner = hwnd;
    ofn.lpstrFilter = "Bes Files (*.bes)\0*.bes\0All Files (*.*)\0*.*\0";
    ofn.lpstrFile = szFileName;
    ofn.nMaxFile = MAX_PATH;
    ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
    ofn.lpstrDefExt = "bes";

	if(isNewFile){
		GetSaveFileName(&ofn);
		strcpy(openedFileName, ofn.lpstrFile);
		isNewFile = 0;
		saveFile();
		return 1;
	}

    if(GetOpenFileName(&ofn)){        
        HANDLE hFile;
	    int bSuccess = 0;
	
		createTextArea();
		
		strcpy(openedFileName, szFileName);
	
	    hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
	        OPEN_EXISTING, 0, NULL);
	        
	    if(hFile != INVALID_HANDLE_VALUE){
	        DWORD dwFileSize;
	        dwFileSize = GetFileSize(hFile, NULL);
	        if(dwFileSize != 0xFFFFFFFF){
	            LPSTR pszFileText;
	            pszFileText = GlobalAlloc(GPTR, dwFileSize + 1);
	            if(pszFileText != NULL){
	                DWORD dwRead;
	                if(ReadFile(hFile, pszFileText, dwFileSize, &dwRead, NULL)){
	                    pszFileText[dwFileSize] = 0; // Add null terminator
	                    if(SetWindowText(hEdit, pszFileText))
	                        bSuccess = 1; // It worked!
	                }
	                GlobalFree(pszFileText);
	            }
	        }
	        CloseHandle(hFile);
	    }
	    return bSuccess;
    } else {
    	return 0;
	}
    
}
Пример #3
0
    // Just override the mandatory create scene method
    void createScene(void)
    {
		// Create our two rendering cameras. Since we're using the ExampleApplication and we want to individually translate/rotate
		// our two cameras, I'll use the ExampleApplication::mCamera as a virtual camera(it will not render anything) and use it
		// to translate our selected camera.
		mVirtualCamera = mCamera;

		mCameras[0] = mSceneMgr->createCamera("Camera1");
		mCameras[1] = mSceneMgr->createCamera("Camera2");

		for(Ogre::uint32 k = 0; k < 2; k++)
		{
			mCameras[k]->setPosition(mVirtualCamera->getPosition());
			mCameras[k]->setOrientation(mVirtualCamera->getOrientation());
			mCameras[k]->setAspectRatio(mVirtualCamera->getAspectRatio()/2); // /2 since we're going to use a half-width viewport size
			mCameras[k]->setFarClipDistance(30000);
			mCameras[k]->setNearClipDistance(20);
		}

		// Remove the existing viewport (created by the ExampleApplication) and create our new viewports
		mWindow->removeViewport(0);
		
		Ogre::Viewport* vp1 = mWindow->addViewport(mCameras[0], 0, 0, 0, 0.5, 1);
		Ogre::Viewport* vp2 = mWindow->addViewport(mCameras[1], 1, 0.5, 0, 0.5, 1);
		vp2->setOverlaysEnabled(false);

		// Create our text area for display SkyX parameters
		createTextArea();

		// Create SkyX
		mBasicController = new SkyX::BasicController();
		mSkyX = new SkyX::SkyX(mSceneMgr, mBasicController);
		mSkyX->create();

		// Distance geometry falling is a feature introduced in SkyX 0.2
		// When distance falling is enabled, the geometry linearly falls with the distance and the
		// amount of falling in world units is determinated by the distance between the cloud field "plane"
		// and the camera height multiplied by the falling factor.
		// For this demo, a falling factor of two is good enough for the point of view we're using. That means that if the camera
		// is at a distance of 100 world units from the cloud field, the fartest geometry will fall 2*100 = 200 world units.
		// This way the cloud field covers a big part of the sky even if the camera is in at a very low altitude.
		// The second parameter is the max amount of falling distance in world units. That's needed when for example, you've an 
		// ocean and you don't want to have the volumetric cloud field geometry falling into the water when the camera is underwater.
		// -1 means that there's not falling limit.
		mSkyX->getVCloudsManager()->getVClouds()->setDistanceFallingParams(Ogre::Vector2(2,-1));

		// Register SkyX listeners
		mRoot->addFrameListener(mSkyX);
		// Since our two viewports are created through the mWindow render window, we've just add SkyX as a RenderTargetListener
		// and SkyX will automatically handle all the multi-camera stuff.
		// In very specific applications(like editors or when you're using a complex rendering pipeline), you'll need to manually
		// update the SkyX geometry instead of handle it by using listeners. In these situations just invoke SkyX::notifyCameraRender(...)
		// before rendering the camera frame.
		mWindow->addListener(mSkyX);

		setPreset(mPresets[mCurrentPreset]);
    }
Пример #4
0
void newFile(){
	createTextArea();
	createNotifs();
	isNewFile = 1;
	if(hEdit != NULL){
		ModifyMenu(hMenu, ID_FILE_SAVE, MF_BYCOMMAND | MF_ENABLED, ID_FILE_SAVE, "&Save\tCtrl + S");
		ModifyMenu(hMenu, ID_FILE_CLOSE, MF_BYCOMMAND | MF_ENABLED, ID_FILE_CLOSE, "&Close\tCtrl + C");
		HDC hdc;
		hdc = GetWindowDC(hwnd);
		TextOut(hdc, 160, 70, "untitled.bes", strlen("untitled.bes"));
		ReleaseDC(hwnd, hdc);
	}
}
HudStatusDisplay::HudStatusDisplay(hud_part_design_t& a_hud_part_design)
  : HudPart(a_hud_part_design), hud_part_interval(0.1), hud_part_accumulator(0)
{
  // read parameters
  if (a_hud_part_design.parameters.size() < 1) { // kill the game if too few params
    Game::kill(string("hud_part missing param: ") + a_hud_part_design.name);
  }
  font_size = a_hud_part_design.parameters[0]; // read the size of the status font

  // line hieght for line poistioning
  usint line_height = (size.second) / HUD_NUM_OF_LOG_LINES;

  // create the OGRE text elements to show the log lines
  for (size_t i = 0; i < HUD_NUM_OF_COLOURS; ++i) { // element for each colour
    for (size_t j = 0; j < HUD_NUM_OF_STATUS_LINES; ++j) { // and each line
      string id = a_hud_part_design.name + "_" + intoString(i) + intoString(j);
      status_text_elements[i][j]
        = createTextArea(id, "", font_size, Game::Hud->HudDesign.status_colours[i],
                         0, (j * line_height), size.first, size.second, Container);
    }
  }
}
Пример #6
0
    // Just override the mandatory create scene method
    void createScene(void)
    {
		// Set default ambient light
		mSceneMgr->setAmbientLight(ColourValue(1, 1, 1));

		// Set some camera params
        mCamera->setFarClipDistance(99999*6);
		mCamera->setPosition(311.902,128.419,1539.02);
		mCamera->setDirection(0.155, 0.1808, -0.97);

	    // Light
		Ogre::Light *mLight0 = mSceneMgr->createLight("Light0");
		mLight0->setDiffuseColour(1, 1, 1);
		mLight0->setCastShadows(false);

		// Shadow caster
		Ogre::Light *mLight1 = mSceneMgr->createLight("Light1");
		mLight1->setType(Ogre::Light::LT_DIRECTIONAL);

		// Hydrax initialization code ---------------------------------------------
		// ------------------------------------------------------------------------

        // Create Hydrax object
		mHydrax = new Hydrax::Hydrax(mSceneMgr, mCamera, mWindow->getViewport(0));

		// Create our projected grid module  
		Hydrax::Module::ProjectedGrid *mModule 
			= new Hydrax::Module::ProjectedGrid(// Hydrax parent pointer
			                                    mHydrax,
												// Noise module
			                                    new Hydrax::Noise::Perlin(/*Generic one*/),
												// Base plane
			                                    Ogre::Plane(Ogre::Vector3(0,1,0), Ogre::Vector3(0,0,0)),
												// Normal mode
												Hydrax::MaterialManager::NM_VERTEX,
												// Projected grid options
										        Hydrax::Module::ProjectedGrid::Options(/*Generic one*/));

		// Set our module
		mHydrax->setModule(static_cast<Hydrax::Module::Module*>(mModule));

		// Load all parameters from config file
		// Remarks: The config file must be in Hydrax resource group.
		// All parameters can be set/updated directly by code(Like previous versions),
		// but due to the high number of customizable parameters, since 0.4 version, Hydrax allows save/load config files.
		mHydrax->loadCfg("HydraxDemo.hdx");

        // Create water
        mHydrax->create();

		// Add the Hydrax Rtt listener
		mHydrax->getRttManager()->addRttListener(new HydraxRttListener());

		// Hydrax initialization code end -----------------------------------------
		// ------------------------------------------------------------------------

		// SkyX initialization code ---------------------------------------------
		// ------------------------------------------------------------------------

		// Create SkyX object
		mSkyX = new SkyX::SkyX(mSceneMgr, mCamera);

		// No smooth fading
		mSkyX->getMeshManager()->setSkydomeFadingParameters(false);

		// A little change to default atmosphere settings :)
		SkyX::AtmosphereManager::Options atOpt = mSkyX->getAtmosphereManager()->getOptions();
		atOpt.RayleighMultiplier = 0.003075f;
		atOpt.MieMultiplier = 0.00125f;
		atOpt.InnerRadius = 9.92f;
		atOpt.OuterRadius = 10.3311f;
		mSkyX->getAtmosphereManager()->setOptions(atOpt);

		// Create the sky
		mSkyX->create();

		// Add a basic cloud layer
		mSkyX->getCloudsManager()->add(SkyX::CloudLayer::Options(/* Default options */));

		// SkyX initialization code end -----------------------------------------
		// ------------------------------------------------------------------------

		// Bloom compositor
		Ogre::CompositorManager::getSingleton().
			addCompositor(mWindow->getViewport(0), "Bloom")->addListener(new BloomListener());
		Ogre::CompositorManager::getSingleton().
			setCompositorEnabled(mWindow->getViewport(0), "Bloom", mBloomCompositor);

		// Shadows
		mSceneMgr->setShadowCameraSetup(Ogre::ShadowCameraSetupPtr(new Ogre::FocusedShadowCameraSetup()));
		mSceneMgr->setShadowTextureCasterMaterial("ShadowCaster");
		mSceneMgr->getLight("Light1")->setShadowFarDistance(1750);
		setShadowMode(mSceneMgr, static_cast<ShadowMode>(mShadowMode));

		// Load island
		mSceneMgr->setWorldGeometry("Island.cfg");

		// Add the Hydrax depth technique to island material
		mHydrax->getMaterialManager()->addDepthTechnique(
			static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName("Island"))
			->createTechnique());

		// Create palmiers
		createPalms(mSceneMgr);

		// Create text area to show skyboxes information
		createTextArea();
		
		// Add frame listener
		mRoot->addFrameListener(new ExampleHydraxDemoListener(mWindow, mCamera, mSceneMgr));
    }