Reeperbahn's picture

Problem Loading Textures. Parameter is not valid.

Alright, I have a big problem.
While everyone else here is having their textures appear white, mine aren't appearing at all. In fact, to try and make them appear is making my game crash.

Here's the code.

// Released to the public domain. Use, modify and relicense at will.
 
using System;
using System.Drawing;
using System.Drawing.Imaging;
 
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using OpenTK.Audio;
using OpenTK.Audio.OpenAL;
using OpenTK.Input;
 
namespace StarterKit
{
    class Game : GameWindow
    {
        /// <summary>Creates a 800x600 window with the specified title.</summary>
        public Game()
            : base(800, 600, GraphicsMode.Default, "OpenTK Quick Start Sample")
        {
            VSync = VSyncMode.Off;
            GraphicsContext.CurrentContext.VSync = true;
        }
 
        public string FN = "Projects/openTK_Game1/4chan.jpg";
 
        /// <summary>Load resources here.</summary>
        /// <param name="e">Not used.</param>
        /// 
 
 
 
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            //this.WindowBorder = OpenTK.WindowBorder.Fixed;
            //this.WindowBorder = OpenTK.WindowBorder.Hidden;
            //X = 0;
            //Y = 0;
 
 
            if (!String.IsNullOrEmpty(FN)) 
            {
                int ID = GL.GenTexture();
                GL.BindTexture(TextureTarget.Texture2D, ID);
 
                Bitmap BMP = new Bitmap(FN);
                BitmapData BMPd = BMP.LockBits(new Rectangle(0, 0, BMP.Width, BMP.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
 
                GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, BMPd.Width, BMPd.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, BMPd.Scan0);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
            }
 
 
 
            //DisplayDevice.AvailableDisplays[0].ChangeResolution(Width, Height, 32, 32);
 
 
            GL.ClearColor(1.0f, 1.0f, 1.0f, 0.0f);
            GL.Enable(EnableCap.DepthTest);
        }
 
        /// <summary>
        /// Called when your window is resized. Set your viewport here. It is also
        /// a good place to set up your projection matrix (which probably changes
        /// along when the aspect ratio of your window).
        /// </summary>
        /// <param name="e">Not used.</param>
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
 
            GL.Viewport(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height);
 
            Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 4, Width / (float)Height, 1.0f, 64.0f);
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadMatrix(ref projection);
        }
 
        /// <summary>
        /// Called when it is time to setup the next frame. Add you game logic here.
        /// </summary>
        /// <param name="e">Contains timing information for framerate independent logic.</param>
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            base.OnUpdateFrame(e);
 
 
            if (Keyboard[Key.Escape])
                Exit();
        }
 
        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            base.OnClosing(e);
 
            DisplayDevice.AvailableDisplays[0].RestoreResolution();
 
        }
 
        /// <summary>
        /// Called when it is time to render the next frame. Add your rendering code here.
        /// </summary>
        /// <param name="e">Contains timing information.</param>
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            base.OnRenderFrame(e);
 
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
 
            GL.MatrixMode(MatrixMode.Modelview);
           // GL.LoadMatrix(ref modelview);
 
            GL.Begin(BeginMode.Quads);
 
 
            GL.End();
 
            SwapBuffers();
        }
 
 
 
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
 
 
 
            // The 'using' idiom guarantees proper resource cleanup.
            // We request 30 UpdateFrame events per second, and unlimited
            // RenderFrame events (as fast as the computer can handle).
            using (Game game = new Game())
            {
                game.Run(30.0);
            }
        }
    }
}

I'm trying to import 4chan.jpg (don't worry about the purpose, it's safe) to the stage, however, I can't seem to pick the right file location, then C# tries to load hot-air and the game breaks.
Where on earth am I supposed to search when I want to open or access a file?

PS:
4chan.jpg is located in the same folder as the project file, as well as in the father folder.