<div dir="ltr">>> As far as I can tell your code at every paint event creates pipeline then deletes it.<div class=""><div id=":32i" class="" tabindex="0"><img class="" src="https://mail.google.com/mail/images/cleardot.gif"></div>
<div id=":32i" class="" tabindex="0">And that does mean that there is nothing visually happens beside time consuming operations which allocate memory, create child window, draw in it, then delete everything what just was done and return to native pain event .</div>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 23, 2013 at 10:43 AM, Alex Malyushytskyy <span dir="ltr"><<a href="mailto:alexmalvtk@gmail.com" target="_blank">alexmalvtk@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>You will have more chances to get help if you post/reply to mailing list, so I am forwarding this to it.<br>
</div>As for your problem, look at the code I recommended to look above.<br></div><div>
</div><div>As far as I can tell your code at every paint event creates pipeline then deletes it.<span class="HOEnZb"><font color="#888888"><br></font></span></div></div><span class="HOEnZb"><font color="#888888"><div><br>
</div><div><br></div>Alex<br></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 22, 2013 at 9:16 PM, Le Minh Nhat <span dir="ltr"><<a href="mailto:nhatleminh10@gmail.com" target="_blank">nhatleminh10@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hi Alex,<br></div>Yes, I tried what u said adding the function SetParentId(handler). However, when I ran the program, it was hang and nothing happened! Do u have any idea? Is it because of the place I called the function drawSphere(handler) in the WinProc?<br>
</div>Looking forward to hearing from you!<br></div>Thanks.<br><br></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 23, 2013 at 2:06 AM, Alex Malyushytskyy <span dir="ltr"><<a href="mailto:alexmalvtk@gmail.com" target="_blank">alexmalvtk@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>try add<br><br>renWin->SetParentId(handler);<br><br></div>to<br><div>drawSphere(HWND handler)<br>
<br></div><div>vtk source has Win32Cone.cxx example which might be useful<br><br></div><div>Alex<br></div>
<div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div>On Wed, May 22, 2013 at 2:36 AM, Le Minh Nhat <span dir="ltr"><<a href="mailto:nhatleminh10@gmail.com" target="_blank">nhatleminh10@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><div><div><div><div>Hi everyone,<br></div>I am quite new to Vtk, and I have tried to create a sphere using Vtk. However, the rendering window is separated from my existing window. Here is my source code:<br>
<br>#include <windows.h><br><br>#include "vtkSphereSource.h"<br>#include "vtkPolyDataMapper.h"<br>#include "vtkProperty.h"<br>#include "vtkActor.h"<br>#include "vtkRenderWindow.h"<br>
#include "vtkRenderer.h"<br>#include "vtkRenderWindowInteractor.h"<br>#include "vtkWin32OpenGLRenderWindow.h"<br>#include "vtkNew.h"<br>#include "vtkCamera.h"<br>//<br>//<br>
void drawSphere(HWND handler)<br>{<br> // create sphere geometry<br> vtkSphereSource *sphere = vtkSphereSource::New();<br> sphere->SetRadius(1.0);<br> sphere->SetThetaResolution(18);<br> sphere->SetPhiResolution(18);<br>
<br> // map to graphics library<br> vtkPolyDataMapper *map = vtkPolyDataMapper::New();<br> map->SetInput(sphere->GetOutput());<br><br> // actor coordinates geometry, properties, transformation<br> vtkActor *aSphere = vtkActor::New();<br>
aSphere->SetMapper(map);<br> aSphere->GetProperty()->SetColor(0,0,1); // sphere color blue<br><br> // a renderer and render window<br> vtkRenderer *ren1 = vtkRenderer::New();<br> vtkRenderWindow *renWin = vtkRenderWindow::New();<br>
<br> renWin->AddRenderer(ren1);<br><br> // an interactor<br> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<br> iren->SetRenderWindow(renWin);<br><br> // add the actor to the scene<br> ren1->AddActor(aSphere);<br>
ren1->SetBackground(1,1,1); // Background color white<br><br> // render an image (lights and cameras are created automatically)<br> //renWin->InitializeFromCurrentContext();<br> renWin->Render();<br> <br><br>
// begin mouse interaction<br> iren->Start();<br><br> // release memory and return<br> sphere->Delete();<br> map->Delete();<br> aSphere->Delete();<br> ren1->Delete();<br> renWin->Delete();<br> iren->Delete();<br>
<br>}<br><br>LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)<br>{<br> switch(msg)<br> {<br> <br><br> case WM_CLOSE:<br> DestroyWindow(hwnd);<br> break;<br>
<br> case WM_DESTROY:<br> PostQuitMessage(0);<br> break;<br><br> case WM_PAINT:<br> drawSphere(hwnd);<br> break;<br><br> default:<br> return DefWindowProc(hwnd, msg, wParam, lParam);<br>
}<br> return 0;<br>}<br><br>int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)<br>{<br> WNDCLASSEX wc;<br> HWND hwnd;<br> MSG Msg;<br><br> wc.cbSize = sizeof(WNDCLASSEX);<br>
wc.style = 0;<br> wc.lpfnWndProc = WndProc;<br> wc.cbClsExtra = 0;<br> wc.cbWndExtra = 0;<br> wc.hInstance = hInstance;<br> wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);<br>
wc.hCursor = LoadCursor(NULL, IDC_ARROW);<br> wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);<br> wc.lpszMenuName = NULL;<br> wc.lpszClassName = "mySphere";<br> wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);<br>
<br> if(!RegisterClassEx(&wc))<br> {<br> MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);<br> return 0;<br> }<br><br> hwnd = CreateWindowEx(<br>
WS_EX_CLIENTEDGE,<br> "mySphere",<br> "Sphere",<br> WS_OVERLAPPEDWINDOW,<br> CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,<br> NULL, NULL, hInstance, NULL);<br><br>
if(hwnd == NULL)<br> {<br> MessageBox(NULL, "Window Creation Failed!", "Error!",<br> MB_ICONEXCLAMATION | MB_OK);<br> return 0;<br> }<br><br> ShowWindow(hwnd, nCmdShow);<br>
UpdateWindow(hwnd);<br><br> while(GetMessage(&Msg, NULL, 0, 0) > 0)<br> {<br> TranslateMessage(&Msg);<br> DispatchMessage(&Msg);<br> }<br> return Msg.wParam;<br>}<br><br></div>
Anyone has any idea how to set the rendering window and the existing window to be one! Any response will be appreciated.<br></div>Best regards,<br></div>Bent<br></div>
<br></div></div>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>