VCL Component (TOpenGLAPPanel)

Fixes for typecasting error in Get3DTextSize, DrawText2D and DrawText3D.

Remember to change the range for FirstGlyph and NumGlyph to 0 and 255 to get the full range of characters.

Download TOpenGLAPPanel 1.2.0
(274.37 kB Downloaded 1722 times)
OpenGL VCL Component for Embarcadero RAD Studio 2010

4 comments to VCL Component (TOpenGLAPPanel)

  • Phil

    Hi
    OpenGLAP working well so far but my new installation of Builder2010 forces certain include files to appear in the header files of units containing forms, and forces #include “TOpenGLAPPanel.h” to appear before pragma hdrstop in the main unit, although it is already called in a subsequent header file (I have them daisychained to minimise repeated calls). Can anyone explain the logic behind this and whether it should be a problem.

    I am also getting Linker warnings “Public symbol -gtd appearing in both module… and module…, and similarly for _dfb and _m but I think this is a legacy problem.

  • Builder is including the headers to make sure no compiler errors occur when we compile.
    unfortunally it is not very good to remove them when we delete a component again.

    for repeated calls, headers normally include defines like

    #ifndef TOpenGLAPPanelH
    #define TOpenGLAPPanelH
    … code
    #endif

    this ensures only one interpretation of the linker.

  • Phil

    Hi

    All working very well. I would appreciate any clues regarding copying my OpenGLAPP image to clipboard please.

    Thanks

  • Here is a clue….:-)

    //—- begin
    // Get client geometry
    int ii, Bytes, bb;
    SIZE glsize;
    unsigned char *pPixelData;

    OpenGLPanel->MakeOpenGLPanelCurrent();
    ClearSelection ();
    Redraw ();

    glsize.cx = OpenGLPanel->ClientWidth;
    glsize.cy = OpenGLPanel->ClientHeight;

    // —- Lines have to be 32 bytes aligned, suppose 24 bits per pixel
    // —- just cropped it
    glsize.cx -= glsize.cx % 4;

    // —- Create a bitmap and select it in the device context
    // —- Note that this will never be used ;-) but no matter

    // —- Alloc pixel bytes
    Bytes = 3 * glsize.cx * glsize.cy;
    pPixelData = new unsigned char [Bytes];

    // —- Copy from OpenGL
    glReadPixels (0,0,glsize.cx,glsize.cy, GL_RGB, GL_UNSIGNED_BYTE, pPixelData);

    // —- Pixel data is stored as GRB, not RGB
    for (ii=0; ii bb = pPixelData[ii+1];
    pPixelData[ii+1] = pPixelData[ii];
    pPixelData[ii] = bb;
    }

    // ---- Fill header
    // --- BITMAPINFOHEADER header;
    BITMAPINFO header;

    header.bmiHeader.biWidth = glsize.cx;
    header.bmiHeader.biHeight = glsize.cy;
    header.bmiHeader.biSizeImage = Bytes;
    header.bmiHeader.biSize = 40;
    header.bmiHeader.biPlanes = 1;
    header.bmiHeader.biBitCount = 24; // RGB
    header.bmiHeader.biCompression = 0;
    header.bmiHeader.biXPelsPerMeter = 0;
    header.bmiHeader.biYPelsPerMeter = 0;
    header.bmiHeader.biClrUsed = 0;
    header.bmiHeader.biClrImportant = 0;

    // ---- Generate handle
    HANDLE handle = (HANDLE)GlobalAlloc (GHND,sizeof(BITMAPINFO) + Bytes);
    if (handle != NULL) {
    // Lock handle
    char *pData = (char *) ::GlobalLock((HGLOBAL)handle);
    // Copy header and data
    memcpy(pData,&header,sizeof(BITMAPINFO));
    memcpy(pData+sizeof(BITMAPINFO),pPixelData,Bytes);
    // Unlock
    GlobalUnlock((HGLOBAL)handle);

    // Push DIB in clipboard
    OpenClipboard(OpenGLPanel->Handle);
    EmptyClipboard();
    SetClipboardData(CF_DIB, handle);
    CloseClipboard();
    }

    delete [] pPixelData;
    // —- End

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>