Can't see anything

Hello,
I am very new to OpenGL and am trying to run an example from a book. It is a very basic bouncing box example. The problem is sometimes I see the bouncing box and sometimes just a colored background without any box. I don’t know if this problem is becuase of the code, OpenGL or because of my graphics card.

Here is the code:
</font><blockquote><font size=“1” face=“Verdana, Arial”>code:</font><hr /><pre style=“font-size:x-small; font-family: monospace;”>
#include <windows.h>
#include <glut.h>

//Initial square position and size
GLfloat x1 = 100.0f;
GLfloat y1 = 150.0f;
GLsizei rsize = 25;

//Step size in and y directions
//no. of pixels to move each time
GLfloat xstep = 1.0f;
GLfloat ystep = 1.0;

//keep track of windows changing width and height
GLfloat windowWidth;
GLfloat windowHeight;

//Called to draw scene
void RenderScene ( void )
{
//Clear the window with current clearing color
glClear ( GL_COLOR_BUFFER_BIT );

//set current drawing color
glColor3f ( 1.0f, 0.0f, 0.0f );

//Draw a filled rectangle with current color
glRectf ( x1, y1, x1+rsize, y1+rsize );

//Flush drawing commands and swap
glutSwapBuffers();
}

//Called by GLUT library when idle (window not being resized or moved)
void TimerFunction (int value)
{
//Reverse direct when you reach left or right edge
if ( x1>windowWidth-rsize

I think the problem is somewhere in the rest of your code. Did you specify a double buffered window (GLUT_DOUBLE)?

Nico