problem in setting backround image to a form created using OpenGL in c#
-
Hi, I have a small problem.I have created a form using OpenGL controls.My task is to set an image file as background to the form.I am able to set the image when the form is loading but my image is flickering on the form.I dunnow what to do.Please have a look at my code below and do tel me what is the mistake there. code : public Form1() { sName = "C:\\Winter.jpg"; InitializeComponent(); simpleOpenGlControl1.InitializeContexts(); nFstFime = 0; Gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); simpleOpenGlControl1.BackgroundImage = Image.FromFile(sName); Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glLoadIdentity(); Glu.gluOrtho2D(0, simpleOpenGlControl1.Width, 0, simpleOpenGlControl1.Height); } private void simpleOpenGlControl1_Paint_1(object sender, PaintEventArgs e) { Gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); if (nFstFime == 0) { b = new Bitmap(simpleOpenGlControl1.Width, simpleOpenGlControl1.Height); nFstFime++; } b = (Bitmap)Image.FromFile(sName); simpleOpenGlControl1.BackgroundImage = b; Graphics g = e.Graphics; g.DrawImage(Image.FromFile(sName), new Rectangle(0, 0, simpleOpenGlControl1.Width, simpleOpenGlControl1.Height)); } Thnx, Raesa