<br><div class="gmail_quote"><pre><span>I write follow code,but renwin hast not member InitializeFromCurrentContext()?<br>How to solve this problem,and how to use opengl in vtk?</span></pre><br><br><div dir="ltr" style="text-align:left">
<div><pre><span>#ifndef __APPLE_CC__</span>
<span>#include &lt;GL/glut.h&gt;</span>
<span>#else</span>
<span>#include &lt;glut.h&gt;</span>
<span>#endif</span>
<span>#include &quot;vtkConeSource.h&quot;</span>
<span>#include &quot;vtkPolyDataMapper.h&quot;</span>
<span>#include &quot;vtkRenderWindow.h&quot;</span>
<span>#include &quot;vtkCamera.h&quot;</span>
<span>#include &quot;vtkActor.h&quot;</span>
<span>#include &quot;vtkRenderer.h&quot;</span>
<span>#include &quot;vtkNew.h&quot;</span>
 
vtkNew<span>&lt;</span>vtkRenderer<span>&gt;</span> ren<span>;</span>
vtkNew<span>&lt;</span>vtkRenderWindow<span>&gt;</span> renWin<span>;</span>
 
<span>void</span> Reshape<span>(</span> <span>int</span> width, <span>int</span> height <span>)</span>
<span>{</span>          
  renWin<span>-</span><span>&gt;</span>SetSize<span>(</span> width, height <span>)</span><span>;</span>
<span>}</span>          
 
<span>void</span> Draw<span>(</span><span>)</span>
<span>{</span>         
  renWin<span>-</span><span>&gt;</span>Render<span>(</span><span>)</span><span>;</span>
  ren<span>-</span><span>&gt;</span>GetActiveCamera<span>(</span><span>)</span><span>-</span><span>&gt;</span>Azimuth<span>(</span> <span>1</span> <span>)</span><span>;</span>
  glutPostRedisplay<span>(</span><span>)</span><span>;</span>
<span>}</span>
 <span><br>int</span> main<span>(</span> <span>int</span> argc, <span>char</span> <span>**</span>argv <span>)</span>
<span>{</span>
  <span>// GLUT initialization</span>
  glutInit<span>(</span> <span>&amp;</span>argc, argv <span>)</span><span>;</span>
  glutInitDisplayMode<span>(</span> GLUT_RGBA <span>|</span> GLUT_DOUBLE <span>|</span> GLUT_DEPTH <span>)</span><span>;</span>
  glutCreateWindow<span>(</span> <span>&quot;VTK-GLUT Example&quot;</span><span>)</span> <span>;</span>
  glutReshapeFunc<span>(</span> Reshape <span>)</span><span>;</span>
  glutDisplayFunc<span>(</span> Draw <span>)</span><span>;</span>
 
  <span>// Creation of a simple VTK pipeline</span>
  vtkNew<span>&lt;</span>vtkConeSource<span>&gt;</span> cone<span>;</span>
 
  vtkNew<span>&lt;</span>vtkPolyDataMapper<span>&gt;</span> coneMapper<span>;</span>
  coneMapper<span>-</span><span>&gt;</span>SetInputConnection<span>(</span> cone<span>-</span><span>&gt;</span>GetOutputPort<span>(</span><span>)</span> <span>)</span><span>;</span>
 
  vtkNew<span>&lt;</span>vtkActor<span>&gt;</span> coneActor<span>;</span>
  coneActor<span>-</span><span>&gt;</span>SetMapper<span>(</span> coneMapper.<span>GetPointer</span><span>(</span><span>)</span> <span>)</span><span>;</span>
 
  ren<span>-</span><span>&gt;</span>AddActor<span>(</span> coneActor.<span>GetPointer</span><span>(</span><span>)</span> <span>)</span><span>;</span>
  renWin<span>-</span><span>&gt;</span>AddRenderer<span>(</span> ren.<span>GetPointer</span><span>(</span><span>)</span> <span>)</span><span>;</span>
 
  <span>// Here is the trick: we ask the RenderWindow to join the current OpenGL context created by GLUT</span>
  renWin<span>-</span><span>&gt;</span>InitializeFromCurrentContext<span>(</span><span>)</span><span>;</span>
 
  <span>// Let&#39;s start the main GLUT rendering loop</span>
  glutMainLoop<span>(</span><span>)</span><span>;</span>
 
  <span>return</span> <span>EXIT_SUCCESS</span><span>;</span>
<span>}</span></pre></div></div>
</div><br>