/// <summary> /// /// </summary> /// <param name="fullscreen"></param> public void executar() { AppState.Instance.setLanguage(AppState.Instance.Language); #region Inicializações Glut Glut.glutInit(); Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_RGBA | Glut.GLUT_DEPTH); if (AppState.Instance.Fullscreen) { Glut.glutGameModeString(AppState.Instance.Width + "x" + AppState.Instance.Height + ":32"); if (Glut.glutGameModeGet(Glut.GLUT_GAME_MODE_POSSIBLE) == 1) { Glut.glutEnterGameMode(); Glut.glutSetCursor(Glut.GLUT_CURSOR_NONE); } else { System.Environment.Exit(0); } } else { Glut.glutInitWindowSize(AppState.Instance.Width, AppState.Instance.Height); Glut.glutCreateWindow(Settings.Default.ApplicationName + "-" + Settings.Default.VersionNumber); } #endregion #region Inicializações OpenGL Gl.glEnable(Gl.GL_DEPTH_TEST); Gl.glShadeModel(Gl.GL_SMOOTH); Gl.glEnable(Gl.GL_POINT_SMOOTH); Gl.glEnable(Gl.GL_LINE_SMOOTH); Gl.glEnable(Gl.GL_POLYGON_SMOOTH); Gl.glEnable(Gl.GL_TEXTURE_2D); Gl.glEnable(Gl.GL_NORMALIZE); Gl.glEnable(Gl.GL_LIGHTING); Gl.glEnable(Gl.GL_AUTO_NORMAL); //Gl.glEnable(Gl.GL_CULL_FACE); Gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); #endregion Camera cam = new Camera(); cam.IsActive = true; cam.Following = (ThreeDObject)this.ActiveTourist; Camera.CameraList.Add(cam); this.Renderer.Atmosphere = this.AtmosphericConditions; #region Inicialização do DevIL, Alut e bibliotecas associadas Il.ilInit(); Ilut.ilutInit(); Ilut.ilutRenderer(Ilut.ILUT_OPENGL); Alut.alutInit(); #endregion #region Carregar os Recursos Console.WriteLine(AppState.Instance.ResourceManager.GetString("LoadingTextures")); Assets.Instance.loadTextures(); Console.WriteLine(AppState.Instance.ResourceManager.GetString("Loading3DS")); Assets.Instance.loadModels(); Console.WriteLine(AppState.Instance.ResourceManager.GetString("LoadingSounds")); Assets.Instance.loadSounds(); #endregion #region Skybox Skybox skybox = new Skybox(); skybox.createDisplayList(); this.Renderer.ObjectosCena.Add(skybox); #endregion #region Terreno Terrain terreno = new Terrain(); terreno.createDisplayList(); this.Renderer.ObjectosCena.Add(terreno); #endregion #region Sol Sun sol = new Sun(); this.Renderer.IluminacaoCena.Add(sol); #endregion #region Carregamento dos Dados obtidos atrávés do WebService this.Ws.loadTour(ref this.tour); this.Ws.loadCartography(ref this.cartography, this.tour.cityID); AppState.Instance.CurrentDate = this.tour.begin; #endregion #region Adicionar Elementos "Colidíveis" foreach (PointOfInterest p in this.Cartography.pointsOfInterest) { this.collidible.Add(p); } foreach (GenericObject go in this.Cartography.genericObjects) { if (go is RandomBuilding) { this.collidible.Add(go); } } #endregion #region Adicionar Elementos Visitáveis PointOfInterest poi; foreach (ToVisit t in this.CurrentTour.toVisit) { poi = this.Cartography.getPointOfInterestWithID(t.attractionID); poi.ToVisit = true; poi.Visited = t.visited; } #endregion #region Ajustes à Área de Colisão dos Modelos String[] adjustment; String[] dimensions; foreach (PointOfInterest col in this.Cartography.pointsOfInterest) { adjustment = ModelSettings.Default[col.ModelName + "Adjustment"].ToString().Split('|'); col.ColisionArea.Adjustment.set(Double.Parse(adjustment[0]), Double.Parse(adjustment[1]), Double.Parse(adjustment[2])); dimensions = ModelSettings.Default[col.ModelName + "Dimensions"].ToString().Split('|'); col.ColisionArea.Dimensions.set(Double.Parse(dimensions[0]), Double.Parse(dimensions[1]), Double.Parse(dimensions[2])); col.SoundName = ModelSettings.Default[col.ModelName + "SoundName"].ToString(); col.ColisionArea.Visible = true; } #endregion #region Turista this.ActiveTourist.ModelName = "Turista"; this.ActiveTourist.setPosicao(20.0, -0.9, 0.0); this.ActiveTourist.SoundName = "HeroStep3"; this.ActiveTourist.setSoundPosition(); this.Renderer.ObjectosCena.Add(this.ActiveTourist); #endregion // TODO: Cria uma propriedade para isto new Ambiente().definirProperiedades(); Glut.glutDisplayFunc(new Glut.DisplayCallback(this.Renderer.render)); Glut.glutKeyboardFunc(new Glut.KeyboardCallback(this.Input.tecladoNormal)); Glut.glutKeyboardUpFunc(new Glut.KeyboardUpCallback(this.Input.tecladoNormalUp)); Glut.glutReshapeFunc(new Glut.ReshapeCallback(this.Renderer.redimensionar)); Glut.glutSpecialFunc(new Glut.SpecialCallback(this.Input.tecladoEspecial)); Glut.glutTimerFunc(30, new Glut.TimerCallback(this.timer), 0); this.createPopupMenus(); if (this.CurrentTour.toVisit.Count > 0) { Messaging.Instance.Permanent.Add(AppState.Instance.ResourceManager.GetString("ToVisitLabel") + ":"); foreach (ToVisit tv in this.CurrentTour.toVisit) { poi = this.Cartography.getPointOfInterestWithID(tv.attractionID); if (poi.ToVisit && !poi.Visited) { Messaging.Instance.Permanent.Add("- " + poi.Nome); } else { Messaging.Instance.Permanent.Add("- " + poi.Nome + " (" + AppState.Instance.ResourceManager.GetString("VisitedLabel") + ")"); } } } else { Messaging.Instance.Permanent.Add(AppState.Instance.ResourceManager.GetString("NoPOIsToVisit")); } #region Inicializar Música Ambiente this.SoundManager.switchAmbientMusicTo("MusicaAmbiente1"); #endregion this.Renderer.Map = this.Cartography; Glut.glutMainLoop(); }
public static void Main(string[] args) { int menuID, subMenuA, subMenuB; Glut.glutInitDisplayString("stencil~2 rgb double depth>=16 samples"); Glut.glutInitDisplayMode(Glut.GLUT_RGB | Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH); Glut.glutInitWindowPosition(100, 100); Glut.glutInit(); subMenuA = Glut.glutCreateMenu(SampleMenu); Glut.glutAddMenuEntry("Sub menu A1 (01)", 1); Glut.glutAddMenuEntry("Sub menu A2 (02)", 2); Glut.glutAddMenuEntry("Sub menu A3 (03)", 3); subMenuB = Glut.glutCreateMenu(SampleMenu); Glut.glutAddMenuEntry("Sub menu B1 (04)", 4); Glut.glutAddMenuEntry("Sub menu B2 (05)", 5); Glut.glutAddMenuEntry("Sub menu B3 (06)", 6); Glut.glutAddSubMenu("Going to sub menu A", subMenuA); menuID = Glut.glutCreateMenu(SampleMenu); Glut.glutAddMenuEntry("Entry one", 1); Glut.glutAddMenuEntry("Entry two", 2); Glut.glutAddMenuEntry("Entry three", 3); Glut.glutAddMenuEntry("Entry four", 4); Glut.glutAddMenuEntry("Entry five", 5); Glut.glutAddSubMenu("Enter sub menu A", subMenuA); Glut.glutAddSubMenu("Enter sub menu B", subMenuB); Glut.glutCreateWindow("Hello world!"); Glut.glutDisplayFunc(new Glut.DisplayCallback(SampleDisplay)); Glut.glutReshapeFunc(new Glut.ReshapeCallback(SampleReshape)); Glut.glutKeyboardFunc(new Glut.KeyboardCallback(SampleKeyboard)); Glut.glutSpecialFunc(new Glut.SpecialCallback(SampleSpecial)); Glut.glutIdleFunc(new Glut.IdleCallback(SampleIdle)); Glut.glutAttachMenu(Glut.GLUT_LEFT_BUTTON); Glut.glutInitWindowPosition(200, 200); Glut.glutCreateWindow("I am not Jan B."); Glut.glutDisplayFunc(new Glut.DisplayCallback(SampleDisplay)); Glut.glutReshapeFunc(new Glut.ReshapeCallback(SampleReshape)); Glut.glutKeyboardFunc(new Glut.KeyboardCallback(SampleKeyboard)); Glut.glutSpecialFunc(new Glut.SpecialCallback(SampleSpecial)); Glut.glutIdleFunc(new Glut.IdleCallback(SampleIdle)); Glut.glutAttachMenu(Glut.GLUT_LEFT_BUTTON); Console.WriteLine("Testing game mode string parsing, don't panic!\n"); Glut.glutGameModeString("320x240:32@100"); Glut.glutGameModeString("640x480:16@72"); Glut.glutGameModeString("1024x768"); Glut.glutGameModeString(":32@120"); Glut.glutGameModeString("Toudi glupcze, Danwin bedzie moj!"); Glut.glutGameModeString("640x480:16@72"); Glut.glutEnterGameMode(); Glut.glutDisplayFunc(new Glut.DisplayCallback(SampleDisplay)); Glut.glutReshapeFunc(new Glut.ReshapeCallback(SampleReshape)); Glut.glutKeyboardFunc(new Glut.KeyboardCallback(SampleGameModeKeyboard)); Glut.glutIdleFunc(new Glut.IdleCallback(SampleIdle)); Glut.glutAttachMenu(Glut.GLUT_LEFT_BUTTON); Console.WriteLine("current window is %ix%i+%i+%i", Glut.glutGet(Glut.GLUT_WINDOW_X), Glut.glutGet(Glut.GLUT_WINDOW_Y), Glut.glutGet(Glut.GLUT_WINDOW_WIDTH), Glut.glutGet(Glut.GLUT_WINDOW_HEIGHT) ); /* * Enter the main FreeGLUT processing loop */ Glut.glutMainLoop(); Console.WriteLine("glutMainLoop() termination works fine!\n"); }