
Have a problem with texturing
Posted Tuesday, 27 November, 2012 - 20:47 by Symkortem inHello!
I have a problem with texturing. I want to draw a quad with a texture on it, but my quad is always white.
In this part of my programm i load my picture.
private void LoadPicture() { //bitmap1.MakeTransparent(Color.White); //texture = texturearray[0]; GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.Blend); GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest); GL.GenTextures(1,out texture); //GL.BindTexture(TextureTarget.Texture2D, texture); BitmapData data = bitmap1.LockBits(new Rectangle(0, 0, bitmap1.Width, bitmap1.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); bitmap1.UnlockBits(data); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, data.Width, data.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0); }
Now i want draw the quad with the texture
private void glControl1_Paint(object sender, PaintEventArgs e) { GL.ClearColor(Color.Green); GL.Clear(ClearBufferMask.DepthBufferBit | ClearBufferMask.ColorBufferBit); GL.MatrixMode(MatrixMode.Texture); GL.LoadIdentity(); GL.Enable(EnableCap.Texture2D); GL.BindTexture(TextureTarget.Texture2D, texture); //label1.Text = texture.ToString(); //label2.Text = bitmap1.RawFormat.ToString(); GL.Begin(BeginMode.Quads); { GL.TexCoord2(0, 0); GL.Vertex3(0, 0, 0); GL.TexCoord2(1, 0); GL.Vertex3(256, 0, 0); GL.TexCoord2(1, 1); GL.Vertex3(256, 256, 0); GL.TexCoord2(0, 1); GL.Vertex3(0, 256, 0); } GL.End(); GL.Disable(EnableCap.Texture2D); glControl1.SwapBuffers(); }
i am totally confused because every tutorial i saw looked like my programm.
i am programming on windows 7, dot net 4 and with visual studio c# 2010 express
thanks for help
kind regards
symkortem

