I’m glad to be the first one writing about OpenGL at this site. What I want to show you in this article is that it is fairly easy to setup a form that is capable of showing 3D. We will accomplish this with the OpenGLControl. So before we can start we (that means you) have to download CsGL here, or if it isn’t there anymore, from its project page. For this article I used the CsGL version 1.4.0 I think it will run on later versions though.
Ok let we start. First thing to do is make a new Windows Application. Which
I called SimpelOpenGL but its not important. Ok when that done popup the “Solution
explorer” and “add reference” the reference for CsGL must
be in "D:\WINDOWS\system32\" which are called csgl.dll and csgl-base.dllnotice
that there is .dll called csgl-native.dll but you don’t need
it.
Ok import the following namespaces
-
System.Threading -
CsGL.OpenGL
Hi All, I ran into some trouble with the thread above, but, I found a solution... Aperantly, while using Visual Studio 2008 such a cross thread action is considered unsafe. Anyway, the "Invoke" method can take care of that with just a few lines of code:
private void OpenGL_Start() { if( this.view.InvokeRequired) { ThreadStart aDelegate = new ThreadStart(this.view.Refresh); for( ; ; ) { Thread.Sleep(1000); if( !thrOpenGL.IsAlive ) return; this.Invoke(aDelegate); } } else { for( ; ; ) { // infinity loop for rendering Thread.Sleep(1000); this.view.Refresh(); } } }
The 'if' statement check to see if the action is done on the current thread or not and uses the "invoke" when necessary.
I hope I saved someone the 60 minutes it took me... ;-)
!--removed tag-->(sorry for not marking the code as code in the comment above...)
Hi Johnny, Still there? I know it's been a while since 2003... But if you are still around, or anyone else, I have a question:
How do I draw two separate sets of drawing in parallel? I want to draw an Anaglyph. Let's say, a blue cube and a red cude. each in a different color and at a slightly different angle acording to two POV (points of view).
Any suggestions?
All the best. Amir
!--removed tag-->private void OpenGL_Start() { if( this.view.InvokeRequired) { ThreadStart aDelegate = new ThreadStart(this.view.Refresh); for( ; ; ) { Thread.Sleep(1000); if( !thrOpenGL.IsAlive ) return; this.Invoke(aDelegate); } } else { for( ; ; ) { // infinity loop for rendering Thread.Sleep(1000); this.view.Refresh(); } } }
!--removed tag-->the solution i know is:
which is simpler
!--removed tag-->the solution i know is:
which is simpler
!--removed tag-->First of all there is no csgl-base.dll in a package csgl.dll.zip downloaded from project site. Secound of all can anybody tell me why it doesn't work? Sometimes I have to change widnow size to see the scene, sometimes it never showes up :| why? What I'm doing wrong? uffff F1 F1 F1 HELP!
!--removed tag-->Strange, I've added a menu in the top of the window and now everything works perfectly :) thx for the tutorial. Without it I would never start. We Polish used to say "The first step is the hardest"
!--removed tag-->Thanks for the tutorial, unfortunately it does not work for me. All I see is white background with a red cross of which I don't know where it comes from... Thanks for any help...
!--removed tag-->hi! i have a problem... i can't seem to work it out to use Open GL library in my C# project. i downloaded csgl.1.4.1.dll archive from the net ( http://sourceforge.net/project/showfiles.php?group_id=33241) copied those 3 files (csgl, csgl.dll and csgl.native.dll) to C:\WINDOWS\system32\ then i made a reference from my project to that files i remembered before, and put at the beginning : using System.Threading; using CsGL.OpenGl;
BUT
it doesn't recognize the OpenGL from CsGL.
what should i do to fix it?
!--removed tag-->