Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: drawing an object on a dialog box

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2000
    Location
    tucson,AZ,USA
    Posts
    1

    drawing an object on a dialog box

    Hi:
    I am trying to draw an object onto a dialog box in a win32 application. The dialog box has edit boxes and radio buttons and so forth.

    If I use single buffering then I can get both the object and the dialog controls to display on the dialog box, but the object is screwed up.
    If I use double buffering then the object is perfect, but I lose the dialog controls. Does anyone have experience or can provide some sort of help please.

    Kausik

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Feb 2000
    Posts
    569

    Re: drawing an object on a dialog box

    I would create a child window on the dialog box use its Device Context to draw the object.

  3. #3
    Intern Contributor
    Join Date
    Mar 2000
    Location
    PA, USA
    Posts
    70

    Re: drawing an object on a dialog box

    It sounds like you are drawing to the hWnd of the dialog box, which is incorrect. I think what happens is that the buttons and stuff are first drawn using GDI, then you are drawing with OpenGL and swapping buffers. The buffer swap causes the the entire dialog area to be replaced with your OpenGL scene.

    One thing to do is to include in your dialog resource a picture window (assuming you are using the VC++ dialog editor). In your code, you can use one of the get dialog item functions (with the resource identifier of the picture window that you added) in order to get the hWnd of the picture box. Set up a OpenGL rendering context for this hWnd instead of the hWnd of you dialog box. Now, you can issue OpenGL calls and have the results end up in the picture box rather than the entire dialog. Make sure you keep you do a wglMakeCurrent call to make the picture box's rendering context current when you need to draw it and a wglMakeCurrent(NULL, NULL) to make no RC current when you are done drawing.

    The only thing that you might see using this method is some flickering in the picture box. You might be able to fiddle with preventing the picture box from doing anything when the erase background message is received. This is what causes the flicker.

    Good luck.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •