aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt
Commit message (Collapse)AuthorAgeFilesLines
* Fix Bug 879 Regression (2/2) - NewtCanvasAWT.FocusAction must take focus ↵Sven Gothel2013-11-181-3/+11
| | | | | | | | | when in offscreen-mode (OSX/CALayer) NewtCanvasAWT.FocusAction must take focus when in offscreen-mode (OSX/CALayer) since the NEWT window _is_ offscreen (no input events) and AWT events are translated to NEWT. Regression of commit 0be87f241c0f0b2f5881d9a602ce12378b8e453d
* Nativewindow/NEWT: Fix C Return StatementSven Gothel2013-11-171-1/+2
|
* Fix Bug 879 - Threads deadlock in native keyboardfocus calls made form ↵Sven Gothel2013-11-171-12/+11
| | | | | | | | | | | | | | | | | multiple threads; Fix Bug 892: Reduce Focus Hopping Since we manage focus key traversal ourselves w/o requiring the AWT component to have the focus[1], we simply can drop requesting the focus for 'focus hopping' NEWT -> AWT -> NEWT[2]. Further more, 'MenuSelectionManager.defaultManager().clearSelectedPath()' must be performed on AWT-EDT w/o blocking. Otherwise it may perform blocking tasks on AWT-EDT. [1] Commit cb7118fc875b6722803e4b11d5681671962a8d3a introduced function to query the next or previous 'to be focused' component: AWTMisc.getNextFocus(..) .. etc. [2] Focus hopping is also addressed in Bug 892
* Bug 903 - NEWT: Support 'Continue Drag on Exit'; Consistent Mouse ENTER/EXITSven Gothel2013-11-175-121/+257
| | | | | | | | | | | | | | | | | | | | | | | | | | | - Support 'Continue Drag on Exit' - Track dragging operation, allow exterior dragging - Hence track EXIT (see below) - Windows: - Capture mouse for exterior dragging - Only 'NewtWindows_trackPointerLeave' if 'entering' - Simplify touch: No 'inside' check - Not required. - Consistent Mouse ENTER/EXIT - Track ENTER/EXIT and synthesize if required, drop duplicate - OSX benefits, since it never produced ENTER/EXIT events - AWT (or other TK) translated events beahve equal now. - Required for EXIT event after ending exterior dragging and final RELEASE Tests: Passed unit tests 'junit.run.newt.event' on - GNU/Linux - Windows7 - OSX 10.7 Tested exterior tracking manually w/ NEWT TestGearsES2NEWT and TestGearsES2NewtCanvasAWT: - GNU/Linux - Windows7 (mouse) - Windows8.1 (touch) - OSX 10.7
* NEWT: Add more documentation to WindowImpl's doPointerEvent(..) and ↵Sven Gothel2013-11-131-9/+46
| | | | consumePointerEvent(..) impl. details
* Fix Bug 901 - NEWT: Lookup Windows 7 Touch Event Functions Dynamically to ↵Sven Gothel2013-11-101-5/+39
| | | | not break Windows < 7 Compatibility
* Android Newt[Debug|Version]Activity: Separate both activities (testing odd ↵Sven Gothel2013-11-073-86/+130
| | | | reusing of app)
* Android: Add NewtDebugActivitySven Gothel2013-11-074-49/+112
|
* Bug 894 - GLDrawableFactory* [dummy|offscreen] Surface creation w/ own ↵Sven Gothel2013-11-061-1/+0
| | | | device does _not_ require locking on global shared device.
* NEWT Window: Expose 'setVisible(boolean wait, boolean visible)' allowing ↵Sven Gothel2013-11-063-16/+33
| | | | applications to not block until window becomes visible.
* Bug 882 - Crash on OSX when closing NEWT window - Fix: Release NewtMacWindow ↵Sven Gothel2013-11-011-7/+21
| | | | | | | | | | manually in close0() Release NewtMacWindow manually in close0() - Mark [NewtMacWindow setReleasedWhenClosed: NO] in init0(..) - Release NewtMacWindow manually in close0(..) Check pointer args in close0(..)
* Bug 882 - Crash on OSX when closing NEWT window - Check JavaVM and JNIEnv ↵Sven Gothel2013-11-011-11/+43
| | | | handles before usage in NewtMacWindow (Not the culprit .. but more safe)
* Android NEWT.ScreenDriver MonitorSize: Use xdpi for for width (fix); Add ↵Sven Gothel2013-10-301-25/+35
| | | | DEBUG output.
* Bug 776 GLContext Sharing: Refine API for relaxed and lazy GLContext sharing ↵Sven Gothel2013-10-272-32/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ; Fix GLContext memory contract (volatile) (Unit test remarks see below) - Add shared GLContext queries - Refined GLContextShareSet: - Use IdentityHashMap since GLContext's can only be identical w/ same reference (footprint, performance) - Add API doc for clarification - Add methods: - ArrayList<GLContext> getCreatedShares(final GLContext context) - ArrayList<GLContext> getDestroyedShares(final GLContext context) - Use 'final' where possible - Add GLContext methods: - boolean isShared() - List<GLContext> getCreatedShares() - List<GLContext> getDestroyedShares() - Add GLSharedContextSetter interface defining setting a shared GLContext directly (GLContext) or via a GLAutoDrawable: - setSharedContext(GLContext) - setSharedAutoDrawable(GLAutoDrawable) Both cause initialization/creation of GLAutoDrawable's drawable/context to be postponed, if the shared GLContext is not yet created natively or the shared GLAutoDrawable's GLContext does not yet exist. Most of impl. resides in GLDrawableHelper Implemented in: - GLAutoDrawableBase, GLOffscreenAutoDrawable - GLWindow - AWT GLCanvas TODO: - GLJPanel - SWT GLCanvas - GLDrawableFactory: - Add 'GLOffscreenAutoDrawable createOffscreenAutoDrawable(..)' variant w/o passing the optional shared GLContext _and_ specifying lazy GLContext creation. This allows to benefit from GLSharedContextSetter contract. Lazy GLContext creation is performed at 2st display() call at the latest. All JOGL code and unit tests use this new method now. - Mark 'createOffscreenAutoDrawable(..)' w/ shared GLContext argument and immediate GLContext creation deprecated - shall be removed in 2.2.0 - Make reference to GLContext and it's native handle volatile Since we rely on the query 'GLContext.isCreated()' to properly allow GLAutoDrawable's to query whether a shared GLContext is natively created (already), the handle must be volatile since such query and the actual creation may operate on different threads. +++++ - Add/Refine shared GLContext unit tests demonstrating diff. sharing methods. All variants of using shared GLContext: com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBO* Most convenient way to share via setSharedAutoDrawable(GLAutoDrawable): com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2[NEWT|AWT]3 AWT use w/ JTabbedPane using setSharedAutoDrawable(GLAutoDrawable): com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextWithJTabbedPaneAWT
* PinchToZoomGesture: Add ctor arg 'allowMorePointer', should be false to be ↵v2.1.1Sven Gothel2013-10-191-5/+13
| | | | more stable (i.e. only 2 pointer pressed)
* jogl: avoid creating a second String object, one is enoughHarvey Harrison2013-10-181-1/+1
| | | | | | | One String is already being built, passing it to new String() is just wasteful as the temp String can be returned just as easily. Signed-off-by: Harvey Harrison <[email protected]>
* jogl: add missing @Override annotationsHarvey Harrison2013-10-1760-0/+288
| | | | Signed-off-by: Harvey Harrison <[email protected]>
* jogl: remove all trailing whitespaceHarvey Harrison2013-10-1792-2004/+2004
| | | | Signed-off-by: Harvey Harrison <[email protected]>
* MouseEvent: Clarify button-number and pointer-ID relation incl. case 'no ↵Sven Gothel2013-10-182-21/+76
| | | | | | | | | | button/pointer', i.e. button == 0, pointer-ID == -1 doPointerEvent: - allow id==-1 -> button==0 for no button, i.e. mouse move doMouseEvent: - keep button 0 value, i.e. map to pointer-ID -1
* AWTPrintLifecycle.setupPrint(..): Fix regression of commit ↵Sven Gothel2013-10-181-6/+8
| | | | | | | | | | | | a05b87a369441d9ef38f97929f866b3d4ced0e57: NULL printGLAD of GLCanvas and NewtCanvasAWT We have to pre-init printGLAD w/ current GLAD (similiar w/ GLJPanel). Also properly define reqNewGLAD: reqNewGLAD = !caps.getSampleBuffers() && ( reqNewGLADOnscrn || reqNewGLADSamples || reqNewGLADSize ); where '!caps.getSampleBuffers() && ( .. )' is due to Bug 830, swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX does not work.
* Bug 800: Windows 7 Touch Event Support for NEWT: Fix Focus and ↵Sven Gothel2013-10-171-51/+74
| | | | | | | | | | | | | LBUTTON[DOWN|UP] issues - w/ TOUCH, Win8 may steal focus (KILLFOCUS), quickly grab FOCUS again when on TOUCH operation - track 'touchDownLastUp', and don't act on LBUTTON[UP|DOWN] and MOUSEMOVE if just lifted last finger - don't use GetMessageExtraInfo() to distinguish MOUSE/TOUCH, simply use tracked touchDownCount - Also track mouseInside in TOUCH operation, i.e. true if _all_ fingers are inside, otherwise don't send TOUCH event
* WindowImpl: Fix DEBUG output's method name of doPointerEvent and ↵Sven Gothel2013-10-171-11/+11
| | | | consumePointerEvent
* Bug 800: Add Windows 7 Touch Event Support for NEWTSven Gothel2013-10-172-112/+368
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Native: - WindowUserData tracks: - window size - mouse inside - pointer touch-down count and flags whether multiple-touch is supported. - Suppress WM_*BUTTON* events if within TOUCH operations, e.g. fingers are pressed, or if event is determined as TOUCH (0 != GetMessageExtraInfo()) - MOUSEMOVE issues NewtWindows_trackPointerLeave(..) directly if no TOUCH operation is in process. Removes need for MouseListener on Java side. - TOUCH events are send as follows: - PRIMARY first - 1 MOVE 2nd (if not sent already) - UP/DOWN (if not sent already) We only send max. one MOVE event, since Win7 / Win8 assignes MOVE per default, even if no actual move happened. Hence a single MOVE event shall suffice and is compatible w/ e.g. Android (AFAIK). - TOUCH pointer names are mapped to consecutive IDs on the java side.
* WindowImpl.doPointerEvent(..) Simplify pointer name->ID mapping, fix DEBUG.Sven Gothel2013-10-171-5/+7
|
* Regression of commit a90bf31f8747dd38c61d518f8af4d4d4a64a8e90: ↵Sven Gothel2013-10-171-3/+3
| | | | | | 'consume<Type>Event(<Type>Event ..)' must be protected and non-final Overriding by impl. class allowed.
* NEWT Multiple-Pointer API: Use PointerType[] instead of ordinal int[], ↵Sven Gothel2013-10-172-46/+108
| | | | implementer can use PointerType.valuesOf(int[] ordinals) to convert. Enhanced API doc. Methods 'final'
* Refine Int -> Enum conversion (commit ↵Sven Gothel2013-10-171-5/+30
| | | | | | | 40863632d1428de015099b5967e5136425e99f25), throw IllegalArgumentException if ordinal is out-of-range. Add API doc. - FFMPEGNatives - MouseEvent.PointerType
* PinchToZoomGesture: Validate pointer-IDs, skip if invalid.Sven Gothel2013-10-171-24/+26
|
* NEWT PointerEvent: Unify event processing in new doPointerEvent(..) and ↵Sven Gothel2013-10-174-288/+297
| | | | | | | | | | | | | | | consumePointerEvent(..) - Unifies native mouse and Android's pointer event, ready for Win7 touch Unify event processing in new doPointerEvent(..), which is also invoked from doMouseEvent(..), and consumePointerEvent(). doPointerEvent(..): Validates and modifies event data and finally creates the event, where consumePointerEvent(..) calls gesture handlers and may synthesize events. Unifies native mouse and Android's pointer event, ready for Win7 touch. AndroidNewtEventFactory calls doPointerEvent(..) directly. Removed lots of duplicated pointer event handling code.
* Int -> Enum using EnumClass.values()[ordinal] instead of for-loop - ↵Sven Gothel2013-10-171-4/+14
| | | | FFMPEGNatives's Enums and new MouseEvent.PointerType.valueOf(int)
* MouseEvent: Clarify 'Multiple-Pointer' w/ button[mask] semantics, ; ↵Sven Gothel2013-10-173-35/+106
| | | | | | | | | | | | | | InputEvent: getButtonDownCount() and isAnyButtonDown(); - Clarify 'Multiple-Pointer' w/ button[mask] semantics - Pointer IDs start w/ 0 and are consecutive numbers. - 'button' == triggering pointer-ID - buttonMask in modifiers show pressed button _and_ pointer-IDs - deprecated BUTTON_NUMBER -> use BUTTON_COUNT (name semantics)
* Add efficient set(..all..) to Dimension, Insets, Point and Rectangle of ↵Sven Gothel2013-10-1611-41/+12
| | | | NativeWindow's util types.
* AWTPrintLifecycle.setupPrint(..): Add optional tileWidth and tileHeight, ↵Sven Gothel2013-10-151-9/+18
| | | | allowing user to set custom tile size for performance evaluation/tweak
* Bug 861 - NEWT: Unify MouseEvent Processing incl. gesture processingSven Gothel2013-10-1511-433/+1487
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We processed MouseEvents within NEWT as follows: sendMouseEvent/enqueueMouseEvent -> doMouseEvent, - called by native code to be delivered via consumeMouseEvent (now or later) - events are validated (move/drag, boundaries) - missing events are synthesized (click, enter, ..) as well as in several factories, i.e.: - AWTNewtEventFactory (1:1) - AndroidNewtEventFactory - synthesized events .. (click, ..) - android typed gesture detection (drag -> 1 finger scroll..) The latter enqueues events do Window/Display directly to be consumed by WindowImpl. Then users may have their own gesture detection etc. +++ This change unifies mouse/pointer event processing within NEWT within consumeEvent(..) which represents a common entry point. Gesture processing is now realized w/ a public API - GestureHandler - GestureHandler.GestureListener - GestureHandler.GesureEvent which supplies: - default impl. of optional gesture handlers (scroll, .. - default: enabled) - public API to add/remove gesture-handler and -listener +++ This allows our impl. to scale better in support of more multiple pointer devices (-> Win7/Win8, X11, ..).
* Bug 859: Let TileRenderer detect zero columns and rows in eot() where ↵Sven Gothel2013-10-121-9/+15
| | | | beginTile() throws an EOT IllegalStateException to avoid division by zero
* NEWT Reparent/Fullscreen: Add 'waitForPosition(..)' when reparenting or back ↵Sven Gothel2013-10-092-4/+21
| | | | from fullscreen; JOGLNewtAppletBase: Reparent to pos 32/32, trying to avoid browser window focus/top stealing on X11.
* NewtCanvasAWT Focus Traversal: Remove AWT's requestFocus*() overrides in ↵Sven Gothel2013-10-091-46/+18
| | | | | | | | | | favor of FocusPropertyChangeListener requestFocusNEWTChild() The AWT's requestFocus*() overrides were intended to receive the AWT focus (default) and clear it afterwards to forward the focus to the NEWT component -> requestFocusNEWTChild(). This can be achieved simply by using our FocusPropertyChangeListener and invoking requestFocusNEWTChild() when receiving the focus on the NewtCanvasAWT component.
* NEWT Reparent/Fullscreen: Fixes X11 unsuccessful return to parent window; ↵Sven Gothel2013-10-094-45/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add reparentWindow(..) top-level position arguments; Misc - Fixes X11 unsuccessful return to parent window On X11 when returning to parent window (-> CHILD), we have to set the window invisible and wait for the result. Otherwise it sometimes happens that the WM's reparent operation fails, i.e. the window won't become a child of desired parent and is positioned randomly. - Add reparentWindow(..) top-level position arguments .. allows bringing the child-window to top-level w/ a desired position. Otherwise the window would be positioned elsewhere as a top-level as the plain reparenting operation. X11 needs to set position and size _after_ making the window visible, otherwise WM may ignore the XConfigureWindow request. - Reparent recreate shall always store the desired position and size On OSX/CALayer when recreation is being used, we need to store the pos/size for later creation. - Tests: Use 'NewtAWTReparentingKeyAdapter' where possible (reparent/fullscreen) instead of duplicating such code. NewtAWTReparentingKeyAdapter: Performs reparenting and fullscreen operations off-thread (i.e. not on AWT/NEW EDT) while decorating the action w/ revoking/restoring the ExclusiveContextThread (ECT). Manually tested 'TestGearsES2NewtCanvasAWT' reparenting and fullscreen on X11, Windows and OSX/CALayer w/ JDK 7u40 successful.
* NEWT Display: Issue EDTUtil.start() at runOnEDTIfAvail(..) even if on EDT, ↵Sven Gothel2013-10-097-39/+39
| | | | | | | | | | | | | | | | | which is to be stopped. This case appears on e.g. OSX/CALayer (offscreen) reparenting using recreation (onscreen <-> offscreen), i.e. display destroy/create is performed on EDT. Misc Cleanup: - Rename EDTUtil: restart() -> start() - Rename Display: validateEDT() -> validateEDTStopped() - Simplify Display.setEDTUtil(..): Remove need for redundant 'newEDTUtil' local var. - Simplify Display.runOnEDTIfAvail(..): edtUtil is never null
* NEWT/OSX (Bug 836): Only WindowDriver.initWindow0(..) operation on ↵Sven Gothel2013-10-091-8/+13
| | | | | | main-thread must be synchronized (wait-until-done) - Leave WindowDriver.close0(..) w/o sync
* NEWT/OSX (Bug 836): Lifecycle operations performed on main-thread must be ↵Sven Gothel2013-10-072-38/+48
| | | | | | | | | | | | | synchronized (wait-until-done) Wait-until-done (main thread): - WindowDriver.close0(..) - WindowDriver.initWindow0(..) Otherwise a re-queued operation (i.e. CALayer attachment) will mixup the order .. Experienced w/ fullscreen exit.
* NEWT/Fullscreen (Bug 836): Exit re-parenting fullscreen w/ ↵Sven Gothel2013-10-072-22/+33
| | | | | | | | | | | | | | | [invisible-exit-visible] (-> like reparent); Always force focus; X11: Always use ALWAYSONTOP. - Remove unused 'fullscreenUseSpanningMode' state - Exit re-parenting fullscreen w/ [invisible-exit-visible] (-> like reparent) solves X11 issue, where the NEWT window doesn't 'return to it's parent'. Probably also fixes Bug 836! - Always force focus when enter and exit FS - X11: Always use ALWAYSONTOP No reason to behave different (spanning and normal-fs)
* Bug 816/848: Cleanup test applet layout/size ; Note Bug 848: Not ↵Sven Gothel2013-10-041-3/+3
| | | | reproducible after restart of OSX test machine!
* AWT Printing: releasePrint() issue reshape from AWT-EDT; GLJPanel: Issue ↵Sven Gothel2013-09-281-1/+0
| | | | 'handleReshape' if panelSize/awtSize mismatch, otherwise 'sendReshape' and exception if offscreen size doesn't match panelSize.
* Fix AWT Printing: Use delegated GLDrawable's size for tile-size instead of ↵Sven Gothel2013-09-281-2/+5
| | | | | | | | | AWT-GLAD's size, since the latter uses AWT's component size. .. the AWT component size could have been modified after setupPrinting(..). The AWT-GLAD getWidth() and getHeight() is implemented by AWT's component and hence may not reflect the actual GLDrawable size while printing.
* TileRenderer*: TileRendererNotify -> TileRendererListener w/ clarifying ↵Sven Gothel2013-09-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | functionality (reshapeTile(..), ..); Only process GLEventListener impl. TileRendererListener; attachToAutoDrawable -> attachAutoDrawable, etc. -TileRendererNotify -> TileRendererListener - Added methods: - void reshapeTile(TileRendererBase tr,int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight); - void startTileRendering(TileRendererBase tr); - void endTileRendering(TileRendererBase tr); allowing to clarify user code and API specification, i.e. TR only processes GLEventListener which impl. TileRendererListener. This also allows simplifying the API doc, while having a more descriptive reshape method focusing solely on tile rendering. Further more, the start/end TR methods allow certain GL related actions while the context is current before and after iterating through the tiles. This is even used for RandomTileRenderer (one tile only), to allow to reuse same TileRendererListener for diff TRs. - Fix language, attach and detach usage was vice versa. We do attach an GLAutoDrawable to a TR - attachToAutoDrawable -> attachAutoDrawable - detachFromAutoDrawable -> detachAutoDrawable - Adapted unit tests.
* Bug 816: Fix OSX CALayer 'quirks' for AWT 1.7.0_40 - See JAWTUtil ↵Sven Gothel2013-09-242-4/+8
| | | | | | | | | JAWT_OSX_CALAYER_QUIRK_SIZE and JAWT_OSX_CALAYER_QUIRK_POSITION. - Provide quirk bits for OSX CALayer depending on used JVM/AWT and act accordingly. - TestBug816OSXCALayerPosAWT: Add resize by frame
* Fix Bug 840: DefaultEDTUtil.restart() shall only reuse ThreadGroup (tg) is ↵Sven Gothel2013-09-221-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | not destroyed, otherwise use current thread's tg. With jdk7u40, when re-launching a NEWT applet (JOGLNewtApplet1Run), i.e. via browser back and forth, the following exception happens: java.lang.RuntimeException: java.lang.IllegalThreadStateException at com.jogamp.newt.awt.applet.JOGLNewtApplet1Run.init(JOGLNewtApplet1Run.java:218) at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.init(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.IllegalThreadStateException at java.lang.ThreadGroup.addUnstarted(Unknown Source) at java.lang.Thread.init(Unknown Source) at java.lang.Thread.<init>(Unknown Source) at jogamp.newt.DefaultEDTUtil$NEDT.<init>(DefaultEDTUtil.java:280) at jogamp.newt.DefaultEDTUtil.restart(DefaultEDTUtil.java:91) at jogamp.newt.DisplayImpl.runOnEDTIfAvail(DisplayImpl.java:231) at jogamp.newt.WindowImpl.runOnEDTIfAvail(WindowImpl.java:1758) at jogamp.newt.WindowImpl.setUndecorated(WindowImpl.java:1477) at com.jogamp.newt.opengl.GLWindow.setUndecorated(GLWindow.java:278) at com.jogamp.newt.awt.applet.JOGLNewtApplet1Run.init(JOGLNewtApplet1Run.java:188) ... 3 more This is due to 7u40's changed ThreadGroup (tg) lifecycle, i.e. the tg is destroyed. In such case, DefaultEDTUtil.restart() shall use the current threads tg.
* AWTTilePainter.setupGraphics2DAndClipBounds(): Use 'Shape getClip()'; Use ↵Sven Gothel2013-09-191-9/+15
| | | | | | | | | | | | | | | | double precicion clip bounds 'all the way'; Explicitly scale image and clip w/ current scaled transform. - Use 'Shape getClip()' Don't assume Rectangle2D, but use Shape's getBounds2D() - Use double precicion clip bounds 'all the way' Remove rounding error on clip bounds w/ start value, which was _not_ using doubles. - Explicitly scale image and clip w/ current scaled transform. Instead of abusing Graphics2D's clip shape to scale image size and clip-area, explicitly use transform both bounding boxes into transformed space, scale space and transform out (inversion). A possible NoninvertibleTransformException will be thrown while Graphics2D has not been modified.
* AWT Printing: Move init-test of setupPrint(..) to AWT-EDT Runnable ; ↵Sven Gothel2013-09-171-23/+27
| | | | GLJPanel: Attempt to initialize if not done yet (similar to GLCanvas)