title: The renderer is not using the texture in Open TK
body: <p>Hi I'm trying to use Textures in OpenGL using Open TK. I got a basic example from the <a href="http://www.opentk.com/doc/graphics/textures" rel="nofollow noreferrer">official page of OpenTK Framework</a>, but didn't work. I searched here on stackoverflow for some help and changed some parts of the code, but still is not working. (Found and tested: <a href="https://stackoverflow.com/questions/19169452/opentk-texture-not-display-the-image">OpenTk texture not display the image</a>)</p>
  
  <p>So far I came with this snippet, but this is not displaying the texture (display white instead):</p>
  
  <p><strong>UPDATED</strong> (With @The Fiddler suggestions)</p>
  
  <p>In <code>OpenTK.GLControl.Load</code> event handler:</p>
  
  <pre><code>GL.ClearColor(Color.MidnightBlue);
  GL.Enable(EnableCap.Texture2D);
  
  GL.Viewport(0, 0, control.Width, control.Height);
  
  GL.MatrixMode(MatrixMode.Projection);
  GL.LoadIdentity();
  GL.Ortho(0, 4, 0, 3, -1, 1);
  
  GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);
  
  GL.GenTextures(1, out textureId);
  GL.BindTexture(TextureTarget.Texture2D, textureId);
  GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
  GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
  
  var bmp = new Bitmap(@"C:\myfolder\texture.png");
  var data = bmp.LockBits(new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height),
      ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
  
  GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, data.Width, data.Height, 0,
      OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);
  
  System.Windows.Forms.MessageBox.Show("Erro: " + GL.GetError());
  
  bmp.UnlockBits(data);
  </code></pre>
  
  <p>In <code>OpenTK.GLControl.Paint</code> event handler:</p>
  
  <pre><code>GL.Clear(ClearBufferMask.ColorBufferBit);
  
  GL.MatrixMode(MatrixMode.Modelview);
  GL.LoadIdentity();
  GL.BindTexture(TextureTarget.Texture2D, textureId);
  
  GL.Begin(BeginMode.Quads);
  
  GL.TexCoord2(0, 0); GL.Vertex2(0, 0);
  GL.TexCoord2(0, 1); GL.Vertex2(0, 1);
  GL.TexCoord2(1, 1); GL.Vertex2(1, 1);
  GL.TexCoord2(1, 0); GL.Vertex2(1, 0);
  
  GL.End();
  
  control.SwapBuffers();
  </code></pre>
  
  <p>The erro code get in first part is: <code>1281</code> = <code>ErrorCode.InvalidValue</code>.
  Does anyone have any idea why it isn't rendering the texture?</p>