Results 1 to 4 of 4

Thread: DirextX/OpenGL TImage.

  1. #1

    DirextX/OpenGL TImage.

    For an imaging application I have to display an image (bmp) in a part of a normal Delphi screen. Updating a picture takes about 5-7ms, more if it is fullscreen, and I'd like to decrease that. (at 25 frames per second, that being quite a lot of the per frame budget)

    So using accelerated api's would be great, however can it be done without chucking out the entire VCL/LCL? IOW can one effectively use dx/gl for parts of a form?

    Of course pointers to bmp drawing using accelerated techniques would be great.

  2. #2

    DirextX/OpenGL TImage.

    Hi MarcoV,
    Using TImage is always really slow. Are you able to draw directly onto the Form surface instead? I suppose the questions that need answering are how big is the image you are blitting and is it static or animated?

    Just for interests sake, what machine specs are you aiming your application at?
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  3. #3

    DirextX/OpenGL TImage.

    Quote Originally Posted by savage
    Hi MarcoV,
    Using TImage is always really slow. Are you able to draw directly onto the Form surface instead?
    (we use an own developed variant that draws to the canvas using .draw
    there also is a SetStretchBltMode and canvas.copyrect using variant, but it is not in use at the moment. It is already quite a bit faster than TImage, sorry for the inexactness of the question)

    Quote Originally Posted by savage
    I suppose the questions that need answering are how big is the image you are blitting and is it static or animated?
    Not just blitting, zooming too. Usually full screen and bigger. The largest are over 4k x2kx8bpp. (but the really large ones have lower framerates, typically 2fps). Typical is 1280x960x8bpp or 1024x1800x8bpp with a framerate of 8-15fps. The images come from digital camera's and are 8bit.

    The user can scroll and zoom the image. Currently only by powers of 2, but continuous zoom in the future is planned.

    Just for interests sake, what machine specs are you aiming your application at?
    Multiple configurations. E.g. heavy machines (think E6700) but then they have multiple image sources (so effective framerates of 2 x 10fps or even 3x), or C7 1200Mhz for lowpowered ones. (usually for hot environments).

    All but the C7's have GF6200TD as lowest GPU. New ones typically have budget 7300's. (the reason for the GPU is actually not the GPU, but just the cheapest external GPU. Chipset GPU usually use too much memory bandwidth). The C7 hasn't arrived yet, but probably will have some S3 unichrome.

  4. #4

    DirextX/OpenGL TImage.

    It is possible to use OpenGL and VCL/ LCL in the same time. All you need is a VCL control which has a handle. The very simple OpenGL form would look something like this
    Code:
    TGLForm = class&#40;TForm&#41;
    private
      FGLRC &#58; HGLRC;
      fGLDC &#58; HDC;
      fPFD &#58; TPixelFormatDescriptor;
      ...
    public
      constructor Create&#40;AOwner &#58; TComponent&#41;;
      destructor Destroy; override;
      procedure InitGL;
      ...
    end;
    
    implementation
    
    constructor TGLForm.Create&#40;AOwner &#58; TComponent&#41;;
    var
     formatIndex &#58; integer;
    begin
     inherited;
     //setup pixel format
     with fPFD do begin
       nSize &#58;= SizeOf&#40;fPFD&#41;;
       nVersion &#58;= 1;
       dwFlags &#58;= PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER;
       iPixelType &#58;= PFD_TYPE_RGBA;
       cColorBits &#58;= 24; //bits per pixel
       cDepthBits &#58;= 24; //size of depth buffer
       cStencilBits &#58;= 8;  //size of stencilbuffer
       iLayerType &#58;= PFD_MAIN_PLANE;
     end;
     fGLDC &#58;= getDC&#40;self.Handle&#41;;
     FormatIndex &#58;= ChoosePixelFormat&#40;fGLDC,@FPFD&#41;;
     //if FormatIndex = 0 then error
     SetPixelFormat&#40;fGLDC,FormatInsex,@fPFD&#41;;
     //create rendering context;
     fGLRC &#58;= wglCreateContext&#40;fGLDC&#41;;
     wglMakeCurrent&#40;fGLDC,fGLRC&#41;;
    end;
    
    destructor TGLForm.Destroy;
    begin
     //destroy rendering context;
     wglMakeCurrent&#40;fGLDC,0&#41;;
     wglDeleteContext&#40;fGLRC&#41;;
     ReleaseDC&#40;self.Handle,fGLDC&#41;;
     inherited;
    end;
    
    procedure TGLForm.InitGL;
    begin
     glMatrixMode&#40;GL_PROJECTION&#41;;
     glOrtho&#40;0,ClientWidth,0,ClientHeight,0,1&#41;;
     glMatrixMode&#40;GL_MODELVIEW&#41;;
     glLoadIdentity;
     glViewport&#40;0,0,ClientWidth,ClientHeight&#41;;
    end;
    Drawing can be done in TGLForm.OnPaint event.
    For more sophisticated example look there:
    http://www.delphi3d.net/dot/

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
  •