Skip to content

Commit

Permalink
[Examples] Fixed all warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
thefiddler committed Jul 21, 2014
1 parent 98399c2 commit 7a064c3
Show file tree
Hide file tree
Showing 34 changed files with 147 additions and 1,223 deletions.
3 changes: 2 additions & 1 deletion Source/Examples/OpenGL/1.x/Anaglyph.cs
Expand Up @@ -72,7 +72,8 @@ protected override void OnUpdateFrame(FrameEventArgs e)
{
base.OnUpdateFrame(e);

if (Keyboard[Key.Escape])
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[Key.Escape])
Exit();
}

Expand Down
3 changes: 2 additions & 1 deletion Source/Examples/OpenGL/1.x/DisplayLists.cs
Expand Up @@ -112,7 +112,8 @@ protected override void OnResize(EventArgs e)

protected override void OnUpdateFrame(FrameEventArgs e)
{
if (Keyboard[OpenTK.Input.Key.Escape])
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[OpenTK.Input.Key.Escape])
{
this.Exit();
}
Expand Down
3 changes: 2 additions & 1 deletion Source/Examples/OpenGL/1.x/FramebufferObject.cs
Expand Up @@ -220,7 +220,8 @@ protected override void OnUpdateFrame(FrameEventArgs e)
{
base.OnUpdateFrame(e);

if (Keyboard[Key.Escape])
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[Key.Escape])
this.Exit();
}

Expand Down
3 changes: 2 additions & 1 deletion Source/Examples/OpenGL/1.x/ImmediateMode.cs
Expand Up @@ -88,7 +88,8 @@ protected override void OnUpdateFrame(FrameEventArgs e)
{
base.OnUpdateFrame(e);

if (Keyboard[OpenTK.Input.Key.Escape])
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[OpenTK.Input.Key.Escape])
{
this.Exit();
return;
Expand Down
3 changes: 2 additions & 1 deletion Source/Examples/OpenGL/1.x/OpenGLDiagnostics.cs
Expand Up @@ -411,7 +411,8 @@ protected override void OnUpdateFrame(FrameEventArgs e)
{
base.OnUpdateFrame(e);

if (Keyboard[Key.Escape])
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[Key.Escape])
Exit();
}

Expand Down
14 changes: 11 additions & 3 deletions Source/Examples/OpenGL/1.x/Picking.cs
Expand Up @@ -24,11 +24,19 @@ namespace Examples.Tutorial
[Example("Picking", ExampleCategory.OpenGL, "1.x", Documentation = "Picking")]
class Picking : GameWindow
{
int mouse_x, mouse_y;

/// <summary>Creates a 800x600 window with the specified title.</summary>
public Picking()
: base(800, 600, GraphicsMode.Default, "Picking", GameWindowFlags.Default, DisplayDevice.Default, 1, 1, GraphicsContextFlags.Default)
{
VSync = VSyncMode.On;

MouseMove += (sender, e) =>
{
mouse_x = e.X;
mouse_y = e.Y;
};
}

struct Byte4
Expand Down Expand Up @@ -192,7 +200,6 @@ protected override void OnLoad(EventArgs e)
GL.UseProgram(0);
*/
#endregion Shader

}

protected override void OnUnload(EventArgs e)
Expand Down Expand Up @@ -224,7 +231,8 @@ protected override void OnResize(EventArgs e)
/// <param name="e">Contains timing information for framerate independent logic.</param>
protected override void OnUpdateFrame(FrameEventArgs e)
{
if (Keyboard[Key.Escape])
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[Key.Escape])
Exit();
}

Expand Down Expand Up @@ -256,7 +264,7 @@ protected override void OnRenderFrame(FrameEventArgs e)

// Read Pixel under mouse cursor
Byte4 Pixel = new Byte4();
GL.ReadPixels(Mouse.X, this.Height - Mouse.Y, 1, 1, PixelFormat.Rgba, PixelType.UnsignedByte, ref Pixel);
GL.ReadPixels(mouse_x, this.Height - mouse_y, 1, 1, PixelFormat.Rgba, PixelType.UnsignedByte, ref Pixel);
SelectedTriangle = Pixel.ToUInt32();
#endregion Pass 1: Draw Object and pick Triangle

