Another "delete" issue - how to selectively update text messge?

I like to track state machine on window.
There must be a simple way to clear the previous text, but this test code does not do it. It just "writes over " - even tried empty text.
( maybe OpenGL is smart and won’t bother outputting empty string )

Any hint woudl be appreciated.

PS I cannot just clear the entire buffer, I need to do this selectively.

	{  // print system_state code block 

			glPushMatrix();
			//change matrix relative to "current matrix"
			glTranslatef(0.1f, 0.1f, 0.0f);
			//glRotated(rotVar, 20.0, 20.0, 10.0);
			//drawRGBCube();
			//glPopMatrix();
			char *message = "system_state   ZOOM_IDLE ";
			// output message relative to "push" matrix
			OpenGL_text(message, 0, 0.5, 0); //"FAILED bad file descriptor ");
			glPopMatrix();
			glutSwapBuffers();
			sleep(5);
			// test "erase "
			glPushMatrix();
			//change matrix relative to "current matrix"
			glTranslatef(0.1f, 0.1f, 0.0f);
			//glRotated(rotVar, 20.0, 20.0, 10.0);
			//drawRGBCube();
			//glPopMatrix();
			message = "test erase ";
			"";
			// output message relative to "push" matrix
			OpenGL_text(message, 0, 0.5, 0); //"FAILED bad file descriptor ");
			glPopMatrix();
			glutSwapBuffers();
			sleep(5);

			glPushMatrix();
			//change matrix relative to "current matrix"
			glTranslatef(0.1f, 0.1f, 0.0f);
			//glRotated(rotVar, 20.0, 20.0, 10.0);
			//drawRGBCube();
			//glPopMatrix();
			message = "system_state   ZOOM_IDLE ";
			// output message ralative to "push" matrix
			OpenGL_text(message, 0, 0.5, 0); //"FAILED bad file descriptor ");
			glPopMatrix();
			glutSwapBuffers();

			// no need glFlush(); // ??

		}

Addendum / debugging
putting glLoadIdentity() after push matrix
did not work

What does this function do, and more importantly how does it do it?

void OpenGL_text(char *message, float x, float y, float z) {
	char menu[80];
	strcpy(menu, message); // local copy 
	int len;
	len = strlen(menu);
	glColor3f(1, 1, 1);         // white 
	glRasterPos3f(x, y, z); // text start postion
	for (int i = 0; i < len; ++i) {
		glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, menu[i]);
	}
}

OpenGL renders what you tell it to render. It doesn’t store “objects”.

Does the display function start with a call to glClear?

The arguments to glRasterPos are in object coordinates; they’re transformed by the modelview and projection matrices. glWindowPos allows the raster position to be specified in window coordinates. The raster position is stored in window coordinates, so the transformation is based upon the values of the matrices at the time of the glRasterPos call.

I don’t think there’s anything wrong with that part.

Thanks , it is a start.

It is back to coordinates nightmare.
On first look - raster position is specified in normalized coordinates.
Perhaps I will take a second look on raster position man to make sure .
Window coordinates are “in pixels”.
But that should not matter - if I transform either coordinate system OUT of “window space” - wherever that means - to some other space - presumably matrix- , I still have no clue how to replace the text ( actually a bitmap ).

Here is the latest modification to the code.
The disabled #ifdef / #endif code was added , the text is still being written over the initial bitmap and now in wrong raster position.

It is my understanding that OpenGL keeps the data - bitmap in this case - in video card hardware. So to override / update the data I have to access that particular hardware .
Or in another words - OpenGL “variable / object” cannot be just overwritten like C code.

So I believe I need to keep track of “matrix” where the initial bitmap is written and then

glLoadIdentity();
should clear the entire matrix.

Correct me if I am wrong, but glClear would not work SELECTIVELY , it would clear entire buffer. But I can verify that.

//display
// normal parametrized function
// passive
void OpenGL_text(char *message, float x, float y, float z) {

//#ifdef BYPASS
	printf("\nOPENGL TRACE OpenGL  @function %s  @line %i \n", __FUNCTION__,
	__LINE__);
	printf("\nOPENGL TRACE STOP passed message %s @line %i\n", message,
	__LINE__);
//#endif passive
	char menu[80];
	strcpy(menu, message); // local copy ??
	int len;
	len = strlen(menu);
	glColor3f(1, 1, 1);    // white text
//#ifdef BYPASS
	{ // GL_PROJECTION block
		glMatrixMode( GL_PROJECTION); // ??
		glPushMatrix();               // there is only one (?)
		glLoadIdentity();             // clear projection matrix  - why (?)
		gluOrtho2D(0, 500, 0, 500);   // MN !!
		{ // GL_MODELVIEW block
			glMatrixMode( GL_MODELVIEW);
			glPushMatrix();
			glLoadIdentity();         // clear bitmap (?)
//#endif
			glRasterPos3f(x, y, z); // wrong  position  text start postion
			for (int i = 0; i < len; ++i) {
				glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, menu[i]);
			}
//#ifdef BYPASS
			glPopMatrix();        // GL_MODELVIEW
		} // GL_MODELVIEW block
		glMatrixMode( GL_PROJECTION);
		glPopMatrix();
	} // GL_PROJECTION block
	glMatrixMode( GL_MODELVIEW);
//#endif

}

The posted code is pretty much hacked from my ancient version 1.1 red book and after deleting the ortho works as expected.
As the book said - it is specifically useful to write temporary debugging text - into secondary projection matrix (!)
Unfortunately I still do no know HOW to erase the message.
It woudl be nice for some guru to help me.

Broadly speaking, you don’t “erase” things in OpenGL. If you to “remove” a thing, then you redraw the screen without the part that you want to remove.

Still does not compute - using the red book debug text example - I cannot “write” (to secondary projection matrix) AGAIN unless I do glClear.
OK, it will work…for any “objects”, no problema.