void parseTimer(wchar_t *wcstr, time_t &timer, time_t &end) { char *cstr = new char[MAX_CHAR_LEN]; wcstombs(cstr, wcstr, MAX_CHAR_LEN); string str = string(cstr); delete[] cstr; cstr = NULL; int h=0, m=0, s=0; stringstream sstr; int offset = str.length()-6; //how many digits has the first number? *:XX:XX string h_str = str.substr(0, offset); sstr = stringstream(h_str); sstr >> h; string m_str = str.substr(offset+1, 2); sstr = stringstream(m_str); sstr >> m; string s_str = str.substr(offset+4, 2); sstr = stringstream(s_str); sstr >> s; end = time(0) + h*60*60+m*60+s; timer = h*60*60+m*60+s; }
bool Game::InitBricks() { brick_info.clear(); // LOAD BRICK INFO std::string row; std::ifstream fstream("../maps/bricks.txt"); if(!fstream.is_open()) return false; while(!fstream.eof()) { std::getline(fstream, row); std::stringstream stringstream(row); char id; stringstream >> id; std::string filename; stringstream >> filename; brick_info.insert(std::pair<int, std::string>(Utils::char_to_int(id), filename)); } std::string path = "../maps/" + Utils::int_to_string(level) + ".txt"; fstream.close(); fstream.open(path.c_str()); if(!fstream.is_open()) return false; int brick_width; int brick_height; int row_size; fstream >> row_size >> brick_width >> brick_height; columns = row_size; int x = 0; int y = 0; row = ""; int count_rows = 0; while(!fstream.eof()) { std::getline(fstream, row, '\n'); if(row.length() == 0) continue; x = 0; for(unsigned int i = 0; i < row.length(); i++) { if(row[i] == '0') { x += brick_width; continue; } auto it = brick_info.find(Utils::char_to_int(row[i])); if(it == brick_info.end()) continue; Brick *brick = new Brick(it->second, (float)x, (float)y + (float)gamearea_y, brick_width, brick_height); brick->Create(spriteManager, 0, 0); brick->setLevel(Utils::char_to_int(row[i])); bricks.push_back(brick); x += brick_width; } y += brick_height; count_rows++; } rows = count_rows; return true; }
// // Simple colunm multiplication // string Multipclication(const MyBigInt& first, const MyBigInt& second) { stringstream ss;// temp for inside for loop string gl = "0"; // this will hold whole result //global << 0; int remain = 0; // temporary which will hold remain for next stem of multiplying(9*2)-->remain 1 int counter = 1; for (int i = first.get_value().length() - 1; i >= 0; i--) { for (int j = second.get_value().length() - 1; j >= 0; j--) { // multiplication in column int temp = (first.get_value()[i] - '0') * (second.get_value()[j] - '0') + remain; remain = temp / 10; temp %= 10; ss << temp; } if (remain) ss << remain; remain = 0; auto s = ss.str(); reverse(s.begin(), s.end()); ss = stringstream(); for (int k = 0; k < counter; k++) ss << 0; counter++; b::cpp_int first_m(gl); b::cpp_int second_m(s); b::cpp_int res = first_m + second_m; gl = res.str(); } return gl; }
void SystemUserMappingUnix::GetGroupnames(uid_t uid, gid_t gid, pid_t pid, std::list<std::string>* groupnames) { groupnames->push_back(GIDToGroupname(gid)); #ifdef __linux__ // Parse /proc/<pid>/task/<pid>/status like fuse_req_getgroups. string filename = "/proc/" + boost::lexical_cast<string>(pid) + "/task/" + boost::lexical_cast<string>(pid) + "/status"; ifstream in(filename.c_str()); string line; // C++ getline() does check for failbit or badbit of the istream. If of these // bits are set, it does break from the while loop, for instance if the file // does not exist. In this case no additional groups are added. while (getline(in, line)) { if (line.length() >= 8 && line.substr(0, 8) == "Groups:\t") { // "Groups: " entry found, read all groups std::stringstream stringstream(line.substr(8, line.length() - 8 - 1)); std::string group_id; while (getline(stringstream, group_id, ' ')) { gid_t supplementary_gid = boost::lexical_cast<gid_t>(group_id); if (supplementary_gid != gid) { groupnames->push_back(GIDToGroupname(supplementary_gid)); } } break; } } #endif }
void parseScore(wchar_t *wcstr, int &score, Status &status) { char *cstr = new char[MAX_CHAR_LEN]; wcstombs(cstr, wcstr, MAX_CHAR_LEN); stringstream ss = stringstream(cstr); ss >> score; delete[] cstr; cstr = NULL; if (score == 0) {status = DEFEAT;} }
//================================================================================================// bool InitSDL(const char* winName, int width, int height, int bpp, bool vsync, bool fscreen) { gLog.OutPut("\n[Initializing Video Settings]\n"); const SDL_VideoInfo* info = NULL; if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE) < 0 || !(info = SDL_GetVideoInfo())) { gLog.OutPut("\n[Failed to initialize Video Settings]\n"); return false; } SDL_WM_SetIcon(SDL_LoadBMP("icon1.bmp"), NULL); int flags = SDL_OPENGL | (fscreen?SDL_FULLSCREEN:0); /* SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); // SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); */ SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); SDL_GL_SetAttribute( SDL_GL_BUFFER_SIZE, 0); if(SDL_SetVideoMode(width, height, bpp, flags) == 0) { SDL_Quit(); return false; } stringstream(str); str << "Resolution Set: " << width << "x" << height << "x" << bpp << endl; gLog.OutPut(str.str()); #ifdef _WIN32 if(!vsync) { PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) wglGetProcAddress("wglSwapIntervalEXT"); if(wglSwapIntervalEXT==NULL) PostQuitMessage(0); wglSwapIntervalEXT(0); gLog.OutPut("Vsync Disabled.\n"); } #endif /* else { PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) wglGetProcAddress("wglSwapIntervalEXT"); if(wglSwapIntervalEXT==NULL) PostQuitMessage(0); wglSwapIntervalEXT(1); gLog.OutPut("Vsync Enabled.\n"); } */ SDL_ShowCursor(0); SDL_WM_SetCaption(winName, NULL); gLog.OutPut("Complete...\n\n"); return true; }
cObj::cObj(std::string filename) { std::ifstream ifs(filename.c_str(), std::ifstream::in); std::string line, key; while (ifs.good() && !ifs.eof() && std::getline(ifs, line)) { key = ""; std::stringstream stringstream(line); stringstream >> key >> std::ws; if (key == "v") { // vertex vertex v; float x; while (!stringstream.eof()) { stringstream >> x >> std::ws; v.v.push_back(x); } vertices.push_back(v); } else if (key == "vp") { // parameter
MacroAtom::MacroAtom(vector<ProgramLine> definition){ string token; //extract name string header = definition[0].text; Parser::extractAndRemoveFirstToken(header, token); stringstream ss = stringstream(header); getline(ss, this->name, '('); string parameterList; getline(ss, parameterList, ')'); parameters = Parser::commaSeparatedLiteralListExplode(parameterList); for(int i=1; i<definition.size()-1; i++){ this->body.push_back(definition[i]); } numTimesUsed = 0; }
string GameStatus::toString(){ stringstream buf = stringstream(); struct tm * timeinfo; time_t rawCurrenttime; time ( &rawCurrenttime ); buf << "Gamestatus:\n"; buf << " name: "+name << "\n"; //buf << " year: "+year << "\n"; char bufff[MAX_CHAR_LEN]; sprintf(bufff,"%d",year); buf << " year: " + string(bufff) << "\n"; //buf << " nextRound: " + nextRound << "\n"; buf << " nextRound: "; buf << asctime(localtime(&nextRound)) << "\n"; buf << " updated: "; buf << asctime(localtime(&rawCurrenttime)) << "\n"; for (int i =0; i<nPlayer;++i){ buf << " P"<<i<<": "<<player[i].toString()<<"\n"; } return buf.str(); }
SDL_RenderTarget* Create_pBuffer(unsigned int width, unsigned int height) { SDL_RenderTarget* pTarget=NULL; GLuint tID; glGenTextures(1, &tID); UTIL_GL::BindTexture(GL_TEXTURE_2D, tID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); pTarget = SDL_GL_CreateRenderTarget(width, height, NULL); if(pTarget) { #ifdef DEBUG_VERBOSE int value; stringstream(str); str << "Created render target:\n"; gLog.OutPut(str.str());str.clear(); SDL_GL_GetRenderTargetAttribute( pTarget, SDL_GL_RED_SIZE, &value ); str << "SDL_GL_RED_SIZE:" << value << endl; gLog.OutPut(str.str());str.clear(); SDL_GL_GetRenderTargetAttribute( pTarget, SDL_GL_GREEN_SIZE, &value ); str << "SDL_GL_GREEN_SIZE:" << value << endl; gLog.OutPut(str.str());str.clear(); SDL_GL_GetRenderTargetAttribute( pTarget, SDL_GL_BLUE_SIZE, &value ); str << "SDL_GL_BLUE_SIZE:" << value << endl; gLog.OutPut(str.str());str.clear(); SDL_GL_GetRenderTargetAttribute( pTarget, SDL_GL_ALPHA_SIZE, &value ); str << "SDL_GL_ALPHA_SIZE:" << value << endl; gLog.OutPut(str.str());str.clear(); SDL_GL_GetRenderTargetAttribute( pTarget, SDL_GL_DEPTH_SIZE, &value ); str << "SDL_GL_DEPTH_SIZE:" << value << endl; gLog.OutPut(str.str());str.clear(); #endif SDL_GL_BindRenderTarget(pTarget, tID); } return pTarget; }
string to_string(T const& a){ return ((stringstream&)(stringstream()<<a)).str(); }
//! エラー内容を取得する std::string Exception::Message() const { // 未定義の場合は最初にエラー番号を表示 stringstream message = stringstream(); message << this->ErrorCode() << ": "; // エラー番号によって文字列を変化 switch(this->ErrorCode()) { case CL_SUCCESS: message << "成功(SUCCESS)"; break; case CL_DEVICE_NOT_FOUND: message << "デバイスが見つからない(DEVICE_NOT_FOUND)"; break; case CL_DEVICE_NOT_AVAILABLE: message << "デバイスが使用不可(DEVICE_NOT_AVAILABLE)"; break; case CL_COMPILER_NOT_AVAILABLE: message << "コンパイラーが使用不可(COMPILER_NOT_AVAILABLE)"; break; case CL_MEM_OBJECT_ALLOCATION_FAILURE: message << "(MEM_OBJECT_ALLOCATION_FAILURE)"; break; case CL_OUT_OF_RESOURCES: message << "(OUT_OF_RESOURCES)"; break; case CL_OUT_OF_HOST_MEMORY: message << "(OUT_OF_HOST_MEMORY)"; break; case CL_PROFILING_INFO_NOT_AVAILABLE: message << "(PROFILING_INFO_NOT_AVAILABLE)"; break; case CL_MEM_COPY_OVERLAP: message << "(MEM_COPY_OVERLAP)"; break; case CL_IMAGE_FORMAT_MISMATCH: message << "(IMAGE_FORMAT_MISMATCH)"; break; case CL_IMAGE_FORMAT_NOT_SUPPORTED: message << "(IMAGE_FORMAT_NOT_SUPPORTED)"; break; case CL_BUILD_PROGRAM_FAILURE: message << "プログラムビルド失敗(BUILD_PROGRAM_FAILURE)"; break; case CL_MAP_FAILURE: message << "(MAP_FAILURE)"; break; case CL_MISALIGNED_SUB_BUFFER_OFFSET: message << "(MISALIGNED_SUB_BUFFER_OFFSET)"; break; case CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST: message << "(EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST)"; break; case CL_INVALID_VALUE: message << "不正な値(INVALID_VALUE)"; break; case CL_INVALID_DEVICE_TYPE: message << "不正なデバイスタイプ(INVALID_DEVICE_TYPE)"; break; case CL_INVALID_PLATFORM: message << "不正なプラットフォーム(INVALID_PLATFORM)"; break; case CL_INVALID_DEVICE: message << "不正なデバイス(INVALID_DEVICE)"; break; case CL_INVALID_CONTEXT: message << "不正なコンテキスト(INVALID_CONTEXT)"; break; case CL_INVALID_QUEUE_PROPERTIES: message << "不正なキュープロパティ(INVALID_QUEUE_PROPERTIES)"; break; case CL_INVALID_COMMAND_QUEUE: message << "不正なコマンドキュー(INVALID_COMMAND_QUEUE)"; break; case CL_INVALID_HOST_PTR: message << "不正なホストメモリのポインタ(INVALID_HOST_PTR)"; break; case CL_INVALID_MEM_OBJECT: message << "(INVALID_MEM_OBJECT)"; break; case CL_INVALID_IMAGE_FORMAT_DESCRIPTOR: message << "(INVALID_IMAGE_FORMAT_DESCRIPTOR)"; break; case CL_INVALID_IMAGE_SIZE: message << "(INVALID_IMAGE_SIZE)"; break; case CL_INVALID_SAMPLER: message << "(INVALID_SAMPLER)"; break; case CL_INVALID_BINARY: message << "(INVALID_BINARY)"; break; case CL_INVALID_BUILD_OPTIONS: message << "(INVALID_BUILD_OPTIONS)"; break; case CL_INVALID_PROGRAM: message << "不正なプログラム(INVALID_PROGRAM)"; break; case CL_INVALID_PROGRAM_EXECUTABLE: message << "(INVALID_PROGRAM_EXECUTABLE)"; break; case CL_INVALID_KERNEL_NAME: message << "不正なカーネル名(INVALID_KERNEL_NAME)"; break; case CL_INVALID_KERNEL_DEFINITION: message << "不正なカーネル定義(INVALID_KERNEL_DEFINITION)"; break; case CL_INVALID_KERNEL: message << "不正なカーネル(INVALID_KERNEL)"; break; case CL_INVALID_ARG_INDEX: message << "不正な引数番号(INVALID_ARG_INDEX)"; break; case CL_INVALID_ARG_VALUE: message << "不正な引数値(INVALID_ARG_VALUE)"; break; case CL_INVALID_ARG_SIZE: message << "不正な引数サイズ(INVALID_ARG_SIZE)"; break; case CL_INVALID_KERNEL_ARGS: message << "不正なカーネル引数(INVALID_KERNEL_ARGS)"; break; case CL_INVALID_WORK_DIMENSION: message << "不正な次元(INVALID_WORK_DIMENSION)"; break; case CL_INVALID_WORK_GROUP_SIZE: message << "不正なワークグループ数(INVALID_WORK_GROUP_SIZE)"; break; case CL_INVALID_WORK_ITEM_SIZE: message << "不正なワークアイテム数(INVALID_WORK_ITEM_SIZE)"; break; case CL_INVALID_GLOBAL_OFFSET: message << "(INVALID_GLOBAL_OFFSET)"; break; case CL_INVALID_EVENT_WAIT_LIST: message << "(INVALID_EVENT_WAIT_LIST)"; break; case CL_INVALID_EVENT: message << "不正なイベント(INVALID_EVENT)"; break; case CL_INVALID_OPERATION: message << "(INVALID_OPERATION)"; break; case CL_INVALID_GL_OBJECT: message << "(INVALID_GL_OBJECT)"; break; case CL_INVALID_BUFFER_SIZE: message << "(INVALID_BUFFER_SIZE)"; break; case CL_INVALID_MIP_LEVEL: message << "(INVALID_MIP_LEVEL)"; break; case CL_INVALID_GLOBAL_WORK_SIZE: message << "(INVALID_GLOBAL_WORK_SIZE)"; break; case CL_INVALID_PROPERTY: message << "(INVALID_PROPERTY)"; break; default: message << "不明なエラー"; break; } // メッセージ文字列を返す return message.str(); }
bool memory_module::update() { float kb_total; float kb_avail; // long kb_free; try { std::ifstream in(PATH_MEMORY_INFO); std::stringstream buffer; string str, rdbuf; int i = 0; in.exceptions(in.failbit); buffer.imbue(std::locale::classic()); while (std::getline(in, str) && i++ < 3) { size_t off = str.find_first_of("1234567890", str.find(':')); buffer << std::strtol(&str[off], 0, 10) << std::endl; } buffer >> rdbuf; kb_total = std::atol(rdbuf.c_str()); buffer >> rdbuf; // kb_free = std::atol(rdbuf.c_str()); buffer >> rdbuf; kb_avail = std::atol(rdbuf.c_str()); } catch (const std::ios_base::failure& e) { kb_total = 0; // kb_free = 0; kb_avail = 0; m_log.err("Failed to read memory values (what: %s)", e.what()); } if (kb_total > 0) m_perc[memtype::FREE] = (kb_avail / kb_total) * 100.0f + 0.5f; else m_perc[memtype::FREE] = 0; m_perc[memtype::USED] = 100 - m_perc[memtype::FREE]; // replace tokens if (m_label) { m_label->reset_tokens(); auto replace_unit = [](label_t& label, string token, float value, string unit) { auto formatted = string_util::from_stream( stringstream() << std::setprecision(2) << std::fixed << value << " " << unit); label->replace_token(token, formatted); }; replace_unit(m_label, "%gb_used%", (kb_total - kb_avail) / 1024 / 1024, "GB"); replace_unit(m_label, "%gb_free%", kb_avail / 1024 / 1024, "GB"); replace_unit(m_label, "%gb_total%", kb_total / 1024 / 1024, "GB"); replace_unit(m_label, "%mb_used%", (kb_total - kb_avail) / 1024, "MB"); replace_unit(m_label, "%mb_free%", kb_avail / 1024, "MB"); replace_unit(m_label, "%mb_total%", kb_total / 1024, "MB"); m_label->replace_token("%percentage_used%", to_string(m_perc[memtype::USED]) + "%"); m_label->replace_token("%percentage_free%", to_string(m_perc[memtype::FREE]) + "%"); } return true; }
//============================================================================= // Processes the command entered, performing different actions depending on the command // Returns true if command was processed, false on no processing //============================================================================= bool Grpg::processCommand(std::string command) { if (command == "pro") { pro = !pro; return true; } else if (command == "easter") { //Send event that player just talked to the Easter Bunny GameEvent* ge = new GameEvent_EntityAction(personLoader->getNPC(28)); gameEventManager->informListeners(ge); return true; } else if (command == "shop") { ui->drawWindow("Solomon's General Store"); ui->setShopItems(vector<Entity*>()); return true; } else if (command == "more") { drawManager->addObject(player, 3); return true; } else if (command == "fish") { player->startFishing(false); return true; } else if (command == "mine") { player->startMining(false); return true; } else if (command.substr(0, 2) == "tp") { std::string location = command.substr(3); VECTOR2 coordinates; if (location == "shop") coordinates = mapLoader->translateIdToCoords('$'); else if (location == "doctor") coordinates = mapLoader->translateIdToCoords('+'); else if (location == "stove") coordinates = mapLoader->translateIdToCoords('b'); else coordinates = mapLoader->translateIdToCoords(*(location.c_str())); player->setX(coordinates.x); player->setY(coordinates.y); player->setVictim(0); player->releaseDestination(); mouseOverEntity = nullptr; player->setIsTeleporting(2); return true; } else if (command.substr(0, 5) == "spawn") { std::string enemyToSpawn = command.substr(6); int enemyId = stoi(enemyToSpawn); NPC::spawn(this, enemyId, VECTOR2(player->getX() + 50, player->getY() - 50), player); return true; } else if (command.substr(0, 2) == "sk") { int a = stoi(command.substr(3)); stringstream ss = stringstream(); ss << Skill::calculateXPRequired(a); ui->addChatText(ss.str()); return true; } else if (command.substr(0, 2) == "se") { bool error = command.length() < 6; if (!error) { std::string eventType = command.substr(3, 2); std::string furtherSubtype = command.substr(6); if (eventType == "ea") { int npcId = stoi(furtherSubtype); gameEventManager->informListeners(new GameEvent_EntityAction(personLoader->getNPC(npcId))); ui->addChatText("GameEvent_EntityAction sent with Entity: " + personLoader->getNPC(npcId)->getname()); } else if (eventType == "ir") { int itemId = stoi(furtherSubtype); gameEventManager->informListeners(new GameEvent_ItemReceived(itemLoader->getItem(itemId))); ui->addChatText("GameEvent_ItemReceived sent with Item: " + itemLoader->getItem(itemId)->getName()); } else if (eventType == "iu") { int itemId = stoi(furtherSubtype); gameEventManager->informListeners(new GameEvent_ItemUsed(itemLoader->getItem(itemId))); ui->addChatText("GameEvent_ItemUsed sent with Item: " + itemLoader->getItem(itemId)->getName()); } else { error = true; } } if (error) { ui->addChatText("Invalid GameEvent Type. Specify either ea, ir or iu"); ui->addChatText("with appropriate parameters"); } return true; } return false; }
void Editor::saveMap() { ofstream out; out.open("Map1.txt"); stringstream line; line << "radius 0.2"; out << line.str() << endl; line = stringstream(); line << "fog 0.1 0.2 0.3"; out << line.str() << endl; float playerX; float playerY; vec2 pos; if (player) { pos = player->getOrigPos(); playerX = pos.x; playerY = pos.y; } else { playerX = 0; playerY = 0; } line = stringstream(); line << "player " << playerX << " " << playerY; out << line.str() << endl; float goalX, goalY; if (goal) { pos = goal->getOrigPos(); goalX = pos.x; goalY = pos.y; } else { goalX = 2; goalY = 2; } line = stringstream(); line << "goal " << goalX << " " << goalY; out << line.str() << endl; line = stringstream(); line << "nrOfObjects " << nrOfObjects; out << line.str() << endl; float wX = 0, wY = 0; string clr; for (int i = 0; i < nrOfObjects; i++) { //wall - 3 4 green pos = allObjects[i]->getOrigPos(); wX = pos.x; wY = pos.y; line = stringstream(); line << "wall " << wX << " " << wY << " " << allObjects[i]->getColorString(); out << line.str() << endl; } }
std::string to_string() { return stringstream().str(); }
bool InitSDL(char* winName, int width, int height, int bpp, bool vsync, bool fscreen) { gLog.OutPut("\n[Initializing Video Settings]\n"); #ifdef USE_SDL2 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE) < 0) #else const SDL_VideoInfo* info = NULL; if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE) < 0 || !(info = SDL_GetVideoInfo())) #endif { gLog.OutPut("\n[Failed to initialize Video Settings]\n"); return false; } #ifdef USE_SDL2 int flags = SDL_WINDOW_OPENGL | (fscreen?SDL_WINDOW_FULLSCREEN_DESKTOP:0); #else int flags = SDL_OPENGL | (fscreen?SDL_FULLSCREEN:0); SDL_WM_SetIcon(SDL_LoadBMP("icon1.bmp"), NULL); #endif /* SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); // SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); */ SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); SDL_GL_SetAttribute( SDL_GL_BUFFER_SIZE, 0); #ifdef USE_SDL2 glWindow = SDL_CreateWindow("Prototype", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, flags); if(!glWindow) { SDL_Quit(); return false; } glContext = SDL_GL_CreateContext(glWindow); if(!glContext) { SDL_Quit(); return false; } SDL_SetWindowIcon(glWindow, SDL_LoadBMP("icon1.bmp")); GetWindowSizeSDL2(width, height); #else if(SDL_SetVideoMode(width, height, bpp, flags) == 0) { SDL_Quit(); return false; } #endif stringstream(str); str << "Resolution Set: " << width << "x" << height << "x" << bpp << endl; gLog.OutPut(str.str()); /* if(!vsync) { PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) wglGetProcAddress("wglSwapIntervalEXT"); if(wglSwapIntervalEXT==NULL) PostQuitMessage(0); wglSwapIntervalEXT(0); gLog.OutPut("Vsync Disabled.\n"); } else { PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) wglGetProcAddress("wglSwapIntervalEXT"); if(wglSwapIntervalEXT==NULL) PostQuitMessage(0); wglSwapIntervalEXT(1); gLog.OutPut("Vsync Enabled.\n"); } */ SDL_ShowCursor(0); #ifdef USE_SDL2 SDL_SetWindowTitle(glWindow, winName); #else SDL_WM_SetCaption(winName, NULL); #endif gLog.OutPut("Complete...\n\n"); return true; }