void MM_Load(void) { MM_Stack = new TX_STACK; MM_TStack = new TX_STACK; MM_BStack = new B_STACK; bg_MainMenu = LoadTexture("bg_MainMenu.png", "Main Menu: Background"); MM_Btx[0] = LoadText("OPTIONS", 26, "Main Menu: OPTIONS text"); MM_Btx[1] = LoadText("EDITOR", 26, "Main Menu: EDITOR text"); MM_Btx[2] = LoadText("PLAY", 26, "Main Menu: PLAY text"); Stack_Texture(MM_Stack, bg_MainMenu, 0, 0); Stack_Text(MM_TStack, MM_Btx[2], 970, 565); //LEVEL MENU Stack_Text(MM_TStack, MM_Btx[1], 970, 725); //LEVEL EDIT Stack_Text(MM_TStack, MM_Btx[0], 970, 895); //OPTIONS BUTTON Stack_Button(MM_BStack, 620, 500, 700, 130, B_Level_Menu); //LEVEL MENU Stack_Button(MM_BStack, 620, 660, 700, 130, B_LevelEdit); //LEVEL EDIT Stack_Button(MM_BStack, 620, 830, 700, 130, B_OptionsMenu); //OPTIONS BUTTON Stack_Stack(MM_Stack); Stack_TStack(MM_TStack); Stack_BStack(MM_BStack); Exit_Sequence_Add(MM_Unload); }
int NeuralNet::LoadAscii(char *pWeightFile, char *pNormFile, int bunchSize) { mBunchSize = bunchSize; // Weights char *pweights = LoadText(pWeightFile); if(pweights == 0) { return NN_NOWEIGHTS; } if(!GetInfo(pweights, &mNInp, &mNHid, &mNOut)) { delete [] pweights; return NN_BADWEIGHTS; } Alloc(); if(!ParseWeights(pweights)) { delete [] pweights; return NN_BADWEIGHTS; } delete [] pweights; // Norms if(pNormFile) { char *pnorms = LoadText(pNormFile); if(pnorms == 0) { delete [] pweights; return NN_NONORMS; } if(!ParseNorms(pnorms)) { delete [] pweights; return NN_BADWEIGHTS; } mUseNorms = true; delete [] pnorms; } return NN_OK; }
void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_RectF& rect, const CFX_RectF& rtClip) { ASSERT(m_pFont && m_fFontSize >= 1.0f); if (!pwsStr || iLength < 1) return; if (rect.width < m_fFontSize || rect.height < m_fFontSize) { return; } FX_FLOAT fLineWidth = rect.width; if (m_dwStyles & FDE_TTOSTYLE_VerticalLayout) { fLineWidth = rect.height; } m_pTxtBreak->SetLineWidth(fLineWidth); m_ttoLines.RemoveAll(TRUE); m_wsText.clear(); LoadText(pwsStr, iLength, rect); if (m_dwStyles & FDE_TTOSTYLE_Ellipsis) { ReplaceWidthEllipsis(); } Reload(rect); DoAlignment(rect); OnDraw(rtClip); }
int main(int argc, char* argv[]) { if ((argc < 2) || (argc < 3 && argv[1] == "-f" || (argc > 3))) { std::cerr << "Usage: " << argv[0] << " TEXT" << std::endl; std::cerr << "or: " << argv[0] << " -f <filename>" << std::endl; std::cin.get(); return 1; } StateMachineClass NewMachine; std::string text; std::string par = argv[1]; if (par == "-f") { LoadText(argv[2], text); } else { text = argv[1]; } std::clock_t start; double duration; start = std::clock(); NewMachine.Process(text); duration = (std::clock() - start) / (double)CLOCKS_PER_SEC; std::cout << "Words count: " << NewMachine.Words() << std::endl; std::cout << "Spaces count: " << NewMachine.Spaces() << std::endl; std::cout << "Characters count: " << NewMachine.Charecters() << std::endl; std::cout << "Numbers count: " << NewMachine.Numbers() << std::endl; std::cout << "The algorithm took: " << duration << std::endl; //std::cin.get(); return 0; }
BOOL CCollectionFile::Open(LPCTSTR lpszFileName) { Close(); const int nLength = (int)_tcslen( lpszFileName ); if ( nLength < 4 ) return FALSE; if ( _tcsicmp( lpszFileName + nLength - 3, L".co" ) == 0 || nLength > 11 && _tcsicmp( lpszFileName + nLength - 11, L".collection" ) == 0 ) { if ( LoadCollection( lpszFileName ) ) return TRUE; } else if ( nLength > 16 && _tcsicmp( lpszFileName + nLength - 16, L".emulecollection" ) == 0 ) { if ( LoadEMule( lpszFileName ) ) return TRUE; } else if ( nLength > 8 && _tcsicmp( lpszFileName + nLength - 8, L".xml.bz2" ) == 0 ) { if ( LoadDC( lpszFileName ) ) return TRUE; } return LoadText( lpszFileName ); }
void MK_Shader::LoadShader(const char *fileName, GLenum ShaderType) { GLchar *vsString; const GLchar *vsStringPtr[1]; GLint success; vsString = LoadText(fileName); if (!vsString) { fprintf(stderr, "Unable to load \"%s\"\n", fileName); cout << "Unable to load program shader!\n" << fileName << endl; Sleep(5000); exit(0); } vsStringPtr[0] = vsString; GLuint vShader= glCreateShader(ShaderType); glShaderSource(vShader, 1, vsStringPtr, NULL); glCompileShader(vShader); glGetShaderiv(vShader, GL_COMPILE_STATUS, &success); if (!success) { GLchar infoLog[MAX_INFO_LOG_SIZE]; glGetShaderInfoLog(vShader, MAX_INFO_LOG_SIZE, NULL, infoLog); cout << "Error in vertex shader # compilation!\n" << "Info log: " << infoLog << endl; Sleep(5000); exit(0); } glAttachShader(progObj, vShader); free(vsString); }
//Creates a shader with defines void gfx::ShaderProgram::CreateShader ( ifstream* FileStream, GLenum shaderType, const rString& filename,bool print, ShaderDefineContainer& container ) { rString line; size_t found; rString shaderText; getline(*FileStream, line); shaderText += line; shaderText += "\n"; shaderText += container.GetAllDefineLines(); shaderText += container.GetDefinesShaderStage ( shaderType ); bool end = false; while ( !end ) { getline ( *FileStream, line ); //search for the end of the shader found = line.find ( "#include " ); if ( found != rString::npos ) { int i = static_cast<int> ( found ) + 9; //found + "#include " rString s; while ( i < static_cast<int> ( line.length() ) ) { s += line[i]; i++; } rString str = GetDir ( rString ( filename.c_str() ) ) + s; shaderText += LoadText ( str.c_str() ); shaderText += "\n"; } else { found = line.find ( "#end_shader" ); if ( found != rString::npos ) { //break loop end = true; break; } else if ( FileStream->eof() ) { Logger::Log( "Could not find end of file " + filename, "ShaderProgram", LogSeverity::ERROR_MSG ); return; } else { shaderText += line; shaderText += '\n'; } } } if ( shaderText.length() > 0 ) { Shader* shader = tNew( Shader ); shader->CreateFromString ( shaderText, shaderType, filename,print ); m_Shaders.push_back ( shader ); shaderText.clear(); } }
void Update_restext(void) { RemoveTexture(restext, "Options: Resolutions"); Unstack_Texture(Op_TStack, restext); restext = LoadText(Resolutions[Sel_Resolution], 26, "Options: Resolutions"); Stack_Text(Op_TStack, restext, 950, 400); }
double MyService::onAction() { if (init){ LoadText(); //Time = getLocalTime(); obj_index = obj_pos.size(); question_counter = 0; init = false; } else{ if (start){ string message; if (first){ for (int i = 0; i < obj_pos.size(); ++i){ SendToController(obj_pos[i].first, obj_pos[i].second); } this->sendMsgToCtr("man_0", "end"); first = false; cout << "あたらしい物体配置が完了した場合:はじめ" << endl; } cout << "入力待ち:"; cin >> message; if (message == "はじめ"){ this->sendMsgToCtr("man_0", "go"); this->sendMsg("sigverse_DB", "Start"); start = false; } } if (obj_counter == obj_index - 1){ cout << "終了" << endl; obj_counter = 0; } } return 0.1; }
sint32 GreatLibraryWindow::LoadHistoricalText ( SlicObject &so ) { if (!strcmp(m_history_file, "NULL")) return GREAT_LIBRARY_PANEL_BLANK; return(LoadText(m_techHistoricalText, m_history_file, so)); }
sint32 GreatLibraryWindow::LoadGameplayText ( SlicObject &so ) { if (!strcmp(m_gameplay_file, "NULL")) return GREAT_LIBRARY_PANEL_BLANK; return(LoadText(m_techGameplayText, m_gameplay_file, so)); }
// Reads a text resource into m_Text bool CSettingsParser::LoadText( HMODULE hMod, HRSRC hResInfo ) { HGLOBAL hRes=LoadResource(hMod,hResInfo); int size=SizeofResource(hMod,hResInfo); unsigned char *buf=(unsigned char*)LockResource(hRes); if (!buf) return false; LoadText(buf,size); return true; }
bool CResParser::Parse(CResNode* pRootNode, const wchar_t* pszFileName) { CUniString str; result_t r=LoadText(pszFileName, str); if (r) { SetError(Format(L"Failed to load '%s' - %s", pszFileName, FormatResult(r).sz()), L"<inputfile>", -1); return false; } return Parse(pRootNode, str, pszFileName); }
void Op_Load() { Op_Stack = new TX_STACK; Op_TStack = new TX_STACK; Op_BStack = new B_STACK; T_Resolution = LoadText("Resolution", 26, "Options: Resolution"); bg_Options = LoadTexture("OPTIONS.png", "Options Background"); GS_Words[0] = LoadText("BACK", 26, "GS: Text"); GS_Words[1] = LoadText("SAVE", 26, "GS: Text"); restext = LoadText(Resolutions[Sel_Resolution], 26, "Options: Resolutions"); Stack_Button(Op_BStack, 360, 345, 145, 120, decResolution); //Left Arrow Stack_Button(Op_BStack, 1400, 345, 145, 120, incResolution); //Right Arrow Stack_Button(Op_BStack, 1075, 930, 280, 105, Write_Settings); //Save Button Stack_Button(Op_BStack, 548, 926, 280, 105, B_Op_Back); //Back Button Stack_Texture(Op_Stack, bg_Options, NULL, NULL); //Background Stack_Text(Op_TStack, T_Resolution, 950, 300); Stack_Text(Op_TStack, restext, 950, 400); Stack_Text(Op_TStack, GS_Words[0], 688, 980); Stack_Text(Op_TStack, GS_Words[1], 1215, 980); Stack_Stack(Op_Stack); Stack_TStack(Op_TStack); Stack_BStack(Op_BStack); Exit_Sequence.push_back(Op_Unload); return; }
bool CSkinParser::LoadVariation( const wchar_t *fname ) { m_VarText.swap(m_Text); bool res=LoadText(fname); if (res) { std::vector<const wchar_t*> lines; lines.swap(m_Lines); lines.push_back(L"[TRUE]"); ParseText(); m_Lines.insert(m_Lines.begin(),lines.begin(),lines.end()); } m_VarText.swap(m_Text); return res; }
bool CSkinParser::LoadVariation( HMODULE hMod, HRSRC hResInfo ) { m_VarText.swap(m_Text); bool res=LoadText(hMod,hResInfo); if (res) { std::vector<const wchar_t*> lines; lines.swap(m_Lines); lines.push_back(L"[TRUE]"); ParseText(); m_Lines.insert(m_Lines.begin(),lines.begin(),lines.end()); } m_VarText.swap(m_Text); return res; }
void MAINMENU::Init() { // Init VBO here glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Set background color glEnable(GL_DEPTH_TEST); // Enable depth buffer and depth testing glEnable(GL_CULL_FACE); // Enable back face culling // Enable blending glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // Default to fill mode //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); // Generate a default VAO for now glGenVertexArrays(1, &m_vertexArrayID); glBindVertexArray(m_vertexArrayID); m_programID = LoadShaders("Shader//Texture.vertexshader", "Shader//Text.fragmentshader"); m_parameters[U_MVP] = glGetUniformLocation(m_programID, "MVP"); m_parameters[U_MODELVIEW] = glGetUniformLocation(m_programID, "MV"); m_parameters[U_MODELVIEW_INVERSE_TRANSPOSE] = glGetUniformLocation(m_programID, "MV_inverse_transpose"); m_parameters[U_TEXT_ENABLED] = glGetUniformLocation(m_programID, "textEnabled"); m_parameters[U_TEXT_COLOR] = glGetUniformLocation(m_programID, "textColor"); // Get a handle for our "colorTexture" uniform m_parameters[U_COLOR_TEXTURE_ENABLED] = glGetUniformLocation(m_programID, "colorTextureEnabled"); m_parameters[U_COLOR_TEXTURE] = glGetUniformLocation(m_programID, "colorTexture"); glUseProgram(m_programID); //Initialize camera settings camera.Init(Vector3(20, 5, 5), Vector3(0, 0, 0), Vector3(0, 1, 0)); Mtx44 projection; projection.SetToPerspective(45.f, 4.f / 3.f, 0.1f, 100000.f); projectionStack.LoadMatrix(projection); meshList[TEXT] = MeshBuilder::GenerateText("MenuList", 16, 16); meshList[TEXT]->textureID = LoadTGA("Image//calibri.tga"); LoadText("Menu.txt", menuList); c_UserInterface::GetEnum()->UI = START; }
// Reads a file into m_Text bool CSettingsParser::LoadText( const wchar_t *fname ) { // read settings file into buf FILE *f=NULL; if (_wfopen_s(&f,fname,L"rb")) return false; if (!f) return false; fseek(f,0,SEEK_END); int size=ftell(f); fseek(f,0,SEEK_SET); std::vector<unsigned char> buf(size); if (size<4 || fread(&buf[0],1,size,f)!=size) { fclose(f); return false; } fclose(f); LoadText(&buf[0],size); return true; }
void CSisCertificateChain::Load (const std::wstring& aName) { try { LoadText (aName); return; } catch (...) { try { LoadBinary (aName); return; } catch (...) { } throw; } }
//----------------------------------------------------------------------------- bool LoadShader(char *file, GLenum type, GLhandleARB context) { // GLSL shader. GLhandleARB shader; // Load shader's source text. char *code = LoadText(file); if(code == NULL) return false; // Create the shader from a text file. shader = glCreateShaderObjectARB(type); glShaderSourceARB(shader, 1, (const char**)&code, NULL); glCompileShaderARB(shader); GLint result; char error[1024]; // Returns the results of the shader compilation. glGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &result); delete[] code; // Display shader errors if any. if(!result) { // Get the error message and display it. glGetInfoLogARB(shader, sizeof(error), NULL, error); printf("Error in %s...\n%s\n", file, error); return false; } // Attach to the effect's context. glAttachObjectARB(context, shader); glDeleteObjectARB(shader); return true; }
void TextRenderCentered( TTF_Font *font, const char *text, const int startY, const SDL_Color c) { int y = startY; for (;;) { // Render the text line-by-line const char *nl = strchr(text, '\n'); char buf[256]; if (nl != NULL) { const size_t len = nl - text; strncpy(buf, text, len); buf[len] = '\0'; } else { strcpy(buf, text); } if (strlen(buf) > 0) { Tex t = LoadText(buf, font, c); if (t.T == NULL) return; const int x = (SCREEN_WIDTH - t.W) / 2; SDL_Rect dest = { x, y, t.W, t.H }; RenderTex(t.T, NULL, &dest); SDL_DestroyTexture(t.T); } y += TTF_FontHeight(font); if (nl == NULL) { break; } text = nl + 1; } }
void OSMData::LoadText (const char *filename) { LatLonBox clip; clip.open(); // Pas de restriction LoadText (filename, clip); }
sint32 GreatLibraryWindow::LoadVariablesText ( SlicObject &so ) { return(LoadText(m_techVariablesText, m_variable_file, so)); }
sint32 GreatLibraryWindow::LoadRequirementsText ( SlicObject &so ) { return(LoadText(m_techRequirementsText, m_requirement_file, so)); }
/* Find contextual information */ static void FindContext ( Header* record, /* record to work with */ Char* text, /* text of record */ UInt16 pos, /* position of the pattern */ Char* result, /* will contain the result string after return of function */ Int16 resultBufferSize /* how much space is available for the result */ ) { WChar context[ 2 * MAX_CONTEXT ]; WChar* right; Paragraph* paragraph; Int16 paragraphOffset; Int16 size; Int16 rightSize; Int16 leftSize; Int16 contextSize; Char* endResult; WChar* inPtr; paragraph = GET_PARAGRAPH( record, 0 ); paragraphOffset = 0; while ( paragraphOffset + paragraph->size <= pos ) { paragraphOffset += paragraph->size; paragraph++; } text += paragraphOffset; pos -= paragraphOffset; size = paragraph->size; right = context + MAX_CONTEXT; rightSize = LoadText( right, text + pos, text + size, MAX_CONTEXT, MAX_CONTEXT ); leftSize = LEFT_CONTEXT; if ( rightSize < RIGHT_CONTEXT ) leftSize += ( RIGHT_CONTEXT - rightSize ); leftSize = LoadText( context, text, text + pos, leftSize, pos ); if ( leftSize < LEFT_CONTEXT ) { Int16 tryRight; tryRight = RIGHT_CONTEXT + ( LEFT_CONTEXT - leftSize ); if ( tryRight < rightSize ) rightSize = tryRight; } else if ( RIGHT_CONTEXT < rightSize ) rightSize = RIGHT_CONTEXT; MemMove ( context + leftSize, right, rightSize * sizeof(WChar) ); contextSize = leftSize + rightSize; endResult = result + resultBufferSize - 1; inPtr = context; while ( 0 < contextSize ) { Int16 charSize; charSize = TxtGlueCharSize( *inPtr ); if ( endResult <= result + charSize ) break; TxtGlueSetNextChar( result, 0, *inPtr ); result += charSize; contextSize--; inPtr++; } *result = '\0'; }
bool gfx::Shader::CreateFromFile( const rString& Filename, GLenum ShaderType, bool print ) { m_Path = Filename; m_Type = ShaderType; std::ifstream fin; fin.open ( Filename.c_str() ); if ( !fin.is_open() ) { if ( print ) { Logger::Log( "Cant open shader file " + Filename, "Shader", LogSeverity::ERROR_MSG ); } return false; } rString shadertext; size_t found; rString line; while ( !fin.eof() ) { getline ( fin, line ); found = line.find ( "#include " ); if ( found != rString::npos ) { int i = static_cast<int> ( found ) + 9; //found + "#include " rString s; while ( i < line.length() ) { s += line[i]; i++; } rString str = GetDir ( rString ( Filename ) ) + s; shadertext += LoadText ( str.c_str() ); shadertext += "\n"; } else { shadertext += line; shadertext += '\n'; } } fin.close(); //create shader object m_Handle = glCreateShader ( ShaderType ); if ( m_Handle == 0 ) { if ( print ) { Logger::Log( "Error creating shader", "Shader", LogSeverity::ERROR_MSG ); } } const char* text = shadertext.c_str(); glShaderSource ( m_Handle,1,&text,nullptr ); glCompileShader ( m_Handle ); int result = 0; glGetShaderiv ( m_Handle, GL_COMPILE_STATUS, &result ); if ( result == GL_FALSE ) { if ( print ) { Logger::Log( "ERROR, compiling shader " + Filename, "Shader", LogSeverity::ERROR_MSG ); } int length = 0; glGetShaderiv ( m_Handle, GL_INFO_LOG_LENGTH, &length ); if ( length > 0 ) { // create a log of error messages char* errorLog = fNewArray (char, length); int written = 0; glGetShaderInfoLog ( m_Handle, length, &written, errorLog ); if ( print ) { Logger::Log( "Error log: " + rString( errorLog ), "Shader", LogSeverity::ERROR_MSG ); } fDeleteArray (errorLog); } return false; }