本文整理汇总了C++中std::fstream::rdbuf方法的典型用法代码示例。如果您正苦于以下问题:C++ fstream::rdbuf方法的具体用法?C++ fstream::rdbuf怎么用?C++ fstream::rdbuf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::fstream
的用法示例。
在下文中一共展示了fstream::rdbuf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void Game::init() {
//Set up log file
logFile.open("log.txt", std::fstream::out);
//Make std::cerr redirect to the log file
std::cerr.rdbuf(logFile.rdbuf());
logFile << "Initializing...\n";
SDL_Init(SDL_INIT_EVERYTHING);
if((window = SDL_CreateWindow(baseWindowTitle.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, screenWidth, screenHeight, SDL_WINDOW_OPENGL)) == 0) {
logFile << "Error creating window: " << SDL_GetError() << std::endl;
stop();
return;
}
logFile << "Created window" << std::endl;
if((renderer = SDL_CreateRenderer(window, -1, 0)) == NULL) {
logFile << "Error creating renderer: " << SDL_GetError() << std::endl;
stop();
return;
}
logFile << "Created renderer" << std::endl;
if((glcontext = SDL_GL_CreateContext(window)) == NULL) {
logFile << "Error creating OpenGL context: " << SDL_GetError() << std::endl;
stop();
return;
}
glewInit();
logFile << "Created OpenGL context" << std::endl;
//Initialize OpenGL
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
resizeWindow(screenWidth, screenHeight);
lastMouseState = 0;
//Initialize things here
curScene = new Scene();
//
logFile << "Finished initializing" << std::endl;
}