More Problems with OpenGL and the Client Area

This is a discussion on More Problems with OpenGL and the Client Area within the Windows Programming forums, part of the Platform Specific Boards category; I've tried several ways over the past couple of days to get opengl to draw to the client area without ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    4

    More Problems with OpenGL and the Client Area

    I've tried several ways over the past couple of days to get opengl to draw to the client area without any problems.

    I was able to get it to draw using WM_PAINT, but this caused some conflicts with my menus(and any other user input). I've looked around but can't seem to find the answer.

    Here's a snipet of my code right now. I'm trying to make it so that the opengl rendering is cut off when messages are input(accessing menus, other input, etc.) You can assume that all the functions with the "s3d" prefix work properly on their own(and they do), but for some reason this code just gives me a blank screen that shows nothing that the opengl code should be showing.

    Code:
    bool bQuit = false;
    
    while(!bQuit) 
            {
                if (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) 
                {
                    if (Msg.message) 
                    {
                        bQuit = true;
                    } 
                } 
                else 
                {
                    s3dEnableOpenGL(hwnd, &hDC, &hRC);
                    s3dclrscrn();
                    s3dsetscreen(width , height);
                    SwapBuffers(hDC);
                    s3dDisableOpenGL(hwnd, hDC, hRC); 
                }
            }
    Basically I'm trying to get opengl to render and then possibly leave the image there without continuous rendering, or to stop rendering when the program receives input.

    Should I be doing this through the WM_PAINT command or another way? How?

    I have a feeling I'm close, but I'm missing something crucial here.

  2. #2
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    What are you trying to do? A GUI interface through GL? Do you think windows is only refreshed when a WM_PAINT message is recieved? well no its not, its refreshed every time your monitor is, and why do you only want it to draw when theres no input? Are you making a paint program or modeler or.....? Anyways how were you doing this in the WM_PAINT message? if all your doing is drawing and then returning 0 then you should try returning the DefWindowProc so that windows will handle your menus being redrawn. And what problems are you having with drawing? Is nothing being drawn, if so try calling glTranslate* before you draw. Is it that what you are drawing is in a different place in the window than you thought it would be, well if so then either you are calling glTranslate* wrong, you set up your coordinate system wrong, ......? theres more but Id like to know the specifics first before i try to give a souloution.

    [EDIT]
    oh and by your code snippet you should initialize gl before your message loop b/c its redundant to set up over and over and over and over....

  3. #3
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    OpenGL is capable of drawing to a memory dc. You need to use a DibSection. Then you can blit this dibsection onto your window during a WM_PAINT. You lose some of the advantage of OpenGL this way but it works. OpenGL isn't really meant to be used this way. It's more of a full screen game machine. I have done this for the sole purpose of outputting 3d images though.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21