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. Other Discussions
  3. Article Writing
  4. Drawing lines with OpenGL(like the Paint program in windows)

Drawing lines with OpenGL(like the Paint program in windows)

Scheduled Pinned Locked Moved Article Writing
c++graphicshelpquestiongame-dev
2 Posts 2 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.
  • S Offline
    S Offline
    Steve Lai
    wrote on last edited by
    #1

    Hi everyone, I'm new to programming in C++ and have the following problem: I would like to Drawing lines (and other objects, ie squares, circles, etc) with OpenGL(like the Paint program in windows)with a MFC application. I've created a MFC application that is linked to OpenGL. How do I created functions like the ones we see in the "Paint" program found in windows accesories? For example, if I click on the menu which as a "draw lines" function and after clicking on that, I would like to use the mouse to draw lines, (line starts when the mouse is clicked and dragged. Then the line stops when mouse is released). I'm having great difficulty doing this and if anyone can help it would be greatly appreciated. Thank you in advance! Steve

    J 1 Reply Last reply
    0
    • S Steve Lai

      Hi everyone, I'm new to programming in C++ and have the following problem: I would like to Drawing lines (and other objects, ie squares, circles, etc) with OpenGL(like the Paint program in windows)with a MFC application. I've created a MFC application that is linked to OpenGL. How do I created functions like the ones we see in the "Paint" program found in windows accesories? For example, if I click on the menu which as a "draw lines" function and after clicking on that, I would like to use the mouse to draw lines, (line starts when the mouse is clicked and dragged. Then the line stops when mouse is released). I'm having great difficulty doing this and if anyone can help it would be greatly appreciated. Thank you in advance! Steve

      J Offline
      J Offline
      Jonathan de Halleux
      wrote on last edited by
      #2

      1. Override OnLeftMouseDwn Store the position of the mouse when clicked, set a flag to tell that the left button is down, 2. Override OnMove Store the position of the actual position of the mouse, ask for redraw, (InvalidateRect(NULL,FALSE); 3. In OnDraw, check if left button is down, if so, draw a line from initial position to actual position, 4. Override OnLeftMouseUp, unset the flag. This is the basic idea, of course you can refine the concept. Jonathan de Halleux, Belgium.

      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