<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 <GL/glut.h></span>
<span>#else</span>
<span>#include <glut.h></span>
<span>#endif</span>
<span>#include "vtkConeSource.h"</span>
<span>#include "vtkPolyDataMapper.h"</span>
<span>#include "vtkRenderWindow.h"</span>
<span>#include "vtkCamera.h"</span>
<span>#include "vtkActor.h"</span>
<span>#include "vtkRenderer.h"</span>
<span>#include "vtkNew.h"</span>
vtkNew<span><</span>vtkRenderer<span>></span> ren<span>;</span>
vtkNew<span><</span>vtkRenderWindow<span>></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>></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>></span>Render<span>(</span><span>)</span><span>;</span>
ren<span>-</span><span>></span>GetActiveCamera<span>(</span><span>)</span><span>-</span><span>></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>&</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>"VTK-GLUT Example"</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><</span>vtkConeSource<span>></span> cone<span>;</span>
vtkNew<span><</span>vtkPolyDataMapper<span>></span> coneMapper<span>;</span>
coneMapper<span>-</span><span>></span>SetInputConnection<span>(</span> cone<span>-</span><span>></span>GetOutputPort<span>(</span><span>)</span> <span>)</span><span>;</span>
vtkNew<span><</span>vtkActor<span>></span> coneActor<span>;</span>
coneActor<span>-</span><span>></span>SetMapper<span>(</span> coneMapper.<span>GetPointer</span><span>(</span><span>)</span> <span>)</span><span>;</span>
ren<span>-</span><span>></span>AddActor<span>(</span> coneActor.<span>GetPointer</span><span>(</span><span>)</span> <span>)</span><span>;</span>
renWin<span>-</span><span>></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>></span>InitializeFromCurrentContext<span>(</span><span>)</span><span>;</span>
<span>// Let'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>