private Vibrator vibrator = null;
private boolean cameraDisconnectedHappened = false;
private WifiConnection wifiConnection = null;
+ private CameraLiveViewListenerImpl liveViewListener =null;
+ private boolean enableGlView = false;
//private boolean ambientMode = false;
/**
liveView = findViewById(R.id.liveview);
liveView.setVisibility(View.VISIBLE);
}
- CameraLiveViewListenerImpl liveViewListener = new CameraLiveViewListenerImpl(liveView);
- gestureParser = null;
- glView = null;
- boolean enableGlView = preferences.getBoolean(IPreferenceCameraPropertyAccessor.THETA_GL_VIEW, false);
- if ((enableGlView)&&(connectionMethod.contains(IPreferenceCameraPropertyAccessor.CONNECTION_METHOD_THETA)))
+ liveViewListener = new CameraLiveViewListenerImpl(liveView);
+ if (glView == null)
{
- if (glView == null)
+ glView = findViewById(R.id.glview);
+ }
+ if (glView != null)
+ {
+ if (gestureParser == null)
{
- // GL VIEW に切り替える
- glView = findViewById(R.id.glview);
+ gestureParser = new GestureParser(getApplicationContext(), glView);
}
- if (glView != null)
+ enableGlView = preferences.getBoolean(IPreferenceCameraPropertyAccessor.THETA_GL_VIEW, false);
+ if ((enableGlView)&&(connectionMethod.contains(IPreferenceCameraPropertyAccessor.CONNECTION_METHOD_THETA)))
{
// GL VIEW に切り替える
- gestureParser = new GestureParser(getApplicationContext(), glView);
glView.setImageProvider(liveViewListener);
glView.setVisibility(View.VISIBLE);
liveView.setVisibility(View.GONE);
public boolean dispatchTouchEvent(MotionEvent event)
{
//Log.v(TAG, " dispatchTouchEvent() ");
- if (gestureParser != null)
+ if (enableGlView)
{
//Log.v(TAG, " onTouch() ");
gestureParser.onTouch(event);
String connectionMethod = preferences.getString(IPreferenceCameraPropertyAccessor.CONNECTION_METHOD, IPreferenceCameraPropertyAccessor.CONNECTION_METHOD_DEFAULT_VALUE);
int methodId = (connectionMethod.contains(IPreferenceCameraPropertyAccessor.CONNECTION_METHOD_THETA)) ? R.string.connection_method_theta : R.string.connection_method_opc;
setMessage(IShowInformation.AREA_7, Color.MAGENTA, getString(methodId));
- if (liveView == null)
+ if (liveView != null)
{
- liveView = findViewById(R.id.liveview);
- }
- liveView.setupInitialBackgroundImage(this);
- liveView.setVisibility(View.VISIBLE);
- liveView.invalidate();
-
- if (glView != null)
- {
- glView.setVisibility(View.GONE);
- glView = null;
+ liveView.setupInitialBackgroundImage(this);
+ liveView.setVisibility(View.VISIBLE);
+ liveView.invalidate();
}
-
-
-
}
catch (Exception e)
{
currentCoordinator = method;
preferences.putString(IPreferenceCameraPropertyAccessor.CONNECTION_METHOD, parameter);
vibrate(IShowInformation.VIBRATE_PATTERN_SHORT_DOUBLE);
+ enableGlView = preferences.getBoolean(IPreferenceCameraPropertyAccessor.THETA_GL_VIEW, false);
+ if ((enableGlView)&&(parameter.contains(IPreferenceCameraPropertyAccessor.CONNECTION_METHOD_THETA)))
+ {
+ if (glView == null)
+ {
+ // GL VIEW に切り替える
+ glView = findViewById(R.id.glview);
+ }
+ if (glView != null)
+ {
+ // GL VIEW に切り替える
+ gestureParser = new GestureParser(getApplicationContext(), glView);
+ glView.setImageProvider(liveViewListener);
+ glView.setVisibility(View.VISIBLE);
+ liveView.setVisibility(View.GONE);
+ }
+ }
+ else
+ {
+ if (liveView == null)
+ {
+ liveView = findViewById(R.id.liveview);
+ }
+ if (liveView != null)
+ {
+ if (glView != null)
+ {
+ glView.setVisibility(View.GONE);
+ }
+ liveView.setVisibility(View.VISIBLE);
+ }
+ }
}
catch (Exception e)
{
gl?.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_REPLACE.toFloat())
/////////////////////////////////////////////////////////////////////
- val inputStream: InputStream = mContext.getResources().openRawResource(resourceId)
+ val inputStream: InputStream = mContext.resources.openRawResource(resourceId)
val bitmap: Bitmap
bitmap = try
{
}
catch (e: IOException)
{
- // Ignore.
e.printStackTrace()
}
}
}
catch (ex: Exception)
{
- // ignore
ex.printStackTrace()
}
return textures[0]
return -1
}
}
-
- /**
- * テクスチャの準備(ビットマップ指定)
- *
- *
- */
- fun prepareTextureBitmap(gl: GL10?, bitmap: Bitmap): Int
- {
- try
- {
- /*
- * Create our texture. This has to be done each time the
- * surface is created.
- */
- val textures = IntArray(1)
- gl?.glGenTextures(1, textures, 0)
- gl?.glBindTexture(GL10.GL_TEXTURE_2D, textures[0])
- gl?.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST.toFloat())
- gl?.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR.toFloat())
- gl?.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE.toFloat())
- gl?.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE.toFloat())
- gl?.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_REPLACE.toFloat())
-
- try
- {
- GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0)
- //bitmap.recycle()
- }
- catch (ex: Exception)
- {
- // ignore
- ex.printStackTrace()
- }
- return textures[0]
- }
- catch (e : Exception)
- {
- e.printStackTrace()
- return -1
- }
- }
-
- fun updateTexture(gl: GL10?, bitmap: Bitmap)
- {
- try
- {
- GLUtils.texSubImage2D(GL10.GL_TEXTURE_2D, 0, 0, 0, bitmap)
- }
- catch (ex: Exception)
- {
- // ignore
- ex.printStackTrace()
- }
-
-
-
- }
}
\ No newline at end of file
class GokigenGLView : GLSurfaceView, ILiveViewRefresher
{
- private var graphicsDrawer : IGraphicsDrawer = EquirectangularDrawer(context)
+ private var graphicsDrawer : IGraphicsDrawer = SphereDrawer(context)
private lateinit var imageProvider : IImageProvider
companion object
constructor(context: Context) : super(context)
{
- initializeSelf(context, null)
+ initializeSelf(context)
}
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
{
- initializeSelf(context, attrs)
+ initializeSelf(context)
}
/**
* クラスの初期化処理...レンダラを設定する
*
*/
- private fun initializeSelf(context: Context, attrs: AttributeSet?)
+ private fun initializeSelf(context: Context)
{
try
{