31
31
#include < cassert>
32
32
#include < sstream>
33
33
34
- #ifdef ANDROID
34
+ #if defined(__ANDROID__) || defined( ANDROID)
35
35
#include < android/native_window.h>
36
+ #include < vtkAndroidRenderWindowInteractor.h>
36
37
#endif
37
38
38
39
namespace
@@ -139,7 +140,7 @@ struct vtkEGLRenderWindow::vtkInternals
139
140
vtkEGLRenderWindow::vtkEGLRenderWindow ()
140
141
{
141
142
this ->Internals = new vtkInternals ();
142
- this ->OwnWindow = 1 ;
143
+ this ->OwnWindow = true ;
143
144
this ->ScreenSize [0 ] = 1920 ;
144
145
this ->ScreenSize [1 ] = 1080 ;
145
146
@@ -338,7 +339,7 @@ void vtkEGLRenderWindow::ResizeWindow(int width, int height)
338
339
*/
339
340
EGLint surfaceType, clientAPI;
340
341
const EGLint* contextAttribs;
341
- #ifdef ANDROID
342
+ #if defined(__ANDROID__) || defined( ANDROID)
342
343
surfaceType = EGL_WINDOW_BIT;
343
344
clientAPI = EGL_OPENGL_ES2_BIT;
344
345
const EGLint contextES2[] = { EGL_CONTEXT_CLIENT_VERSION, 2 , EGL_NONE };
@@ -354,7 +355,7 @@ void vtkEGLRenderWindow::ResizeWindow(int width, int height)
354
355
EGL_RED_SIZE, 8 , EGL_ALPHA_SIZE, 8 , EGL_DEPTH_SIZE, 8 , EGL_RENDERABLE_TYPE, clientAPI,
355
356
EGL_NONE };
356
357
357
- #if !defined(ANDROID)
358
+ #if !defined(__ANDROID__) && !defined( ANDROID)
358
359
const EGLint surface_attribs[] = { EGL_WIDTH, width, EGL_HEIGHT, height, EGL_NONE };
359
360
#endif
360
361
@@ -375,7 +376,7 @@ void vtkEGLRenderWindow::ResizeWindow(int width, int height)
375
376
376
377
EGLint major = 0 , minor = 0 ;
377
378
vtkEGLDisplayInitializationHelper::Initialize (impl->Display , &major, &minor);
378
- #if !defined(ANDROID)
379
+ #if !defined(__ANDROID__) && !defined( ANDROID)
379
380
if (major <= 1 && minor < 4 )
380
381
{
381
382
vtkErrorMacro (" Only EGL 1.4 and greater allows OpenGL as client API. "
@@ -396,7 +397,7 @@ void vtkEGLRenderWindow::ResizeWindow(int width, int height)
396
397
return ;
397
398
}
398
399
399
- #ifdef ANDROID
400
+ #if defined(__ANDROID__) || defined( ANDROID)
400
401
EGLint format = 0 ;
401
402
/* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
402
403
* guaranteed to be accepted by ANativeWindow_setBuffersGeometry().
@@ -417,13 +418,22 @@ void vtkEGLRenderWindow::ResizeWindow(int width, int height)
417
418
eglDestroySurface (impl->Display , impl->Surface );
418
419
}
419
420
420
- #ifdef ANDROID
421
+ #if defined(__ANDROID__) || defined( ANDROID)
421
422
impl->Surface = eglCreateWindowSurface (impl->Display , config, impl->Window , nullptr );
422
423
#else
423
424
impl->Surface = eglCreatePbufferSurface (impl->Display , config, surface_attribs);
424
425
#endif
425
426
this ->Mapped = this ->ShowWindow ;
426
- this ->OwnWindow = 1 ;
427
+ this ->OwnWindow = true ;
428
+
429
+ #if defined(__ANDROID__) || defined(ANDROID)
430
+ vtkAndroidRenderWindowInteractor* interactor =
431
+ vtkAndroidRenderWindowInteractor::SafeDownCast (this ->Interactor );
432
+ if (interactor)
433
+ {
434
+ interactor->SetOwnWindow (this ->OwnWindow );
435
+ }
436
+ #endif
427
437
428
438
this ->MakeCurrent ();
429
439
@@ -485,9 +495,18 @@ void vtkEGLRenderWindow::WindowInitialize(void)
485
495
this ->OpenGLInit ();
486
496
487
497
// for offscreen EGL always turn on point sprites
488
- #if !defined(ANDROID) && defined(GL_POINT_SPRITE)
498
+ #if !defined(__ANDROID__) && !defined( ANDROID) && defined(GL_POINT_SPRITE)
489
499
glEnable (GL_POINT_SPRITE);
490
500
#endif
501
+
502
+ #if defined(__ANDROID__) || defined(ANDROID)
503
+ vtkAndroidRenderWindowInteractor* interactor =
504
+ vtkAndroidRenderWindowInteractor::SafeDownCast (this ->Interactor );
505
+ if (interactor)
506
+ {
507
+ interactor->SetOwnWindow (this ->OwnWindow );
508
+ }
509
+ #endif
491
510
}
492
511
493
512
// Initialize the rendering window.
@@ -608,8 +627,17 @@ void vtkEGLRenderWindow::SetPosition(int x, int y)
608
627
// Set this RenderWindow to a pre-existing window.
609
628
void vtkEGLRenderWindow::SetWindowInfo (const char *)
610
629
{
611
- this ->OwnWindow = 0 ;
612
630
this ->Mapped = 1 ;
631
+ this ->OwnWindow = false ;
632
+
633
+ #if defined(__ANDROID__) || defined(ANDROID)
634
+ vtkAndroidRenderWindowInteractor* interactor =
635
+ vtkAndroidRenderWindowInteractor::SafeDownCast (this ->Interactor );
636
+ if (interactor)
637
+ {
638
+ interactor->SetOwnWindow (this ->OwnWindow );
639
+ }
640
+ #endif
613
641
}
614
642
615
643
void vtkEGLRenderWindow::SetWindowName (const char * name)
0 commit comments