public void onSurfaceCreated(GL10 gl, EGLConfig config) { if(DBG) Log.d(TAG, "onSurfaceCreated"); // mGL = gl; // Tell the listener as soon as GL stack is ready if(DBG) Log.d(TAG,"GL_READY"); mListener.sendEmptyMessage(RendererListener.MSG_GL_READY); // Depth management is done "by hand", by sorting covers. Because of Blending. // Sometimes I even want to display cover behind, to mimic transparency glDisable(GL_DEPTH_TEST); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); // Enable stuff (...) glEnableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); // This must be disabled to use glColor for covers glEnableClientState(GL_TEXTURE_COORD_ARRAY); }
@Override public void onSurfaceCreated(GL10 gl, EGLConfig eglConfig) { mRenderListener.onSurfaceCreated(gl); mEngine.getTextureLibrary().LoadTextures(gl); gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Enable Smooth Shading, default not really needed. gl.glShadeModel(GL10.GL_SMOOTH); // Depth buffer setup. gl.glClearDepthf(1.0f); // Enables depth testing. gl.glEnable(GL10.GL_DEPTH_TEST); // The type of depth testing to do. gl.glDepthFunc(GL10.GL_LEQUAL); // Really nice perspective calculations. gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST); gl.glEnable(GL10.GL_ALPHA_TEST); gl.glAlphaFunc(GL10.GL_GREATER, 0.1f); }
@Override public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display){ final int EGL_OPENGL_ES2_BIT = 0x0004; int[] attribList = { EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL10.EGL_SURFACE_TYPE, EGL10.EGL_PBUFFER_BIT, EGL10.EGL_NONE }; EGLConfig[] configs = new EGLConfig[1]; int[] numConfigs = new int[1]; if (!egl.eglChooseConfig(display, attribList, configs, configs.length, numConfigs)) { throw new RuntimeException("unable to find RGB888+recordable ES2 EGL config"); } return configs[0]; }
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) { int[] num_config = new int[1]; egl.eglChooseConfig(display, mConfigSpec, null, 0, num_config); int numConfigs = num_config[0]; if (numConfigs <= 0) { throw new IllegalArgumentException("No configs match configSpec"); } EGLConfig[] configs = new EGLConfig[numConfigs]; egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs, num_config); EGLConfig config = chooseConfig(egl, display, configs); if (config == null) { throw new IllegalArgumentException("No config chosen"); } return config; }
@Override public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs) { for (EGLConfig config : configs) { int d = findConfigAttrib(egl, display, config, EGL10.EGL_DEPTH_SIZE, 0); int s = findConfigAttrib(egl, display, config, EGL10.EGL_STENCIL_SIZE, 0); if ((d >= mDepthSize) && (s >= mStencilSize)) { int r = findConfigAttrib(egl, display, config, EGL10.EGL_RED_SIZE, 0); int g = findConfigAttrib(egl, display, config, EGL10.EGL_GREEN_SIZE, 0); int b = findConfigAttrib(egl, display, config, EGL10.EGL_BLUE_SIZE, 0); int a = findConfigAttrib(egl, display, config, EGL10.EGL_ALPHA_SIZE, 0); if ((r == mRedSize) && (g == mGreenSize) && (b == mBlueSize) && (a == mAlphaSize)) { return config; } } } return null; }
public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) { Log.d(LOG_TAG, "createContext " + egl + " " + display + " " + eglConfig); checkEglError("before createContext", egl); int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE}; EGLContext ctx; if (mRenderer.mEGLCurrentContext == null) { mRenderer.mEGLCurrentContext = egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list); ctx = mRenderer.mEGLCurrentContext; } else { ctx = mRenderer.mEGLCurrentContext; } checkEglError("after createContext", egl); return ctx; }
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) { int[] num_config = new int[1]; if (!egl.eglChooseConfig(display, mConfigSpec, null, 0, num_config)) { throw new IllegalArgumentException("eglChooseConfig failed"); } int numConfigs = num_config[0]; if (numConfigs <= 0) { throw new IllegalArgumentException( "No configs match configSpec"); } EGLConfig[] configs = new EGLConfig[numConfigs]; if (!egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs, num_config)) { throw new IllegalArgumentException("eglChooseConfig#2 failed"); } EGLConfig config = chooseConfig(egl, display, configs); if (config == null) { throw new IllegalArgumentException("No config chosen"); } return config; }
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display, EGLConfig config, Object nativeWindow) { EGLSurface result = null; try { result = egl.eglCreateWindowSurface(display, config, nativeWindow, null); } catch (IllegalArgumentException e) { // This exception indicates that the surface flinger surface // is not valid. This can happen if the surface flinger surface has // been torn down, but the application has not yet been // notified via SurfaceHolder.Callback.surfaceDestroyed. // In theory the application should be notified first, // but in practice sometimes it is not. See b/4588890 Log.e(TAG, "eglCreateWindowSurface", e); } return result; }
public void onSurfaceCreated(GL10 unused, EGLConfig config) { GLES31.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); GLES31.glClearDepthf(1.0f); //GLES31.glEnable(GLES31.GL_CULL_FACE); //GLES31.glCullFace(GLES31.GL_BACK); GLES31.glEnable(GL10.GL_LINE_SMOOTH); GLES31.glHint(GL10.GL_LINE_SMOOTH_HINT, GLES31.GL_NICEST); GLES31.glFrontFace(GLES31.GL_CCW); GLES31.glEnable(GLES31.GL_DEPTH_TEST); mSoildWireframeRenderingShader.initShader(); mSolidRenderingShader.initShader(); mWireframeRenderingShader.initShader(); mNormalsRenderingShader.initShader(); mPointsRenderingShader.initShader(); }
private EGLConfig chooseConfig() { int[] attribList = new int[] { EGL_DEPTH_SIZE, 0, EGL_STENCIL_SIZE, 0, EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, EGL10.EGL_RENDERABLE_TYPE, 4, EGL_NONE }; // No error checking performed, minimum required code to elucidate logic // Expand on this logic to be more selective in choosing a configuration int[] numConfig = new int[1]; mEGL.eglChooseConfig(mEGLDisplay, attribList, null, 0, numConfig); int configSize = numConfig[0]; mEGLConfigs = new EGLConfig[configSize]; mEGL.eglChooseConfig(mEGLDisplay, attribList, mEGLConfigs, configSize, numConfig); if (LIST_CONFIGS) { listConfig(); } return mEGLConfigs[0]; // Best match is probably the first configuration }
@Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { Log.d(TAG, "onSurfaceCreated: "); mFullScreen = new FullFrameRect( new Texture2dProgram(Texture2dProgram.ProgramType.TEXTURE_EXT)); mTextureId = mFullScreen.createTextureObject(); mSurfaceTexture = new SurfaceTexture(mTextureId); mSurface = new Surface(mSurfaceTexture); mSurfaceTexture.setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() { @Override public void onFrameAvailable(SurfaceTexture surfaceTexture) { mGLSurfaceView.requestRender(); } }); }
@Override public void onSurfaceCreated(GL10 gl10, EGLConfig eglConfig) { glClearColor(1f, 1.0f, 1.0f, 0.0f); glEnable(GL_DEPTH_TEST); int a = glGetError(); if (a == GL_INVALID_ENUM) { Log.d("particle", "Invalid enum"); } else if (a == GL_INVALID_VALUE) { Log.d("particle", "Invalid value"); } else if (a == GL_INVALID_OPERATION) { Log.d("particle", "Invalid operation"); } if (!isInit) { init(); isInit = true; } }
@Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { Log.d(TAG, "onSurfaceCreated"); final CameraView cameraView = mCameraViewRef.get(); if (cameraView != null) { cameraView.mGLSurfaceFilter = new GLSurfaceFilter(); Matrix.setIdentityM(mMvpMatrix, 0); mTextureId = cameraView.mGLSurfaceFilter.createTexture(); cameraView.mSurfaceTexture = new SurfaceTexture(mTextureId); cameraView.mSurfaceTexture.setOnFrameAvailableListener(cameraView); if (cameraView.mCameraSurfaceListener != null) { cameraView.mCameraSurfaceListener.onCameraSurfaceCreate(cameraView.mSurfaceTexture); } } }
private EGLConfig getConfig() { int renderableType = 4; // EGL14.EGL_OPENGL_ES2_BIT; int[] attribList = { EGL10.EGL_DEPTH_SIZE, 0, EGL10.EGL_STENCIL_SIZE, 0, EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_RENDERABLE_TYPE, renderableType, EGL10.EGL_NONE }; EGLConfig[] configs = new EGLConfig[1]; int[] numConfigs = new int[1]; if (!mEGL.eglChooseConfig(mEGLDisplay, attribList, configs, configs.length, numConfigs)) { Log.w("ImageEglSurface", "unable to find RGB8888 EGLConfig"); return null; } return configs[0]; }
@Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { if (!isCreated) { Context.gl.calculateMaxTextureSize(); Audio.al.init(); isCreated = true; Context.setApplication(app); listener.onCreateApplication(app); } }
private void eglSetup(int width, int height) { mEGL = (EGL10) EGLContext.getEGL(); mEGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); if (mEGLDisplay == EGL10.EGL_NO_DISPLAY) { throw new RuntimeException("unable to get EGL10 display"); } if (!mEGL.eglInitialize(mEGLDisplay, null)) { mEGLDisplay = null; throw new RuntimeException("unable to initialize EGL10"); } int[] attribList = { EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_SURFACE_TYPE, EGL10.EGL_PBUFFER_BIT, EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL10.EGL_NONE }; EGLConfig[] configs = new EGLConfig[1]; int[] numConfigs = new int[1]; if (!mEGL.eglChooseConfig(mEGLDisplay, attribList, configs, configs.length, numConfigs)) { throw new RuntimeException("unable to find RGB888+pbuffer EGL config"); } int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE }; mEGLContext = mEGL.eglCreateContext(mEGLDisplay, configs[0], EGL10.EGL_NO_CONTEXT, attrib_list); checkEglError("eglCreateContext"); if (mEGLContext == null) { throw new RuntimeException("null context"); } int[] surfaceAttribs = { EGL10.EGL_WIDTH, width, EGL10.EGL_HEIGHT, height, EGL10.EGL_NONE }; mEGLSurface = mEGL.eglCreatePbufferSurface(mEGLDisplay, configs[0], surfaceAttribs); checkEglError("eglCreatePbufferSurface"); if (mEGLSurface == null) { throw new RuntimeException("surface was null"); } }
@Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { //设置背景颜色 GLES20.glClearColor(0.5f , 0.5f , 0.5f , 1.0f); mCube = new Cube(ScaleSurfaceView.this); //深度测试 GLES20.glEnable(GLES20.GL_DEPTH_TEST); //背面裁剪 GLES20.glEnable(GLES20.GL_CULL_FACE); }
@Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { GLES20.glClearColor(0.5f, 0.5f, 0.5f, 1.0f); mImageAngle = new ImageAngle(getContext()); GLES20.glEnable(GLES20.GL_DEPTH_TEST); initTexture(); GLES20.glDisable(GLES20.GL_CULL_FACE); }
private int findConfigAttrib(EGL10 egl, EGLDisplay display, EGLConfig config, int attribute, int defaultValue) { mValue[0] = -1; if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) { return mValue[0]; } Log.w("SDL", "GLSurfaceView_SDL::EGLConfigChooser::findConfigAttrib(): attribute doesn't exist: " + attribute); return defaultValue; }
public static int getMaxTextureSize() { final int IMAGE_MAX_BITMAP_DIMENSION = 2048; EGL10 egl = (EGL10) EGLContext.getEGL(); EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); int[] version = new int[2]; egl.eglInitialize(display, version); int[] totalConfigurations = new int[1]; egl.eglGetConfigs(display, null, 0, totalConfigurations); EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]]; egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations); int[] textureSize = new int[1]; int maximumTextureSize = 0; for (int i = 0; i < totalConfigurations[0]; i++) { egl.eglGetConfigAttrib(display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize); if (maximumTextureSize < textureSize[0]) maximumTextureSize = textureSize[0]; } egl.eglTerminate(display); return Math.max(maximumTextureSize, IMAGE_MAX_BITMAP_DIMENSION); }
@Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { gl.glGenTextures(NUMBER_OF_TEXTURES, mtextureMgr.mtextures, 0); gl.glShadeModel(GL10.GL_SMOOTH); //Enable Smooth Shading gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); //Black Background gl.glClearDepthf(1.0f); //Depth Buffer Setup gl.glEnable(GL10.GL_DEPTH_TEST); //Enables Depth Testing gl.glDepthFunc(GL10.GL_LEQUAL); //The Type Of Depth Testing To Do //Really Nice Perspective Calculations gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST); }
@Override public synchronized void onSurfaceCreated(GL10 gl, EGLConfig config) { if (DBG) { Log.d(LOG_TAG, "onSurfaceCreated " + gl); } initCameraTexture(); Log.d(LOG_TAG, "onSurfaceCreated " + gl + " end"); }
@Override public void onSurfaceCreated(GL10 glUnused, EGLConfig config) { program = createProgram(vertexShader, this.resolveShader()); if (program == 0) { return; } aPositionHandle = GLES20.glGetAttribLocation(program, "aPosition"); checkGlError("glGetAttribLocation aPosition"); if (aPositionHandle == -1) { throw new RuntimeException("Could not get attrib location for aPosition"); } aTextureHandle = GLES20.glGetAttribLocation(program, "aTextureCoord"); checkGlError("glGetAttribLocation aTextureCoord"); if (aTextureHandle == -1) { throw new RuntimeException("Could not get attrib location for aTextureCoord"); } uMVPMatrixHandle = GLES20.glGetUniformLocation(program, "uMVPMatrix"); checkGlError("glGetUniformLocation uMVPMatrix"); if (uMVPMatrixHandle == -1) { throw new RuntimeException("Could not get attrib location for uMVPMatrix"); } uSTMatrixHandle = GLES20.glGetUniformLocation(program, "uSTMatrix"); checkGlError("glGetUniformLocation uSTMatrix"); if (uSTMatrixHandle == -1) { throw new RuntimeException("Could not get attrib location for uSTMatrix"); } prepareSurface(); }
private int findConfigAttrib(EGL10 egl, EGLDisplay display, EGLConfig config, int attribute, int defaultValue) { if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) { return mValue[0]; } return defaultValue; }
@Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { // Set the background clear color to black. GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Use culling to remove back face. GLES20.glEnable(GLES20.GL_CULL_FACE); // Enable depth testing GLES20.glEnable(GLES20.GL_DEPTH_TEST); mCube = new Cube(); }
@Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { GLES20.glClearColor(0.1f, 0.1f, 0.1f, 1.0f); // Create the texture and pass it to ARCore session to be filled during update(). mBackgroundRenderer.createOnGlThread(/*context=*/this); mSession.setCameraTextureName(mBackgroundRenderer.getTextureId()); try { mPlaneRenderer.createOnGlThread(/*context=*/this, "trigrid.png"); } catch (IOException e) { Log.e(TAG, "Failed to read plane texture"); } mPointCloud.createOnGlThread(/*context=*/this); }
@Override public void onSurfaceCreated(GL10 unused, EGLConfig config) { GLES20.glClearColor(0.0f, 0.15f, 0.15f, 1.0f); GLES20.glEnable(GLES20.GL_DEPTH_TEST); lastFrameTime = System.currentTimeMillis(); myShader = new MyShader(); }
@Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { //设置屏幕背景色RGBA GLES20.glClearColor(0,0,0, 1.0f); //创建点或线对象 pointsOrLines=new PonitOrLines(PointLineSurfaceView.this); //打开深度检测 GLES20.glEnable(GLES20.GL_DEPTH_TEST); //打开背面剪裁 GLES20.glEnable(GLES20.GL_CULL_FACE); }
@Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { // Set the background clear color to black. GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Use culling to remove back face. GLES20.glEnable(GLES20.GL_CULL_FACE); // Enable depth testing GLES20.glEnable(GLES20.GL_DEPTH_TEST); mCube = new Cube(mActivity); }
@Override public void onSurfaceCreated(GL10 gl10, EGLConfig eglConfig) { // Set the background frame color GLES20.glClearColor(0f, 0f, 0f, 1f); GLES20.glEnable(GL10.GL_LINE_SMOOTH); // IMPORTANT: This must be created here, it can't be moved to the constructor. this.line = new GraphGLLine(ctx, new float[]{0f, 1f, 0f, 1f}, durationSec); }
@Override public void onSurfaceCreated(GL10 unused, EGLConfig config) { GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); mTable = new Table(); mMallet = new Mallet(); mTextureShaderProgram = new TextureShaderProgram(mContext); mColorShaderProgram = new ColorShaderProgram(mContext); mTexture = Utils.loadTexture(mContext, R.drawable.air_hockey_surface); }
protected int findConfigAttrib( EGL10 egl, EGLDisplay display, EGLConfig config, int attribute, int defaultValue) { if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) { return mValue[0]; } return defaultValue; }
@Override public void onSurfaceCreated( GL10 gl, EGLConfig config) { // mMapDrawing.openMap(); mMapDrawing.initDrawContext(mEgl, mEglDisplay, mEglSurface, mEglContext); }