I don't usually work with low level binds so this might be something silly that I'm overlooking, but I wouldn't know.
When I create a texture from a file like this
public Texture ( List<byte> pixels, int width, int height ) {
handle = GL.GenTexture();
GL.TexParameter( TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat );
GL.TexParameter( TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat );
GL.TexParameter( TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest );
GL.TexParameter( TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear );
GL.TexImage2D( TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, width, height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, pixels.ToArray() );
}
public void Use () {
GL.Enable( EnableCap.Texture2D );
GL.ActiveTexture( TextureUnit.Texture0 );
GL.BindTexture( TextureTarget.Texture2D, handle );
}
And then render it like this:
public void Draw () {
GL.BindVertexArray( VAO );
//texture.Use();
shader.Use();
GL.DrawElements( PrimitiveType.Triangles, indices.Length, DrawElementsType.UnsignedInt, 0 );
}
Pretty much everything works fine, until I load another texture. ( that makes everything the second texture )
Back to just one texture, when I uncomment texture.Use();
All My triangles turn black. What is going on?
I checked what values the GL.GenTexture();
yields, and it's 1 and 2, while the only time the texture renders, the GL.BindTexture
handle is 0. Setting it to 1 or 2 makes the triangles black.