Solved

Using Canvas.Handle for OpenGL

Posted on 1998-10-31
8
312 Views
Last Modified: 2010-04-03
Hello everybody!
Here is my little problem:
I want to use OpenGL API calls to draw some graphic into my form but for creating correct RC context i need to call several WinAPI functions such as ChoosePixelFormat, GetPixelFormat, SetPixelFormat etc. All of them need HDC of my window so i set MyForm.Canvas.Handle as HDC. But they do not work. GetLastError returns error#126.
Here is the question:
How can I use Canvas.Handle correctly and make it work as i would wish?
Thank you in advance!
0
Comment
Question by:Dune081198
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 4

Expert Comment

by:dwwang
ID: 1345148
Why not simply try some existing OpenGL components on Internet?
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1345149
0
 

Author Comment

by:Dune081198
ID: 1345150
it's good idea to use existing OpenGL components but it not solve the Canvas problem. :)
I'd like to make this funcs working.Thanks Zif for your link
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:ZifNab
ID: 1345151
Dune, what happens if you pass a handle of the TPaintBox. What if you just pass the handle of the window? form1.handle.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1345152
Dune, pardon me for not answering your question directly.

I've found a sample program for using OpenGL. Now, I could just look at the source and give you the answer, but I guess it's better that I just give you the link to the example on using OpenGL. In there you'll find much more information, then if I just answer it.

http://torry.rimini.com/samples/samples/primscr.zip

PS. The link I gave you before has great links to other OpenGL thingies.

Regards, Zif.
0
 

Author Comment

by:Dune081198
ID: 1345153
sorry ZifNab. it not works neither OnCreate event nor OnPaint :(
as i could find the error 126 means  "Can't find this DC" or close
it seams the reason must be in form creation or somthing about this.
i think it's not very good idea to use window handle as device context

0
 

Author Comment

by:Dune081198
ID: 1345154
Oh! Sorry Zif! i did not notice your added coment. this example is excelent! just request your awnser to correct my mistake.
thanks a lot.
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 150 total points
ID: 1345155
Hi Dune,

Glad it helped you.

I've found a sample program for using OpenGL. Now, I could just look at the source and give you the answer, but I guess it's better that I just give you the link to the example on using OpenGL. In there you'll find much more information, then if I just answer it.

http://torry.rimini.com/samples/samples/primscr.zip 

Regards, Zif.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question