4 thoughts on “VCL Component (TOpenGLAPPanel)”

  1. Hi.
    Thank you for sharing this component but could ask you a tutorial how to install this package. I am getting some stranges messages and nothing happens after. (using XE2 update 3)
    Thank ypu

  2. Having a problem with SaveOpenGLPanelToFile. It is saving a blank image. Have you seen that before, or is it my implementation. BTW, love this component.


  3. Hi John

    It is an implementation that might not work like you expect, I have personally replaced it with something like this:

    bool CopyToBitmap (Graphics::TBitmap *BitMap)
    // —- Creating Directly into bitmap
    int Bytes, yy;
    SIZE glsize;
    unsigned char *pPixelDataStart;
    unsigned char *pPixelData;
    Byte *Ptr;


    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;
    glsize.cy -= glsize.cy % 4;

    // —- Alloc pixel bytes
    Bytes = ((glsize.cx*24+31)/32 * 4)*glsize.cy;
    if (Bytes < 4 || glsize.cy < 1) { return (false); } pPixelData = new unsigned char [Bytes]; // ---- Copy from OpenGL glReadPixels (0,0,glsize.cx,glsize.cy, GL_BGR_EXT, GL_UNSIGNED_BYTE, pPixelData); /* int rc = glGetError (); if (rc != GL_NO_ERROR) { return (false); } */ BitMap->PixelFormat = pf24bit;
    BitMap->HandleType = bmDIB;
    BitMap->Width = glsize.cx;
    BitMap->Height = glsize.cy;

    Bytes = (24*glsize.cx) >> 3;
    while (Bytes%4) Bytes++;

    pPixelDataStart = pPixelData;
    for (yy=glsize.cy-1; yy>=0; yy–) {
    Ptr = (Byte *) BitMap->ScanLine[yy];
    memcpy (Ptr, pPixelData, Bytes);
    pPixelData += Bytes;
    delete [] pPixelDataStart;

    return (true);

    Best Regards

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>