I'm currently working on Windows with c# using OpenTK.

I was able to load a texture fine until I implemented a fragment and vertex shader of my own.

I tested around to see if the fragment buffer actually contained any of my texture data and that failed as well.

Here's my shader code:

// GLSL for fragment shader
String fragSource = @"

varying vec3 N;
varying vec3 v;

void main (void)
{
vec3 L = normalize(gl_LightSource[0].position.xyz + v);
vec3 E = normalize(v); // we are in Eye Coordinates, so EyePos is (0,0,0)
vec3 R = normalize(reflect(-L,N));

//calculate Ambient Term:
vec4 Iamb = gl_FrontLightProduct[0].ambient;

//calculate Diffuse Term:
vec4 Idiff = gl_FrontLightProduct[0].diffuse * max(dot(N,L), 0.0);
Idiff = clamp(Idiff, 0.0, 1.0);

// calculate Specular Term:
vec4 Ispec = gl_FrontLightProduct[0].specular * pow(max(dot(R,E),0.0), 0.3 * gl_FrontMaterial.shininess);
Ispec = clamp(Ispec, 0.0, 1.0);

// write Total Color:
gl_FragColor = gl_FrontLightModelProduct.sceneColor + Iamb + Idiff + Ispec;
}
";

// GLSL for vertex shader
String vertSource = @"

varying vec3 N;
varying vec3 v;

void main(void)
{
v = vec3(gl_ModelViewMatrix * gl_Vertex);
N = normalize(gl_NormalMatrix * gl_Normal);
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
";

This is where I'm loading my texture:

#region LoadTexture
GL.Enable(EnableCap.Texture2D);
Texture = LoadTexture("dotcode_image" + img_num + ".tiff");

string save_path = @"c:\NDAC_Simulator";
if (!Directory.Exists(save_path))
{
DirectoryInfo di = Directory.CreateDirectory(save_path);
}

GL.ActiveTexture(TextureUnit.Texture0);
//GL.BindTexture(TextureTarget.Texture2D, Texture);

#endregion

static int LoadTexture(string filename)
{
string path = System.IO.Directory.GetCurrentDirectory() + "\\" + filename;

if (String.IsNullOrEmpty(path))
throw new ArgumentException(path);

int id = GL.GenTexture();
GL.BindTexture(TextureTarget.Texture2D, id);

Bitmap bmp = new Bitmap(path);
BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb );

GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bmp_data.Width, bmp_data.Height, 0,
OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, bmp_data.Scan0);

bmp.UnlockBits(bmp_data);

// We haven't uploaded mipmaps, so disable mipmapping (otherwise the texture will not appear).
// On newer video cards, we can use GL.GenerateMipmaps() or GL.Ext.GenerateMipmaps() to create
// mipmaps automatically. In that case, use TextureMinFilter.LinearMipmapLinear to enable them.
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);

return id;
}


And this is my draw:

protected override void OnRenderFrame(FrameEventArgs e)
{
base.OnRenderFrame(e);

GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

Matrix4 modelview = Matrix4.LookAt(Vector3.Zero, Vector3.UnitZ, Vector3.UnitY);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadIdentity();
GL.LoadMatrix(ref modelview);

GL.Rotate(pitch, 1.0f, 0.0f, 0.0f);
GL.Rotate(yaw, 0.0f, 1.0f, 0.0f);
GL.Rotate(roll, 0.0f, 0.0f, 1.0f);
GL.Translate(x, y, depth);

GL.BindTexture(TextureTarget.Texture2D, Texture);
GL.Begin(BeginMode.Quads);

GL.TexCoord2(0.0f, 1.0f); GL.Vertex2(-2657.0f, -3683.5f);
GL.TexCoord2(1.0f, 1.0f); GL.Vertex2(2657.0f, -3683.5f);
GL.TexCoord2(1.0f, 0.0f); GL.Vertex2(2657.0f, 3683.5f);
GL.TexCoord2(0.0f, 0.0f); GL.Vertex2(-2657.0f, 3683.5f);
GL.End();

GL.LoadIdentity();



Can anybody help me find what seems to be the problem here?