why my z axis is point to the inner of the screen?

I’m an opengl beginner.I’m sorry my english is very poor,I am just puzzled by my program,because i think it show me that z axis
is point to the inner of the screen.Shouldn’t it point out?
the follow is my program;

#include <gl/glut.h>

static float angle_x = 0, angle_y=-10,angle_z=0;

void axis() //draw the axis
{

glBegin(GL_LINES);
    glColor3f(1.0,0.0,0.0);
 glVertex3f(-0.25f,0.0f,0.0f);    //x   red
 glVertex3f(0.8f,0.0f,0.0f); 
 
 glColor3f(0.8f,0.5f,0.9f);	 
 glVertex3f(0.0f,-0.25f,0.0f);  //y
 glVertex3f(0.0f,0.8f,0.0f);
 
 glColor3f(1.0,1.0,1.0);	 
 glVertex3f(0.0f,0.0f,-0.5f);  //z   white
 glVertex3f(0.0f,0.0f,0.8f);
glEnd();


glBegin(GL_TRIANGLES);

glVertex3f(-0.1,-0.1,0.8);//z
glVertex3f(0.1,0.1,0.8);
glVertex3f(0.0,0.0,1.0);

glColor3f(1.0,0.0,0.0);//x
glVertex3f(0.8,0.1,0.1);
glVertex3f(0.8,-0.1,-0.1);
glVertex3f(1.0,0.0,0.0);

glColor3f(0.8f,0.5f,0.9f);//y
glVertex3f(-0.1,0.8,0.1);
glVertex3f(0.1,0.8,-0.1);
glVertex3f(0.0,1.0,0.0);

glEnd();

}

void myplay()
{

glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);	
glLoadIdentity();	

/* gluPerspective(60.0f,1,0.1f,100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0,0,-2);

*/
glRotatef(-30,0,1,0);
glRotatef(-30,1,0,0);
axis();
glBegin(GL_POLYGON);
glColor3f(1.0,0.0,0.0);
glVertex3f(0.0f,0.0f,0.0f);
glVertex3f(0.0f,0.5f,0.0f);
glVertex3f(0.5f,0.5f,0.0f);
glVertex3f(0.5f,0.0f,0.0f);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1.0f,1.0,0.0);
glVertex3f(0.0f,0.0f,0.0f);
glVertex3f(0.0f,0.5f,0.0f);
glVertex3f(0.0f,0.5f,0.5f);
glVertex3f(0.0f,0.0f,0.5f);
glEnd();

glBegin(GL_POLYGON);
glColor3f(1.0,0.0,1.0);
glVertex3f(0.0f,0.0f,0.0f);      
glVertex3f(0.0f,0.0f,0.5f);
glColor3f(1.0,0.0,0.0);
glVertex3f(0.5f,0.0f,0.5f);
glColor3f(0.0,1.0,0.0);
glVertex3f(0.5f,0.0f,0.0f);
  glEnd();

  glBegin(GL_POLYGON);
  glColor3f(0.0,1.0,0.0);
  glVertex3f(0.0f,0.5f,0.0f);      
  glVertex3f(0.5f,0.5f,0.0f);	 
  glVertex3f(0.5f,0.5f,0.5f);	  
  glVertex3f(0.0f,0.5f,0.5f);
  glEnd();

  glBegin(GL_POLYGON);
  glColor3f(0.0,1.0,1.0);
  glVertex3f(0.5f,0.5f,0.0f);      
  glVertex3f(0.5f,0.5f,0.5f);	 
  glVertex3f(0.5f,0.0f,0.5f);	  
  glVertex3f(0.5f,0.0f,0.0f);
  glEnd();
  
  glBegin(GL_POLYGON);
  glColor3f(0.4,1.0,0.6);
  glVertex3f(0.5f,0.5f,0.5f);      
  glVertex3f(0.5f,0.0f,0.5f);	 
  glVertex3f(0.0f,0.0f,0.5f);	  
  glVertex3f(0.0f,0.5f,0.5f);
  glEnd();

  glFlush();

}

int main(int argc, char *argv[])

{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(300,200);
glutInitWindowSize(400,400);
glutCreateWindow(“cube”);
glutDisplayFunc(&myplay);

glutMainLoop();
return 0;

}

I think the result tell me that the Z axis is point to the innner of the screen.why?
and i found that if i add the remarked code in the founction myplay(),the Z axis direction
will point out,it will be ok,but at this time the rotate angle will be not right .why?
Thank you very much .Now is the spring festival in china ,I wish
you happy new year,have a good luck!恭喜发财!

you are drawing the Z axis in a weird way:


glVertex3f(0.0f,0.0f,-0.5f); //z white
glVertex3f(0.0f,0.0f,0.8f);

The common way is to draw a line from origin (0,0,0) to (0,0,1). This way you display a normalized vector along z axis.
I have noticed that you are computing some rotations before drawing axis, it would change the axis orientation then.

thank you very much.now i think i know the answer to my second question.but i still don’t know the first question.

I compute some rotation is to look at the z axis ,and as we know the rotation won’t change the right-handed cartesian coordinates ,but the program result is left-handed cartesian coordinates.i am puzzled.if you can run the program and tell me more about the result ,it is too greatful,thank you very much