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 / C++ / MFC
  4. OpenGL in a portion of a dialog box

OpenGL in a portion of a dialog box

Scheduled Pinned Locked Moved C / C++ / MFC
c++graphicsgame-devquestion
6 Posts 4 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.
  • C Offline
    C Offline
    ComboController
    wrote on last edited by
    #1

    I have created a dialog that is rendered into by an OpenGL RC. Now that I have that going I'd like to be able to add a few control variables. What I'd like to do is set OpenGL to only render into a portion of the dialog..... I was wondering how I'd go about this, do I have to create another window in the dialog? If so, what type is appropriate, I'm only getting started with MFC. A quick aside, in my OnPaint() I call the base OnPaint() function and THEN render my scene, yet the OK and CANCEL buttons still get painted. Shouldn't they be painted over by RC?

    B R M 3 Replies Last reply
    0
    • C ComboController

      I have created a dialog that is rendered into by an OpenGL RC. Now that I have that going I'd like to be able to add a few control variables. What I'd like to do is set OpenGL to only render into a portion of the dialog..... I was wondering how I'd go about this, do I have to create another window in the dialog? If so, what type is appropriate, I'm only getting started with MFC. A quick aside, in my OnPaint() I call the base OnPaint() function and THEN render my scene, yet the OK and CANCEL buttons still get painted. Shouldn't they be painted over by RC?

      B Offline
      B Offline
      Bugra Barin
      wrote on last edited by
      #2

      I would create a picture control inside the dialog and assign a CStatic control variable to it, say m_cPic. Then in OnInitDialog you can get a DC for the picture control and assign this DC to the OpenGL rendering context. Something like HDC hdc = m_cPic.GetDC()->GetSafeHdc(); wglMakeCurrent(hdc, hGLRC); // hGLRC is handle to the OpenGL rendering context This approach worked for me before.

      C 1 Reply Last reply
      0
      • B Bugra Barin

        I would create a picture control inside the dialog and assign a CStatic control variable to it, say m_cPic. Then in OnInitDialog you can get a DC for the picture control and assign this DC to the OpenGL rendering context. Something like HDC hdc = m_cPic.GetDC()->GetSafeHdc(); wglMakeCurrent(hdc, hGLRC); // hGLRC is handle to the OpenGL rendering context This approach worked for me before.

        C Offline
        C Offline
        ComboController
        wrote on last edited by
        #3

        Thanks I'll give it a go. Is any special cleanup necessary if you use this approach?

        B 1 Reply Last reply
        0
        • C ComboController

          Thanks I'll give it a go. Is any special cleanup necessary if you use this approach?

          B Offline
          B Offline
          Bugra Barin
          wrote on last edited by
          #4

          You should release the device context hdc using ::ReleaseDC API function

          1 Reply Last reply
          0
          • C ComboController

            I have created a dialog that is rendered into by an OpenGL RC. Now that I have that going I'd like to be able to add a few control variables. What I'd like to do is set OpenGL to only render into a portion of the dialog..... I was wondering how I'd go about this, do I have to create another window in the dialog? If so, what type is appropriate, I'm only getting started with MFC. A quick aside, in my OnPaint() I call the base OnPaint() function and THEN render my scene, yet the OK and CANCEL buttons still get painted. Shouldn't they be painted over by RC?

            R Offline
            R Offline
            Roger Allen
            wrote on last edited by
            #5

            ComboController wrote: A quick aside, in my OnPaint() I call the base OnPaint() function and THEN render my scene, yet the OK and CANCEL buttons still get painted. Shouldn't they be painted over by RC? You window gets its OnPaint() first because its at the back of the TAB or window order. The OK/Cancel buttons gets theirs after the dialogs OnPaint(), so they would appear over your scene. On a second not, when your added your own OnPaint() function for your dialog, you would have seen a comment such as: // DO NOT CALL base Class OnPaint() This is a bad thing to do, as the CDC parameter passed through to the OnPaint() handler gets setup in some way by the system, so what your doing could crash/corrupt things. If you can, see if you can avoid calling the base class function in this way. Roger Allen Sonork 100.10016 Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003

            1 Reply Last reply
            0
            • C ComboController

              I have created a dialog that is rendered into by an OpenGL RC. Now that I have that going I'd like to be able to add a few control variables. What I'd like to do is set OpenGL to only render into a portion of the dialog..... I was wondering how I'd go about this, do I have to create another window in the dialog? If so, what type is appropriate, I'm only getting started with MFC. A quick aside, in my OnPaint() I call the base OnPaint() function and THEN render my scene, yet the OK and CANCEL buttons still get painted. Shouldn't they be painted over by RC?

              M Offline
              M Offline
              MemLeak
              wrote on last edited by
              #6

              There is a lot of stuff in there to help you. http://pws.prserv.net/mfcogl/ Mykel Everything's beautiful if you look at it long enough...

              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