Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.06 KB | None | 0 0
  1. // Released to the public domain. Use, modify and relicense at will.
  2.  
  3. using System;
  4. using System.Drawing;
  5.  
  6. using OpenTK;
  7. using OpenTK.Graphics;
  8. using OpenTK.Graphics.OpenGL;
  9. using OpenTK.Audio;
  10. using OpenTK.Audio.OpenAL;
  11. using OpenTK.Input;
  12. using Wrak.Objects;
  13. using System.Globalization;
  14. using System.Threading;
  15. using Wrak.Objects.Particles;
  16.  
  17.  
  18. namespace Wrak
  19. {
  20. class Wrak : GameWindow
  21. {
  22. public static KeyboardDevice keyboard;
  23. public static MouseDevice mouse;
  24.  
  25.  
  26.  
  27.  
  28. /// <summary>Creates a 800x600 window with the specified title.</summary>
  29. public Wrak()
  30. : base(800, 600, GraphicsMode.Default, "Wizualizacja Danych Przestrzennych: Wrak")
  31. {
  32. VSync = VSyncMode.On;
  33. Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
  34.  
  35. }
  36.  
  37. /// <summary>Load resources here.</summary>
  38. /// <param name="e">Not used.</param>
  39. protected override void OnLoad(EventArgs e)
  40. {
  41. base.OnLoad(e);
  42. keyboard = Keyboard;
  43. mouse = Mouse;
  44. World.Initialize();
  45.  
  46. GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
  47. GL.Enable(EnableCap.DepthTest);
  48.  
  49. // LAB 1
  50. World.Add(new Triangle());
  51.  
  52. World.Add(new Spring(new Vector3(1,1,1),1));
  53. World.Add(new Quad(new Vector3(1, 1, 1)));
  54. World.Add(new CUbe(new Vector3(0,0,0)));
  55.  
  56. // LAB 2
  57. //for (int i=0; i<10;i++)
  58. // World.Add(new PointSet("../../../cleona.txt", new Vector3(10.0f,0,0)));
  59.  
  60. //World.Add(new Wykres(new Vector3(1, 1, 1),40,40,1,1));
  61.  
  62. //World.Add(new Pole(new Vector3(5, 5, -3), 500, 10, 10, 2, 5));
  63.  
  64. //World.Add(new ProgramableTextureQuad(new Vector3(1, 1, 1),"../../shaders/PTQKolo_VS.glsl", "../../shaders/PTQKolo_FS.glsl"));
  65. //World.Add(new ProgramableTextureQuad(new Vector3(5, 3, 1),"../../shaders/PTQWykres_VS.glsl", "../../shaders/PTQWykres_FS.glsl"));
  66.  
  67. //LAB 3
  68. //World.Add(new Weather());
  69. //World.Add(new Fire(new Vector3(0, 0, 0), 10, 500));
  70.  
  71. //World.Add(new Quad(new Vector3(0, 0, 0), "", "../../shaders/Texture_Nothing_VS.glsl", "../../shaders/Texture_Edge_FS.glsl"));
  72. //World.Add(new Quad(new Vector3(0, 0, 0), "", "../../shaders/Texture_Nothing_VS.glsl", "../../shaders/Texture_Smooth_FS.glsl"));
  73. //World.Add(new Quad(new Vector3(0, 0, 0), "", "../../shaders/Texture_Nothing_VS.glsl", "../../shaders/Texture_Random_FS.glsl"));
  74. //World.Add(new Quad(new Vector3(0, 0, 0), "", "../../shaders/Texture_Nothing_VS.glsl", "../../shaders/Texture_Mand_FS.glsl"));
  75. //World.Add(new Quad(new Vector3(0, 0, 0), "", "../../shaders/Texture_Nothing_VS.glsl", "../../shaders/Texture_Swirl_FS.glsl"));
  76.  
  77.  
  78. }
  79.  
  80. /// <summary>
  81. /// Called when your window is resized. Set your viewport here. It is also
  82. /// a good place to set up your projection matrix (which probably changes
  83. /// along when the aspect ratio of your window).
  84. /// </summary>
  85. /// <param name="e">Not used.</param>
  86. protected override void OnResize(EventArgs e)
  87. {
  88. base.OnResize(e);
  89.  
  90. GL.Viewport(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height);
  91.  
  92. Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 4, Width / (float)Height, 1.0f, 256.0f);
  93. GL.MatrixMode(MatrixMode.Projection);
  94. GL.LoadMatrix(ref projection);
  95. }
  96.  
  97. /// <summary>
  98. /// Called when it is time to setup the next frame. Add you game logic here.
  99. /// </summary>
  100. /// <param name="e">Contains timing information for framerate independent logic.</param>
  101. protected override void OnUpdateFrame(FrameEventArgs e)
  102. {
  103. base.OnUpdateFrame(e);
  104.  
  105. World.Run();
  106.  
  107. if (Keyboard[Key.Escape])
  108. Exit();
  109. }
  110.  
  111. /// <summary>
  112. /// Called when it is time to render the next frame. Add your rendering code here.
  113. /// </summary>
  114. /// <param name="e">Contains timing information.</param>
  115. protected override void OnRenderFrame(FrameEventArgs e)
  116. {
  117. base.OnRenderFrame(e);
  118.  
  119. GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
  120.  
  121. World.Draw();
  122.  
  123. SwapBuffers();
  124. }
  125.  
  126. /// <summary>
  127. /// The main entry point for the application.
  128. /// </summary>
  129. // [STAThread]
  130. static void Main()
  131. {
  132. // The 'using' idiom guarantees proper resource cleanup.
  133. // We request 30 UpdateFrame events per second, and unlimited
  134. // RenderFrame events (as fast as the computer can handle).
  135. using (Wrak glw = new Wrak())
  136. {
  137. glw.Run(30.0);
  138. }
  139. }
  140. }
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement