Added the trunk/branches/tags directories at repository root, and moved previous root into trunk/
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1002 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
commit
2f524481c1
974 changed files with 295448 additions and 0 deletions
dotnet/samples/opengl
161
dotnet/samples/opengl/OpenGL.cs
Normal file
161
dotnet/samples/opengl/OpenGL.cs
Normal file
|
@ -0,0 +1,161 @@
|
|||
using System;
|
||||
using SFML;
|
||||
using SFML.Graphics;
|
||||
using SFML.Window;
|
||||
using Tao.OpenGl;
|
||||
|
||||
namespace sample_opengl
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
static void Main()
|
||||
{
|
||||
// Create main window
|
||||
RenderWindow App = new RenderWindow(new VideoMode(800, 600), "SFML.Net OpenGL");
|
||||
App.PreserveOpenGLStates(true);
|
||||
|
||||
// Setup event handlers
|
||||
App.Closed += new EventHandler(OnClosed);
|
||||
App.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
|
||||
App.Resized += new EventHandler<SizeEventArgs>(OnResized);
|
||||
|
||||
// Create a sprite for the background
|
||||
Image BackgroundImage = new Image("datas/opengl/background.jpg");
|
||||
Sprite Background = new Sprite(BackgroundImage);
|
||||
|
||||
// Create a text to display
|
||||
String2D Text = new String2D("This is a rotating cube");
|
||||
Text.Position = new Vector2(250.0F, 300.0F);
|
||||
Text.Color = new Color(128, 0, 128);
|
||||
|
||||
// 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 TempImage = new Image("datas/opengl/texture.jpg"))
|
||||
{
|
||||
Gl.glGenTextures(1, out Texture);
|
||||
Gl.glBindTexture(Gl.GL_TEXTURE_2D, Texture);
|
||||
Glu.gluBuild2DMipmaps(Gl.GL_TEXTURE_2D, Gl.GL_RGBA, (int)TempImage.Width, (int)TempImage.Height, Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE, TempImage.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 (App.IsOpened())
|
||||
{
|
||||
// Process events
|
||||
App.DispatchEvents();
|
||||
|
||||
// Clear the window
|
||||
App.Clear();
|
||||
|
||||
// Draw background
|
||||
App.Draw(Background);
|
||||
|
||||
// Clear depth buffer
|
||||
Gl.glClear(Gl.GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// Apply some transformations
|
||||
Time += App.GetFrameTime();
|
||||
Gl.glMatrixMode(Gl.GL_MODELVIEW);
|
||||
Gl.glLoadIdentity();
|
||||
Gl.glTranslatef(0.0F, 0.0F, -200.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
|
||||
Gl.glBegin(Gl.GL_QUADS);
|
||||
|
||||
Gl.glTexCoord2f(0, 0); Gl.glVertex3f(-50.0F, -50.0F, -50.0F);
|
||||
Gl.glTexCoord2f(0, 1); Gl.glVertex3f(-50.0F, 50.0F, -50.0F);
|
||||
Gl.glTexCoord2f(1, 1); Gl.glVertex3f( 50.0F, 50.0F, -50.0F);
|
||||
Gl.glTexCoord2f(1, 0); Gl.glVertex3f( 50.0F, -50.0F, -50.0F);
|
||||
|
||||
Gl.glTexCoord2f(0, 0); Gl.glVertex3f(-50.0F, -50.0F, 50.0F);
|
||||
Gl.glTexCoord2f(0, 1); Gl.glVertex3f(-50.0F, 50.0F, 50.0F);
|
||||
Gl.glTexCoord2f(1, 1); Gl.glVertex3f( 50.0F, 50.0F, 50.0F);
|
||||
Gl.glTexCoord2f(1, 0); Gl.glVertex3f( 50.0F, -50.0F, 50.0F);
|
||||
|
||||
Gl.glTexCoord2f(0, 0); Gl.glVertex3f(-50.0F, -50.0F, -50.0F);
|
||||
Gl.glTexCoord2f(0, 1); Gl.glVertex3f(-50.0F, 50.0F, -50.0F);
|
||||
Gl.glTexCoord2f(1, 1); Gl.glVertex3f(-50.0F, 50.0F, 50.0F);
|
||||
Gl.glTexCoord2f(1, 0); Gl.glVertex3f(-50.0F, -50.0F, 50.0F);
|
||||
|
||||
Gl.glTexCoord2f(0, 0); Gl.glVertex3f(50.0F, -50.0F, -50.0F);
|
||||
Gl.glTexCoord2f(0, 1); Gl.glVertex3f(50.0F, 50.0F, -50.0F);
|
||||
Gl.glTexCoord2f(1, 1); Gl.glVertex3f(50.0F, 50.0F, 50.0F);
|
||||
Gl.glTexCoord2f(1, 0); Gl.glVertex3f(50.0F, -50.0F, 50.0F);
|
||||
|
||||
Gl.glTexCoord2f(0, 1); Gl.glVertex3f(-50.0F, -50.0F, 50.0F);
|
||||
Gl.glTexCoord2f(0, 0); Gl.glVertex3f(-50.0F, -50.0F, -50.0F);
|
||||
Gl.glTexCoord2f(1, 0); Gl.glVertex3f( 50.0F, -50.0F, -50.0F);
|
||||
Gl.glTexCoord2f(1, 1); Gl.glVertex3f( 50.0F, -50.0F, 50.0F);
|
||||
|
||||
Gl.glTexCoord2f(0, 1); Gl.glVertex3f(-50.0F, 50.0F, 50.0F);
|
||||
Gl.glTexCoord2f(0, 0); Gl.glVertex3f(-50.0F, 50.0F, -50.0F);
|
||||
Gl.glTexCoord2f(1, 0); Gl.glVertex3f( 50.0F, 50.0F, -50.0F);
|
||||
Gl.glTexCoord2f(1, 1); Gl.glVertex3f( 50.0F, 50.0F, 50.0F);
|
||||
|
||||
Gl.glEnd();
|
||||
|
||||
// Draw some text on top of our OpenGL object
|
||||
App.Draw(Text);
|
||||
|
||||
// Finally, display the rendered frame on screen
|
||||
App.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 == KeyCode.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);
|
||||
}
|
||||
}
|
||||
}
|
66
dotnet/samples/opengl/sample-opengl.csproj
Normal file
66
dotnet/samples/opengl/sample-opengl.csproj
Normal file
|
@ -0,0 +1,66 @@
|
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{160AE11E-138A-4B77-9642-EA74F9A79B4D}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>sample_opengl</RootNamespace>
|
||||
<AssemblyName>opengl</AssemblyName>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Graphics\sfml-graphics.csproj">
|
||||
<Project>{46786269-57B9-48E7-AA4F-8F4D84609FE6}</Project>
|
||||
<Name>sfml-graphics</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\src\Window\sfml-window.csproj">
|
||||
<Project>{D17DE83D-A592-461F-8AF2-53F9E22E1D0F}</Project>
|
||||
<Name>sfml-window</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="OpenGL.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Tao.FreeGlut, Version=2.4.0.2, Culture=neutral, PublicKeyToken=6e602a6ad6c0d06d, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\..\Bibliothèques\TaoFramework\bin\Tao.FreeGlut.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Tao.OpenGl, Version=2.1.0.12, Culture=neutral, PublicKeyToken=1ca010269a4501ef, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\..\Bibliothèques\TaoFramework\bin\Tao.OpenGl.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
Loading…
Add table
Add a link
Reference in a new issue