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:
laurentgom 2009-01-28 16:18:34 +00:00
commit 2f524481c1
974 changed files with 295448 additions and 0 deletions

View file

@ -0,0 +1,168 @@
using System;
using System.Collections.Generic;
using SFML;
using SFML.Graphics;
using SFML.Window;
namespace sample_postfx
{
static class Program
{
private static Dictionary<string, PostFx> Effects;
private static Dictionary<string, PostFx>.Enumerator CurrentEffect;
private static String2D CurFXStr;
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
// Create the main window
RenderWindow App = new RenderWindow(new VideoMode(800, 600), "SFML.Net PostFX");
// Setup event handlers
App.Closed += new EventHandler(OnClosed);
App.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
// Check that the system can use post effects
if (PostFx.CanUsePostFX == false)
{
DisplayError(App);
return;
}
// Load a cute background image to display :)
Sprite Background = new Sprite(new Image("datas/post-fx/background.jpg"));
// Load the text font
Font Cheeseburger = new Font("datas/post-fx/cheeseburger.ttf");
// Load the image needed for the wave effect
Image WaveImage = new Image("datas/post-fx/wave.jpg");
// Load all effects
Effects = new Dictionary<string, PostFx>();
Effects["nothing"] = new PostFx("datas/post-fx/nothing.sfx");
Effects["blur"] = new PostFx("datas/post-fx/blur.sfx");
Effects["colorize"] = new PostFx("datas/post-fx/colorize.sfx");
Effects["fisheye"] = new PostFx("datas/post-fx/fisheye.sfx");
Effects["wave"] = new PostFx("datas/post-fx/wave.sfx");
CurrentEffect = Effects.GetEnumerator();
CurrentEffect.MoveNext();
// Do specific initializations
Effects["nothing"].SetTexture("framebuffer", null);
Effects["blur"].SetTexture("framebuffer", null);
Effects["blur"].SetParameter("offset", 0.0F);
Effects["colorize"].SetTexture("framebuffer", null);
Effects["colorize"].SetParameter("color", 1.0F, 1.0F, 1.0F);
Effects["fisheye"].SetTexture("framebuffer", null);
Effects["wave"].SetTexture("framebuffer", null);
Effects["wave"].SetTexture("wave", WaveImage);
// Define a string for displaying current effect description
CurFXStr = new String2D();
CurFXStr.Text = "Current effect is \"" + CurrentEffect.Current.Key + "\"";
CurFXStr.Font = Cheeseburger;
CurFXStr.Position = new Vector2(20.0F, 0.0F);
// Define a string for displaying help
String2D InfoStr = new String2D();
InfoStr.Text = "Move your mouse to change the effect parameters\nPress numpad + to change effect\nWarning : some effects may not work\ndepending on your graphics card";
InfoStr.Font = Cheeseburger;
InfoStr.Position = new Vector2(20.0F, 460.0F);
InfoStr.Color = new Color(200, 100, 150);
// Start the game loop
while (App.IsOpened())
{
// Process events
App.DispatchEvents();
// Get the mouse position in the range [0, 1]
float X = App.Input.GetMouseX() / (float)App.Width;
float Y = App.Input.GetMouseY() / (float)App.Height;
// Update the current effect
if (CurrentEffect.Current.Key == "blur") CurrentEffect.Current.Value.SetParameter("offset", X * Y * 0.1f);
else if (CurrentEffect.Current.Key == "colorize") CurrentEffect.Current.Value.SetParameter("color", 0.3f, X, Y);
else if (CurrentEffect.Current.Key == "fisheye") CurrentEffect.Current.Value.SetParameter("mouse", X, 1.0F - Y);
else if (CurrentEffect.Current.Key == "wave") CurrentEffect.Current.Value.SetParameter("offset", X, Y);
// Clear the window
App.Clear();
// Draw background and apply the post-fx
App.Draw(Background);
App.Draw(CurrentEffect.Current.Value);
// Draw interface strings
App.Draw(CurFXStr);
App.Draw(InfoStr);
// Finally, display the rendered frame on screen
App.Display();
}
}
/// <summary>
/// Fonction called when the post-effects are not supported ;
/// Display an error message and wait until the user exits
/// </summary>
private static void DisplayError(RenderWindow App)
{
// Define a string for displaying the error message
String2D ErrorStr = new String2D("Sorry, your system doesn't support post-effects");
ErrorStr.Position = new Vector2(100.0F, 250.0F);
ErrorStr.Color = new Color(200, 100, 150);
// Start the game loop
while (App.IsOpened())
{
// Process events
App.DispatchEvents();
// Clear the window
App.Clear();
// Draw the error message
App.Draw(ErrorStr);
// Finally, display the rendered frame on screen
App.Display();
}
}
/// <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)
{
// Close the window
window.Close();
}
else if (e.Code == KeyCode.Add)
{
// Advance to the next effect
if (CurrentEffect.MoveNext() == false)
{
CurrentEffect = Effects.GetEnumerator();
CurrentEffect.MoveNext();
}
CurFXStr.Text = "Current effect is \"" + CurrentEffect.Current.Key + "\"";
}
}
}
}

View file

@ -0,0 +1,54 @@
<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>{9D4738F7-34EA-433A-A765-AF85A52A174D}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>sample_postfx</RootNamespace>
<AssemblyName>post-fx</AssemblyName>
</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="PostFx.cs" />
</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>