Sign In/My Account | View Cart  

advertisement

AddThis Social Bookmark Button

Article:
  Using OpenGL with VB.NET
Subject:   Traps
Date:   2003-05-06 00:24:41
From:   anonymous2
As an avid OpenGL AND C# (or VB.NET) programmer I would like to make two remarks:


1. Watch out for the 'OpenGL Thread'! When using a seperate thread things could go wrong: a) ALL the OpenGL code must be called on the SAME thread (OpenGL isn't multithreaded yet) and b) ALL the Window Form code must be called on the original (Form creating) thread.


2. (This is worse) the OnSizeChanged function calls itself... stack overflow is bound to follow; I guess (as it should) that the code had to be MyBase.OnSizeChanged(e) instead of Me.OnSizeChanged(e)


Happy Coding!
Erno


PS: I'm still wondering why CSGL changed to TAO... did it?


Full Threads Oldest First

Showing messages 1 through 3 of 3.

  • Traps
    2003-05-06 20:28:59  anonymous2 [View]

    >all the WIndow Form Code must be called on the original (Form Creating) thread

    is this why I can't create 2 forms in Sub Main(), one a docked GL viewport and the other a panel of controls for it? if so, any tips? I want to create an MDI app with one form class a fully-docked GL renderer of the data being manipulated in the other forms...?

    Total GL newbie here, not too good with Forms and threading either but I'll learn and that's the idea here.

    thanks!
    • Forms
      2003-05-07 03:17:34  anonymous2 [View]

      Sure, you can create 2 Forms but you must be very carefull that the actual OpenGL calls are being done on the thread of the form with the OpenGL view. To do this follow the following procedures:

      1. create functions on the view window that do the OpenGL calls

      2. instead of calling these functions DIRECTLY from within the control window you should use the Invoke function from the view windows. (Look in the MSDN-help on Form.Invoke) This way the view form's thread will call the function!

      Just a remark: I'm not to keen about scattering OpenGL functions thoughout my application. I prefer the Model-View-Controller design pattern. So I created a Renderer class that is called by the view window which does all the OpenGL work based upon data that describes the state of the models I want to show. The control window just changes that state. I really prefer OO programming AND design...

      Hope this helps.

      Regards,

      Erno
  • Traps
    2003-05-06 01:43:42  anonymous2 [View]

    Re (2): Yes, Me.OnSizeChanged(e) ought to be changed to MyBase.OnSizeChanged(3). It's my typo.

    Thanks,

    Jacek