24 #include "vtkRenderWindow.h" 25 #include "vtkJavaUtil.h" 31 jlong cptr_to_jlong(
void* p)
34 memset(&pointer, 0,
sizeof(jlong));
35 memcpy(&pointer, &p,
sizeof(p));
39 extern "C" JNIEXPORT jlong JNICALL
40 Java_tools_viewer_user_Screen_GetDisplay(JNIEnv* xenv,
46 awt.version = JAWT_VERSION_1_3;
47 if(JAWT_GetAWT(xenv, &awt) == JNI_FALSE)
54 JAWT_DrawingSurface* ds = awt.GetDrawingSurface(xenv, xcanvas);
57 std::cout <<
"Error getting drawing surface" << std::endl;
63 jint lock = ds->Lock(ds)
65 if((lock & JAWT_LOCK_ERROR) != 0)
67 std::cout <<
"Error locking drawing surface" << std::endl;
68 awt.FreeDrawingSurface(ds);
74 JAWT_DrawingSurfaceInfo* dsi = ds->GetDrawingSurfaceInfo(ds);
77 std::cout <<
"Error getting surface info" << std::endl;
79 awt.FreeDrawingSurface(ds);
83 #if defined(_WIN32) || defined(WIN32) 85 JAWT_Win32DrawingSurfaceInfo* dsi_win =
86 (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
90 jlong result = cptr_to_jlong(dsi_win->hwnd);
94 JAWT_X11DrawingSurfaceInfo* dsi_x11 =
95 (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
99 jlong result = cptr_to_jlong(dsi_x11->display);
105 ds->FreeDrawingSurfaceInfo(dsi);
113 awt.FreeDrawingSurface(ds);
119 extern "C" JNIEXPORT jlong JNICALL
120 Java_tools_viewer_user_Screen_GetDrawable(JNIEnv* xenv,
126 awt.version = JAWT_VERSION_1_3;
127 if(JAWT_GetAWT(xenv, &awt) == JNI_FALSE)
134 JAWT_DrawingSurface* ds = awt.GetDrawingSurface(xenv, xcanvas);
142 jint lock = ds->Lock(ds)
144 if((lock & JAWT_LOCK_ERROR) != 0)
146 awt.FreeDrawingSurface(ds);
152 JAWT_DrawingSurfaceInfo* dsi = ds->GetDrawingSurfaceInfo(ds);
155 cout <<
"Error getting surface info" << endl;
157 awt.FreeDrawingSurface(ds);
161 #if defined(_WIN32) || defined(WIN32) 163 JAWT_Win32DrawingSurfaceInfo* dsi_win =
164 (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
165 jlong result = (jlong)dsi_win->hwnd;
169 JAWT_X11DrawingSurfaceInfo* dsi_x11 =
170 (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
173 jlong result = dsi_x11->drawable;
179 ds->FreeDrawingSurfaceInfo(dsi);
187 awt.FreeDrawingSurface(ds);
201 extern "C" JNIEXPORT jlong JNICALL
202 Java_tools_viewer_user_Screen_Lock(JNIEnv* xenv,
208 awt.version = JAWT_VERSION_1_3;
210 if(JAWT_GetAWT(xenv, &awt) == JNI_FALSE)
217 JAWT_DrawingSurface* ds = awt.GetDrawingSurface(xenv, xcanvas);
226 jint lock = ds->Lock(ds)
229 if((lock & JAWT_LOCK_ERROR) != 0)
231 awt.FreeDrawingSurface(ds);
242 extern "C" JNIEXPORT jint JNICALL
243 Java_tools_viewer_user_Screen_UnLock(JNIEnv* xenv,
249 awt.version = JAWT_VERSION_1_3;
251 if(JAWT_GetAWT(xenv, &awt) == JNI_FALSE)
258 JAWT_DrawingSurface* ds = awt.GetDrawingSurface(xenv, xcanvas);
271 awt.FreeDrawingSurface(ds);