Exemplo n.º 1
0
Sound* SoundManager::loadSound2(const char* filename, bool alternative)
{
	outputln(std::string("Loading sound:    ") + filename << " (shared)");
#if defined(USES_SDL_FOR_SOUND)
	
	Mix_Chunk* sound = Mix_LoadWAV( filename );
	if (sound == NULL) AssertMessage(false, "Could not open WAV sound file");
	return reinterpret_cast<Sound*>(new Sound_Basic(sound));
#elif defined(USES_WINDOWS_OPENGL) || defined(USES_LINUX)
	unsigned int bufferID;
	unsigned int sourceID;
	SoundLoad::loadSound(filename, &bufferID, &sourceID);
	return reinterpret_cast<Sound*>(new Sound_Basic(bufferID, sourceID));
#elif defined(USES_WINDOWS8_DESKTOP) || defined(USES_WINDOWS8_METRO)
	if (alternative)
	{
		Sound_Stream* ss = new Sound_Stream(filename);
		m_soundStreams.push_back(ss);
		return reinterpret_cast<Sound*>(ss);
	}
	else
	{
		return reinterpret_cast<Sound*>(new Sound_Basic(new SoundFileReader(filename), m_soundPlayer));
	}
#else
	#error
#endif
}
Exemplo n.º 2
0
	void CSteamAchievements::OnUserStatsReceived(UserStatsReceived_t *pCallback)
	{
		// we may get callbacks for other games' stats arriving, ignore them
		if (m_iAppID == static_cast<int64>(pCallback->m_nGameID))
		{
			if (k_EResultOK == pCallback->m_eResult)
			{
				Utils::print("Received stats and achievements from Steam\n");
				m_bInitialized = true;

				// load achievements
				for (int iAch = 0; iAch < m_iNumAchievements; ++iAch)
				{
					Achievement_t &ach = m_pAchievements[iAch];

					SteamUserStats()->GetAchievement(ach.m_pchAchievementID, &ach.m_bAchieved);
					_snprintf(ach.m_rgchName, sizeof(ach.m_rgchName), "%s", SteamUserStats()->GetAchievementDisplayAttribute(ach.m_pchAchievementID, "name"));
					_snprintf(ach.m_rgchDescription, sizeof(ach.m_rgchDescription), "%s", SteamUserStats()->GetAchievementDisplayAttribute(ach.m_pchAchievementID, "desc"));
				}
			}
			else
			{
				char buffer[128];
				_snprintf(buffer, 128, "RequestStats - failed, %d\n", pCallback->m_eResult);
				Utils::print(buffer);
				outputln("AccountId: " << pCallback->m_steamIDUser.GetAccountID());// << ";" << pCallback->m_steamIDUser.Render() );
			}
		}
	}
