Solved

Using Canvas.Handle for OpenGL

Posted on 1998-10-31
8
305 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
  • 4
  • 3
8 Comments
 
LVL 4

Expert Comment

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

Expert Comment

by:ZifNab
Comment Utility
0
 

Author Comment

by:Dune081198
Comment Utility
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
 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
Dune, what happens if you pass a handle of the TPaintBox. What if you just pass the handle of the window? form1.handle.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now