bool RenderService::loadComponentInfo(Renderable *c) { if (c->typeID == COMPONENT_TYPE_RENDERABLE_TEXTURE) return loadTextureInfo(c); else if (c->typeID == COMPONENT_TYPE_RENDERABLE_COLOR) return loadColorInfo(c); else return false; }
//Main program void init(){ // srand((unsigned int)time(void)); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA | GLUT_DEPTH ); glutInitWindowPosition(0,0); glutInitWindowSize( 512, 512 ); // glutInitContextVersion( 2, 1 ); glutCreateWindow("Window"); GLfloat mat_diffuse[] = { 0.7, 0.7, 0.7, 1.0 }; GLfloat mat_specular[] = { 0.0, 0.0, 0.0, 1.0 }; GLfloat mat_shininess[] = { 10.0 }; GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; glClearColor (0.0, 0.0, 0.0, 0.0); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); glEnable(GL_AUTO_NORMAL); glEnable(GL_NORMALIZE); glEnable(GL_COLOR_MATERIAL); glEnable(GL_RESCALE_NORMAL); glClearColor(0,0,0,1.0); glClearDepth(20.0f); // Set background depth to farthest glDepthFunc(GL_LEQUAL); // Set the type of depth-test #ifdef USE_PERSPECTIVE glViewport(0,0,1.0,1.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); // Reset // Enable perspective projection with fovy, aspect, zNear and zFar gluPerspective (60.0f, 1.0f, 0.1f, 10.0f); glTranslatef(0.0f,0.0f,-1.5f); glScalef(0.60f,0.60f,0.60f); #endif #ifdef USE_ORTHOGRAPHIC glViewport(0,0,1.0,1.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1,1,-1,1,-1,1); glTranslatef(0.0f,0.0f,-0.0f); glScalef(0.50f,0.50f,0.50f); #endif glMatrixMode(GL_MODELVIEW); loadTextureInfo(); }