Expand Down
11 changes: 5 additions & 6 deletions Source/Examples/OpenGL/1.x/StencilCSG.cs
Expand Up @@ -42,7 +42,7 @@ public StencilCSG()
: base(800, 600, new GraphicsMode(new ColorFormat(8, 8, 8, 8), 24, 8)) // request 8-bit stencil buffer
{
base.VSync = VSyncMode.Off;
Keyboard.KeyDown += delegate(object sender, KeyboardKeyEventArgs e)
KeyDown += delegate(object sender, KeyboardKeyEventArgs e)
{
switch (e.Key)
{
Expand Down Expand Up @@ -174,11 +174,10 @@ protected override void OnUnload(EventArgs e)

protected override void OnUpdateFrame(FrameEventArgs e)
{
#region Magic numbers for camera
CameraRotX = -Mouse.X * .5f;
CameraRotY = Mouse.Y * .5f;
CameraZoom = Mouse.Wheel * .2f;
#endregion Magic numbers for camera
var mouse = OpenTK.Input.Mouse.GetState();
CameraRotX = -mouse.X * .5f;
CameraRotY = mouse.Y * .5f;
CameraZoom = mouse.Wheel * .2f;
}

public void DrawOperandB()
Expand Down
3 changes: 2 additions & 1 deletion Source/Examples/OpenGL/1.x/TextRendering.cs
Expand Up @@ -215,7 +215,8 @@ protected override void OnResize(EventArgs e)

protected override void OnUpdateFrame(FrameEventArgs e)
{
if (Keyboard[OpenTK.Input.Key.Escape])
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[OpenTK.Input.Key.Escape])
{
this.Exit();
}
Expand Down
11 changes: 8 additions & 3 deletions Source/Examples/OpenGL/1.x/TextureMatrix.cs
Expand Up @@ -18,6 +18,7 @@ namespace Examples.Tutorial

class TextureMatrix : GameWindow
{
Vector2 orientation;

public TextureMatrix()
: base(800, 600, new GraphicsMode(32, 16, 0, 4))
Expand Down Expand Up @@ -89,8 +90,12 @@ protected override void OnResize(EventArgs e)

protected override void OnUpdateFrame(FrameEventArgs e)
{
if (Keyboard[Key.Escape])
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[Key.Escape])
Exit();

var mouse = OpenTK.Input.Mouse.GetState();
orientation = new Vector2(mouse.X, mouse.Y);
}

protected override void OnRenderFrame(FrameEventArgs e)
Expand All @@ -107,8 +112,8 @@ protected override void OnRenderFrame(FrameEventArgs e)

GL.Translate(0f, 0f, 1.5f);

GL.Rotate(Mouse.X, Vector3.UnitY);
GL.Rotate(Mouse.Y, Vector3.UnitX);
GL.Rotate(orientation.X, Vector3.UnitY);
GL.Rotate(orientation.Y, Vector3.UnitX);

GL.CallList(list);

Expand Down
3 changes: 2 additions & 1 deletion Source/Examples/OpenGL/1.x/Textures.cs
Expand Up @@ -93,7 +93,8 @@ protected override void OnResize(EventArgs e)
/// <remarks>There is no need to call the base implementation.</remarks>
protected override void OnUpdateFrame(FrameEventArgs e)
{
if (Keyboard[OpenTK.Input.Key.Escape])
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[OpenTK.Input.Key.Escape])
this.Exit();
}

Expand Down
3 changes: 2 additions & 1 deletion Source/Examples/OpenGL/1.x/VBODynamic.cs
Expand Up @@ -136,7 +136,8 @@ protected override void OnResize(EventArgs e)
/// <param name="e">Contains timing information for framerate independent logic.</param>
protected override void OnUpdateFrame(FrameEventArgs e)
{
if (Keyboard[Key.Escape])
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[Key.Escape])
{
Exit();
}
Expand Down
3 changes: 2 additions & 1 deletion Source/Examples/OpenGL/1.x/VBOStatic.cs
Expand Up @@ -88,7 +88,8 @@ protected override void OnUpdateFrame(FrameEventArgs e)
{
base.OnUpdateFrame(e);

if (Keyboard[OpenTK.Input.Key.Escape])
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[OpenTK.Input.Key.Escape])
this.Exit();
}

Expand Down
21 changes: 11 additions & 10 deletions Source/Examples/OpenGL/1.x/VertexArrays.cs
Expand Up @@ -36,7 +36,7 @@ public T02_Vertex_Arrays()
: base(800, 600)
{
//this.VSync = VSyncMode.On;
this.Keyboard.KeyUp += Keyboard_KeyUp;
KeyUp += Keyboard_KeyUp;
}

void Keyboard_KeyUp(object sender, KeyboardKeyEventArgs e)
Expand Down Expand Up @@ -107,29 +107,30 @@ protected override void OnResize(EventArgs e)
/// </remarks>
protected override void OnUpdateFrame(FrameEventArgs e)
{
// Escape quits.
if (Keyboard[Key.Escape])
var keyboard = OpenTK.Input.Keyboard.GetState();

if (keyboard[Key.Escape])
{
this.Exit();
return;
}

if (Keyboard[Key.F11])
if (keyboard[Key.F11])
if (WindowState != WindowState.Fullscreen)
WindowState = WindowState.Fullscreen;
else
WindowState = WindowState.Normal;

// Plus/Minus change the target render frequency.
// PageUp/PageDown change the target update frequency.
if (Keyboard[Key.Plus] || Keyboard[Key.KeypadAdd]) TargetRenderFrequency++;
if (Keyboard[Key.Minus] || Keyboard[Key.KeypadSubtract]) TargetRenderFrequency--;
if (Keyboard[Key.PageUp]) TargetUpdateFrequency++;
if (Keyboard[Key.PageDown]) TargetUpdateFrequency--;
if (keyboard[Key.Plus] || keyboard[Key.KeypadAdd]) TargetRenderFrequency++;
if (keyboard[Key.Minus] || keyboard[Key.KeypadSubtract]) TargetRenderFrequency--;
if (keyboard[Key.PageUp]) TargetUpdateFrequency++;
if (keyboard[Key.PageDown]) TargetUpdateFrequency--;

// Right/Left control the rotation speed and direction.
if (Keyboard[Key.Right]) rotation_speed += 0.5f;
if (Keyboard[Key.Left]) rotation_speed -= 0.5f;
if (keyboard[Key.Right]) rotation_speed += 0.5f;
if (keyboard[Key.Left]) rotation_speed -= 0.5f;
}

#endregion
Expand Down
13 changes: 8 additions & 5 deletions Source/Examples/OpenGL/1.x/VertexLighting.cs
Expand Up @@ -100,24 +100,27 @@ protected override void OnResize(EventArgs e)
/// </remarks>
protected override void OnUpdateFrame(FrameEventArgs e)
{
if (Keyboard[OpenTK.Input.Key.Escape])
var keyboard = OpenTK.Input.Keyboard.GetState();
var mouse = OpenTK.Input.Mouse.GetState();

if (keyboard[OpenTK.Input.Key.Escape])
{
this.Exit();
return;
}

if (Keyboard[OpenTK.Input.Key.F11])
if (keyboard[OpenTK.Input.Key.F11])
if (WindowState != WindowState.Fullscreen)
WindowState = WindowState.Fullscreen;
else
WindowState = WindowState.Normal;

if (Mouse[OpenTK.Input.MouseButton.Left])
x_angle = Mouse.X;
if (mouse[OpenTK.Input.MouseButton.Left])
x_angle = mouse.X;
else
x_angle += 0.5f;

zoom = Mouse.Wheel * 0.5f; // Mouse.Wheel is broken on both Linux and Windows.
zoom = mouse.Wheel * 0.5f; // Mouse.Wheel is broken on both Linux and Windows.

// Do not leave x_angle drift too far away, as this will cause inaccuracies.
if (x_angle > 360.0f)
Expand Down
20 changes: 11 additions & 9 deletions Source/Examples/OpenGL/2.x/DDSCubeMap.cs
Expand Up @@ -198,19 +198,21 @@ protected override void OnResize( EventArgs e )
/// <summary>Add your game logic here.</summary>
/// <param name="e">Contains timing information.</param>
/// <remarks>There is no need to call the base implementation.</remarks>
protected override void OnUpdateFrame( FrameEventArgs e )
protected override void OnUpdateFrame(FrameEventArgs e)
{
base.OnUpdateFrame( e );
base.OnUpdateFrame(e);

if ( Keyboard[OpenTK.Input.Key.Escape] )
this.Exit( );
if ( Keyboard[OpenTK.Input.Key.Space] )
Trace.WriteLine( "GL: " + GL.GetError( ) );
var keyboard = OpenTK.Input.Keyboard.GetState();
var mouse = OpenTK.Input.Mouse.GetState();

Trackball.X = Mouse.X;
Trackball.Y = Mouse.Y;
Trackball.Z = Mouse.Wheel * 0.5f;
if (keyboard[OpenTK.Input.Key.Escape])
this.Exit();
if (keyboard[OpenTK.Input.Key.Space])
Trace.WriteLine("GL: " + GL.GetError());

Trackball.X = mouse.X;
Trackball.Y = mouse.Y;
Trackball.Z = mouse.Scroll.Y * 0.5f;
}

/// <summary>Add your game rendering code here.</summary>
Expand Down
5 changes: 3 additions & 2 deletions Source/Examples/OpenGL/2.x/GeometryShader.cs
Expand Up @@ -195,14 +195,15 @@ protected override void OnUpdateFrame(FrameEventArgs e)
{
base.OnUpdateFrame(e);

if (Keyboard[Key.Space])
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[Key.Space])
{
ErrorCode err = GL.GetError();
//Console.WriteLine(err + " " + Glu.ErrorString((GluErrorCode)err));
Console.WriteLine("GL error code: {0}", err);
}

if (Keyboard[Key.Escape])
if (keyboard[Key.Escape])
this.Exit();
}

Expand Down
5 changes: 3 additions & 2 deletions Source/Examples/OpenGL/2.x/GeometryShaderAdvanced.cs
Expand Up @@ -46,7 +46,7 @@ public class SimpleGeometryShader2 : GameWindow
public SimpleGeometryShader2()
: base(800, 600)
{
Keyboard.KeyDown += Keyboard_KeyDown;
KeyDown += Keyboard_KeyDown;
}

enum ViewMode
Expand Down Expand Up @@ -900,7 +900,8 @@ protected override void OnUpdateFrame(FrameEventArgs e)
eyePos.X = (float)Math.Cos(elapsed / 3000) * 8;
eyePos.Z = (float)Math.Sin(elapsed / 2000) * 8;

if (Keyboard[Key.Space])
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[Key.Space])
{
ErrorCode err = GL.GetError();
//Console.WriteLine(err + " " + Glu.ErrorString((GluErrorCode)err));
Expand Down
7 changes: 4 additions & 3 deletions Source/Examples/OpenGL/2.x/JuliaSetFractal.cs
Expand Up @@ -157,8 +157,8 @@ protected override void OnLoad(EventArgs e)
bitmap.UnlockBits(data);
}
#endregion Textures
Keyboard.KeyUp += Keyboard_KeyUp;

KeyUp += Keyboard_KeyUp;
}

int i = 0;
Expand Down Expand Up @@ -233,7 +233,8 @@ protected override void OnUpdateFrame(FrameEventArgs e)
{
base.OnUpdateFrame(e);

if (Keyboard[OpenTK.Input.Key.Escape])
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[OpenTK.Input.Key.Escape])
{
this.Exit();
}
Expand Down
5 changes: 3 additions & 2 deletions Source/Examples/OpenGL/2.x/SimpleGLSL.cs
Expand Up @@ -214,10 +214,11 @@ protected override void OnResize(EventArgs e)
/// </remarks>
protected override void OnUpdateFrame(FrameEventArgs e)
{
if (Keyboard[OpenTK.Input.Key.Escape])
var keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard[OpenTK.Input.Key.Escape])
this.Exit();

if (Keyboard[OpenTK.Input.Key.F11])
if (keyboard[OpenTK.Input.Key.F11])
if (WindowState != WindowState.Fullscreen)
WindowState = WindowState.Fullscreen;
else
Expand Down

0 comments on commit 7a064c3

Please sign in to comment.