Hi,

I know what i am asking is a silly question, but somehow i am not able to get the answer of it. I want to create a window & then clear a particular area of that window with a given color. I am able to clear the whole buffer/window using glClearColor, but not able to achieve clearing a specific region. I am putting my code here, if any one please point out where i am going wrong, it would be great.Thanks a lot.

#include <stdio.h>
#include <GL/gl.h>
#include <GL/glut.h>
#include <GLES/egl.h>


#define WIDTH 400
#define HEIGHT 400


EGLDisplay disp;
EGLSurface egl_surf;
void display(void)
{
/* draw white polygon (rectangle) with corners at
* (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
*/
glColor4f (0.0, 0.0, 1.0,1.0);
//glBegin(GL_POLYGON);
glVertex3f (100, 100, 0.0);
glVertex3f (300, 100, 0.0);
glVertex3f (300, 250, 0.0);
glVertex3f (100, 250, 0.0);
//glEnd();
//HERE the above code does not work. i am not able to clear the area with BLUE

/* don't wait!
* start processing buffered OpenGL routines
*/
glFlush ();
eglSwapBuffers(disp,egl_surf);
}

void init (void)
{
/* select clearing (background) color */
glClearColor (1.0, 0.0, 0.0, 1.0);
glClear (GL_COLOR_BUFFER_BIT);
eglSwapBuffers(disp,egl_surf); // ==>THIS IS SUCCESSFUL, i can see the buffer cleared with RED.

/* initialize viewing values */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}

/*
* Declare initial window size, position, and display mode
* (single buffer and RGBA). Open window with "hello"
* in its title bar. Call initialization routines.
* Register callback function to display graphics.
* Enter main loop and process events.
*/


int main (int argc,
char *argv[])
{
//RAHAMAN -EGL related code

EGLint cfg_attribs[] = {
EGL_BUFFER_SIZE, EGL_DONT_CARE,
EGL_RED_SIZE, 5,
EGL_GREEN_SIZE, 6,
EGL_BLUE_SIZE, 5,
EGL_DEPTH_SIZE, 16,
EGL_ALPHA_SIZE, EGL_DONT_CARE,
EGL_STENCIL_SIZE, 2,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_NONE
};

EGLBoolean status=EGL_FALSE;
printf("Default value of status %d \n",status);
EGLConfig configs[2];
EGLint config_count;
EGLContext egl_context;

GLshort rect_verts[8] = {
(GLshort) 100, (GLshort) 100,
(GLshort) 140, (GLshort) 100,
(GLshort) 100, (GLshort) 300,
(GLshort) 140, (GLshort) 300
};


int egl_major,egl_minor;


//RAHAMAN EGL context related code
disp = eglGetDisplay(EGL_DEFAULT_DISPLAY);

status = eglInitialize (disp,
&egl_major,
&egl_minor);
printf("eglInit returns status %d \n",status);
status = eglGetConfigs (disp,
configs,
2,
&config_count);
printf("eglGetConfig returns status %d \n",status);
status = eglChooseConfig (disp,
cfg_attribs,
configs,
1,
&config_count);
printf("eglChoose returns status %d \n",status);
egl_surf=eglCreateWindowSurface (disp,configs[0],
//(NativeWindowType) stage_x11->xwin,
(NativeWindowType) updater_get_native_window(0, 0, WIDTH,HEIGHT),
NULL);

printf("eglCreateWindow returns status %d \n",eglGetError());

egl_context=eglCreateContext (disp,configs[0],EGL_NO_CONTEXT,NULL);

printf("eglCreateContext returns status %d \n",eglGetError());
eglMakeCurrent (disp,egl_surf,egl_surf,egl_context);
printf("eglMakeCurrent returns status %d \n",eglGetError());

init ();
display();
//glutMainLoop();
return 0; /* ISO C requires main to return int. */
}