The texture examples I've seen only shows how to use a single texture (to keep it simple obviously), but I'm trying to use two textures, and am having a problem. I use the following code to load a texture (I believe there is nothing special about this code):
Bitmap bitmap = new Bitmap( path ); BitmapData data = bitmap.LockBits( new System.Drawing.Rectangle( 0, 0, bitmap.Width, bitmap.Height ), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppRgb ); int textureId = GL.GenTexture(); GL.TexImage2D( TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, data.Width, data.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0 ); bitmap.UnlockBits( data );
Loading two textures I get textureId's 1 and 2. This is done once in the start of the program (...OnLoad...).
I then use only the first texture on some quads (GL.BindTexture( 1 ) etc.).
It all works fine but for one thing, it always uses the last texture loaded! If I only load the first texture it looks fine, but it's like it always uses the last texture nomatter what id I try to use. Note that BindTexture() is never called using 2 anywhere in the code, and GetError() returns no error on neither TexImage2D or BindTexture. Both textures works fine if only one texture is loaded.
What am I missing? Do I have to do something extra to make two textures available?
(using: OpenTK 1.1 (by Subversion), my driver supports only OpenGL 2.1)