Java Code Examples for android.opengl.GLSurfaceView#setRenderer()
The following examples show how to use
android.opengl.GLSurfaceView#setRenderer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java From LearnOpenGL with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (!Utils.supportGlEs20(this)) { Toast.makeText(this, "GLES 2.0 not supported!", Toast.LENGTH_LONG).show(); finish(); return; } mGLSurfaceView = (GLSurfaceView) findViewById(R.id.surface); mGLSurfaceView.setEGLContextClientVersion(2); mRenderer = new DemoRenderer(this); mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0); mGLSurfaceView.setRenderer(mRenderer); mGLSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY); }
Example 2
Source File: MainActivity.java From opengl with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { // Turn off the window's title bar // requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); mGLSurfaceView = new GLSurfaceView(this); if (detectOpenGLES30()) { // Tell the surface view we want to create an OpenGL ES 3.0-compatible // context, and set an OpenGL ES 3.0-compatible renderer. mGLSurfaceView.setEGLContextClientVersion(3); // Set the renderer to our demo renderer, defined below. mGLSurfaceView.setRenderer(new LessonOneRenderer()); } else { // This is where you could create an OpenGL ES 2.0 and/or 1.x compatible // renderer if you wanted to support both ES 1 and ES 2. Log.e("HelloTriangle", "OpenGL ES 3.0 not supported on device. Exiting..."); finish(); } setContentView(mGLSurfaceView); }
Example 3
Source File: MainActivity.java From opengl with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mGLSurfaceView = new GLSurfaceView(this); if (detectOpenGLES30()) { // Tell the surface view we want to create an OpenGL ES 3.0-compatible // context, and set an OpenGL ES 3.0-compatible renderer. mGLSurfaceView.setEGLContextClientVersion(CONTEXT_CLIENT_VERSION); mGLSurfaceView.setRenderer(new HelloTriangleRenderer(this)); } else { Log.e("HelloTriangle", "OpenGL ES 3.0 not supported on device. Exiting..."); finish(); } setContentView(mGLSurfaceView); }
Example 4
Source File: TiledImageView.java From LB-Launcher with Apache License 2.0 | 6 votes |
public TiledImageView(Context context, AttributeSet attrs) { super(context, attrs); if (!IS_SUPPORTED) { return; } mRenderer = new ImageRendererWrapper(); mRenderer.image = new TiledImageRenderer(this); View view; if (USE_TEXTURE_VIEW) { mTextureView = new BlockingGLTextureView(context); mTextureView.setRenderer(new TileRenderer()); view = mTextureView; } else { mGLSurfaceView = new GLSurfaceView(context); mGLSurfaceView.setEGLContextClientVersion(2); mGLSurfaceView.setRenderer(new TileRenderer()); mGLSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); view = mGLSurfaceView; } addView(view, new LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); //setTileSource(new ColoredTiles()); }
Example 5
Source File: GameActivity.java From Tanks with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); handler = new Handler(); renderer = new Renderer(); initializeContext(); initializeFactory(); // OpenGL init glView = new GLSurfaceView(this); glView.getHolder().setFormat(PixelFormat.RGBA_8888); glView.setEGLContextClientVersion(2); glView.setEGLConfigChooser(new ConfigChooser()); glView.setRenderer(renderer); glView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); // Bind listener glView.setOnTouchListener(this); // Set view setContentView(glView); // Set menu and world initializeContent(); }
Example 6
Source File: MediaEffectsFragment.java From android-MediaEffects with Apache License 2.0 | 5 votes |
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { mEffectView = (GLSurfaceView) view.findViewById(R.id.effectsview); mEffectView.setEGLContextClientVersion(2); mEffectView.setRenderer(this); mEffectView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); if (null != savedInstanceState && savedInstanceState.containsKey(STATE_CURRENT_EFFECT)) { setCurrentEffect(savedInstanceState.getInt(STATE_CURRENT_EFFECT)); } else { setCurrentEffect(R.id.none); } }
Example 7
Source File: OpenGlDemo.java From opengl with Apache License 2.0 | 5 votes |
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); GLSurfaceView view = new GLSurfaceView(this); view.setRenderer(new OpenGLRenderer()); setContentView(view); }
Example 8
Source File: CompressedTextureActivity.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mGLView = new GLSurfaceView(this); mGLView.setEGLConfigChooser(false); StaticTriangleRenderer.TextureLoader loader; if (TEST_CREATE_TEXTURE) { loader = new SyntheticCompressedTextureLoader(); } else { loader = new CompressedTextureLoader(); } mGLView.setRenderer(new StaticTriangleRenderer(this, loader)); setContentView(mGLView); }
Example 9
Source File: InvertedColorsVideoRenderer.java From opentok-android-sdk-samples with MIT License | 5 votes |
public InvertedColorsVideoRenderer(Context context) { this.mContext = context; mView = new GLSurfaceView(context); mView.setEGLContextClientVersion(2); mRenderer = new MyRenderer(); mView.setRenderer(mRenderer); mView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); }
Example 10
Source File: SurfaceViewOverlay.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.surface_view_overlay); GLSurfaceView glSurfaceView = (GLSurfaceView) findViewById(R.id.glsurfaceview); glSurfaceView.setRenderer(new CubeRenderer(false)); // Find the views whose visibility will change mVictimContainer = findViewById(R.id.hidecontainer); mVictim1 = findViewById(R.id.hideme1); mVictim1.setOnClickListener(new HideMeListener(mVictim1)); mVictim2 = findViewById(R.id.hideme2); mVictim2.setOnClickListener(new HideMeListener(mVictim2)); // Find our buttons Button visibleButton = (Button) findViewById(R.id.vis); Button invisibleButton = (Button) findViewById(R.id.invis); Button goneButton = (Button) findViewById(R.id.gone); // Wire each button to a click listener visibleButton.setOnClickListener(mVisibleListener); invisibleButton.setOnClickListener(mInvisibleListener); goneButton.setOnClickListener(mGoneListener); }
Example 11
Source File: MatrixPaletteActivity.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mGLSurfaceView = new GLSurfaceView(this); mGLSurfaceView.setRenderer(new MatrixPaletteRenderer(this)); setContentView(mGLSurfaceView); }
Example 12
Source File: PreviewTranscode.java From media-for-mobile with Apache License 2.0 | 5 votes |
public PreviewTranscode(GLSurfaceView glView, IEglUtil eglUtil) { this.glView = glView; this.eglUtil = eglUtil; textureRender = new TextureRenderer(eglUtil); glView.setEGLContextClientVersion(2); glView.setEGLConfigChooser(true); glView.setRenderer(this); glView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); }
Example 13
Source File: BouncyCubeActivity.java From opengl with Apache License 2.0 | 5 votes |
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); GLSurfaceView view = new GLSurfaceView(this); view.setRenderer(new BouncyCubeRenderer(true)); setContentView(view); }
Example 14
Source File: FlipViewController.java From UltimateAndroid with Apache License 2.0 | 5 votes |
private void setupSurfaceView(Context context) { surfaceView = new GLSurfaceView(getContext()); cards = new FlipCards(this, flipOrientation == VERTICAL); renderer = new FlipRenderer(this, cards); surfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0); surfaceView.setZOrderOnTop(true); surfaceView.setRenderer(renderer); surfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT); surfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); addViewInLayout(surfaceView, -1, new AbsListView.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT), false); }
Example 15
Source File: OpenGlDemo1Activity.java From opengl with Apache License 2.0 | 5 votes |
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); GLSurfaceView view = new GLSurfaceView(this); view.setRenderer(new SquareRenderer(true)); setContentView(view); }
Example 16
Source File: SpriteTextActivity.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mGLSurfaceView = new GLSurfaceView(this); mGLSurfaceView.setGLWrapper(new GLSurfaceView.GLWrapper() { public GL wrap(GL gl) { return new MatrixTrackingGL(gl); }}); mGLSurfaceView.setRenderer(new SpriteTextRenderer(this)); setContentView(mGLSurfaceView); }
Example 17
Source File: EffectsFilterActivity.java From ImageEffects with Eclipse Public License 1.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.main); /** * Initialise the renderer and tell it to only render when Explicit * requested with the RENDERMODE_WHEN_DIRTY option */ mEffectView = (GLSurfaceView) findViewById(R.id.effectsview); mEffectView.setEGLContextClientVersion(2); mEffectView.setRenderer(this); mEffectView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); mCurrentEffect = R.id.none; }
Example 18
Source File: VRPlayerActivity.java From IjkVRPlayer with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Uri uri = getIntent().getData(); if (uri == null) { Toast.makeText(this, "no media file to open!", Toast.LENGTH_SHORT).show(); finish(); return; } setContentView(R.layout.activity_vr_player); mGLView = (GLSurfaceView) findViewById(R.id.surface); mGLView.setEGLContextClientVersion(2); //GLES 2.0 mHandler = new Handler() { @Override public void handleMessage(Message msg) { if (msg.what == 1) { prepareMediaPlayerIfReady(); return; } else if (msg.what == 2) { mGLView.requestRender(); } super.handleMessage(msg); } }; // TODO: implements your TextureRender mRenderer = new IjkVRRender(mHandler); mGLView.setRenderer(mRenderer); mGLView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1); } else { initMediaPlayer(uri); } }
Example 19
Source File: OGLESContext.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * <code>createView</code> creates the GLSurfaceView that the renderer will * draw to. <p> The result GLSurfaceView will receive input events and * forward them to the Application. Any rendering will be done into the * GLSurfaceView. Only one GLSurfaceView can be created at this time. The * given configType specifies how to determine the display configuration. * * @return GLSurfaceView The newly created view */ public GLSurfaceView createView(Context context) { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ConfigurationInfo info = am.getDeviceConfigurationInfo(); // NOTE: We assume all ICS devices have OpenGL ES 2.0. if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // below 4.0, check OpenGL ES 2.0 support. if (info.reqGlEsVersion < 0x20000) { throw new UnsupportedOperationException("OpenGL ES 2.0 or better is not supported on this device"); } } else if (Build.VERSION.SDK_INT < 9){ throw new UnsupportedOperationException("jME3 requires Android 2.3 or later"); } // Start to set up the view GLSurfaceView view = new GLSurfaceView(context); logger.log(Level.INFO, "Android Build Version: {0}", Build.VERSION.SDK_INT); if (androidInput == null) { if (Build.VERSION.SDK_INT >= 14) { androidInput = new AndroidInputHandler14(); } else if (Build.VERSION.SDK_INT >= 9){ androidInput = new AndroidInputHandler(); } } androidInput.setView(view); androidInput.loadSettings(settings); // setEGLContextClientVersion must be set before calling setRenderer // this means it cannot be set in AndroidConfigChooser (too late) // use proper openGL ES version view.setEGLContextClientVersion(info.reqGlEsVersion>>16); view.setFocusableInTouchMode(true); view.setFocusable(true); // setFormat must be set before AndroidConfigChooser is called by the surfaceview. // if setFormat is called after ConfigChooser is called, then execution // stops at the setFormat call without a crash. // We look at the user setting for alpha bits and set the surfaceview // PixelFormat to either Opaque, Transparent, or Translucent. // ConfigChooser will do its best to honor the alpha requested by the user // For best rendering performance, use Opaque (alpha bits = 0). int curAlphaBits = settings.getAlphaBits(); logger.log(Level.FINE, "curAlphaBits: {0}", curAlphaBits); if (curAlphaBits >= 8) { logger.log(Level.FINE, "Pixel Format: TRANSLUCENT"); view.getHolder().setFormat(PixelFormat.TRANSLUCENT); view.setZOrderOnTop(true); } else if (curAlphaBits >= 1) { logger.log(Level.FINE, "Pixel Format: TRANSPARENT"); view.getHolder().setFormat(PixelFormat.TRANSPARENT); } else { logger.log(Level.FINE, "Pixel Format: OPAQUE"); view.getHolder().setFormat(PixelFormat.OPAQUE); } AndroidConfigChooser configChooser = new AndroidConfigChooser(settings); view.setEGLConfigChooser(configChooser); view.setRenderer(this); // Attempt to preserve the EGL Context on app pause/resume. // Not destroying and recreating the EGL context // will help with resume time by reusing the existing context to avoid // reloading all the OpenGL objects. if (Build.VERSION.SDK_INT >= 11) { view.setPreserveEGLContextOnPause(true); } return view; }
Example 20
Source File: PointCloudActivity.java From tango with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_jpoint_cloud); setTitle(R.string.app_name); mPoseTextView = (TextView) findViewById(R.id.pose); mQuatTextView = (TextView) findViewById(R.id.quat); mPoseCountTextView = (TextView) findViewById(R.id.posecount); mDeltaTextView = (TextView) findViewById(R.id.deltatime); mTangoEventTextView = (TextView) findViewById(R.id.tangoevent); mPoseStatusTextView = (TextView) findViewById(R.id.status); mPointCountTextView = (TextView) findViewById(R.id.pointCount); mTangoServiceVersionTextView = (TextView) findViewById(R.id.version); mApplicationVersionTextView = (TextView) findViewById(R.id.appversion); mAverageZTextView = (TextView) findViewById(R.id.averageZ); mFrequencyTextView = (TextView) findViewById(R.id.frameDelta); mSaveButton = (Button) findViewById(R.id.saveButton); mSaveButton.setOnClickListener(this); mFirstPersonButton = (Button) findViewById(R.id.first_person_button); mFirstPersonButton.setOnClickListener(this); mThirdPersonButton = (Button) findViewById(R.id.third_person_button); mThirdPersonButton.setOnClickListener(this); mTopDownButton = (Button) findViewById(R.id.top_down_button); mTopDownButton.setOnClickListener(this); mGLView = (GLSurfaceView) findViewById(R.id.gl_surface_view); mGLView.setEGLContextClientVersion(2); mTango = new Tango(this); mConfig = mTango.getConfig(TangoConfig.CONFIG_TYPE_CURRENT); // tangoCameraPreview = (TangoCameraPreview) findViewById(R.id.cameraView); int maxDepthPoints = mConfig.getInt("max_point_cloud_elements"); mRenderer = new PCRenderer(maxDepthPoints); mGLView.setRenderer(mRenderer); mConfig.putBoolean(TangoConfig.KEY_BOOLEAN_DEPTH, true); mGLView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); PackageInfo packageInfo; try { packageInfo = this.getPackageManager().getPackageInfo( this.getPackageName(), 0); mApplicationVersionTextView.setText(packageInfo.versionName); } catch (NameNotFoundException e) { e.printStackTrace(); } // Display the version of Tango Service mServiceVersion = mConfig.getString("tango_service_library_version"); mTangoServiceVersionTextView.setText(mServiceVersion); mIsTangoServiceConnected = false; // Set up OpenGL ES surface mCamView = new GLSurfaceView(this); mCamView.setEGLContextClientVersion(2); mCamView.setDebugFlags(GLSurfaceView.DEBUG_CHECK_GL_ERROR); mCamView.setRenderer(renderer_ = new FrameRenderer(this)); mCamView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); mCamView.setOnClickListener(this); FrameLayout placeholder = (FrameLayout)findViewById(R.id.cameraFrame); placeholder.addView(mCamView); cameraTextures_ = new HashMap<>(); }