Results 1 to 4 of 4

Thread: Rendering Context With Docking

  1. #1

    Rendering Context With Docking

    i have to problem with rendering context.
    iam using DGLOpengl Header and i found some Sample code.
    and i am create Redering context with this code. its Render to a Tpanel

    Code:
        FDC:=GetDC(fChwnd);
    
    
        InitOpenGL;
        fpfd.dwFlags := PFD_DRAW_TO_WINDOW OR PFD_SUPPORT_OPENGL OR PFD_DOUBLEBUFFER;
        SetPixelFormat ( fDC, ChoosePixelFormat ( fDC, @fpfd ), @fpfd );
        fhlgrc:=wglCreateContext ( fDC );
        ActivateRenderingContext( fDC, fhlgrc, TRUE );
        fStart := GetTickCount;
        fElapsedTime:=1;
        //load simple glsl shader
        fglslsimpleprog := TGLSLProgram.Create();
        fglslsimplevert := TGLSLShader.Create('Resources\Shaders\simple.vert');
        fglslsimplefrag := TGLSLShader.Create('Resources\Shaders\simple.frag', GL_FRAGMENT_SHADER_ARB);
        fglslsimpleprog.Attach(fglslsimplevert);
        fglslsimpleprog.Attach(fglslsimplefrag);
        fglslsimpleprog.Link;
        fglslsimpleprog.Enable;
        fglslsimpleprog.Set2F('resolution',fwidth*2,fheight*2);
    when Docking or unDocking i call this this code
    Code:
        fpaint:=false;
        fglslsimpleprog.Disable;
    
    
        DeactivateRenderingContext;
        ReleaseDC(fChwnd, fDC);
        fchwnd:=hwnd;
        fdc:=GetDC(FChwnd);
        InitOpenGL;
        fpfd.dwFlags := PFD_DRAW_TO_WINDOW OR PFD_SUPPORT_OPENGL OR PFD_DOUBLEBUFFER;
        SetPixelFormat ( fDC, ChoosePixelFormat ( fDC, @fpfd ), @fpfd );
        fhlgrc:=wglCreateContext ( fDC );
        ActivateRenderingContext( fDC, fhlgrc, TRUE );
        fglslsimpleprog.Enable;
        fpaint:=true;
    while Panel Docking There isnt any Problem. But When Undock this Panel its not Render on Panel

    What is wrong i dont understand . How i should change rendering Context ?

  2. #2
    I doubt that you can use SetPixelFormat() for TPanel, or even TForm. Where do you get fChwnd? Shouldn't it be FDC:=GetDC(panel1.handle); Then you should call ReadExtensions; after the InitOpenGL;

  3. #3
    I guess fChwnd is panel1.handle if this works
    And if there's a need to call the second part of code at all then I guess panel handle changes while docking/dragging?

  4. #4
    Long time Later i found where i do wrong
    if handle is change its need use SetPixelFormat and ActivateRenderingContext

    my wrong i tryed to delete RC,DC ..



    pfd.dwFlags := PFD_DRAW_TO_WINDOW OR PFD_SUPPORT_OPENGL OR PFD_DOUBLEBUFFER;
    SetPixelFormat ( DC, ChoosePixelFormat ( DC, @pfd ), @pfd );
    ActivateRenderingContext( DC, wglCreateContext ( DC ), TRUE );

    Last edited by serkank; 22-10-2014 at 07:06 PM.

Bookmarks

Posting Permissions

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