<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2600.0" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi all,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> I did a little class that open
an stl file, the construction of this classe set all parameters to see a blue
background and gouraud shaded object.</FONT></DIV>
<DIV><FONT face=Arial size=2> I instantiate my class on
WM_CREATE funcion of visual c++ wizard.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> Until now all works fine, but
when I try change background color through a method that I implemented, I
always recieve a error message saying the memory can't be read, acess
violation.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> What is wrong ?</FONT></DIV>
<DIV><FONT face=Arial size=2> Can't I acess a RenderWindow
object method after it has being created ?</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> Look a fragment of my
code:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>
<DIV><FONT face=Arial size=2><STRONG>method to change background
color:</STRONG></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><EM> void
CVTKStlViewer::BackgroundColor(COLORREF
newColor)<BR>{<BR> <BR> ren->SetBackground(GetRValue(newColor),GetGValue(newColor),GetBValue(newColor)); </EM><STRONG>//
this line is the
problem</STRONG><BR><EM> iren->Render();</EM></FONT></DIV>
<DIV><EM></EM> </DIV>
<DIV><FONT face=Arial size=2><EM>}</EM></FONT></DIV>
<DIV><FONT face=Arial size=2>
</FONT></DIV><STRONG>constructor:</STRONG></FONT></DIV>
<DIV><FONT face=Arial size=2>CVTKStlViewer::CVTKStlViewer(HWND
childview)<BR>{<BR> BkgColor = RGB(0,0,1);<BR> ObjColor =
RGB(1,0.5,0);<BR> </FONT></DIV>
<DIV> </DIV><FONT face=Arial size=2>
<DIV><BR> // create a rendering window and renderer<BR> vtkRenderer
*ren = vtkRenderer::New();<BR> vtkRenderWindow *renWindow =
vtkRenderWindow::New();<BR>
renWindow->AddRenderer(ren);<BR> renWindow->SetParentId(childview);<BR> renWindow->SetSize(
800, 600 );</DIV>
<DIV> </DIV>
<DIV> iren =
vtkRenderWindowInteractor::New();<BR> vtkInteractorStyleTrackballCamera
*TrackballCameraStyle = vtkInteractorStyleTrackballCamera::New();</DIV>
<DIV> </DIV>
<DIV> iren->SetInteractorStyle
(TrackballCameraStyle);<BR> iren->SetRenderWindow(renWindow);</DIV>
<DIV> </DIV>
<DIV> sr = vtkSTLReader::New();<BR> sr->SetFileName
("c:/vtk-src-windows/vtkData/cow.stl");</DIV>
<DIV> </DIV>
<DIV> vtkPolyDataNormals *pNormals =
vtkPolyDataNormals::New();<BR> pNormals->SetFeatureAngle
(80);<BR> pNormals->SetInput(sr->GetOutput());</DIV>
<DIV> </DIV>
<DIV> stlMapper =
vtkPolyDataMapper::New();<BR> stlMapper->SetInput(pNormals->GetOutput());</DIV>
<DIV> </DIV>
<DIV> stlActor =
vtkLODActor::New();<BR> stlActor->SetMapper(stlMapper);<BR> stlActor->GetProperty()->SetColor(GetRValue(ObjColor),GetGValue(ObjColor),GetBValue(ObjColor));</DIV>
<DIV> </DIV>
<DIV><BR> stlActor->GetProperty()->SetInterpolationToGouraud();</DIV>
<DIV> </DIV>
<DIV> ren->AddActor(stlActor);<BR> ren->SetBackground(GetRValue(BkgColor),GetGValue(BkgColor),GetBValue(BkgColor));</DIV>
<DIV> </DIV>
<DIV> // draw the resulting scene<BR> renWindow->Render();</DIV>
<DIV> </DIV>
<DIV>}</FONT></DIV></BODY></HTML>