Exemplo n.º 3
0
void prt_nesc_function_declaration(data_declaration fndecl, void *data)
{
  if (fndecl->definition && fndecl->isused && !fndecl->suppress_definition)
    {
      prt_nesc_function_hdr(fndecl, psd_print_default);
      outputln(";");
    }
}
Exemplo n.º 4
0
void Engine::initLowLevel()
{
	outputln("Init Engine...");
	Utils::indentLog();
	Utils::initClock();
	Utils::initRandomSeed();
	m_appSetup->init();
	m_scene2D = new Scene2D;
	m_keyboardManager = new KeyboardManager;
	m_mouseManager = new MouseManager;
	m_joystickManager = new JoystickManager;
#ifdef USES_SOUND
	m_soundManager = new SoundManager(m_argv0.c_str());
#endif 
	m_scene3D = new Scene3D;
	m_isInit = true;
	Utils::unindentLog();
	outputln("Init Engine done.");

	this->onWindowResizeInternals();
}
Exemplo n.º 5
0
void VBO::commonConstructor(const Meshes3D::BasicVertex* vertices, int verticesSize, const TypeIndex* indices, int indicesSize)
{
	outputln("Building VBO with " << verticesSize << " vertices and " << indicesSize << " indices");
	if (!isExtensionSupport) {outputln("      extension not supported");return;}

	if (DEBUG_VERBOSE) outputln("      extension supported");
	vboImpl->vertexCount = verticesSize;

	//Thread::claimSemaphore();

	//std::cout << "Adding VBO of " << vboImpl->vertexCount << " vertices." << std::endl;
	
	glGenBuffersARB( 1, &vboImpl->idVertices );
	if (DEBUG_VERBOSE) outputln("        Gen buffers ok.");
	glBindBufferARB( GL_ARRAY_BUFFER, vboImpl->idVertices );
	if (DEBUG_VERBOSE) outputln("        Bind buffer ok." << vboImpl->idVertices);
	glBufferDataARB( GL_ARRAY_BUFFER, vboImpl->vertexCount*sizeof(Meshes3D::BasicVertex), vertices, GL_STATIC_DRAW );
	if (DEBUG_VERBOSE) outputln("        Buffer data vertices done." << vboImpl->vertexCount << "," << sizeof(Meshes3D::BasicVertex));

	if (indices != NULL)
	{
		glGenBuffersARB( 1, &vboImpl->idIndices );
		glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER, vboImpl->idIndices );
		glBufferDataARB( GL_ELEMENT_ARRAY_BUFFER, indicesSize*sizeof(TypeIndex), indices, GL_STATIC_DRAW );
		vboImpl->indicesSize = indicesSize;
		if (DEBUG_VERBOSE) outputln("        Indices done.");
	}

	//Thread::releaseSemaphore();
	
	//http://stackoverflow.com/questions/10545479/why-does-binding-a-gl-element-array-buffer-to-0-produce-a-memmove-error
	//glBindBuffer(GL_ARRAY_BUFFER, 0);
	//glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

	if (Fog::isVolumetricFog())
	{
		vboImpl->fogCoordsSize = vboImpl->vertexCount;
		float* fogCoordsBuffer = new float[ vboImpl->fogCoordsSize ];
		Float3 posCamera = Engine::instance().getScene3DMgr().getCamera().getPosition();
		for (int i = 0; i < vboImpl->vertexCount; ++i)
		{
			Float3 pos(vertices[i].pos.x, vertices[i].pos.y, vertices[i].pos.z);
			float dist = pos.distanceTo(posCamera) / 1000.f;
			fogCoordsBuffer[i] = dist > 1.f ? 1.f : dist;
		}

		glGenBuffersARB( 1, &vboImpl->idFogCoords );
		glBindBufferARB( GL_ARRAY_BUFFER, vboImpl->idFogCoords );
		glBufferDataARB( GL_ARRAY_BUFFER, vboImpl->fogCoordsSize*sizeof(float), fogCoordsBuffer, GL_STATIC_DRAW );

		delete [] fogCoordsBuffer;
	}
}
Exemplo n.º 6
0
void SoundManager::removeSound(Sound* sound)
{
	m_counter[sound]--;
	if (m_counter[sound] == 0)
	{
		m_counter.erase(sound);
		iterateMapConst(m_database, std::string, Sound*)
		{
			if ((*it).second == sound)
			{
				outputln(std::string("Unloading sound (shared): ") + (*it).first);
				this->removeSound2(sound);
				m_database.erase((*it).first);
				break;
			}
		}
	}
Exemplo n.º 7
0
void TestCasesHandler::getResponse()
{
	string response = m_builder.getResponse(m_input.c_str()).c_str();
	outputln("Response:       " + response);
	
	if(!m_expectedAnswer.empty())
	{
		if(response == m_expectedAnswer)
		{
			outputln("<p style=\"color:green\">[OK]</p>");
		}
		else
		{
			outputln("<p style=\"color:red\">[FAILED]</p>");
		}
	}
	else if(!m_keyWords.empty())
	{
		typedef vector<string>::const_iterator VCI;
		bool allFound = true;
		for(VCI it = m_keyWords.begin(); it != m_keyWords.end(); ++it)
		{
			typedef tokenizer<char_separator<char> > tokenize;
			typedef tokenizer<char_separator<char> >::const_iterator CI;

			char_separator<char> sep(",");
			tokenize keyWordsToken((*it), sep);
			bool oneFound = false;
			for(CI it = keyWordsToken.begin(); it != keyWordsToken.end(); ++it)
			{	
				string toLookFor = trim_copy(*it);
				if(find_first(response, toLookFor))
				{
					erase_first(response, toLookFor);
					oneFound = true;
					break;
				}
			}

			if(oneFound == false)
			{
				allFound = false;
			}
		}

		if(allFound)
		{
			outputln("<p style=\"color:green\">[OK]</p>");
		}
		else
		{
			outputln("<p style=\"color:red\">[FAILED]</p>");
		}
	}
	else
	{
		outputln("[No expected answer or keywords given, ERROR]");
	}

	outputln("");
}
Exemplo n.º 8
0
void DesktopApp::Run()
{
	// ------------- init Engine objects
	Assert(!Engine::instance().isInit());
	Engine::instance().initLowLevel();

	try
	{
		// ------------- call main class init()
		m_mainClass->init();
		m_frameDurationCounter.init();

		while (Engine::instance().isRunning() && !reinterpret_cast<const DesktopWindow*>(getWindow())->mustBeDestroyed()) // ------------ MAIN LOOP
		{
			// ------------ manage events

			this->manageEvents();

			if (!m_suspended)
			{
				// ------------- call main class update()

				bool needProcessAgain = m_mainClass->update();

				if (reinterpret_cast<const DesktopWindow*>(getWindow())->mustBeDestroyed() || !Engine::instance().isRunning()) break;

				Engine::instance().updateInternals();

				// ------------ call main class render()

				this->BeginDraw();
				m_mainClass->render();
				this->EndDraw();
			}

			Engine::instance().m_frameDuration = m_frameDurationCounter.retrieve();
		}

		m_mainClass->deinit();
		Engine::instance().deinitLowLevel();
	}
	catch (EngineError e)
	{
		outputln("Caught EngineError");
		if (this->isDrawing()) this->EndDraw();
		m_isCrashedState = true;

		while (true)
		{
			this->manageEvents();
			Engine::instance().updateInternals();

			this->BeginDraw();
			Engine::instance().clearScreen(CoreUtils::colorBlack);
			Engine::instance().getScene2DMgr().drawText(NULL, Utils::convertWStringToString(e.getFullText(), false).c_str(), Int2(20, 40), 18, CoreUtils::colorWhite);
			this->EndDraw();
			Engine::instance().m_frameDuration = m_frameDurationCounter.retrieve();
		}
	}

	cleanup();

	uninitializeWindow();

	outputln("======== CLEANUP DONE ========");

#ifndef NDEBUG
	// http://gamedev.stackexchange.com/questions/14633/what-do-these-state-creation-warnings-mean-in-the-dx11-debug-output
	typedef HRESULT(__stdcall *fPtr)(const IID&, void**);
	HMODULE hDll = GetModuleHandleW(L"dxgidebug.dll");
	fPtr DXGIGetDebugInterface = (fPtr)GetProcAddress(hDll, "DXGIGetDebugInterface");
	IDXGIDebug* pDxgiDebug;
	DXGIGetDebugInterface(__uuidof(IDXGIDebug), (void**)&pDxgiDebug);
	pDxgiDebug->ReportLiveObjects(DXGI_DEBUG_ALL, DXGI_DEBUG_RLO_ALL);
#endif
}