Permalink
Browse files

Initial commit -- moved from https://github.com/LaurentGomila/SFML (b…

…indings/dotnet)
  • Loading branch information...
LaurentGomila committed Jul 6, 2011
0 parents commit a03db64015805afd9a860b24d914f8df1337455e
Showing with 10,788 additions and 0 deletions.
  1. +96 −0 build/vc2008/SFML.net.sln
  2. +71 −0 doc/build/MainPage.html
  3. +38 −0 doc/build/SFML.ndoc
  4. +174 −0 examples/opengl/OpenGL.cs
  5. +80 −0 examples/opengl/opengl.csproj
  6. BIN examples/opengl/resources/background.jpg
  7. BIN examples/opengl/resources/texture.jpg
  8. +247 −0 examples/shader/Shader.cs
  9. BIN examples/shader/resources/arial.ttf
  10. BIN examples/shader/resources/background.jpg
  11. +16 −0 examples/shader/resources/blur.sfx
  12. +11 −0 examples/shader/resources/colorize.sfx
  13. +13 −0 examples/shader/resources/fisheye.sfx
  14. +6 −0 examples/shader/resources/nothing.sfx
  15. +10 −0 examples/shader/resources/pixelate.sfx
  16. BIN examples/shader/resources/sprite.png
  17. BIN examples/shader/resources/wave.jpg
  18. +12 −0 examples/shader/resources/wave.sfx
  19. +75 −0 examples/shader/shader.csproj
  20. +82 −0 examples/sound/Sound.cs
  21. BIN examples/sound/resources/canary.wav
  22. BIN examples/sound/resources/orchestral.ogg
  23. +75 −0 examples/sound/sound.csproj
  24. +83 −0 examples/sound_capture/SoundCapture.cs
  25. +75 −0 examples/sound_capture/sound_capture.csproj
  26. +13 −0 examples/visualbasic/My Project/Application.Designer.vb
  27. +10 −0 examples/visualbasic/My Project/Application.myapp
  28. +35 −0 examples/visualbasic/My Project/AssemblyInfo.vb
  29. +63 −0 examples/visualbasic/My Project/Resources.Designer.vb
  30. +117 −0 examples/visualbasic/My Project/Resources.resx
  31. +73 −0 examples/visualbasic/My Project/Settings.Designer.vb
  32. +7 −0 examples/visualbasic/My Project/Settings.settings
  33. +161 −0 examples/visualbasic/OpenGL.vb
  34. BIN examples/visualbasic/resources/background.jpg
  35. BIN examples/visualbasic/resources/texture.jpg
  36. +26 −0 examples/visualbasic/visualbasic.sln
  37. +159 −0 examples/visualbasic/visualbasic.vbproj
  38. +134 −0 examples/window/Window.cs
  39. +75 −0 examples/window/window.csproj
  40. BIN extlibs/x64/csfml-audio-2.dll
  41. BIN extlibs/x64/csfml-graphics-2.dll
  42. BIN extlibs/x64/csfml-window-2.dll
  43. BIN extlibs/x64/libsndfile-1.dll
  44. BIN extlibs/x64/openal32.dll
  45. BIN extlibs/x86/csfml-audio-2.dll
  46. BIN extlibs/x86/csfml-graphics-2.dll
  47. BIN extlibs/x86/csfml-window-2.dll
  48. BIN extlibs/x86/libsndfile-1.dll
  49. BIN extlibs/x86/openal32.dll
  50. +31 −0 license.txt
  51. +36 −0 readme.txt
  52. +72 −0 src/Audio/Listener.cs
  53. +333 −0 src/Audio/Music.cs
  54. +325 −0 src/Audio/Sound.cs
  55. +209 −0 src/Audio/SoundBuffer.cs
  56. +83 −0 src/Audio/SoundBufferRecorder.cs
  57. +192 −0 src/Audio/SoundRecorder.cs
  58. +386 −0 src/Audio/SoundStream.cs
  59. +133 −0 src/Audio/Vector3.cs
  60. +88 −0 src/Audio/sfml-audio.csproj
  61. +110 −0 src/Graphics/Color.cs
  62. +91 −0 src/Graphics/Context.cs
  63. +130 −0 src/Graphics/Drawable.cs
  64. +238 −0 src/Graphics/Font.cs
  65. +462 −0 src/Graphics/Image.cs
  66. +247 −0 src/Graphics/Rect.cs
  67. +336 −0 src/Graphics/RenderImage.cs
  68. +133 −0 src/Graphics/RenderTarget.cs
  69. +630 −0 src/Graphics/RenderWindow.cs
  70. +267 −0 src/Graphics/Shader.cs
  71. +565 −0 src/Graphics/Shape.cs
  72. +397 −0 src/Graphics/Sprite.cs
  73. +465 −0 src/Graphics/Text.cs
  74. +251 −0 src/Graphics/View.cs
  75. +97 −0 src/Graphics/sfml-graphics.csproj
  76. +92 −0 src/Window/ContextSettings.cs
  77. +266 −0 src/Window/Event.cs
  78. +378 −0 src/Window/EventArgs.cs
  79. +159 −0 src/Window/Joystick.cs
  80. +146 −0 src/Window/Keyboard.cs
  81. +84 −0 src/Window/LoadingFailedException.cs
  82. +81 −0 src/Window/Mouse.cs
  83. +93 −0 src/Window/ObjectBase.cs
  84. +246 −0 src/Window/Vector2.cs
  85. +124 −0 src/Window/VideoMode.cs
  86. +690 −0 src/Window/Window.cs
  87. +85 −0 src/Window/sfml-window.csproj
