[prev in list] [next in list] [prev in thread] [next in thread]
List: insight-users
Subject: [Insight-users] renWin->InitializeFromCurrentContext() ;
From: yas --- <yas2349 () gmail ! com>
Date: 2013-02-27 9:40:48
Message-ID: CAL3mhwvfMPsiGnZhLyXhV0WYhAfzmWqnrUaijaoGVVzqzAHyEA () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
I write follow code,but renwin hast not member InitializeFromCurrentContext()?
How to solve this problem,and how to use opengl in vtk?
#ifndef __APPLE_CC__#include <GL/glut.h>#else#include
<glut.h>#endif#include "vtkConeSource.h"#include
"vtkPolyDataMapper.h"#include "vtkRenderWindow.h"#include
"vtkCamera.h"#include "vtkActor.h"#include "vtkRenderer.h"#include
"vtkNew.h"
vtkNew<vtkRenderer> ren;
vtkNew<vtkRenderWindow> renWin;
void Reshape( int width, int height ){
renWin->SetSize( width, height );}
void Draw(){
renWin->Render();
ren->GetActiveCamera()->Azimuth( 1 );
glutPostRedisplay();}
int main( int argc, char **argv ){
// GLUT initialization
glutInit( &argc, argv );
glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH );
glutCreateWindow( "VTK-GLUT Example") ;
glutReshapeFunc( Reshape );
glutDisplayFunc( Draw );
// Creation of a simple VTK pipeline
vtkNew<vtkConeSource> cone;
vtkNew<vtkPolyDataMapper> coneMapper;
coneMapper->SetInputConnection( cone->GetOutputPort() );
vtkNew<vtkActor> coneActor;
coneActor->SetMapper( coneMapper.GetPointer() );
ren->AddActor( coneActor.GetPointer() );
renWin->AddRenderer( ren.GetPointer() );
// Here is the trick: we ask the RenderWindow to join the current
OpenGL context created by GLUT
renWin->InitializeFromCurrentContext();
// Let's start the main GLUT rendering loop
glutMainLoop();
return EXIT_SUCCESS;}
[Attachment #5 (text/html)]
<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>
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php
Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic