예제 #1
0
void EngineActions::LoadScene( const QString& p_filePath )
{
	QFileInfo fileInfo(p_filePath);
	QProgressDialog dialog(0,0);
	Utils::ShowProgressBar(&dialog, "Level: " + fileInfo.completeBaseName());

	ClearScene();
	//Utils::RunWithProgressBar(QtConcurrent::run(m_treenityMain->GetProjectManager(), &ProjectManager::Import, p_filePath));
	m_treenityMain->GetProjectManager()->Import(p_filePath);
	AddDefaultEntities();
	InitializeScene();
	m_treenityMain->GetEditor()->GetUi().statusBar->showMessage("Level loaded: " + p_filePath, 5000);
}
예제 #2
0
void BVIRayTracerApplication::CreateScene07()
{
    ClearScene();
    Material::shared_ptr m_Material01(new StandardMaterial(1.0, 0.5, COLOUR_GREEN));
    Material::shared_ptr m_Material_Scatter(new ScatterBoardMaterial(1.0, 0.5, COLOUR_RED, COLOUR_GREEN));
    Material::shared_ptr m_Material_PerlinNoiseRed(new PerlinNoiseMaterial(0.0, 1.0, COLOUR_RED));
    Material::shared_ptr m_Material_PerlinNoiseBlue(new PerlinNoiseMaterial(0.0, 1.0, COLOUR_BLUE));
    m_Camera = Camera::shared_ptr(defaultCamera());
    Scene& scene = *m_Scene;

    scene.AddPointLight(new PointLight(TColor(1), Vector( 300,  300, 300), 800));
    scene.AddPointLight(new PointLight(TColor(1), Vector(-300, -300, 300), 450));
    scene.AddPointLight(new PointLight(TColor(1), Vector( 300, -300, 300), 450));
    scene.AddPointLight(new PointLight(TColor(1), Vector(-300,  300, 300), 450));

    int c = 0;
    for (int x = -100; x <= 100; x += 20)
    {
        if (x != 0)
        {
            for (int y = -100; y <= 100; y += 20)
            {
                for (int z =-1000; z <= 100; z += 20)
                {
                    c++;
                    switch(c % 4)
                    {

                    case 0:
                    {

                        scene.AddSceneObject(new Sphere(m_Material01, Vector( x,   y,   z),  5));
                        break;
                    }
                    case 1:
                        scene.AddSceneObject(new Sphere(m_Material_PerlinNoiseBlue, Vector( x,   y,   z),  5));
                        break;

                    case 2:
                        scene.AddSceneObject(new Sphere(m_Material_PerlinNoiseRed, Vector( x,   y,   z),  5));
                        break;
                    case 3:
                        scene.AddSceneObject(new Sphere(m_Material_Scatter, Vector( x,   y,   z),  5));
                        break;
                    }
                }
            }
        }
    }
}
예제 #3
0
	//-------------------------------------------------------------------------------
	SceneManager::~SceneManager()
	{
		ClearScene();

		std::for_each(m_scenes.begin(), m_scenes.end(), std::default_delete<Scene>());
		m_scenes.clear();

		SAFE_DELETE(m_pShadowMap);
		SAFE_DELETE(m_camera);
		SAFE_DELETE(m_pDebugRTMesh);
		SAFE_DELETE(m_pMeshLoader);
		SAFE_DELETE(m_pSSAO);
		SAFE_RELEASE(m_pDebugRTMaterial);
	}
