Beispiel #1
0
int Core::MainLoop() {
	
	Logger::Instance()->OutputString("MainLoop...");

	BitmapFontGL::Instance()->CreateTexture();
	baseTime = SDL_GetTicks();

	// テキスト用エフェクトだけは事前にコンパイルしておく
	shaderGL[POSTFxID].CompileFromFile(EffectFileTable[POSTFxID]);
	textEditor.Load(EffectFileTable[0]);
	
	glGenTextures(1 , &audioTexture);
	while (!end) {
		if (ProcessSDLEvents() < 0)
			break;

		audioBuffer = audioAnalyzer->Capture();
		
		Render();
	}

	Logger::Instance()->OutputString("End");

	return 0;
}
Beispiel #2
0
int main(int argc, char** argv) {
	int flags = SDL_OPENGL;

	if (argc >= 2) {
	  if (strcmp(argv[1], "-f") == 0) {
		  flags = SDL_OPENGL | SDL_FULLSCREEN ;
	  }
	}
	if (argc >= 4) {
	  windowWidth = atoi(argv[2]);
	  windowHeight = atoi(argv[3]);
	}

	if (Initialize(windowWidth, windowHeight, flags) < 0)
		return 0;

	while (1) {
		if (ProcessSDLEvents() < 0)
			break;
		
		int now = SDL_GetTicks();
		Render();
		int tm = SDL_GetTicks() - now;
		char buf[256];
		sprintf(buf, "%d", tm);
		SDL_WM_SetCaption(buf, NULL);
	}

	return 0;
}
Beispiel #3
0
int main(int argc, char *argv[])
{
	#if defined(NDEBUG)
		argv0 = (argc ? argv[0] : NULL);
	#endif
	#if defined(__MACOSX__)
		static char path[PATH_MAX];
		CFBundleRef mainBundle = CFBundleGetMainBundle();
		CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
		if (CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX)) chdir(path);
		CFRelease(resourcesURL);
		#if defined(NDEBUG)
		resourcesURL = CFBundleCopyExecutableURL(mainBundle);
		if (CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX)) argv0 = path;
		CFRelease(resourcesURL);
		#endif
	#endif
	#if defined(__WIN32__)
		//set this for icon resource identifier
		SDL_Appname = (LPTSTR)"Z\0L\0\0";
		SDL_Instance = GetModuleHandle(NULL);
	#endif
	SDL_EventState(SDL_SYSWMEVENT, SDL_DISABLE);
	ZillaLibInit(argc, argv);
	while (!(ZL_MainApplicationFlags & ZL_APPLICATION_DONE))
	{
		ProcessSDLEvents();
		ZL_MainApplication->Frame();
		SDL_GL_SwapWindow(ZL_SDL_Window);
		//#ifdef __WIN32__
		//if ((ZL_MainApplicationFlags & (ZL_APPLICATION_NOVSYNC|ZL_APPLICATION_VSYNCFAILED|ZL_APPLICATION_VSYNCHACK)) == (ZL_APPLICATION_VSYNCFAILED|ZL_APPLICATION_VSYNCHACK))
		//{
		//	//hack to fix vsync issue on ATI cards on windows (Maybe other platforms/cards affected?)
		//	//see http://www.gamedev.net/topic/544239-jerky-movement-when-vsync-turned-on-wglswapintervalext/page-2
		//	//see https://github.com/LaurentGomila/SFML/issues/320
		//	if (ZL_Application::FrameCount>>2) glFinish();
		//}
		//#endif
		//avoid any "input lag" (see: http://www.opengl.org/wiki/Swap_Interval#GPU_vs_CPU_synchronization)
		if (!(ZL_MainApplicationFlags & ZL_APPLICATION_NOVSYNC)) glFinish();
	}
	ZL_MainApplication->OnQuit();
	//_exit(ZL_DoneReturn); //faster exit without freeing each object, let OS free all memory and resources
	return ZL_DoneReturn;
}