void gtk_attractor_view_open(GtkAttractor_View *attractor_view, char *filename) { #if PRINT_FUNCTION printf("%s\n", __FUNCTION__); #endif int l, t, p; FILE *fp = NULL; fp = fopen(filename, "r"); for (l = 0; l < ATTRACTOR_LESION_LEVEL; l++) { // level of leasioning for (t = 0; t < 3; t++) { // to ensure network in "right" attractor for (p = 0; p < P; p++) { // pattern if (!fscanf(fp, "%d\n", &attractor_view->response[l][t][p])) { throw_warning(__FILE__, __LINE__, __FUNCTION__,"Could not read variable: response[][][]", 0); gtk_attractor_view_init(attractor_view); break; } } } } fprintf(fp, "\nEOF\n"); if (fp) { fclose(fp); } }
Texture Texture_createText(const char* s, int p, SDL_Color c, int wl) { SDL_Surface* swap = NULL; Texture texture; texture.raw = NULL; texture.type = TEXTURE_UNFINISHED; if(wl <= 0) swap = TTF_RenderText_Blended(GAME_FONT, s, c); if(wl > 0) swap = TTF_RenderText_Blended_Wrapped(GAME_FONT, s, c, wl); if(swap == NULL) { throw_warning("Failed to render text! Returning empty texture."); return texture; } texture.raw = SDL_CreateTextureFromSurface(RENDERER, swap); if(texture.raw == NULL) { throw_warning("Failed to create texture! Returning empty texture."); SDL_FreeSurface(swap); return texture; } texture.cropX = 0; texture.cropY = 0; texture.cropW = 0; texture.cropH = 0; texture.positionX = 0; texture.positionY = 0; texture.sizeX = (float)strlen(s) * p; texture.sizeY = (float)p; SDL_FreeSurface(swap); texture.type = TEXTURE_TEXT; return texture; }
void Texture_modText(Texture* t, const char* s, int p, SDL_Color c) { SDL_Surface* swap; if(t == NULL) { throw_warning("Modding texture is NULL!"); return; } if(t->type != TEXTURE_TEXT) { throw_warning("Modding texture is the wrong type!"); return; } if(t->raw == NULL) { throw_warning("SDL_Texture of modding texture is NULL!"); return; } swap = TTF_RenderText_Solid(GAME_FONT, s, c); t->sizeX = (float)strlen(s) * p; if(swap == NULL) { throw_warning("Failed to render modding text!"); return; } SDL_DestroyTexture(t->raw); t->raw = SDL_CreateTextureFromSurface(RENDERER, swap); if(t->raw == NULL) { throw_warning("Failed to create modding texture!"); SDL_FreeSurface(swap); return; } SDL_FreeSurface(swap); }