Simple Question : What's the sequence of init GL,GLSL,and glut ?

In most of simple gl program,we can see the simple sequence ,glutCreateWindow,at last,there’s,glutMainLoop().

In the glsl demo from 3dlabs, I found the “InstallShader” is before the glutMainLoop(),after the functions such as glutResharpFunc().That’s It !

In my CRender class,

void CRender::InitOpenGL(const char* title, int Width,int Height, int argc,char** argv)
{
	glutInit( &argc, argv );
	glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
	glutInitWindowSize(Width, Height);
	Window = glutCreateWindow(title);
        glutReshapeFunc(ReshapeFunction);
	glutIdleFunc(Play);
	EnableDepthTest(GL_LESS);
	glClearColor(0.0, 0.0, 0.0,1.0f);
	glClearDepth(1.0f);
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LESS);
	glShadeModel(GL_SMOOTH);
	ASSERT( Window != 0 );
        isGLInitOK = 1;
};


void CRender::SetupShader(const char* vs,const char* fs)
{
	if( glewInit() != GLEW_OK ){
		cout<<"glew Init Failed"<<endl;
	}else{
		cout<<"glew OK!"<<endl;
		if (GLEW_ARB_shader_objects){
			cout<<"Support Shading Language"<<endl;
			Shader = new CShader;
			Shader->InitShaders(vs,fs);
		}
	}
};

In main.cpp

  
	CRender* RC = new CRender();
	RC->InitOpenGL("HopeOk",800,600,argc,argv);
	CScene* S1 = new CScene(2);

	CModel* M1 = new CSceneTransition();
	CModel* M2 = new CStreamModel(64,1.0f);

	S1->AddModel(M2);
	S1->AddModel(M1);
	RC->PushNewScene(S1);
	RC->SetupShader("demo.vert","demo.frag");
	RC->EnableShaders();
	RC->MainLoop();
	return 0;

if all is above,it’s ok,shaders works not completely correctly,but it’s working.

if i move the " RC->SetupShader(“demo.vert”,“demo.frag”);
RC->EnableShaders();" after the RC->InitGL(),that’s bad.

thanks for your explaination

What is your question?