bool iEngine::Init() { L = lua_open(); renderer_root_ = new renderer::Root(); renderer_root_->restoreConfig(); // 根据配置文件创建渲染窗口 render_window_ = new OSWindow(); std::string name = "test"; int width = 800, height = 600; int colourDepth = 32; bool fullScreen = false; int left = 0, top = 0; bool depthBuffer = true; render_window_->create(name, width, height, colourDepth, fullScreen, left, top, depthBuffer); // ? SetupResource(); renderer_root_->initialise(); // Set default mipmap level (NB some APIs ignore this) renderer::TextureManager::getSingleton().setDefaultNumMipMaps(5); // 读取配置 // 配置渲染器 ConfigRenderer(); // 渲染窗口挂接到渲染系统 renderer_root_->getRenderSystem()->attachRenderTarget(*render_window_); return true; }
// This function does any needed initialization on the rendering context. // This is the first opportunity to do any OpenGL related tasks. void SetupRC() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45, (double)SCREEN_WIDTH / (double)SCREEN_HEIGHT, NEAR_PLANE, FAR_PLANE); gluLookAt(5, 5, 5, 0, 0, 0, 0, 1, 0); // 各种变换应该在GL_MODELVIEW模式下进行 glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Z-buffer glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); // 启用2D贴图 glEnable(GL_TEXTURE_2D); SetupResource(); }