Removed warnings when compiling CSFML in release mode
Changed samples images Added an effect to the post-fx sample git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1008 4e206d99-4929-0410-ac5d-dfc041789085
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 140 KiB |
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 154 KiB After Width: | Height: | Size: 52 KiB |
11
dotnet/samples/bin/datas/post-fx/pixelate.sfx
Normal file
|
@ -0,0 +1,11 @@
|
|||
texture framebuffer
|
||||
vec2 mouse
|
||||
|
||||
effect
|
||||
{
|
||||
float factor = 5 + 100 * length(mouse);
|
||||
|
||||
vec2 pos = floor(_in * factor) / factor;
|
||||
|
||||
_out = framebuffer(pos);
|
||||
}
|
BIN
dotnet/samples/bin/datas/post-fx/sprite.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
|
@ -28,8 +28,8 @@ namespace sample_opengl
|
|||
|
||||
// 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);
|
||||
Text.Position = new Vector2(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),
|
||||
|
@ -76,47 +76,52 @@ namespace sample_opengl
|
|||
// 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 CursorX = App.Input.GetMouseX() * 200.0F / App.Width - 100.0F;
|
||||
float CursorY = -App.Input.GetMouseY() * 200.0F / App.Height + 100.0F;
|
||||
|
||||
// Apply some transformations
|
||||
Time += App.GetFrameTime();
|
||||
Gl.glMatrixMode(Gl.GL_MODELVIEW);
|
||||
Gl.glLoadIdentity();
|
||||
Gl.glTranslatef(0.0F, 0.0F, -200.0F);
|
||||
Gl.glTranslatef(CursorX, CursorY, -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(-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(-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(-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(-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(-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(-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(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(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(-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(-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(-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(-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();
|
||||
|
||||
|
|
|
@ -31,9 +31,12 @@ namespace sample_postfx
|
|||
return;
|
||||
}
|
||||
|
||||
// Load a cute background image to display :)
|
||||
// Load a background image to display
|
||||
Sprite Background = new Sprite(new Image("datas/post-fx/background.jpg"));
|
||||
|
||||
// Load a sprite which we'll move into the scene
|
||||
Sprite Entity = new Sprite(new Image("datas/post-fx/sprite.png"));
|
||||
|
||||
// Load the text font
|
||||
Font Cheeseburger = new Font("datas/post-fx/cheeseburger.ttf");
|
||||
|
||||
|
@ -47,6 +50,7 @@ namespace sample_postfx
|
|||
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");
|
||||
Effects["pixelate"] = new PostFx("datas/post-fx/pixelate.sfx");
|
||||
CurrentEffect = Effects.GetEnumerator();
|
||||
CurrentEffect.MoveNext();
|
||||
|
||||
|
@ -59,12 +63,14 @@ namespace sample_postfx
|
|||
Effects["fisheye"].SetTexture("framebuffer", null);
|
||||
Effects["wave"].SetTexture("framebuffer", null);
|
||||
Effects["wave"].SetTexture("wave", WaveImage);
|
||||
Effects["pixelate"].SetTexture("framebuffer", null);
|
||||
|
||||
// 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);
|
||||
CurFXStr.Color = new Color(150, 70, 110);
|
||||
|
||||
// Define a string for displaying help
|
||||
String2D InfoStr = new String2D();
|
||||
|
@ -74,6 +80,7 @@ namespace sample_postfx
|
|||
InfoStr.Color = new Color(200, 100, 150);
|
||||
|
||||
// Start the game loop
|
||||
float AppTime = 0.0F;
|
||||
while (App.IsOpened())
|
||||
{
|
||||
// Process events
|
||||
|
@ -88,12 +95,21 @@ namespace sample_postfx
|
|||
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);
|
||||
else if (CurrentEffect.Current.Key == "pixelate") CurrentEffect.Current.Value.SetParameter("mouse", X, Y);
|
||||
|
||||
// Animate the sprite
|
||||
AppTime += App.GetFrameTime();
|
||||
float EntityX = (float)(Math.Cos(AppTime * 1.3) + 1.2) * 300;
|
||||
float EntityY = (float)(Math.Cos(AppTime * 0.8) + 1.2) * 200;
|
||||
Entity.Position = new Vector2(EntityX, EntityY);
|
||||
Entity.Rotation = AppTime * 100;
|
||||
|
||||
// Clear the window
|
||||
App.Clear();
|
||||
|
||||
// Draw background and apply the post-fx
|
||||
// Draw background, the sprite and apply the post-fx
|
||||
App.Draw(Background);
|
||||
App.Draw(Entity);
|
||||
App.Draw(CurrentEffect.Current.Value);
|
||||
|
||||
// Draw interface strings
|
||||
|
|