예제 #4
0
// Draw the scene
void Game::Draw()
{
	mScene->DrawShadows(mCamera->GetPos());

	ResetTargetAndViewport();
	ClearScene();

	mScene->Draw(*mCamera);

	RECT textPos = { 0, 0, 300, 300 };
	mDefaultFont->WriteText(mFPSString, &textPos, D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f), GameFont::Left, GameFont::Top);

	RenderScene();
}
예제 #5
0
파일: Game.cpp 프로젝트: rarosu/BTH-Gomoku
// Draw the scene
void Game::Draw()
{
	ClearScene();
	


	// Draw the current state
	mCurrentState->Draw();

	// Draw the HUD
	mRootComponentGroup->Draw();	
	
	// Swap backbuffer
	RenderScene();
}
예제 #6
0
void Application::ProcessSceneSignal(SceneSignal signal) {
	ClearScene();

	switch(signal) {
		case SceneSignal::FIRST:
		case SceneSignal::EXAMPLE_SCENE:
			activeScene = new ExampleScene();
		break;
		default: {
			std::ostringstream msg;
			msg << "Failed to recognize the scene signal: " << signal;
			throw(std::logic_error(msg.str()));
		}
	}
}
예제 #7
0
void FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHeight)
{
	if (width <= 0 || height <= 0)
		I_FatalError("Requested invalid render buffer sizes: screen = %dx%d", width, height);

	int samples = clamp((int)gl_multisample, 0, mMaxSamples);
	bool needsSceneTextures = (gl_ssao != 0);

	GLint activeTex;
	GLint textureBinding;
	glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex);
	glActiveTexture(GL_TEXTURE0);
	glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding);

	if (width != mWidth || height != mHeight)
		CreatePipeline(width, height);

	if (width != mWidth || height != mHeight || mSamples != samples || mSceneUsesTextures != needsSceneTextures)
		CreateScene(width, height, samples, needsSceneTextures);

	mWidth = width;
	mHeight = height;
	mSamples = samples;
	mSceneUsesTextures = needsSceneTextures;
	mSceneWidth = sceneWidth;
	mSceneHeight = sceneHeight;

	glBindTexture(GL_TEXTURE_2D, textureBinding);
	glActiveTexture(activeTex);
	glBindRenderbuffer(GL_RENDERBUFFER, 0);
	glBindFramebuffer(GL_FRAMEBUFFER, 0);

	if (FailedCreate)
	{
		ClearScene();
		ClearPipeline();
		ClearEyeBuffers();
		mWidth = 0;
		mHeight = 0;
		mSamples = 0;
		mSceneWidth = 0;
		mSceneHeight = 0;
		I_FatalError("Unable to create render buffers.");
	}
}
예제 #8
0
void Application::Proc() {
	//load the first scene
	ProcessSceneSignal(SceneSignal::FIRST);

	//fixed frame rate
	typedef std::chrono::steady_clock Clock;

	Clock::time_point simTime = Clock::now();
	Clock::time_point realTime;
	constexpr std::chrono::duration<int, std::milli> frameDelay(16); //~60FPS

	//the game loop continues until the scenes signal QUIT
	while(activeScene->GetSceneSignal() != SceneSignal::QUIT) {
		//switch scenes if necessary
		if(activeScene->GetSceneSignal() != SceneSignal::CONTINUE) {
			ProcessSceneSignal(activeScene->GetSceneSignal());
			continue;
		}

		//update the current time
		realTime = Clock::now();

		//simulate the game or give the machine a break
		if (simTime < realTime) {
			while(simTime < realTime) {
				//call the user defined functions
				activeScene->RunFrame();
				//step to the next frame
				simTime += frameDelay;
			}
		}
		else {
			SDL_Delay(1);
		}

		SDL_RenderClear(renderer);
		activeScene->RenderFrame(renderer);
		SDL_RenderPresent(renderer);
	}

	//cleanup
	ClearScene();
}
void FGLRenderBuffers::CreateScene(int width, int height, int samples, bool needsSceneTextures)
{
	ClearScene();

	if (samples > 1)
	{
		if (needsSceneTextures)
		{
			mSceneMultisample = Create2DMultisampleTexture("SceneMultisample", GL_RGBA16F, width, height, samples, false);
			mSceneDepthStencil = Create2DMultisampleTexture("SceneDepthStencil", GL_DEPTH24_STENCIL8, width, height, samples, false);
			mSceneFog = Create2DMultisampleTexture("SceneFog", GL_RGBA8, width, height, samples, false);
			mSceneNormal = Create2DMultisampleTexture("SceneNormal", GL_RGB10_A2, width, height, samples, false);
			mSceneFB = CreateFrameBuffer("SceneFB", mSceneMultisample, 0, 0, mSceneDepthStencil, true);
			mSceneDataFB = CreateFrameBuffer("SceneGBufferFB", mSceneMultisample, mSceneFog, mSceneNormal, mSceneDepthStencil, true);
		}
		else
		{
			mSceneMultisample = CreateRenderBuffer("SceneMultisample", GL_RGBA16F, width, height, samples);
			mSceneDepthStencil = CreateRenderBuffer("SceneDepthStencil", GL_DEPTH24_STENCIL8, width, height, samples);
			mSceneFB = CreateFrameBuffer("SceneFB", mSceneMultisample, mSceneDepthStencil, true);
			mSceneDataFB = CreateFrameBuffer("SceneGBufferFB", mSceneMultisample, mSceneDepthStencil, true);
		}
	}
	else
	{
		if (needsSceneTextures)
		{
			mSceneDepthStencil = Create2DTexture("SceneDepthStencil", GL_DEPTH24_STENCIL8, width, height);
			mSceneFog = Create2DTexture("SceneFog", GL_RGBA8, width, height);
			mSceneNormal = Create2DTexture("SceneNormal", GL_RGB10_A2, width, height);
			mSceneFB = CreateFrameBuffer("SceneFB", mPipelineTexture[0], 0, 0, mSceneDepthStencil, false);
			mSceneDataFB = CreateFrameBuffer("SceneGBufferFB", mPipelineTexture[0], mSceneFog, mSceneNormal, mSceneDepthStencil, false);
		}
		else
		{
			mSceneDepthStencil = CreateRenderBuffer("SceneDepthStencil", GL_DEPTH24_STENCIL8, width, height);
			mSceneFB = CreateFrameBuffer("SceneFB", mPipelineTexture[0], mSceneDepthStencil, false);
			mSceneDataFB = CreateFrameBuffer("SceneGBufferFB", mPipelineTexture[0], mSceneDepthStencil, false);
		}
	}
}
예제 #10
0
int WINAPI WinMain(HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow)
{
	startup_time = GetTickCount();
	previous_time = 0;
	frames = 0;
	fps = 1;
#ifdef _DEBUG_TIMINGS
	drawtime = 0;
	drawtime_prv = 0;
	drawtime_med = 1;
	cleartime = 0;
	cleartime_prv = 0;
	cleartime_med = 1;
	mainlooptime = 0;
	mainlooptime_prv = 0;
	mainlooptime_med = 1;
	fliptime = 0;
	fliptime_prv = 0;
	fliptime_med = 1;
#endif
	current_state = GAME_MAINMENU;
	difficulty_pick = 0;
	size_pick = 0;
	race_pick = 0;
	opponents_pick = 0;
	mouseX = 0;
	mouseY = 0;
	mouse[0] = false;
	mouse[1] = false;
	mouse[2] = false;
	tex_count = 0;
	font_count = 0;
	srand((unsigned)time(NULL));

	LogToFile("Log started");
	InitWindow(hInstance);
	InitPaths();
	InitTextures();
	InitFonts();
	InitStorages();
	InitDefinitions();
	InitGUI();
	InitOGLSettings();
	ResizeScene(cfg.scr_width, cfg.scr_height);
	LogPaths();

	//Load_v_03("test.txt");
	Load_v_04("test.txt");
	while(current_state != GAME_EXITING)
	{
		MainLoop();
		ClearScene();
		DrawScene();
		Flip(&hDC);
	}

	// Now terminating all
	KillWindow(hInstance);

	LogToFile("Finished logging");




}
예제 #11
0
void ScreamerNode::Update(void)
{
	switch(m_state){
		case WAIT:{
			if(m_waitreply == false){
				m_waitreply = true;

				m_jobfile.clear();
				m_jobfile.open(m_job.c_str(),std::ios::out);

				m_jobfile << "wait";

				m_jobfile.close();

				SetAvailable(true);
			}else{
				if(ReadReply(WAIT) == true){
					m_waitreply = false;
				}
			}
		}break;

		case INIT:{
			if(m_waitreply == false){
				m_waitreply = true;

				m_jobfile.clear();
				m_jobfile.open(m_job.c_str(),std::ios::out);

				m_jobfile << "init";

				m_jobfile.close();

				SetAvailable(false);
			}else{
				if(ReadReply(INIT) == true){
					m_waitreply = false;
					m_state			= CONTENT;
				}
			}
		}break;

		case CONTENT:{
			if(m_waitreply == false){
				m_waitreply = true;

				m_jobfile.clear();
				m_jobfile.open(m_job.c_str(),std::ios::out);


				m_jobfile << "content " << m_contentdir << std::endl;

				m_jobfile.close();
			}else{
				if(ReadReply(CONTENT) == true){
					m_waitreply = false;
					m_state			= LOAD;
				}
			}
		}break;

		case LOAD:{
			if(m_waitreply == false){
				m_waitreply = true;

				m_jobfile.clear();
				m_jobfile.open(m_job.c_str(),std::ios::out);

				m_jobfile << "load" << std::endl << m_scenefile;

				m_jobfile.close();
			}else{
				if(ReadReply(LOAD) == true){
					m_waitreply	=	false;

					m_state			=	RENDERWAIT;
				}
			}
		}break;

		case RENDERWAIT:{
			if(m_waitreply == false){
				m_waitreply = true;

				m_jobfile.clear();
				m_jobfile.open(m_job.c_str(),std::ios::out);

				m_jobfile << "wait";

				m_jobfile.close();
			}else{
				if(ReadReply(WAIT) == true){
					switch(m_renderstate){
						case REQ_BATCH:{
							m_scene->RequestBatch(m_start,m_end,m_step);

							m_state				=	RENDER;
							m_renderstate = RENDERING;
	
							SetFrames();

							m_waitreply = false;

							if(m_start == SCENE_COMPLETE){
								SetAvailable(true);

								ClearScene();
								ClearFrames();

								m_state	= WAIT;
							}
						}break;

						case RENDERING:{
							m_scene->FrameComplete();
							scene_view->Update(m_scene->GetID());

							if(m_start >= m_end){
								m_renderstate = REQ_BATCH;
							}else{
								m_waitreply	= false;

								m_state	=	RENDER;

								m_start++;
							}
						}
					};
				}
			}
		}break;

		case RENDERPAUSE:{
			if(m_waitreply == false){
				m_waitreply = true;
			}else{
				m_waitreply = false;
			}
		}break;

		case RENDER:{
			if(m_waitreply == false){
				m_waitreply = true;

				m_jobfile.clear();
				m_jobfile.open(m_job.c_str(),std::ios::out);

				m_jobfile << "render " << m_start << " " << m_start << " " << m_step;

				m_jobfile.close();
			}else{

				if(ReadReply(RENDER) == true){
					m_waitreply	= false;
					m_state			= RENDERWAIT;
				}
			}
		}break;


	};

	screamer_view->Update(m_number);
}
bool FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHeight)
{
	if (gl_renderbuffers != BuffersActive)
	{
		if (BuffersActive)
			glBindFramebuffer(GL_FRAMEBUFFER, mOutputFB);
		BuffersActive = gl_renderbuffers;
		GLRenderer->mShaderManager->ResetFixedColormap();
	}

	if (!IsEnabled())
		return false;
		
	if (width <= 0 || height <= 0)
		I_FatalError("Requested invalid render buffer sizes: screen = %dx%d", width, height);

	int samples = clamp((int)gl_multisample, 0, mMaxSamples);
	bool needsSceneTextures = (gl_ssao != 0);

	GLint activeTex;
	GLint textureBinding;
	glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex);
	glActiveTexture(GL_TEXTURE0);
	glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding);

	if (width != mWidth || height != mHeight)
		CreatePipeline(width, height);

	if (width != mWidth || height != mHeight || mSamples != samples || mSceneUsesTextures != needsSceneTextures)
		CreateScene(width, height, samples, needsSceneTextures);

	mWidth = width;
	mHeight = height;
	mSamples = samples;
	mSceneUsesTextures = needsSceneTextures;

	// Bloom bluring buffers need to match the scene to avoid bloom bleeding artifacts
	if (mSceneWidth != sceneWidth || mSceneHeight != sceneHeight)
	{
		CreateBloom(sceneWidth, sceneHeight);
		CreateExposureLevels(sceneWidth, sceneHeight);
		CreateAmbientOcclusion(sceneWidth, sceneHeight);
		mSceneWidth = sceneWidth;
		mSceneHeight = sceneHeight;
	}

	glBindTexture(GL_TEXTURE_2D, textureBinding);
	glActiveTexture(activeTex);
	glBindRenderbuffer(GL_RENDERBUFFER, 0);
	glBindFramebuffer(GL_FRAMEBUFFER, 0);

	if (FailedCreate)
	{
		ClearScene();
		ClearPipeline();
		ClearEyeBuffers();
		ClearBloom();
		ClearExposureLevels();
		mWidth = 0;
		mHeight = 0;
		mSamples = 0;
		mSceneWidth = 0;
		mSceneHeight = 0;
	}

	return !FailedCreate;
}
예제 #13
0
파일: scene.cpp 프로젝트: bhbosman/code
void Scene::ClearAll()
{
    ClearPointLights();
    ClearScene();
}
예제 #14
0
// Loads the scene data
void OculusWorldDemoApp::PopulateScene(const char *fileName)
{
    ClearScene();

    XmlHandler xmlHandler;
    if(!xmlHandler.ReadFile(fileName, pRender, &MainScene, &CollisionModels, &GroundCollisionModels, SrgbRequested, AnisotropicSample))
    {
        Menu.SetPopupMessage("FILE LOAD FAILED");
        Menu.SetPopupTimeout(10.0f, true);
    }

    MainScene.SetAmbient(Color4f(1.0f, 1.0f, 1.0f, 1.0f));

    String mainFilePathNoExtension = MainFilePath;
    mainFilePathNoExtension.StripExtension();

    unsigned int fillTextureLoadFlags = 0;
    fillTextureLoadFlags |= SrgbRequested ? TextureLoad_SrgbAware : 0;
    fillTextureLoadFlags |= AnisotropicSample ? TextureLoad_Anisotropic : 0;

    // 10x10x10 cubes.
    Ptr<Fill> fillR = *CreateTextureFill(pRender, mainFilePathNoExtension + "_greenCube.tga", fillTextureLoadFlags);
    PopulateCubeFieldScene(&GreenCubesScene, fillR.GetPtr(), 10, 10, 10, Vector3f(0.0f, 0.0f, 0.0f), 0.4f);

    Ptr<Fill> fillB = *CreateTextureFill(pRender, mainFilePathNoExtension + "_redCube.tga", fillTextureLoadFlags);
    PopulateCubeFieldScene(&RedCubesScene, fillB.GetPtr(), 10, 10, 10, Vector3f(0.0f, 0.0f, 0.0f), 0.4f);
    
    Ptr<Fill> fillY = *CreateTextureFill(pRender, mainFilePathNoExtension + "_yellowCube.tga", fillTextureLoadFlags);
    PopulateCubeFieldScene(&YellowCubesScene, fillY.GetPtr(), 10, 10, 10, Vector3f(0.0f, 0.0f, 0.0f), 0.4f);

    Ptr<Fill> imageFill = *CreateTextureFill(pRender, mainFilePathNoExtension + "_OculusCube.tga", fillTextureLoadFlags);
    PopulateCubeFieldScene(&OculusCubesScene, imageFill.GetPtr(), 11, 4, 35, Vector3f(0.0f, 0.0f, -6.0f), 0.5f);

    Vector3f blockModelSizeVec = Vector3f(BlockModelSize, BlockModelSize, BlockModelSize);

    // Handy untextured green cube.
    Ptr<Model> smallGreenCubeModel = *Model::CreateBox(Color(0, 255, 0, 255), Vector3f(0.0f, 0.0f, 0.0f), blockModelSizeVec);
    SmallGreenCube.World.Add(smallGreenCubeModel);

    // Textured cubes.
    Ptr<Model> smallOculusCubeModel = *Model::CreateBox(Color(255, 255, 255, 255), Vector3f(0.0f, 0.0f, 0.0f), blockModelSizeVec);
    smallOculusCubeModel->Fill = imageFill;
    SmallOculusCube.World.Add(smallOculusCubeModel);

    Ptr<Model> smallOculusGreenCubeModel = *Model::CreateBox(Color(255, 255, 255, 255), Vector3f(0.0f, 0.0f, 0.0f), blockModelSizeVec);
    smallOculusGreenCubeModel->Fill = fillR;
    SmallOculusGreenCube.World.Add(smallOculusGreenCubeModel);

    Ptr<Model> smallOculusRedCubeModel = *Model::CreateBox(Color(255, 255, 255, 255), Vector3f(0.0f, 0.0f, 0.0f), blockModelSizeVec);
    smallOculusRedCubeModel->Fill = fillB;
    SmallOculusRedCube.World.Add(smallOculusRedCubeModel);

    int textureLoadFlags = 0;
    textureLoadFlags |= SrgbRequested ? TextureLoad_SrgbAware : 0;
    textureLoadFlags |= AnisotropicSample ? TextureLoad_Anisotropic : 0;
    textureLoadFlags |= TextureLoad_MakePremultAlpha;
    textureLoadFlags |= TextureLoad_SwapTextureSet;

    Ptr<File> imageFile = *new SysFile(mainFilePathNoExtension + "_OculusCube.tga");
    if (imageFile->IsValid())
        TextureOculusCube = *LoadTextureTgaTopDown(pRender, imageFile, textureLoadFlags, 255);

    imageFile = *new SysFile(mainFilePathNoExtension + "_Cockpit_Panel.tga");
    if (imageFile->IsValid())
        CockpitPanelTexture = *LoadTextureTgaTopDown(pRender, imageFile, textureLoadFlags, 255);

    XmlHandler xmlHandler2;
    String controllerFilename = MainFilePath.GetPath() + "LeftController.xml";
    if (!xmlHandler2.ReadFile(controllerFilename.ToCStr(), pRender, &ControllerScene, NULL, NULL))
    {
        Menu.SetPopupMessage("CONTROLLER FILE LOAD FAILED");
        Menu.SetPopupTimeout(10.0f, true);
    }
    ControllerScene.AddLight(Vector3f(0, 30.0f, 0), Color4f(1.0f, 1.0f, 1.0f, 1.0f));
    ControllerScene.AddLight(Vector3f(0, -10.0f, 0), Color4f(.2f, .2f, .2f, 1.0f));


    // Load "Floor Circle" models and textures - used to display floor for seated configuration.	
    Ptr<File>	 floorImageFile    = *new SysFile(mainFilePathNoExtension + "_SitFloorConcrete.tga");
    Ptr<Texture> roundFloorTexture = *LoadTextureTgaTopDown(pRender, floorImageFile, textureLoadFlags, 220);
    if (roundFloorTexture)
        roundFloorTexture->SetSampleMode(Sample_Anisotropic | Sample_Repeat);
    
    Ptr<ShaderFill> fill = *new ShaderFill(*pRender->CreateShaderSet());
    fill->GetShaders()->SetShader(pRender->LoadBuiltinShader(Shader_Vertex, VShader_MVP));
    fill->GetShaders()->SetShader(pRender->LoadBuiltinShader(Shader_Fragment, FShader_Texture));
    fill->SetTexture(0, roundFloorTexture);

    pRoundFloorModel[0] = *new Model(Prim_Triangles);
    pRoundFloorModel[0]->Fill = fill;
    AddFloorCircleModelVertices(pRoundFloorModel[0], 0.3f);
    OculusRoundFloor[0].World.Add(pRoundFloorModel[0]);

    pRoundFloorModel[1] = *new Model(Prim_Triangles);
    pRoundFloorModel[1]->Fill = fill;
    AddFloorCircleDonutModelVertices(pRoundFloorModel[1], 0.35f);
    OculusRoundFloor[1].World.Add(pRoundFloorModel[1]);

    if (ovr_GetTrackerCount(Session) > 0)
    	PositionalTracker.Init(Session, mainFilePathNoExtension, pRender, SrgbRequested, AnisotropicSample);


}
예제 #15
0
SceneManager::~SceneManager(){
	ClearScene();
	mShaders.DeleteValues();
}
// Loads the scene data
void OculusWorldDemoApp::PopulateScene(const char *fileName)
{
    ClearScene();

    XmlHandler xmlHandler;
    if(!xmlHandler.ReadFile(fileName, pRender, &MainScene, &CollisionModels, &GroundCollisionModels, SrgbRequested, AnisotropicSample))
    {
        Menu.SetPopupMessage("FILE LOAD FAILED");
        Menu.SetPopupTimeout(10.0f, true);
    }

    MainScene.SetAmbient(Color4f(1.0f, 1.0f, 1.0f, 1.0f));

    String mainFilePathNoExtension = MainFilePath;
    mainFilePathNoExtension.StripExtension();

    unsigned int fillTextureLoadFlags = 0;
    fillTextureLoadFlags |= SrgbRequested ? TextureLoad_SrgbAware : 0;
    fillTextureLoadFlags |= AnisotropicSample ? TextureLoad_Anisotropic : 0;

    // 10x10x10 cubes.
    Ptr<Fill> fillR = *CreateTextureFill(pRender, mainFilePathNoExtension + "_greenCube.tga", fillTextureLoadFlags);
    PopulateCubeFieldScene(&GreenCubesScene, fillR.GetPtr(), 10, 10, 10, Vector3f(0.0f, 0.0f, 0.0f), 0.4f);

    // 10x10x10 cubes.
    Ptr<Fill> fillB = *CreateTextureFill(pRender, mainFilePathNoExtension + "_redCube.tga", fillTextureLoadFlags);
    PopulateCubeFieldScene(&RedCubesScene, fillB.GetPtr(), 10, 10, 10, Vector3f(0.0f, 0.0f, 0.0f), 0.4f);

	// Anna: OculusWorldDemo/Assets/Tuscany/Tuscany_OculusCube.tga file needs to be added
    Ptr<Fill> imageFill = *CreateTextureFill(pRender, mainFilePathNoExtension + "_OculusCube.tga", fillTextureLoadFlags);
    PopulateCubeFieldScene(&OculusCubesScene, imageFill.GetPtr(), 11, 4, 35, Vector3f(0.0f, 0.0f, -6.0f), 0.5f);

    // Handy untextured green cube.
    Ptr<Model> smallGreenCubeModel = *Model::CreateBox(Color(0, 255, 0, 255), Vector3f(0.0f, 0.0f, 0.0f), Vector3f(0.004f, 0.004f, 0.004f));
    SmallGreenCube.World.Add(smallGreenCubeModel);

    // Textured cubes.
    Ptr<Model> smallOculusCubeModel = *Model::CreateBox(Color(255, 255, 255, 255), Vector3f(0.0f, 0.0f, 0.0f), Vector3f(0.004f, 0.004f, 0.004f));
    smallOculusCubeModel->Fill = imageFill;
    SmallOculusCube.World.Add(smallOculusCubeModel);

    Ptr<Model> smallOculusGreenCubeModel = *Model::CreateBox(Color(255, 255, 255, 255), Vector3f(0.0f, 0.0f, 0.0f), Vector3f(0.004f, 0.004f, 0.004f));
    smallOculusGreenCubeModel->Fill = fillR;
    SmallOculusGreenCube.World.Add(smallOculusGreenCubeModel);

    Ptr<Model> smallOculusRedCubeModel = *Model::CreateBox(Color(255, 255, 255, 255), Vector3f(0.0f, 0.0f, 0.0f), Vector3f(0.004f, 0.004f, 0.004f));
    smallOculusRedCubeModel->Fill = fillB;
    SmallOculusRedCube.World.Add(smallOculusRedCubeModel);

    int textureLoadFlags = 0;
    textureLoadFlags |= SrgbRequested ? TextureLoad_SrgbAware : 0;
    textureLoadFlags |= AnisotropicSample ? TextureLoad_Anisotropic : 0;
    textureLoadFlags |= TextureLoad_MakePremultAlpha;
    textureLoadFlags |= TextureLoad_SwapTextureSet;

    Ptr<File> imageFile = *new SysFile(mainFilePathNoExtension + "_redCube.tga");
    if (imageFile->IsValid())
        TextureRedCube = *LoadTextureTgaTopDown(pRender, imageFile, textureLoadFlags, 255);

    imageFile = *new SysFile(mainFilePathNoExtension + "_greenCube.tga");
    if (imageFile->IsValid())
        TextureGreenCube = *LoadTextureTgaTopDown(pRender, imageFile, textureLoadFlags, 255);

    imageFile = *new SysFile(mainFilePathNoExtension + "_OculusCube.tga");
    if (imageFile->IsValid())
        TextureOculusCube = *LoadTextureTgaTopDown(pRender, imageFile, textureLoadFlags, 255);

    imageFile = *new SysFile(mainFilePathNoExtension + "_Cockpit_Panel.tga");
    if (imageFile->IsValid())
        CockpitPanelTexture = *LoadTextureTgaTopDown(pRender, imageFile, textureLoadFlags, 255);

    XmlHandler xmlHandler2;
    String controllerFilename = MainFilePath.GetPath() + "LeftController.xml";
    if (!xmlHandler2.ReadFile(controllerFilename.ToCStr(), pRender, &ControllerScene, NULL, NULL))
    {
        Menu.SetPopupMessage("CONTROLLER FILE LOAD FAILED");
        Menu.SetPopupTimeout(10.0f, true);
    }
    ControllerScene.AddLight(Vector3f(0, 30.0f, 0), Color4f(1.0f, 1.0f, 1.0f, 1.0f));
    ControllerScene.AddLight(Vector3f(0, -10.0f, 0), Color4f(.2f, .2f, .2f, 1.0f));
}
예제 #17
0
int WINAPI WinMain(HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow)
{
	LogToFile(DEFAULT_LOG_NAME, "Log started");

	InitWindow(hInstance);
	startup_time = GetTickCount();
	previous_time = 0;
	frames = 0;
	fps = 1;

#ifdef _DEBUG_TIMINGS

	drawtime = 0;
	drawtime_prv = 0;
	drawtime_med = 1;
	cleartime = 0;
	cleartime_prv = 0;
	cleartime_med = 1;
	mainlooptime = 0;
	mainlooptime_prv = 0;
	mainlooptime_med = 1;
	fliptime = 0;
	fliptime_prv = 0;
	fliptime_med = 1;

#endif

	current_state = GAME_MAINMENU;
	mouseX = 0;
	mouseY = 0;
	mouse[0] = false;
	mouse[1] = false;
	mouse[2] = false;
	tex_count = 0;
	font_count = 0;

	InitPaths();
	LogPaths();

	
	LoadTexturesFromFolder(path_textures, textures);

	InitFonts();
	InitGUI();

	

	

	InitOGLSettings();
	ResizeScene(cfg.scr_width, cfg.scr_height);
		
	while(current_state != GAME_EXITING)
	{
		MainLoop();
		ClearScene();
		DrawScene();
		Flip(hDC);
	}

	// Now terminating all
	KillWindow(hInstance);

	LogToFile(DEFAULT_LOG_NAME, "Finished logging");




}