Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 971239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:55:52+00:00 2026-05-16T02:55:52+00:00

I am busy climbing the learning curve for OpenGL, using Delphi (pascal); I am

  • 0

I am busy climbing the learning curve for OpenGL, using Delphi (pascal); I am using an excellent text, but every example in the book draws to the entire Form. I want to place an image component on the from, and draw to that. I tried assigning the Device context handle (GDC) to the handle of the image control’s canvas, rather than to the handle of the form, but that returns an error when ChoosePixelFormat is invoked.

So, if anyone knows how to get this to occur, I’d appreciate any suggestions.

Thanks in advance for any help.

jrDoner

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T02:55:53+00:00Added an answer on May 16, 2026 at 2:55 am

    I always use the following code to setup the window HWND for OpenGL output:

    procedure rglSetupGL(Handle: HWnd);
    var
      DC: HDC;
      PixelFormat: integer;
    const
      PFD: TPixelFormatDescriptor = (
             nSize: sizeOf(TPixelFormatDescriptor);
             nVersion: 1;
             dwFlags: PFD_SUPPORT_OPENGL or PFD_DRAW_TO_WINDOW or PFD_DOUBLEBUFFER;
             iPixelType: PFD_TYPE_RGBA;
             cColorBits: 24;
             cRedBits: 0;
             cRedShift: 0;
             cGreenBits: 0;
             cGreenShift: 0;
             cBlueBits: 0;
             cBlueShift: 0;
             cAlphaBits: 24;
             cAlphaShift: 0;
             cAccumBits: 0;
             cAccumRedBits: 0;
             cAccumGreenBits: 0;
             cAccumBlueBits: 0;
             cAccumAlphaBits: 0;
             cDepthBits: 16;
             cStencilBits: 0;
             cAuxBuffers: 0;
             iLayerType: PFD_MAIN_PLANE;
             bReserved: 0;
             dwLayerMask: 0;
             dwVisibleMask: 0;
             dwDamageMask: 0);
    begin
      DC := GetDC(Handle);
      PixelFormat := ChoosePixelFormat(DC, @PFD);
      SetPixelFormat(DC, PixelFormat, @PFD);
      RC := wglCreateContext(DC);
      wglMakeCurrent(DC, RC);
    end;
    

    As you know (?), there is a huge difference between window handles (HWNDs) and device contexts (DCs). Every window has a HWND, and every window that you can draw to has a HDC. Given a form, Handle is its HWND, and Canvas.Handle is its HDC.

    To get the DC associated with a window, you can use GetDC(HWND).

    You have to setup OpenGL on a window, that is, on a HWND. So you cannot render OpenGL on a control without a window handle, such as a TImage. Use a TPanel or some other decendant of TWinControl.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm busy learning Prism 4 and the in and outs of everything, but I've
Busy learning Ruby... the documentation have an example: hello world.count(lo, o) that return 2
Im busy messing around with the mega menu example shown on sitepoint but noticed
I am busy converting a query using the old style syntax to the new
I am busy writing a login page in Silverlight. I am using an Authentication
I was busy looking deeper into things like multi-threading and deadlocking etc. The book
I´m busy converting an existing project from an Ant build to one using Maven.
I'm busy to enable login stuff via facebook oauth on my website, but the
I'm busy! Most of my time is spent using analytical techniques, or on course
I'm busy with programming a class that creates an index out of a text-file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.