I want to get a image by eglCreatePixmapSurface;but it show the
following error in log when  GL10 be used.

 ERROR/libEGL(2154): call to OpenGL ES API with no current context
(logged once per thread)


my code is :

        public void init() {
                if (!isInit) {
                        // initialize egl
                        egl = (EGL10) EGLContext.getEGL();
                        display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
                        egl.eglInitialize(display, null);
                        int[] configWant = {
                                        EGL10.EGL_SURFACE_TYPE, 
EGL10.EGL_PIXMAP_BIT,
                                        EGL10.EGL_RED_SIZE, 5, 
EGL10.EGL_GREEN_SIZE, 6,
                                        EGL10.EGL_BLUE_SIZE, 5, 
EGL10.EGL_DEPTH_SIZE, 16,
                                        EGL10.EGL_NONE };
                        EGLConfig[] configs = new EGLConfig[1];
                        int[] num_config = new int[1];
                        egl.eglChooseConfig(display, configWant, configs, 1, 
num_config);
                        bmp = Bitmap.createBitmap(100, 100, Config.ARGB_8888);
                        g = new Canvas(bmp);
                        p = new Paint();
                        context = egl.eglCreateContext(display, configs[0],
                                        EGL10.EGL_NO_CONTEXT, null);
                        surface = egl
                                        .eglCreatePixmapSurface(display, 
configs[0], bmp, null);
                        egl.eglMakeCurrent(display, surface, surface, context);
                        gl = (GL10) context.getGL();
                        initData(gl);
                        delta = -1;
                        if (fps > 0) {
                                delta = 1000 / fps;
                        }
                        isInit = true;
                }
        }
        @Override
        public void run() {
                init();
                while (isInit) {
                        if (running) {
                                int w;
                                int h;
                                loopTime = System.currentTimeMillis();
                                synchronized (this) {
                                        w = width;
                                        h = height;
                                }
                                if (resize) {
                                        resize(gl, w, h);
                                        resize = false;
                                }

                                runX();
                                paint(gl);

                                // egl.eglSwapBuffers(display, surface);
                                g.drawBitmap(bmp, 0, 0, p);

                                if (egl.eglGetError() == 
EGL11.EGL_CONTEXT_LOST) {
                                        Context c = getContext();
                                        if (c != null && c instanceof Activity) 
{
                                                ((Activity) c).finish();
                                        }
                                }
                                long time = System.currentTimeMillis() - 
loopTime;
                                try {
                                        Thread.sleep(Math.max(1L, (long) delta 
- time));
                                } catch (InterruptedException e) {
                                        e.printStackTrace();
                                }
                        } else {
                                try {
                                        Thread.sleep(50);
                                } catch (InterruptedException e) {
                                        e.printStackTrace();
                                }
                        }
                }
        }

        protected void initData(GL10 gl) {
                gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);

                gl.glMatrixMode(GL10.GL_PROJECTION);
                gl.glLoadIdentity();
                GLU.gluOrtho2D(gl, 0.0f, 1.3f, 0.0f, 1.0f);
                gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
                gl.glShadeModel(GL10.GL_SMOOTH);
        }

... ...

How can I get a image from egl?
I want to add 3D effects in my program  using GL

kind regards,

joniy

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to