Solved

Using Canvas.Handle for OpenGL

Posted on 1998-10-31
8
318 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
Independent Software Vendors: 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses
Course of the Month3 days, 11 hours left to enroll

630 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