@@ -0,0 +1,96 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sfml-window", "..\..\src\Window\sfml-window.csproj", "{D17DE83D-A592-461F-8AF2-53F9E22E1D0F}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sfml-graphics", "..\..\src\Graphics\sfml-graphics.csproj", "{46786269-57B9-48E7-AA4F-8F4D84609FE6}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sfml-audio", "..\..\src\Audio\sfml-audio.csproj", "{0B202C4D-A457-47FE-84A3-031DD878C6BE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "opengl", "..\..\examples\opengl\opengl.csproj", "{160AE11E-138A-4B77-9642-EA74F9A79B4D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "window", "..\..\examples\window\window.csproj", "{C1FBB9AF-B69A-4D06-9BDC-EAC7606296FF}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sound", "..\..\examples\sound\sound.csproj", "{16E177F3-A0FF-4091-8521-562E0EBAA3AB}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sound_capture", "..\..\examples\sound_capture\sound_capture.csproj", "{F2F48990-F81E-41BA-AD01-168F6178C807}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "shader", "..\..\examples\shader\shader.csproj", "{9D4738F7-34EA-433A-A765-AF85A52A174D}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {D17DE83D-A592-461F-8AF2-53F9E22E1D0F}.Debug|x64.ActiveCfg = Debug|x64
+ {D17DE83D-A592-461F-8AF2-53F9E22E1D0F}.Debug|x64.Build.0 = Debug|x64
+ {D17DE83D-A592-461F-8AF2-53F9E22E1D0F}.Debug|x86.ActiveCfg = Debug|x86
+ {D17DE83D-A592-461F-8AF2-53F9E22E1D0F}.Debug|x86.Build.0 = Debug|x86
+ {D17DE83D-A592-461F-8AF2-53F9E22E1D0F}.Release|x64.ActiveCfg = Release|x64
+ {D17DE83D-A592-461F-8AF2-53F9E22E1D0F}.Release|x64.Build.0 = Release|x64
+ {D17DE83D-A592-461F-8AF2-53F9E22E1D0F}.Release|x86.ActiveCfg = Release|x64
+ {D17DE83D-A592-461F-8AF2-53F9E22E1D0F}.Release|x86.Build.0 = Release|x64
+ {46786269-57B9-48E7-AA4F-8F4D84609FE6}.Debug|x64.ActiveCfg = Debug|x64
+ {46786269-57B9-48E7-AA4F-8F4D84609FE6}.Debug|x64.Build.0 = Debug|x64
+ {46786269-57B9-48E7-AA4F-8F4D84609FE6}.Debug|x86.ActiveCfg = Debug|x86
+ {46786269-57B9-48E7-AA4F-8F4D84609FE6}.Debug|x86.Build.0 = Debug|x86
+ {46786269-57B9-48E7-AA4F-8F4D84609FE6}.Release|x64.ActiveCfg = Release|x64
+ {46786269-57B9-48E7-AA4F-8F4D84609FE6}.Release|x64.Build.0 = Release|x64
+ {46786269-57B9-48E7-AA4F-8F4D84609FE6}.Release|x86.ActiveCfg = Release|x64
+ {46786269-57B9-48E7-AA4F-8F4D84609FE6}.Release|x86.Build.0 = Release|x64
+ {0B202C4D-A457-47FE-84A3-031DD878C6BE}.Debug|x64.ActiveCfg = Debug|x64
+ {0B202C4D-A457-47FE-84A3-031DD878C6BE}.Debug|x64.Build.0 = Debug|x64
+ {0B202C4D-A457-47FE-84A3-031DD878C6BE}.Debug|x86.ActiveCfg = Debug|x86
+ {0B202C4D-A457-47FE-84A3-031DD878C6BE}.Debug|x86.Build.0 = Debug|x86
+ {0B202C4D-A457-47FE-84A3-031DD878C6BE}.Release|x64.ActiveCfg = Release|x64
+ {0B202C4D-A457-47FE-84A3-031DD878C6BE}.Release|x64.Build.0 = Release|x64
+ {0B202C4D-A457-47FE-84A3-031DD878C6BE}.Release|x86.ActiveCfg = Release|x64
+ {0B202C4D-A457-47FE-84A3-031DD878C6BE}.Release|x86.Build.0 = Release|x64
+ {160AE11E-138A-4B77-9642-EA74F9A79B4D}.Debug|x64.ActiveCfg = Debug|x64
+ {160AE11E-138A-4B77-9642-EA74F9A79B4D}.Debug|x64.Build.0 = Debug|x64
+ {160AE11E-138A-4B77-9642-EA74F9A79B4D}.Debug|x86.ActiveCfg = Debug|x86
+ {160AE11E-138A-4B77-9642-EA74F9A79B4D}.Debug|x86.Build.0 = Debug|x86
+ {160AE11E-138A-4B77-9642-EA74F9A79B4D}.Release|x64.ActiveCfg = Release|x64
+ {160AE11E-138A-4B77-9642-EA74F9A79B4D}.Release|x64.Build.0 = Release|x64
+ {160AE11E-138A-4B77-9642-EA74F9A79B4D}.Release|x86.ActiveCfg = Release|x64
+ {160AE11E-138A-4B77-9642-EA74F9A79B4D}.Release|x86.Build.0 = Release|x64
+ {C1FBB9AF-B69A-4D06-9BDC-EAC7606296FF}.Debug|x64.ActiveCfg = Debug|x64
+ {C1FBB9AF-B69A-4D06-9BDC-EAC7606296FF}.Debug|x64.Build.0 = Debug|x64
+ {C1FBB9AF-B69A-4D06-9BDC-EAC7606296FF}.Debug|x86.ActiveCfg = Debug|x86
+ {C1FBB9AF-B69A-4D06-9BDC-EAC7606296FF}.Debug|x86.Build.0 = Debug|x86
+ {C1FBB9AF-B69A-4D06-9BDC-EAC7606296FF}.Release|x64.ActiveCfg = Release|x64
+ {C1FBB9AF-B69A-4D06-9BDC-EAC7606296FF}.Release|x64.Build.0 = Release|x64
+ {C1FBB9AF-B69A-4D06-9BDC-EAC7606296FF}.Release|x86.ActiveCfg = Release|x64
+ {C1FBB9AF-B69A-4D06-9BDC-EAC7606296FF}.Release|x86.Build.0 = Release|x64
+ {16E177F3-A0FF-4091-8521-562E0EBAA3AB}.Debug|x64.ActiveCfg = Debug|x64
+ {16E177F3-A0FF-4091-8521-562E0EBAA3AB}.Debug|x64.Build.0 = Debug|x64
+ {16E177F3-A0FF-4091-8521-562E0EBAA3AB}.Debug|x86.ActiveCfg = Debug|x86
+ {16E177F3-A0FF-4091-8521-562E0EBAA3AB}.Debug|x86.Build.0 = Debug|x86
+ {16E177F3-A0FF-4091-8521-562E0EBAA3AB}.Release|x64.ActiveCfg = Release|x64
+ {16E177F3-A0FF-4091-8521-562E0EBAA3AB}.Release|x64.Build.0 = Release|x64
+ {16E177F3-A0FF-4091-8521-562E0EBAA3AB}.Release|x86.ActiveCfg = Release|x64
+ {16E177F3-A0FF-4091-8521-562E0EBAA3AB}.Release|x86.Build.0 = Release|x64
+ {F2F48990-F81E-41BA-AD01-168F6178C807}.Debug|x64.ActiveCfg = Debug|x64
+ {F2F48990-F81E-41BA-AD01-168F6178C807}.Debug|x64.Build.0 = Debug|x64
+ {F2F48990-F81E-41BA-AD01-168F6178C807}.Debug|x86.ActiveCfg = Debug|x86
+ {F2F48990-F81E-41BA-AD01-168F6178C807}.Debug|x86.Build.0 = Debug|x86
+ {F2F48990-F81E-41BA-AD01-168F6178C807}.Release|x64.ActiveCfg = Release|x64
+ {F2F48990-F81E-41BA-AD01-168F6178C807}.Release|x64.Build.0 = Release|x64
+ {F2F48990-F81E-41BA-AD01-168F6178C807}.Release|x86.ActiveCfg = Release|x64
+ {F2F48990-F81E-41BA-AD01-168F6178C807}.Release|x86.Build.0 = Release|x64
+ {9D4738F7-34EA-433A-A765-AF85A52A174D}.Debug|x64.ActiveCfg = Debug|x64
+ {9D4738F7-34EA-433A-A765-AF85A52A174D}.Debug|x64.Build.0 = Debug|x64
+ {9D4738F7-34EA-433A-A765-AF85A52A174D}.Debug|x86.ActiveCfg = Debug|x86
+ {9D4738F7-34EA-433A-A765-AF85A52A174D}.Debug|x86.Build.0 = Debug|x86
+ {9D4738F7-34EA-433A-A765-AF85A52A174D}.Release|x64.ActiveCfg = Release|x64
+ {9D4738F7-34EA-433A-A765-AF85A52A174D}.Release|x64.Build.0 = Release|x64
+ {9D4738F7-34EA-433A-A765-AF85A52A174D}.Release|x86.ActiveCfg = Release|x64
+ {9D4738F7-34EA-433A-A765-AF85A52A174D}.Release|x86.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
@@ -0,0 +1,71 @@
+<h2>Welcome</h2>
+<p>
+Welcome to the official SFML.Net documentation. Here you will find a detailed
+description of all the SFML.Net classes. <br/>
+If you are looking for tutorials, help or whatever, you can visit the official website
+at <a href="http://www.sfml-dev.org/">www.sfml-dev.org</a>.
+</p>
+
+<h2>Short example</h2>
+<p>
+Here is a short example in C#, to show you how simple it is to use SFML.Net :
+</p>
+
+<pre style="background-color:#F0F0F0">
+<span style="color:blue">using</span> System;
+<span style="color:blue">using</span> SFML.Audio;
+<span style="color:blue">using</span> SFML.Window;
+<span style="color:blue">using</span> SFML.Graphics;
+
+<span style="color:blue">namespace</span> Example
+{
+ <span style="color:blue">class</span> <span style="color:#2B91AF">Program</span>
+ {
+ <span style="color:blue">static void</span> OnClose(<span style="color:blue">object</span> sender, <span style="color:#2B91AF">EventArgs</span> e)
+ {
+ <span style="color:#008000">// Close the window when OnClose event is received</span>
+ <span style="color:#2B91AF">RenderWindow</span> window = (<span style="color:#2B91AF">RenderWindow</span>)sender;
+ window.Close();
+ }
+
+ <span style="color:blue">static void</span> Main(<span style="color:blue">string</span>[] args)
+ {
+ <span style="color:#008000">// Create the main window</span>
+ <span style="color:#2B91AF">RenderWindow</span> window = <span style="color:blue">new</span> <span style="color:#2B91AF">RenderWindow</span>(<span style="color:blue">new</span> <span style="color:#2B91AF">VideoMode</span>(800, 600), <span style="color:#A31515">"SFML window"</span>);
+ window.Closed += <span style="color:blue">new</span> <span style="color:#2B91AF">EventHandler</span>(OnClose);
+
+ <span style="color:#008000">// Load a sprite to display</span>
+ <span style="color:#2B91AF">Image</span> image = <span style="color:blue">new</span> <span style="color:#2B91AF">Image</span>(<span style="color:#A31515">"cute_image.jpg"</span>);
+ <span style="color:#2B91AF">Sprite</span> sprite = <span style="color:blue">new</span> <span style="color:#2B91AF">Sprite</span>(image);
+
+ <span style="color:#008000">// Create a graphical string to display</span>
+ <span style="color:#2B91AF">Font</span> font = <span style="color:blue">new</span> <span style="color:#2B91AF">Font</span>(<span style="color:#A31515">"arial.ttf"</span>);
+ <span style="color:#2B91AF">Text</span> text = <span style="color:blue">new</span> <span style="color:#2B91AF">Text</span>(<span style="color:#A31515">"Hello SFML.Net"</span>, font);
+
+ <span style="color:#008000">// Load a music to play</span>
+ <span style="color:#2B91AF">Music</span> music = <span style="color:blue">new</span> Music(<span style="color:#A31515">"nice_music.ogg"</span>);
+ music.Play();
+
+ <span style="color:#008000">// Start the game loop</span>
+ <span style="color:blue">while</span> (window.IsOpened())
+ {
+ <span style="color:#008000">// Process events</span>
+ window.DispatchEvents();
+
+ <span style="color:#008000">// Clear screen</span>
+ window.Clear();
+
+ <span style="color:#008000">// Draw the sprite</span>
+ window.Draw(sprite);
+
+ <span style="color:#008000">// Draw the string</span>
+ window.Draw(text);
+
+ <span style="color:#008000">// Update the window</span>
+ window.Display();
+ }
+ }
+ }
+}
+</pre>
+
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<project SchemaVersion="2.0">
+ <assemblies>
+ <assembly location="..\..\lib\sfmlnet-audio.dll" documentation=".\audio-doc.xml" />
+ <assembly location="..\..\lib\sfmlnet-graphics.dll" documentation=".\graphics-doc.xml" />
+ <assembly location="..\..\lib\sfmlnet-window.dll" documentation=".\window-doc.xml" />
+ </assemblies>
+ <documenters>
+ <documenter name="MSDN-Help2">
+ <property name="PlugInNamespace" value="ms.vscc" />
+ <property name="OutputDirectory" value="..\html\" />
+ <property name="HtmlHelpName" value="SFML.Net" />
+ <property name="Title" value="SFML.Net documentation" />
+ </documenter>
+ <documenter name="XML">
+ <property name="OutputFile" value=".\doc\doc.xml" />
+ </documenter>
+ <documenter name="Intellisense">
+ <property name="OutputDirectory" value="..\intellisense\" />
+ <property name="DocumentProtected" value="False" />
+ </documenter>
+ <documenter name="MSDN-CHM">
+ <property name="RootPageFileName" value=".\MainPage.html" />
+ <property name="OutputDirectory" value="..\" />
+ <property name="HtmlHelpName" value="SFML.Net" />
+ <property name="Title" value="SFML.Net documentation" />
+ <property name="IncrementalBuild" value="True" />
+ <property name="DocumentExplicitInterfaceImplementations" value="True" />
+ <property name="DocumentProtected" value="False" />
+ <property name="CleanIntermediates" value="True" />
+ </documenter>
+ <documenter name="MSDN-Web">
+ <property name="OutputDirectory" value="..\msdn\" />
+ <property name="HtmlHelpName" value="SFML.Net" />
+ <property name="Title" value="SFML.Net documentation" />
+ </documenter>
+ </documenters>
+</project>
@@ -0,0 +1,174 @@
+using System;
+using SFML;
+using SFML.Graphics;
+using SFML.Window;
+using Tao.OpenGl;
+
+namespace opengl
+{
+ static class Program
+ {
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ static void Main()
+ {
+ // Create main window
+ RenderWindow window = new RenderWindow(new VideoMode(800, 600), "SFML.Net OpenGL", Styles.Default, new ContextSettings(32, 0));
+
+ // Setup event handlers
+ window.Closed += new EventHandler(OnClosed);
+ window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
+ window.Resized += new EventHandler<SizeEventArgs>(OnResized);
+
+ // Create a sprite for the background
+ Image backgroundImage = new Image("resources/background.jpg");
+ Sprite background = new Sprite(backgroundImage);
+
+ // Create a text to display
+ Text text = new Text("SFML / OpenGL demo");
+ text.Position = new Vector2f(250.0F, 450.0F);
+ text.Color = new Color(255, 255, 255, 170);
+
+ // Load an OpenGL texture.
+ // We could directly use a sf::Image as an OpenGL texture (with its Bind() member function),
+ // but here we want more control on it (generate mipmaps, ...) so we create a new one
+ int texture = 0;
+ using (Image image = new Image("resources/texture.jpg"))
+ {
+ Gl.glGenTextures(1, out texture);
+ Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture);
+ Glu.gluBuild2DMipmaps(Gl.GL_TEXTURE_2D, Gl.GL_RGBA, (int)image.Width, (int)image.Height, Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE, image.Pixels);
+ Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);
+ Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR_MIPMAP_LINEAR);
+ }
+
+ // Enable Z-buffer read and write
+ Gl.glEnable(Gl.GL_DEPTH_TEST);
+ Gl.glDepthMask(Gl.GL_TRUE);
+ Gl.glClearDepth(1.0F);
+
+ // Setup a perspective projection
+ Gl.glMatrixMode(Gl.GL_PROJECTION);
+ Gl.glLoadIdentity();
+ Glu.gluPerspective(90.0F, 1.0F, 1.0F, 500.0F);
+
+ // Bind our texture
+ Gl.glEnable(Gl.GL_TEXTURE_2D);
+ Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture);
+ Gl.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+
+ float time = 0.0F;
+
+ // Start game loop
+ while (window.IsOpened())
+ {
+ // Process events
+ window.DispatchEvents();
+
+ // Clear the window
+ window.Clear();
+
+ // Draw background
+ window.SaveGLStates();
+ window.Draw(background);
+ window.RestoreGLStates();
+
+ // Activate the window before using OpenGL commands.
+ // This is useless here because we have only one window which is
+ // always the active one, but don't forget it if you use multiple windows
+ window.SetActive();
+
+ // Clear depth buffer
+ Gl.glClear(Gl.GL_DEPTH_BUFFER_BIT);
+
+ // We get the position of the mouse cursor, so that we can move the box accordingly
+ float x = window.GetCursorPosition().X * 200.0F / window.Width - 100.0F;
+ float y = -window.GetCursorPosition().Y * 200.0F / window.Height + 100.0F;
+
+ // Apply some transformations
+ time += window.GetFrameTime() / 1000.0F;
+ Gl.glMatrixMode(Gl.GL_MODELVIEW);
+ Gl.glLoadIdentity();
+ Gl.glTranslatef(x, y, -100.0F);
+ Gl.glRotatef(time * 50, 1.0F, 0.0F, 0.0F);
+ Gl.glRotatef(time * 30, 0.0F, 1.0F, 0.0F);
+ Gl.glRotatef(time * 90, 0.0F, 0.0F, 1.0F);
+
+ // Draw a cube
+ float size = 20.0F;
+ Gl.glBegin(Gl.GL_QUADS);
+
+ Gl.glTexCoord2f(0, 0); Gl.glVertex3f(-size, -size, -size);
+ Gl.glTexCoord2f(0, 1); Gl.glVertex3f(-size, size, -size);
+ Gl.glTexCoord2f(1, 1); Gl.glVertex3f( size, size, -size);
+ Gl.glTexCoord2f(1, 0); Gl.glVertex3f( size, -size, -size);
+
+ Gl.glTexCoord2f(0, 0); Gl.glVertex3f(-size, -size, size);
+ Gl.glTexCoord2f(0, 1); Gl.glVertex3f(-size, size, size);
+ Gl.glTexCoord2f(1, 1); Gl.glVertex3f( size, size, size);
+ Gl.glTexCoord2f(1, 0); Gl.glVertex3f( size, -size, size);
+
+ Gl.glTexCoord2f(0, 0); Gl.glVertex3f(-size, -size, -size);
+ Gl.glTexCoord2f(0, 1); Gl.glVertex3f(-size, size, -size);
+ Gl.glTexCoord2f(1, 1); Gl.glVertex3f(-size, size, size);
+ Gl.glTexCoord2f(1, 0); Gl.glVertex3f(-size, -size, size);
+
+ Gl.glTexCoord2f(0, 0); Gl.glVertex3f(size, -size, -size);
+ Gl.glTexCoord2f(0, 1); Gl.glVertex3f(size, size, -size);
+ Gl.glTexCoord2f(1, 1); Gl.glVertex3f(size, size, size);
+ Gl.glTexCoord2f(1, 0); Gl.glVertex3f(size, -size, size);
+
+ Gl.glTexCoord2f(0, 1); Gl.glVertex3f(-size, -size, size);
+ Gl.glTexCoord2f(0, 0); Gl.glVertex3f(-size, -size, -size);
+ Gl.glTexCoord2f(1, 0); Gl.glVertex3f( size, -size, -size);
+ Gl.glTexCoord2f(1, 1); Gl.glVertex3f( size, -size, size);
+
+ Gl.glTexCoord2f(0, 1); Gl.glVertex3f(-size, size, size);
+ Gl.glTexCoord2f(0, 0); Gl.glVertex3f(-size, size, -size);
+ Gl.glTexCoord2f(1, 0); Gl.glVertex3f( size, size, -size);
+ Gl.glTexCoord2f(1, 1); Gl.glVertex3f( size, size, size);
+
+ Gl.glEnd();
+
+ // Draw some text on top of our OpenGL object
+ window.SaveGLStates();
+ window.Draw(text);
+ window.RestoreGLStates();
+
+ // Finally, display the rendered frame on screen
+ window.Display();
+ }
+
+ // Don't forget to destroy our texture
+ Gl.glDeleteTextures(1, ref texture);
+ }
+
+ /// <summary>
+ /// Function called when the window is closed
+ /// </summary>
+ static void OnClosed(object sender, EventArgs e)
+ {
+ RenderWindow window = (RenderWindow)sender;
+ window.Close();
+ }
+
+ /// <summary>
+ /// Function called when a key is pressed
+ /// </summary>
+ static void OnKeyPressed(object sender, KeyEventArgs e)
+ {
+ RenderWindow window = (RenderWindow)sender;
+ if (e.Code == Keyboard.Key.Escape)
+ window.Close();
+ }
+
+ /// <summary>
+ /// Function called when the window is resized
+ /// </summary>
+ static void OnResized(object sender, SizeEventArgs e)
+ {
+ Gl.glViewport(0, 0, (int)e.Width, (int)e.Height);
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit a03db64

Please sign in to comment.