Library tutorials & articles

OpenGL and C# - Part 1

Summary

You now know how to set up a OpenGL form where you can draw. But for now play with this and I will come soon with my next article about OpenGL.

BTW: there is one thing I want to tell you and that is that you can put as many glColor3f() functions between the glVertex3f() so that all points get different colors really cool!!! As you may notice we didn’t covered any basics for coordinates and this will be my next article to really draw some figures and so.

Comments

  1. 07 Oct 2009 at 09:29

    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...

  2. 12 Sep 2009 at 20:54

    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"

  3. 10 Sep 2009 at 23:49

    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!

  4. 01 Sep 2009 at 16:27

    the solution i know is:

        CheckForIllegalCrossThreadCalls = false;
    

    which is simpler

  5. 01 Sep 2009 at 16:26

    the solution i know is:

        CheckForIllegalCrossThreadCalls = false;
    

    which is simpler

  6. 13 Aug 2009 at 11:01

    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(); } } }

  7. 08 Aug 2009 at 14:14

    (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

  8. 08 Aug 2009 at 14:08

    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... ;-)

Leave a comment

Sign in or Join us (it's free).

Johnny I'm doing first year Informatica at academy of Amsterdam
AddThis

Related podcasts

  • Object-Oriented Programming in Ruby

    In this episode, I talk with Scott Bellware about object-oriented programming in Ruby, and Ruby's object model. This is taken from a private conversation, and the audio quality suffers at times. Much thanks to Scott for allowing this to be released.This episode of the Alt.NET Podcast is bro...

Want to stay in touch with what's going on? Follow us on twitter!