Announcement

Collapse
No announcement yet.

Open GL dialog jpg dump

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Open GL dialog jpg dump

    Hi, I have been able to make screen dumps of Open GL dialogs in PB. However, I need to make jpg dumps of the graphic dialog and not just the displayed screen portion. I need to make a jpg output of areas not displayed to get a better DPI. Does any one know of any examples Open GL source code to accomplish this. Thx

  • #2
    I guess no one has ventured to answer since perhaps I did not explain the problem well enough. How does one make a bmp capture of the entire Open GL dialog beyond the visible portions of the screen.

    I have used the viewport to expand the Open GL dialog beyond the native screen size, however, the bmp capture seems only limited to the native screen size, irrelevant of the Open GL dialog size.

    Any help would be appreciated... I have included my bmp capture, and some initialization...In the example the dwidth/dheight is arbitrarily set to 2 times the native screen resolution. The capture however, is only the visible screen portion!


    '******************************************************************************
    SUB SizeOpenGL(BYVAL dWidth AS DWORD, BYVAL dHeight AS DWORD)
    '******************************************************************************

    glViewport 0,0,dWidth,dHeight
    glMatrixMode gl_PROJECTION
    glLoadIdentity
    gluPerspective (45.0,dWidth/dHeight,0.1,150.0)
    glMatrixMode gl_MODELVIEW
    glLoadIdentity

    END SUB

    '******************************************************************************
    FUNCTION InitOpenGL(BYVAL dWidth AS DWORD, BYVAL dHeight AS DWORD) AS LONG
    '******************************************************************************

    IF PixelFormatSetup() THEN
    hPicRC = wglCreateContext (hPicDC)
    IF hPicRC THEN
    wglMakeCurrent hPicDC, hPicRC
    glEnable GL_DEPTH_TEST
    SizeOpenGL dwidth, dheight
    FUNCTION = %True
    EXIT FUNCTION
    END IF
    END IF

    FUNCTION = %False

    END FUNCTION


    '*******************************************************************************
    FUNCTION InitDialog(BYVAL hdlg AS DWORD) AS LONG
    '*******************************************************************************

    LOCAL x AS DWORD
    LOCAL y AS DWORD

    CONTROL HANDLE hdlg, %id_glidpic TO hPic
    hPicDC = GetDC(hPic)

    dwidth=2*lxl
    dheight=2*lyl
    IF InitOpenGL (dwidth, dheight) THEN
    FUNCTION = %True
    EXIT FUNCTION
    END IF
    FUNCTION = %False

    END FUNCTION



    FUNCTION openglvolumescreencapture AS LONG

    LOCAL ret AS LONG
    LOCAL hBMPDC AS LONG
    LOCAL hMemDC AS LONG
    LOCAL rc AS RECT
    LOCAL hMemBmp AS LONG
    LOCAL bm AS BITMAP
    LOCAL bmi AS BITMAPINFO
    LOCAL bmpFileHdr AS BITMAPFILEHEADER
    LOCAL bmpInfoHdr AS BITMAPINFOHEADER
    LOCAL hFile AS LONG
    LOCAL sbmpfile$
    LOCAL xx1 AS LONG
    LOCAL yy1 AS LONG

    sbmpfile$=ioutput$+opgl3dident$+".bmp"
    DIALOG SET TEXT hdlggl3d,opgl3dident$+".jpg"
    GetclientRect hdlggl3d, rc


    DIALOG GET LOC hdlggl3d TO xx1,yy1
    DIALOG UNITS hdlggl3d, xx1,yy1 TO PIXELS xx1,yy1

    rc.ntop=-yy1+60 ' fix for getting the client area from the top

    hBMPDC = CreateDC( "Display", BYVAL %NULL, BYVAL %NULL, BYVAL %NULL )
    hMemDC = CreateCompatibleDC( hBMPDC )

    ' showwindow(hwndmain,%sw_hide)

    bmi.bmiHeader.biSize = SIZEOF( bmi.bmiHeader )
    bmi.bmiHeader.biWidth = (rc.nRight - rc.nLeft)
    bmi.bmiHeader.biHeight = (rc.nBottom - rc.nTop)
    bmi.bmiHeader.biPlanes = 1
    bmi.bmiHeader.biBitCount = 24
    bmi.bmiHeader.biCompression = %BI_RGB

    hMemBmp = CreateDIBSection( hMemDC, bmi, %DIB_RGB_COLORS, 0, 0, 0 )
    GlobalLock hMemBmp
    SelectObject hMemDC, hMemBmp
    GetObject hMemBmp, SIZEOF( bm ), bm
    BitBlt hMemDC, 0,0, bm.bmwidth, bm.bmheight, hBMPDC, rc.nLeft, rc.nTop, %SRCCOPY
    bmpFileHdr.bfType = CVI( "BM" )
    bmpFileHdr.bfSize = LEN( bmpFileHdr ) + LEN( bmpInfoHdr ) + bm.bmWidthBytes * bm.bmHeight
    bmpFileHdr.bfOffBits = 54
    bmpInfoHdr.biSize = 40
    bmpInfoHdr.biWidth = bm.bmWidth
    bmpInfoHdr.biHeight = bm.bmHeight
    bmpInfoHdr.biPlanes = 1
    bmpInfoHdr.biBitCount = 24
    bmpInfoHdr.biSizeImage = 54 + bm.bmWidthBytes * bm.bmHeight

    'Write to disk
    hFile = FREEFILE
    ERRCLEAR
    OPEN sBmpFile$ FOR OUTPUT AS #hFile
    PRINT #hFile, bmpFileHdr bmpInfoHdr _
    PEEK$( bm.bmBits, bm.bmWidthBytes * bm.bmHeight );
    CLOSE hFile

    IF ERR THEN ret = %False ELSE ret = %True

    DeleteDC hBMPDC: DeleteDC hMemDC: GlobalUnlock hMemBmp: DeleteObject hMemBmp

    volumebmptojpeg

    FUNCTION = ret

    ' showwindow(hwndmain,%sw_show)

    END FUNCTION

    Comment


    • #3
      You mean the window and the window contents right? Like pressing <alt><print screen> then pasteing into Paint?

      Just tried <alt><print screen>, and it only returns the on screen part, same as your code does. Consider that the off screen part does not exist in video buffer (either main RAM or video board RAM). Windows would draw only the visable portion; and as you grab the window with mouse and move it Windows redraws it.

      If you mean just the contents, like the behavier of GRAPHIC GET BITS on PB GRAPHIC control or window, then the other program would have to cooperate.
      Last edited by Dale Yarker; 29 Sep 2008, 11:19 PM. Reason: control to alt
      Dale

      Comment


      • #4
        ... if your program could relocate the Open GL window, then it could grab the visable pieces and patch them together.

        A brain storm I had on bus to work after previous post. Even if totally wrong, somebody else might give you a better answer while proving me wrong!

        Good luck with the project.

        Cheers,
        Dale

        Comment


        • #5
          Hi Dean,

          I have used the viewport to expand the Open GL dialog beyond the native screen size, however, the bmp capture seems only limited to the native screen size, irrelevant of the Open GL dialog size.
          According to OpenGL specs, the pixels rendered in areas covered by other window or out of screen are undefined.
          So the solution would be to do some offscreen rendering ( not swapping buffers, just rendering to texture / glReadPixels ) using few passes, which would shift camera to get whole image.


          Hope this helped,
          Petr
          [email protected]

          Comment

          Working...
          X