Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. problem in setting backround image to a form created using OpenGL in c#

problem in setting backround image to a form created using OpenGL in c#

Scheduled Pinned Locked Moved C#
graphicscsharpgame-devhelpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    raesa
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups