<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: OpenGL in its own window within an ArcMap extension in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/opengl-in-its-own-window-within-an-arcmap/m-p/32307#M840</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Just a quick update on the progress with our OpenGL ArcMap extension:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Whatever the OpenGL draw issue(s) with the ArcObject "dockable window" may be, they do not affect a regular Windows Form at all.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Even in the same process, if we put the OpenGL viewport on a regular form and have ArcMap show it (instead of putting the OpenGL in the ArcObject "dockable window") the OpenGL drawing in our new Windows form works beautifully.&amp;nbsp; No disappearing viewport, and no flicker.&amp;nbsp; We can call it from ArcMap in the same process.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We're 90% of the way there, except that we still would prefer the integrated dockable functionality if possible.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So the problem with the dockable windows and OpenGL either is *not* the feared issue of a potential tug-of-war between ArcMap&amp;lt;--&amp;gt;Our-extension over the OpenGL context; *or* else ArcMap is placing the extension-as-Form in its own thread for some reason, whereas utilizing the "dockable window" for the container causes the execution of drawing to exist in the main thread where presumably ArcMap has "dibs" on the OpenGL context.&amp;nbsp; Or perhaps it is something else entirely and the "dockable window" simply does not work well with OpenGL for (an)other reason(s)?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can anyone from ESRI please comment?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 16 Aug 2013 20:23:29 GMT</pubDate>
    <dc:creator>BradWind</dc:creator>
    <dc:date>2013-08-16T20:23:29Z</dc:date>
    <item>
      <title>OpenGL in its own window within an ArcMap extension</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/opengl-in-its-own-window-within-an-arcmap/m-p/32306#M839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This request for help follows from the good suggestion by Alexander Gray of The Forum to begin &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;a separate thread around my original post here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/63628-get-reference-to-a-dockable-window-controls?p=319538&amp;amp;highlight=opengl#post319538"&gt;http://forums.arcgis.com/threads/63628-get-reference-to-a-dockable-window-controls?p=319538&amp;amp;highlight=opengl#post319538&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;[As a related aside in reply to Alexander's other comment..&amp;nbsp; Although our development machines &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;are 64-bit we are successfully compiling all of our builds for a 32-bit target architecture, for &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;which example applications other than our ArcMap extension work okay with OpenGL.]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After another couple of days of trying to integrate OpenGL with the ArcObject "dockable window", &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the challenges to doing this seem a little greater than we had first imagined.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Our OpenGL draw code was greatly simplified and in-lined directly into the class itself that extends &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the ArcObject "dockable window."&amp;nbsp; For those whom it might help to understand this distinction, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;formerly our setup was a .Net UserControl containing a Panel object for which a &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;System.Drawing.Graphics object was created and from that the device context ("dc") for OpenGL &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;obtained from it via GetHdc().&amp;nbsp; This control was then pasted into the ArcObject dockable window &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;control class, itself a subclass of UserControl.&amp;nbsp; Now, instead, the device context is obtained directly &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;in said dockable window class that Implements IDockableWindowDef so that the one unified class &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;now contains the OpenGL code in-lined within it.&amp;nbsp; The device context is obtained as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;dc = User.GetDC(Me.Handle)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For utmost simplicity for subsequent drawing, the overridden OnPaint method now merely &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1) activates the rendering context (rc) with Tao.Platform.Windows.Wgl.wglMakeCurrent(dc, rc), where rc was created in the usual OpenGL way using dc&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) sets the OpenGL viewport to be the extents of the Width and Height of the dockable window&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3) sets the glClearColor to green &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4) then just issues glClear.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If all is as it should be, this new setup described should paint the dockable window green.&amp;nbsp; And &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the dockable window should remain green permanently as long as it is visible.&amp;nbsp; What we actually &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;see is as follows.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When we first show the dockable window it is green.&amp;nbsp; If the dockable window is floating and not &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;docked, as happens to be the case when we first create it, any interaction at all whatsoever with &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the main ArcMap application window causes the green dockable window to turn white.&amp;nbsp; This means &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;that in response to this user interaction event, OpenGL drawing suddenly does not work in the &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;undocked dockable window.&amp;nbsp; The same is true when clicking on other application windows that are &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;neither ArcMap nor this new dockable window--the dockable window loses the OpenGL rendering &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and "whites-out" as though not drawn.&amp;nbsp; However our undocked dockable window lost the OpenGL, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;it can be made green (i.e., to be drawn complete with OpenGL rendering again) subsequently by &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;interacting with it.&amp;nbsp; But going back and interacting with the main window or outside of the ArcMap &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;process windows always causes the same behavior of the OpenGL in the undocked dockable &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;window to stop being drawn.&amp;nbsp; For clarity, let us call this Issue #1.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Question regarding Issue #1:&amp;nbsp; Is there perhaps a snag with the main ArcMap application window &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;taking and not relinquishing the device context, and if so any workaround to allow context to be &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;shared when utilizing an Arc dockable window?&amp;nbsp; [Note:&amp;nbsp; I am relatively new both to Arc and OpenGL &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;low-level programming, so any specific pointers are welcome especially if there is something obvious &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;being overlooked here which there may well be.]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Secondly, Issue #2:&amp;nbsp; When the dockable window is not docked, resizes of it also cause the OpenGL &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;to flicker as noted in my original post.&amp;nbsp; Let us refer to this as Issue #2, which may or may not be &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;related to Issue #1.&amp;nbsp; We had a notion to work around this Issue #2 by causing Paint to happen &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;only upon ResizeEnd if posslbe, but this seems not possible because the ResizeEnd event is &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;unavailable to a mere UserControl--it looks only to be available to a Form object.&amp;nbsp; The only other &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;suggested workaround that we found (on older Forms programming message boards) was perhaps &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;to use the Application.Idle event somehow but this seems error-prone, cumbersome, and possibly &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;wasteful besides that it might be more relevant only for older Frameworks and most of all, we don't &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;see how exactly to do this within an ArcMap extension.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;All of this being said, when the dockable window is docked in the main application window, Issues #1 &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and #2 go away completely.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As an alternative, we have not yet tried to load our plain (i.e., non-dockable) Form instead as &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;opposed to one of these "dockable windows."&amp;nbsp; Using the dockable window option seemed most &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;desirable because we already have several such windows all with related integrated functionality &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;that we must manage within our extension and did not want to add yet another that must float apart &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from the rest.&amp;nbsp; Ideally, we also may wish to permit a user of our extension to add more than one &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;instance of this OpenGL window, but only if we can get one of them to function properly to be sure.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks very much ahead for any assistance.&amp;nbsp; As you can see, we have a lot of investigation &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;invested in finding a good solution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Brad&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Aug 2013 18:31:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/opengl-in-its-own-window-within-an-arcmap/m-p/32306#M839</guid>
      <dc:creator>BradWind</dc:creator>
      <dc:date>2013-08-12T18:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: OpenGL in its own window within an ArcMap extension</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/opengl-in-its-own-window-within-an-arcmap/m-p/32307#M840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Just a quick update on the progress with our OpenGL ArcMap extension:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Whatever the OpenGL draw issue(s) with the ArcObject "dockable window" may be, they do not affect a regular Windows Form at all.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Even in the same process, if we put the OpenGL viewport on a regular form and have ArcMap show it (instead of putting the OpenGL in the ArcObject "dockable window") the OpenGL drawing in our new Windows form works beautifully.&amp;nbsp; No disappearing viewport, and no flicker.&amp;nbsp; We can call it from ArcMap in the same process.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We're 90% of the way there, except that we still would prefer the integrated dockable functionality if possible.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So the problem with the dockable windows and OpenGL either is *not* the feared issue of a potential tug-of-war between ArcMap&amp;lt;--&amp;gt;Our-extension over the OpenGL context; *or* else ArcMap is placing the extension-as-Form in its own thread for some reason, whereas utilizing the "dockable window" for the container causes the execution of drawing to exist in the main thread where presumably ArcMap has "dibs" on the OpenGL context.&amp;nbsp; Or perhaps it is something else entirely and the "dockable window" simply does not work well with OpenGL for (an)other reason(s)?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can anyone from ESRI please comment?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Aug 2013 20:23:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/opengl-in-its-own-window-within-an-arcmap/m-p/32307#M840</guid>
      <dc:creator>BradWind</dc:creator>
      <dc:date>2013-08-16T20:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: OpenGL in its own window within an ArcMap extension</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/opengl-in-its-own-window-within-an-arcmap/m-p/32308#M841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You might get more of a response from esri by going to tech support...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I suspect it is the drawing events being handled by ArcMap in a dock window which doesn't happen in a simple form.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 12:46:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/opengl-in-its-own-window-within-an-arcmap/m-p/32308#M841</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2013-08-19T12:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: OpenGL in its own window within an ArcMap extension</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/opengl-in-its-own-window-within-an-arcmap/m-p/32309#M842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm having exactly the same issue. &lt;A href="https://community.esri.com/migrated-users/38892"&gt;Brad Wind&lt;/A&gt;, did ESRI gave you an answer or could you solve by yourself?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Dec 2015 21:15:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/opengl-in-its-own-window-within-an-arcmap/m-p/32309#M842</guid>
      <dc:creator>aricraimundo</dc:creator>
      <dc:date>2015-12-01T21:15:49Z</dc:date>
    </item>
  </channel>
</rss>

