Hi people!

I am having problems drawing things with opengl...
I have two functions, one that sets up all the environment (initOGL),
and other that actually draws something using that environment
(onDraw)
in order to make it easy to understand, at the moment I am just trying
to paint the screen with a pink color (255, 0, 126, 80), using
glClearColor().

This seems quite straight forward, but so far I get nothing but a
frustrating blank screen...

does anybody have any ideas about what I am missing?

Thanks a lot!!




class myView extends SurfaceView implements SurfaceHolder.Callback
{

        GL10 gl;
        EGL10 egl;
        EGLDisplay display;
        EGLConfig config;
        EGLContext glc;
        EGLSurface surface;

        public boolean initOGL()
        {

                egl = (EGL10)EGLContext.getEGL();

                display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

                int[] version = new int[2];
                egl.eglInitialize(display, version);

                int[] configSpec =
                {
                        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, configSpec, configs, 1, 
num_config);
                EGLConfig config = configs[0];

                glc = egl.eglCreateContext(display, config,EGL10.EGL_NO_CONTEXT,
null);

                surface = egl.eglCreateWindowSurface(display,
config,this.getHolder(), null);

                egl.eglMakeCurrent(display, surface, surface, glc);

                gl = (GL10) (glc.getGL());

                gl.glViewport(0, 0, babelView.screenWidth, 
babelView.screenHeight);
                gl.glMatrixMode(GL10.GL_PROJECTION);
                gl.glLoadIdentity();
                float ratio = (float) myView.screenWidth / myView.screenHeight;
                GLU.gluPerspective(gl, 45.0f, ratio, 1, 100f);

                gl.glEnable(GL10.GL_DEPTH_TEST);
                gl.glDepthFunc(GL10.GL_LEQUAL);
                gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

                gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
                gl.glEnable(GL10.GL_TEXTURE_2D);
                gl.glDisable(GL10.GL_DITHER);
        }

        @Override
        protected void onDraw(Canvas canvas)
        {
                egl.eglWaitNative(EGL10.EGL_NATIVE_RENDERABLE, null);

                gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

                gl.glClearColor(255, 0, 126, 80);

                egl.eglWaitGL();

                egl.eglSwapBuffers(display, surface);
        }


}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
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