/* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include "vtkNew.h" #include "vtkActor.h" #include "vtkCamera.h" #include "vtkConeSource.h" #include "vtkDebugLeaks.h" #include "vtkGlyph3D.h" #include "vtkPolyData.h" #include "vtkPolyDataMapper.h" #include "vtkRenderWindow.h" #include "vtkRenderer.h" #include "vtkSphereSource.h" #include "vtkTextActor.h" #include "vtkTextProperty.h" #include "vtkAndroidRenderWindowInteractor.h" #include #include #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "NativeVTK", __VA_ARGS__)) #define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "NativeVTK", __VA_ARGS__)) /** * This is the main entry point of a native application that is using * android_native_app_glue. It runs in its own thread, with its own * event loop for receiving input events and doing other things. */ void android_main(struct android_app* state) { // Make sure glue isn't stripped. app_dummy(); vtkNew renWin; vtkNew renderer; vtkNew iren; // this line is key, it provides the android // state to VTK iren->SetAndroidApplication(state); renWin->AddRenderer(renderer.Get()); iren->SetRenderWindow(renWin.Get()); vtkNew sphere; sphere->SetThetaResolution(8); sphere->SetPhiResolution(8); vtkNew sphereMapper; sphereMapper->SetInputConnection(sphere->GetOutputPort()); vtkNew sphereActor; sphereActor->SetMapper(sphereMapper.Get()); vtkNew cone; cone->SetResolution(6); vtkNew glyph; glyph->SetInputConnection(sphere->GetOutputPort()); glyph->SetSourceConnection(cone->GetOutputPort()); glyph->SetVectorModeToUseNormal(); glyph->SetScaleModeToScaleByVector(); glyph->SetScaleFactor(0.25); vtkNew spikeMapper; spikeMapper->SetInputConnection(glyph->GetOutputPort()); vtkNew spikeActor; spikeActor->SetMapper(spikeMapper.Get()); renderer->AddActor(sphereActor.Get()); renderer->AddActor(spikeActor.Get()); renderer->SetBackground(0.4,0.5,0.6); vtkNew ta; ta->SetInput("Droids Rock"); ta->GetTextProperty()->SetColor( 0.5, 1.0, 0.0 ); ta->SetDisplayPosition(50,50); ta->GetTextProperty()->SetFontSize(32); renderer->AddActor(ta.Get()); renWin->Render(); iren->Start(); }