Example #1
0
void GL::init(int* argcp, char** argv,
	      const char* name, const char* init_data, 
	      const int screen_x, const int screen_y)
{
	/* データ準備 */
	// 基本となる正方形を初期化
	glNewList(PRI_SQUARE, GL_COMPILE);
	glBegin(GL_QUADS);
	glVertex3d(0.0, 0.0, 0.0);
	glVertex3d(1.0, 0.0, 0.0);
	glVertex3d(1.0, 1.0, 0.0);
	glVertex3d(0.0, 1.0, 0.0);
	glEnd();
	glEndList();

	mMap = new Map(name, init_data);
	mStructureManager = new StructureManager();
	Structure* t = new SimpleStructure();
	t->setLocate(1, 1);
	mStructureManager->addStructure(t);

	mViewpoint.setComp(mMap->width() / 2.0, mMap->height() / 2.0, 0.0);
	mCameraDir.setComp(0.0, 1.0, 10.0);
	mCameraDir.normalize();
	mMagni = 10.0;

	mScreenX = screen_x;
	mScreenY = screen_y;

	/* OpenGL, GLUTの設定 */
	glutInitWindowSize(mScreenX, mScreenY);
	glutInit(argcp, argv);
	glutInitDisplayMode(GLUT_RGBA/* | GLUT_DEPTH*/);
	glutCreateWindow("My Sim");

	glutDisplayFunc(GL::display);
	glutReshapeFunc(GL::resize);
	glutMouseFunc(GL::mouse);
	glutMotionFunc(GL::motion);
	glutKeyboardFunc(GL::keyboard);

	//glEnable(GL_DEPTH_TEST);

	glClearColor(1.0, 1.0, 1.0, 1.0);

}