BOOL test_perft960() { BOOL ok = TRUE; int i; t_nodes n = 0; if (!uci.engine_initialized) init_engine(position); //--Position 1 //for (i = 0; i <= 1; i++) { // set_fen(position, "R3rkrR/8/8/8/8/8/8/r3RKRr w EGeg - 0 1"); // n = perft(position, 5); // ok &= (n == 12667098); // global_nodes += n; // flip_board(position); //} //--Position 2 //for (i = 0; i <= 1; i++) { set_fen(position, "qr1kbb1r/1pp2ppp/3npn2/3pN3/1p3P2/4PN2/P1PP2PP/QR1KBB1R w HBhb -"); n = perft(position, 6); ok &= (n == 3206947488); // global_nodes += n; // flip_board(position); //} if (ok) printf("Everything seems Fine - all PERFT 960 scores are correct\n"); else printf("**ERROR** with PERFT 960 scores\n"); return ok; }
void init() { allegro_init(); set_color_depth(32); if(set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 240, 0, 0)) { allegro_message("%s.", allegro_error); exit(1); } init_engine(SCREEN_W, SCREEN_H); point_at_color_buffer(&buffer); setup_projection(90.0, -1.333, 1.333, -1.0, 1.0, 0.0, 200.0); set_znear(1.0); set_clipping_rect(10, 10, buffer->w - 11, buffer->h - 11); init_clipper(); set_rasterizer_function(flat_zbuff_sides); set_world_clip_func(2, wclip_to_rend_int, 0, 0, 0, 0); set_scr_clip_func(4, rend_int_to_tri, 0, 0, 0, 0); install_keyboard(); install_mouse(); srand(time(NULL)); }
void VehicleObject::init_vehicle_physics(const Vector3f& box_size, const PhysObjInfo& info, const VehicleProperties& properties) { m_iright_index = 0; m_iup_index = 1; m_iforward_index = 2; set_vehicle_properties(properties); m_box_size = btVector3((btScalar)box_size.x, (btScalar)box_size.y, (btScalar)box_size.z); //Physics stuff btCollisionShape* pChassisShape = new btBoxShape(m_box_size); m_pListOfCollisionShapes.push_back(pChassisShape); btCompoundShape* pCompoundShape = new btCompoundShape(); m_pListOfCollisionShapes.push_back(pCompoundShape); btTransform localTrans; localTrans.setIdentity(); localTrans.setOrigin(btVector3(0, 1, 0)); pCompoundShape->addChildShape(localTrans, pChassisShape); //Setup chassis btTransform chassisTrans; chassisTrans.setIdentity(); chassisTrans.setOrigin(btVector3(0, 0, 0)); btVector3 localInertia(0, 0, 0); pCompoundShape->calculateLocalInertia(info.mass, localInertia); btDefaultMotionState* vehicleMotionState = new btDefaultMotionState(chassisTrans); btRigidBody::btRigidBodyConstructionInfo cInfo(info.mass, vehicleMotionState, pCompoundShape, localInertia); if(m_rbody) { delete m_rbody; m_rbody = 0; } m_rbody = new btRigidBody(cInfo); m_rbody->setContactProcessingThreshold(1e18f); m_rbody->setUserPointer(&m_entity_id); //initialise other parts of the vehicle init_engine(); init_vehicle(); init_wheels(); }
void cc3200_hash_update(struct cc3200_hash_ctx *ctx, const uint8_t *data, uint32_t len) { if (ctx->block_len > 0) { uint32_t block_remain = CC3200_HASH_BLOCK_SIZE - ctx->block_len; if (block_remain > len) block_remain = len; memcpy(ctx->block + ctx->block_len, data, block_remain); ctx->block_len += block_remain; data += block_remain; len -= block_remain; if (ctx->block_len < CC3200_HASH_BLOCK_SIZE) return; } const uint32_t to_hash = (((uint32_t) ctx->block_len) + len) & ~(CC3200_HASH_BLOCK_SIZE - 1); if (to_hash > 0) { vPortEnterCritical(); init_engine(ctx, 0); HWREG(SHAMD5_BASE + SHAMD5_O_LENGTH) = to_hash; if (ctx->block_len == CC3200_HASH_BLOCK_SIZE) { while ( !(HWREG(SHAMD5_BASE + SHAMD5_O_IRQSTATUS) & SHAMD5_INT_INPUT_READY)) ; uint32_t *p = (uint32_t *) ctx->block; for (int i = 0; i < CC3200_HASH_BLOCK_SIZE; i += 4) { HWREG(SHAMD5_BASE + SHAMD5_O_DATA0_IN + i) = *p++; } } while (len >= CC3200_HASH_BLOCK_SIZE) { while ( !(HWREG(SHAMD5_BASE + SHAMD5_O_IRQSTATUS) & SHAMD5_INT_INPUT_READY)) ; for (int i = 0; i < CC3200_HASH_BLOCK_SIZE; i += 4) { HWREG(SHAMD5_BASE + SHAMD5_O_DATA0_IN + i) = *((uint32_t *) data); data += 4; len -= 4; } } while (!(HWREG(SHAMD5_BASE + SHAMD5_O_IRQSTATUS) & SHAMD5_INT_OUTPUT_READY)) ; MAP_SHAMD5ResultRead(SHAMD5_BASE, (uint8_t *) ctx->digest); /* Must read count register to finish the round. */ HWREG(SHAMD5_BASE + SHAMD5_O_DIGEST_COUNT); MAP_PRCMPeripheralClkDisable(PRCM_DTHE, PRCM_RUN_MODE_CLK); vPortExitCritical(); } memcpy(ctx->block, data, len); ctx->block_len = len; }
static ENGINE_HANDLE_V1 *start_your_engines(const char *engine, const char* cfg, bool engine_init) { init_mock_server(handle); if (!load_engine(engine, &get_mock_server_api, logger_descriptor, &handle)) { fprintf(stderr, "Failed to load engine %s.\n", engine); return NULL; } if (engine_init) { if(!init_engine(handle, cfg, logger_descriptor)) { fprintf(stderr, "Failed to init engine %s with config %s.\n", engine, cfg); return NULL; } } mock_engine = default_mock_engine; handle_v1 = mock_engine.the_engine = (ENGINE_HANDLE_V1*)handle; handle = (ENGINE_HANDLE*)&mock_engine.me; handle_v1 = &mock_engine.me; // Reset all members that aren't set (to allow the users to write // testcases to verify that they initialize them.. assert(mock_engine.me.interface.interface == mock_engine.the_engine->interface.interface); if (mock_engine.the_engine->get_stats_struct == NULL) { mock_engine.me.get_stats_struct = NULL; } if (mock_engine.the_engine->aggregate_stats == NULL) { mock_engine.me.aggregate_stats = NULL; } if (mock_engine.the_engine->unknown_command == NULL) { mock_engine.me.unknown_command = NULL; } if (mock_engine.the_engine->tap_notify == NULL) { mock_engine.me.tap_notify = NULL; } if (mock_engine.the_engine->get_tap_iterator == NULL) { mock_engine.me.get_tap_iterator = NULL; } if (mock_engine.the_engine->errinfo == NULL) { mock_engine.me.errinfo = NULL; } return &mock_engine.me; }
void init() { allegro_init(); set_color_depth(32); if(set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0)) { allegro_message("%s.", allegro_error); exit(1); } init_engine(SCREEN_W, SCREEN_H); point_at_color_buffer(&buffer); set_clipping_rect(10, 10, buffer->w - 11, buffer->h - 11); install_keyboard(); install_mouse(); srand(time(NULL)); }
void test_procedure() { if (!uci.engine_initialized) init_engine(position); assert(test_bitscan()); assert(test_bittwiddles()); assert(test_fen()); assert(test_genmove()); assert(test_make_unmake()); assert(test_hash()); assert(test_eval()); assert(test_capture_gen()); assert(test_check_gen()); assert(test_alt_move_gen()); assert(test_see()); assert(test_position()); assert(test_hash_table()); assert(test_ep_capture()); assert(test_book()); test_search(); }
void cc3200_hash_final(struct cc3200_hash_ctx *ctx, uint8_t *digest) { vPortEnterCritical(); init_engine(ctx, SHAMD5_MODE_CLOSE_HASH); HWREG(SHAMD5_BASE + SHAMD5_O_LENGTH) = ctx->block_len; int bl = ctx->block_len; int i = 0; uint32_t *p = (uint32_t *) ctx->block; while (bl - i > 4) { HWREG(SHAMD5_BASE + SHAMD5_O_DATA0_IN + i) = *p++; i += 4; } if (i < bl) { for (int j = bl; j % 4 != 0; j++) ctx->block[j] = 0; HWREG(SHAMD5_BASE + SHAMD5_O_DATA0_IN + i) = *p; } while (!(HWREG(SHAMD5_BASE + SHAMD5_O_IRQSTATUS) & SHAMD5_INT_OUTPUT_READY)) ; MAP_SHAMD5ResultRead(SHAMD5_BASE, digest); /* Must read count register to finish the round. */ HWREG(SHAMD5_BASE + SHAMD5_O_DIGEST_COUNT); MAP_PRCMPeripheralClkDisable(PRCM_DTHE, PRCM_RUN_MODE_CLK); vPortExitCritical(); }
BOOL test_perft() { BOOL ok = TRUE; int i; t_nodes n = 0; if (!uci.engine_initialized) init_engine(position); global_nodes = 0; perft_start_time = time_now(); //--Position 1 for (i = 0; i <= 1; i++) { set_fen(position, "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"); n = perft(position, 6); ok &= (n == 119060324); global_nodes += n; flip_board(position); } //--Position 2 for (i = 0; i <= 1; i++) { set_fen(position, "r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq -"); n = perft(position, 5); ok &= (n == 193690690); global_nodes += n; flip_board(position); } //--Position 3 for (i = 0; i <= 1; i++) { set_fen(position, "8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - -"); n = perft(position, 7); ok &= (n == 178633661); global_nodes += n; flip_board(position); } //--Position 4 for (i = 0; i <= 1; i++) { set_fen(position, "r3k2r/Pppp1ppp/1b3nbN/nP6/BBP1P3/q4N2/Pp1P2PP/R2Q1RK1 w kq - 0 1"); n = perft(position, 6); ok &= (n == 706045033); global_nodes += n; flip_board(position); } perft_end_time = time_now(); //--Position 5 for (i = 0; i <= 1; i++) { set_fen(position, "1k6/1b6/8/8/7R/8/8/4K2R b K - 0 1"); ok &= (perft(position, 5) == 1063513); flip_board(position); } //--Illegal ep move #1 for (i = 0; i <= 1; i++) { set_fen(position, "3k4/3p4/8/K1P4r/8/8/8/8 b - - 0 1"); ok &= (perft(position, 6) == 1134888); flip_board(position); } //--Illegal ep move #2 for (i = 0; i <= 1; i++) { set_fen(position, "8/8/4k3/8/2p5/8/B2P2K1/8 w - - 0 1"); ok &= (perft(position, 6) == 1015133); flip_board(position); } //--EP Capture Checks Opponent for (i = 0; i <= 1; i++) { set_fen(position, "8/8/1k6/2b5/2pP4/8/5K2/8 b - d3 0 1"); ok &= (perft(position, 6) == 1440467); flip_board(position); } //--Short Castling Gives Check for (i = 0; i <= 1; i++) { set_fen(position, "5k2/8/8/8/8/8/8/4K2R w K - 0 1"); ok &= (perft(position, 6) == 661072); flip_board(position); } //--Long Castling Gives Check for (i = 0; i <= 1; i++) { set_fen(position, "3k4/8/8/8/8/8/8/R3K3 w Q - 0 1"); ok &= (perft(position, 6) == 803711); flip_board(position); } //--Castle Rights for (i = 0; i <= 1; i++) { set_fen(position, "r3k2r/1b4bq/8/8/8/8/7B/R3K2R w KQkq - 0 1"); ok &= (perft(position, 4) == 1274206); flip_board(position); } //--Castling Prevented for (i = 0; i <= 1; i++) { set_fen(position, "r3k2r/8/3Q4/8/8/5q2/8/R3K2R b KQkq - 0 1"); ok &= (perft(position, 4) == 1720476); flip_board(position); } //--Promote out of Check for (i = 0; i <= 1; i++) { set_fen(position, "2K2r2/4P3/8/8/8/8/8/3k4 w - - 0 1"); ok &= (perft(position, 6) == 3821001); flip_board(position); } //--Discovered Check for (i = 0; i <= 1; i++) { set_fen(position, "8/8/1P2K3/8/2n5/1q6/8/5k2 b - - 0 1"); ok &= (perft(position, 5) == 1004658); flip_board(position); } //--Promote to give check for (i = 0; i <= 1; i++) { set_fen(position, "4k3/1P6/8/8/8/8/K7/8 w - - 0 1"); ok &= (perft(position, 6) == 217342); flip_board(position); } //--Under Promote to give check for (i = 0; i <= 1; i++) { set_fen(position, "8/P1k5/K7/8/8/8/8/8 w - - 0 1"); ok &= (perft(position, 6) == 92683); flip_board(position); } //--Self Stalemate for (i = 0; i <= 1; i++) { set_fen(position, "K1k5/8/P7/8/8/8/8/8 w - - 0 1"); ok &= (perft(position, 6) == 2217); flip_board(position); } //--Stalemate & Checkmate for (i = 0; i <= 1; i++) { set_fen(position, "8/k1P5/8/1K6/8/8/8/8 w - - 0 1"); ok &= (perft(position, 7) == 567584); flip_board(position); } //--Stalemate & Checkmate for (i = 0; i <= 1; i++) { set_fen(position, "8/8/2k5/5q2/5n2/8/5K2/8 b - - 0 1"); ok &= (perft(position, 4) == 23527); flip_board(position); } if (ok) printf("Everything seems Fine - all PERFT scores are correct\n"); else printf("**ERROR** with PERFT scores\n"); printf(INFO_STRING_PERFT_SPEED, global_nodes, perft_end_time - perft_start_time, 1000 * global_nodes / (perft_end_time - perft_start_time)); return ok; }
int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPWSTR cmdline, int cmdshow) { const WCHAR *ext, *filename = NULL; IActiveScriptParse *parser; IActiveScript *script; WCHAR **argv; CLSID clsid; int argc, i; DWORD res; WINE_TRACE("(%p %p %s %x)\n", hInst, hPrevInst, wine_dbgstr_w(cmdline), cmdshow); argv = CommandLineToArgvW(cmdline, &argc); if(!argv) return 1; for(i=0; i<argc; i++) { if(*argv[i] == '/' || *argv[i] == '-') { if(!set_host_properties(argv[i])) return 1; }else { filename = argv[i]; argums = argv+i+1; numOfArgs = argc-i-1; break; } } if(!filename) { WINE_FIXME("No file name specified\n"); return 1; } res = GetFullPathNameW(filename, sizeof(scriptFullName)/sizeof(WCHAR), scriptFullName, NULL); if(!res || res > sizeof(scriptFullName)/sizeof(WCHAR)) return 1; ext = strchrW(filename, '.'); if(!ext) ext = filename; if(!get_engine_clsid(ext, &clsid)) { WINE_FIXME("Could not find engine for %s\n", wine_dbgstr_w(ext)); return 1; } CoInitialize(NULL); if(!create_engine(&clsid, &script, &parser)) { WINE_FIXME("Could not create script engine\n"); CoUninitialize(); return 1; } if(init_engine(script, parser)) { run_script(filename, script, parser); IActiveScript_Close(script); ITypeInfo_Release(host_ti); }else { WINE_FIXME("Script initialization failed\n"); } IActiveScript_Release(script); IActiveScriptParse_Release(parser); CoUninitialize(); return 0; }
int main(int argc, char *argv[]) { int time; char method[SCREEN_UPDATE_STR_LEN]; char fps_text[16]; if (argc > 1) { if (strstr(argv[1], "help")) { printf("Type \"kwestkingdom\" to play!\n"); exit(0); } } if (!init_kwestkingdom()) { return 1; } init_engine(); /** * Reset the timers just before the game begins. */ reset_timer(); /** * BEGIN MAIN LOOP */ while (!quitting) { while (get_ticks() == 0) { rest(1); } while (get_ticks() > 0) { time = get_ticks(); /** * UPDATE */ update_engine(); decrease_timer(); if (time <= get_ticks()) { break; } } /** * DRAW */ paint_engine(grab_canvas()); /** * Show FPS */ sprintf(fps_text, "FPS %d", get_fps()); show_text(grab_canvas(), fps_text, 10, 10, WHITE, BLACK); /** * Show the method of screen updating. */ find_screen_update_method(method); show_text( grab_canvas(), method, grab_tile_size() / 5, /* x */ grab_canvas_height() - (grab_tile_size() / 2), /* y */ WHITE, BLACK ); /** * Show all of the new screen changes */ refresh_screen(); mark_frame_complete(); } /** * END MAIN LOOP */ /** * Cleanup */ stop_engine(); stop_screen(); stop_resources(); check_memory(); return 0; }
engine_t * create_engine() { engine_t * e = malloc_engine(); init_engine(e); return e; }
int main ( int argc, char** argv ) { SDL_Surface* screen; //SDL_Rect dstrect; int i; int done; SDL_ExposeEvent expose = { SDL_VIDEOEXPOSE }; // initialize SDL video if ( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { printf( "Unable to init SDL: %s\n", SDL_GetError() ); return 1; } // make sure SDL cleans up before exit atexit(SDL_Quit); TTF_Init(); atexit(TTF_Quit); // create a new window screen = SDL_SetVideoMode(800, 600, 16, SDL_HWSURFACE|SDL_DOUBLEBUF); if ( !screen ) { printf("Unable to set 640x480 video: %s\n", SDL_GetError()); return 1; } fnt = TTF_OpenFont( "DejaVuSansMono.ttf", 16 ); sText = SDL_CreateRGBSurface( SDL_HWSURFACE|SDL_SRCALPHA, screen->w, screen->h, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000 ); memset( sprites, 0, sizeof(sprites) ); display_clear(); init_engine(); // program main loop done = 0; while (!done) { // message processing loop SDL_Event event; //while (SDL_PollEvent(&event)) SDL_WaitEvent(&event); { // check for messages switch (event.type) { // exit if the window is closed case SDL_QUIT: done = 1; break; // check for keypresses case SDL_MOUSEMOTION: { int i; int y = event.button.y; for ( i = 0; i < select_opts; i ++ ) { if ( select_sizes[i][0] <= y && select_sizes[i][1] > y ) { if ( selected_opt != i ) SDL_PushEvent( &expose ); selected_opt = i; break; } } } break; // check for keypresses case SDL_KEYDOWN: if ( !select_opts ) SDL_SemPost( key_sem ); else { switch ( event.key.keysym.sym ) { case SDLK_UP: selected_opt --; if ( selected_opt < 0 ) selected_opt = 0; SDL_PushEvent( &expose ); break; case SDLK_DOWN: selected_opt ++; if ( selected_opt >= select_opts ) selected_opt = select_opts - 1; SDL_PushEvent( &expose ); break; case SDLK_RETURN: if ( selected_opt >= 0 && selected_opt < select_opts ) { SDL_SemPost( key_sem ); } break; } } break; case SDL_MOUSEBUTTONDOWN: /*if ( (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_RETURN) || (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == 1) )*/ if ( !select_opts ) SDL_SemPost( key_sem ); else { int i; int y = event.button.y; for ( i = 0; i < select_opts; i ++ ) { if ( select_sizes[i][0] <= y && select_sizes[i][1] > y ) { selected_opt = i; SDL_SemPost( key_sem ); break; } } } break; case SDL_VIDEOEXPOSE: { // DRAWING STARTS HERE SDL_mutexP(sdl_mutex); // clear screen SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0)); if ( background ) SDL_BlitSurface(background, 0, screen, 0); i = 0x20; while ( i-- ) { if ( sprites[i] ) { SDL_Rect dstrect; dstrect.x = (800/2) + sprites_info[i].x - (sprites[i]->w / 2); dstrect.y = - sprites_info[i].y; //printf("%d %d\n",dstrect.x,dstrect.y); //SDL_SetAlpha( sprites[i], SDL_SRCALPHA, 0x40 ); SDL_BlitSurface( sprites[i], 0, screen, &dstrect ); } } if ( selected_opt >= 0 ) { SDL_Rect rect; rect.x = 0; rect.w = screen->w; rect.y = select_sizes[selected_opt][0]; rect.h = select_sizes[selected_opt][1] - select_sizes[selected_opt][0]; SDL_FillRect(screen, &rect, SDL_MapRGBA(screen->format, 0x80, 0x00, 0x00, 0x80) ); } SDL_BlitSurface(sText, 0, screen, 0); // DRAWING ENDS HERE SDL_mutexV(sdl_mutex); // finally, update the screen :) SDL_Flip(screen); } } // end switch } // end of message processing } // end main loop // free loaded bitmap if ( background ) SDL_FreeSurface(background); TTF_CloseFont( fnt ); SDL_DestroyMutex(sdl_mutex); // all is well ;) printf("Exited cleanly\n"); return 0; }
int main(int argc, char *argv[]) { enum engine_id engine = E_UCT; struct time_info ti_default = { .period = TT_NULL }; char *testfile = NULL; char *gtp_port = NULL; char *log_port = NULL; int gtp_sock = -1; char *chatfile = NULL; char *fbookfile = NULL; char *ruleset = NULL; seed = time(NULL) ^ getpid(); int opt; while ((opt = getopt(argc, argv, "c:e:d:Df:g:l:r:s:t:u:")) != -1) { switch (opt) { case 'c': chatfile = strdup(optarg); break; case 'e': if (!strcasecmp(optarg, "random")) { engine = E_RANDOM; } else if (!strcasecmp(optarg, "replay")) { engine = E_REPLAY; } else if (!strcasecmp(optarg, "montecarlo")) { engine = E_MONTECARLO; } else if (!strcasecmp(optarg, "uct")) { engine = E_UCT; } else if (!strcasecmp(optarg, "distributed")) { engine = E_DISTRIBUTED; } else if (!strcasecmp(optarg, "patternscan")) { engine = E_PATTERNSCAN; } else if (!strcasecmp(optarg, "patternplay")) { engine = E_PATTERNPLAY; } else if (!strcasecmp(optarg, "joseki")) { engine = E_JOSEKI; } else { fprintf(stderr, "%s: Invalid -e argument %s\n", argv[0], optarg); exit(1); } break; case 'd': debug_level = atoi(optarg); break; case 'D': debug_boardprint = false; break; case 'f': fbookfile = strdup(optarg); break; case 'g': gtp_port = strdup(optarg); break; case 'l': log_port = strdup(optarg); break; case 'r': ruleset = strdup(optarg); break; case 's': seed = atoi(optarg); break; case 't': /* Time settings to follow; if specified, * GTP time information is ignored. Useful * e.g. when you want to force your bot to * play weaker while giving the opponent * reasonable time to play, or force play * by number of simulations in timed games. */ /* Please see timeinfo.h:time_parse() * description for syntax details. */ if (!time_parse(&ti_default, optarg)) { fprintf(stderr, "%s: Invalid -t argument %s\n", argv[0], optarg); exit(1); } ti_default.ignore_gtp = true; assert(ti_default.period != TT_NULL); break; case 'u': testfile = strdup(optarg); break; default: /* '?' */ usage(argv[0]); exit(1); } } if (log_port) open_log_port(log_port); fast_srandom(seed); if (DEBUGL(0)) fprintf(stderr, "Random seed: %d\n", seed); struct board *b = board_init(fbookfile); if (ruleset) { if (!board_set_rules(b, ruleset)) { fprintf(stderr, "Unknown ruleset: %s\n", ruleset); exit(1); } } struct time_info ti[S_MAX]; ti[S_BLACK] = ti_default; ti[S_WHITE] = ti_default; chat_init(chatfile); char *e_arg = NULL; if (optind < argc) e_arg = argv[optind]; struct engine *e = init_engine(engine, e_arg, b); if (testfile) { unittest(testfile); return 0; } if (gtp_port) { open_gtp_connection(>p_sock, gtp_port); } for (;;) { char buf[4096]; while (fgets(buf, 4096, stdin)) { if (DEBUGL(1)) fprintf(stderr, "IN: %s", buf); enum parse_code c = gtp_parse(b, e, ti, buf); if (c == P_ENGINE_RESET) { ti[S_BLACK] = ti_default; ti[S_WHITE] = ti_default; if (!e->keep_on_clear) { b->es = NULL; done_engine(e); e = init_engine(engine, e_arg, b); } } else if (c == P_UNKNOWN_COMMAND && gtp_port) { /* The gtp command is a weak identity check, * close the connection with a wrong peer. */ break; } } if (!gtp_port) break; open_gtp_connection(>p_sock, gtp_port); } done_engine(e); chat_done(); free(testfile); free(gtp_port); free(log_port); free(chatfile); free(fbookfile); free(ruleset); return 0; }
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HWND hwnd; char buf[2048]; int tmp; HANDLE lib; void pascal (*regxx)(HANDLE); void pascal (*regxy)(HANDLE); HANDLE mutex; /* create_pnglib(); exit(1); */ parse_cmd(lpCmdLine); mutex=CreateMutex(NULL,0,"MOAB"); if (mutex==NULL || GetLastError()==ERROR_ALREADY_EXISTS && strcmp(host_addr,"192.168.42.1")) { MessageBox(0,"Another instance of "MNAME" is already running.","Error",MB_OK|MB_ICONSTOP); return 0; } lib=LoadLibrary("CTL3D32.DLL"); if (lib) { regxx=(void pascal *)GetProcAddress(lib,"Ctl3dRegister"); if (regxx) regxx(GetCurrentProcess()); ctl3don=(void pascal *)GetProcAddress(lib,"Ctl3dSubclassDlg"); regxy=(void pascal *)GetProcAddress(lib,"Ctl3dUnregister"); } else { regxy=NULL; ctl3don=NULL; } dlg_col=GetSysColor(COLOR_BTNFACE); dlg_back=CreateSolidBrush(dlg_col); dlg_fcol=GetSysColor(COLOR_WINDOWTEXT); hwnd=InitWindow(hInstance,nCmdShow); load_options(); init_engine(); options(); if (quit) exit(0); init_sound(hwnd); if ((tmp=dd_init(hwnd,MODEX,MODEY))!=0) { sprintf(buf,"|DDERROR=%d",-tmp); say(buf); Sleep(1000); sprintf(buf, "DirectX init failed with code %d.\n" "DDError=%s\n" "Client Version %d.%02d.%02d\n" "MAXX=%d, MAXY=%d\n" "R=%04X, G=%04X, B=%04X\n" "RGBM=%d\n" "MAXCACHE=%d\n", -tmp,DDERR,VERSION>>16,(VERSION>>8)&255,VERSION&255,MAXX,MAXY,RED,GREEN,BLUE,RGBM,MAXCACHE); MessageBox(hwnd,buf,"DirectX init failed.",MB_ICONSTOP|MB_OK); exit(1); }
int main (int argc, char **argv) { int targc = argc - 1; char **targv = argv + 1; char *worldname = "demo"; const char* datadir = getenv("GLBUMPER_DATA"); if (!datadir) { datadir = "."; } int fps = 25; int port = 20200; srand(time(NULL)); SDL_Init (SDL_INIT_NOPARACHUTE); sock_init(); #ifdef WIN32 SetConsoleCtrlHandler((PHANDLER_ROUTINE)console_ctrl_handler, TRUE); #else signal(SIGINT, sigint); signal(SIGTERM, sigint); #endif while (targc) { if (**targv == '-') { if (!strcmp (*targv + 1, "p")) { targc--; port = atoi(*++targv); } else if (!strcmp (*targv + 1, "D")) { if (!targc--) usage(argv[0]); datadir = *++targv; } else if (!strcmp (*targv + 1, "fps")) { targc--; fps = atoi(*++targv); } else { usage(argv[0]); } } else { worldname = *targv; } targc--; targv++; } FileResourceLoader::set_data_dir(datadir); int framems = 1000/fps; init_engine(); Socket::init(); sptr<ServerThread> svr = GC::track(new ServerThread(framems)); svr->loadworld(worldname); svr->listen(port); svr->start(); while (!server_exit && svr->isrunning()) { dsleep(0.5); }; cout << "\n\n\nGot signal, exiting" << endl; svr->stop(); svr = NULL; cout << "\nBefore collection:\n"; GC::printstats(); GC::collect(); cout << "After collection:\n"; GC::printstats(); //GC::printobjects(); cout<<endl; SDL_Quit (); return 0; }
int main(int argc, char **argv) { std::string model_filename; if (argc < 2) { model_filename = getBinDir() + BIN2CONFIG + DEFAULT_CONFIG; } else { model_filename = argv[1]; } shm_init(); glfwSetErrorCallback(error_callback); if (!glfwInit()) { return -1; } glfwWindowHint(GLFW_SAMPLES, 4); // TODO how many samples? glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); GLFWwindow *window = glfwCreateWindow(DEFAULT_WIDTH, DEFAULT_HEIGHT, "CUAUV Visualizer " VERSION, NULL, NULL); if (!window) { fprintf(stderr, "ERROR: Failed to create window.\n"); return -1; } glfwMakeContextCurrent(window); if (init_engine(true, true)) { fprintf(stderr, "ERROR: Failed to initalize graphics engine.\n"); return -1; } cam.direction = NORTH; cam.up = UP; cam.width = DEFAULT_WIDTH; cam.height = DEFAULT_HEIGHT; cam.fov = 1.0; libconfig::Config config; config.setOptions(libconfig::Setting::OptionAutoConvert); try { config.readFile(model_filename.c_str()); } catch (libconfig::ParseException &pe) { fprintf(stderr, "ERROR parsing config file %s:%d %s\n", pe.getFile(), pe.getLine(), pe.getError()); return -1; } std::unordered_map<std::string, GLuint> texture_map; auto &objects = config.lookup("objects"); for (const auto &object : objects) { std::string name("Poor nameless object"); object.lookupValue("name", name); std::unique_ptr<SceneObject> scene_object; bool is_sub = (object.exists("sub") && ((bool)object.lookup("sub")) == true) || objects.getLength() == 1; if (!object.exists("model")) { scene_object = std::make_unique<SceneObject>(); if (!scene_object) { fprintf(stderr, "ERROR: Could not allocate memory for SceneObject!\n"); continue; } load_axes(scene_object.get()); } else { auto mesh_object = std::make_unique<MeshObject>(); if (!mesh_object) { fprintf(stderr, "ERROR: Could not allocate memory for MeshObject!\n"); continue; } std::string mesh_name = object.lookup("model"); auto get_file_name = [] (const std::string &filename, const char *folder) { if (filename[0] == '/') { return filename; } return getBinDir() + folder + filename; }; if (load_model(get_file_name(mesh_name, BIN2DATA), mesh_object.get())) { fprintf(stderr, "ERROR: failed to make model \"%s\".\n", mesh_name.c_str()); } if (object.exists("texture")) { std::string texture = object.lookup("texture"); if (texture_map.find(texture) == texture_map.end()) { GLuint texture_ind; if (load_texture(get_file_name(texture, BIN2TEXTURES), texture_ind)) { fprintf(stderr, "WARNING: texture \"%s\" failed to load.\n", texture.c_str()); } texture_map[texture] = texture_ind; } mesh_object->set_texture(texture_map[texture]); } if (object.exists("alpha")) { mesh_object->set_alpha(object.lookup("alpha")); } scene_object = std::move(mesh_object); } auto grab_vec = [&object, &name] (const std::string &att_name, glm::vec3 id_v) -> std::function<glm::vec3()> { auto id = [id_v] { return id_v; }; if (object.exists(att_name)) { auto &att = object.lookup(att_name); if (att.getLength() == 3) { glm::vec3 vec(att[0], att[1], att[2]); return [vec] { return vec; }; } std::string att_s = att; if (att_s == "kalman") { return get_sub_position; } else { fprintf(stderr, "ERROR: Invalid %s for object \"%s\".\n", att_name.c_str(), name.c_str()); } } else { return id; } return id; }; auto grab_orientation = [&object, &name] (const std::string &att_prefix) -> std::function<glm::fquat()> { auto id = [] { return quat_from_hpr(0, 0, 0); }; if (object.exists(att_prefix + "_hpr")) { auto &att = object.lookup(att_prefix + "_hpr"); if (att.getLength() == 3) { glm::fquat q = quat_from_hpr(att[0], att[1], att[2]); return [q] { return q; }; } std::string att_s = att; if (att_s == "desires") { return get_desire_quat; } else { fprintf(stderr, "ERROR: Invalid orientation_hpr for object \"%s\".\n", name.c_str()); } } else if (object.exists(att_prefix + "_q")) { std::string att_s = object.lookup(att_prefix + "_q"); if (att_s == "kalman") { return get_sub_quat; } else { fprintf(stderr, "ERROR: Invalid orientation_q for object \"%s\".\n", name.c_str()); } } return id; }; scene_object->get_position = grab_vec("position", glm::vec3(0, 0, 0)); auto orient_f = grab_orientation("orientation"); scene_object->get_orientation = [orient_f] () { return orient_f(); }; auto mesh_f = grab_orientation("mesh_offset"); scene_object->mesh_offset = mesh_f(); scene_object->get_scale = grab_vec("scale", glm::vec3(1, 1, 1)); if (object.exists("exclude_renders")) { auto &excludes = object.lookup("exclude_renders"); for (const auto &render : excludes) { std::unordered_map<std::string, char> value_map = { {"main", RENDER_MAIN}, {"offscreen", RENDER_OFFSCREEN}, {"shadow", RENDER_SHADOW} }; if (value_map.find(render) == value_map.end()) { std::string s; for (const auto &pair : value_map) { s += pair.first + " "; } fprintf(stderr, "WARNING: Invalid exclude_renders for object \"%s\". " "Possible values are: %s\n", name.c_str(), s.c_str()); } else { scene_object->exclude |= value_map[render]; } } } if (object.exists("camera_attachments")) { if (!load_vision_link_lib()) { auto &cams = object.lookup("camera_attachments"); for (const auto &cam : cams) { auto &pos = cam.lookup("pos"); auto &orient = cam.lookup("orientation"); unsigned int width = DEFAULT_WIDTH; unsigned int height = DEFAULT_HEIGHT; float fov = 1.0; cam.lookupValue("width", width); cam.lookupValue("height", height); cam.lookupValue("fov", fov); add_sub_camera(cam.lookup("name"), width, height, fov, glm::vec3(pos[0], pos[1], pos[2]), quat_from_hpr(orient[0], orient[1], orient[2])); } } else { fprintf(stderr, "WARNING: Loading vision link library failed; " "vision output unavailable.\n"); } } if (is_sub) { sub = scene_object.get(); } scene_objects.push_back(std::move(scene_object)); } if (!sub) { fprintf(stderr, "WARNING: no sub designated; sub follow mode will not work.\n"); } add_light(&light1); add_light(&light2); glfwSetFramebufferSizeCallback(window, reshape_callback); glfwSetKeyCallback(window, key_callback); glfwSetCursorPosCallback(window, [] (GLFWwindow *w, double x, double y) { mouse_handlers[mouse_state](w, x, y); }); glClearColor(0.0, 0.0, 0.0, 1.0); glClearDepth(1.0); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); mouse_move_mode_off(window); mouse_handlers[MOUSE] = handle_mouse_move; mouse_handlers[FIXED] = [] (GLFWwindow *w, int x, int y) {}; register_action(GLFW_KEY_M, [window] { if (mouse_state == MOUSE) { mouse_move_mode_off(window); } else { mouse_move_mode_on(window); } }); register_action(GLFW_KEY_F, [] { if (sub) { sub_follow = !sub_follow; if (sub_follow) { cam.up = UP; } } }); register_action(GLFW_KEY_H, [] { heading_lock = !heading_lock; if (heading_lock) { cam_angle = 0.0; } }); register_action(GLFW_KEY_X, toggle_skybox); register_action(GLFW_KEY_Z, toggle_shadows); register_action(GLFW_KEY_V, toggle_offscreen_rendering); register_action(GLFW_KEY_ESCAPE, [window] () { mouse_move_mode_off(window); }); int width, height; glfwGetFramebufferSize(window, &width, &height); reshape_callback(window, width, height); draw_loop(window); glfwDestroyWindow(window); glfwTerminate(); return 0; }
bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args) { init_args(game_params, cmd_args); // List video modes if requested if (list_video_modes) return print_video_modes(); if (!init_engine(game_params.log_level)) { errorstream << "Could not initialize game engine." << std::endl; return false; } // Create time getter g_timegetter = new IrrlichtTimeGetter(device); // Speed tests (done after irrlicht is loaded to get timer) if (cmd_args.getFlag("speedtests")) { dstream << "Running speed tests" << std::endl; speed_tests(); return true; } video::IVideoDriver *video_driver = device->getVideoDriver(); if (video_driver == NULL) { errorstream << "Could not initialize video driver." << std::endl; return false; } porting::setXorgClassHint(video_driver->getExposedVideoData(), PROJECT_NAME_C); /* This changes the minimum allowed number of vertices in a VBO. Default is 500. */ //driver->setMinHardwareBufferVertexCount(50); // Create game callback for menus g_gamecallback = new MainGameCallback(device); device->setResizable(true); if (random_input) input = new RandomInputHandler(); else input = new RealInputHandler(device, receiver); smgr = device->getSceneManager(); smgr->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true); guienv = device->getGUIEnvironment(); skin = guienv->getSkin(); skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255, 255, 255, 255)); skin->setColor(gui::EGDC_3D_LIGHT, video::SColor(0, 0, 0, 0)); skin->setColor(gui::EGDC_3D_HIGH_LIGHT, video::SColor(255, 30, 30, 30)); skin->setColor(gui::EGDC_3D_SHADOW, video::SColor(255, 0, 0, 0)); skin->setColor(gui::EGDC_HIGH_LIGHT, video::SColor(255, 70, 120, 50)); skin->setColor(gui::EGDC_HIGH_LIGHT_TEXT, video::SColor(255, 255, 255, 255)); g_fontengine = new FontEngine(g_settings, guienv); FATAL_ERROR_IF(g_fontengine == NULL, "Font engine creation failed."); #if (IRRLICHT_VERSION_MAJOR >= 1 && IRRLICHT_VERSION_MINOR >= 8) || IRRLICHT_VERSION_MAJOR >= 2 // Irrlicht 1.8 input colours skin->setColor(gui::EGDC_EDITABLE, video::SColor(255, 128, 128, 128)); skin->setColor(gui::EGDC_FOCUSED_EDITABLE, video::SColor(255, 96, 134, 49)); #endif // Create the menu clouds if (!g_menucloudsmgr) g_menucloudsmgr = smgr->createNewSceneManager(); if (!g_menuclouds) g_menuclouds = new Clouds(g_menucloudsmgr->getRootSceneNode(), g_menucloudsmgr, -1, rand(), 100); g_menuclouds->update(v2f(0, 0), video::SColor(255, 200, 200, 255)); scene::ICameraSceneNode* camera; camera = g_menucloudsmgr->addCameraSceneNode(0, v3f(0, 0, 0), v3f(0, 60, 100)); camera->setFarValue(10000); /* GUI stuff */ ChatBackend chat_backend; // If an error occurs, this is set to something by menu(). // It is then displayed before the menu shows on the next call to menu() std::string error_message; bool first_loop = true; /* Menu-game loop */ bool retval = true; bool *kill = porting::signal_handler_killstatus(); while (device->run() && !*kill && !g_gamecallback->shutdown_requested) { // Set the window caption const wchar_t *text = wgettext("Main Menu"); device->setWindowCaption((narrow_to_wide("MultiCraft") + L" [" + text + L"]").c_str()); delete[] text; #ifdef ANDROID porting::handleAndroidActivityEvents(); #endif try { // This is used for catching disconnects guienv->clear(); /* We need some kind of a root node to be able to add custom gui elements directly on the screen. Otherwise they won't be automatically drawn. */ guiroot = guienv->addStaticText(L"", core::rect<s32>(0, 0, 10000, 10000)); bool game_has_run = launch_game(error_message, game_params, cmd_args); // If skip_main_menu, we only want to startup once if (skip_main_menu && !first_loop) break; first_loop = false; if (!game_has_run) { if (skip_main_menu) break; else continue; } // Break out of menu-game loop to shut down cleanly if (!device->run() || *kill) { if (g_settings_path != "") g_settings->updateConfigFile(g_settings_path.c_str()); break; } if (current_playername.length() > PLAYERNAME_SIZE-1) { error_message = gettext("Player name too long."); playername = current_playername.substr(0, PLAYERNAME_SIZE-1); g_settings->set("name", playername); continue; } device->getVideoDriver()->setTextureCreationFlag( video::ETCF_CREATE_MIP_MAPS, g_settings->getBool("mip_map")); #ifdef HAVE_TOUCHSCREENGUI receiver->m_touchscreengui = new TouchScreenGUI(device, receiver); g_touchscreengui = receiver->m_touchscreengui; #endif the_game( kill, random_input, input, device, worldspec.path, current_playername, current_password, current_address, current_port, error_message, chat_backend, gamespec, simple_singleplayer_mode ); smgr->clear(); #ifdef HAVE_TOUCHSCREENGUI delete g_touchscreengui; g_touchscreengui = NULL; receiver->m_touchscreengui = NULL; #endif } //try catch (con::PeerNotFoundException &e) { error_message = gettext("Connection error (timed out?)"); errorstream << error_message << std::endl; } #ifdef NDEBUG catch (std::exception &e) { std::string error_message = "Some exception: \""; error_message += e.what(); error_message += "\""; errorstream << error_message << std::endl; } #endif // If no main menu, show error and exit if (skip_main_menu) { if (!error_message.empty()) { verbosestream << "error_message = " << error_message << std::endl; retval = false; } break; } } // Menu-game loop g_menuclouds->drop(); g_menucloudsmgr->drop(); return retval; }
int main (int argc, char **argv) { GtkWidget *window; GtkWidget *main_hbox; GtkWidget *vseparator; GtkWidget *button; GtkWidget *main_vbox; GtkWidget *menubar; GtkWidget *vbox; GtkWidget *label; GtkAccelGroup *accel_group; PangoFontDescription *font_desc; int i; char *p; p = progname = argv[0]; while (*p) { if (*p == '/') progname = p+1; p++; } gtk_init (&argc, &argv); for (i=1; i<argc; i++) { if (!strcmp(argv[i], "--data-file") || !strcmp(argv[i], "-f")) { i++; if (i < argc) data_file = argv[i]; else usage(); } else { usage(); } } window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_resizable (GTK_WINDOW (window), TRUE); gtk_window_set_default_size (GTK_WINDOW (window), 350, 350); g_signal_connect (window, "destroy", G_CALLBACK (exit_callback), NULL); gtk_window_set_title (GTK_WINDOW(window), "KanjiPad"); main_vbox = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (window), main_vbox); gtk_widget_show (main_vbox); /* Menu */ GtkActionGroup *action_group; /* Packing group for our Actions */ GtkUIManager *menu_manager; /* The magic widget! */ GError *error; /* For reporting exceptions or errors */ GtkWidget *toolbar; /* The actual toolbar */ action_group = gtk_action_group_new ("MainMenu"); gtk_action_group_add_actions (action_group, entries, n_entries, NULL); gtk_action_group_add_toggle_actions (action_group, toggle_entries, n_toggle_entries, NULL); menu_manager = gtk_ui_manager_new (); gtk_ui_manager_insert_action_group (menu_manager, action_group, 0); error = NULL; gtk_ui_manager_add_ui_from_file (menu_manager, "ui.xml", &error); if (error){ g_message ("building menus failed: %s", error->message); g_error_free (error); } //Add the menu bar menubar = gtk_ui_manager_get_widget (menu_manager, "/MainMenu"); gtk_box_pack_start (GTK_BOX (main_vbox), menubar, FALSE, FALSE, 0); /*accel_group = gtk_accel_group_new (); factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group); gtk_item_factory_create_items (factory, nmenu_items, menu_items, NULL);*/ /* create a menubar */ /*menubar = gtk_item_factory_get_widget (factory, "<main>"); gtk_box_pack_start (GTK_BOX (main_vbox), menubar, FALSE, TRUE, 0); gtk_widget_show (menubar);*/ /* Install the accelerator table in the main window */ //gtk_window_add_accel_group (GTK_WINDOW (window), accel_group); main_hbox = gtk_hbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER(window), main_hbox); gtk_box_pack_start (GTK_BOX(main_vbox), main_hbox, TRUE, TRUE, 0); gtk_widget_show (main_hbox); /* toolbar = gtk_ui_manager_get_widget (menu_manager, "/MainToolbar"); gtk_box_pack_start (GTK_BOX (main_hbox), toolbar, FALSE, FALSE, 0); gtk_window_add_accel_group (GTK_WINDOW (window), gtk_ui_manager_get_accel_group (menu_manager)); */ /* Area for user to draw characters in */ pad_area = pad_area_create (); gtk_box_pack_start (GTK_BOX (main_hbox), pad_area->widget, TRUE, TRUE, 0); gtk_widget_show (pad_area->widget); vseparator = gtk_vseparator_new(); gtk_box_pack_start (GTK_BOX (main_hbox), vseparator, FALSE, FALSE, 0); gtk_widget_show (vseparator); /* Area in which to draw guesses */ vbox = gtk_vbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (main_hbox), vbox, FALSE, FALSE, 0); gtk_widget_show (vbox); karea = gtk_drawing_area_new(); g_signal_connect (karea, "configure_event", G_CALLBACK (karea_configure_event), NULL); g_signal_connect (karea, "expose_event", G_CALLBACK (karea_expose_event), NULL); g_signal_connect (karea, "button_press_event", G_CALLBACK (karea_button_press_event), NULL); gtk_widget_set_events (karea, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK); #ifdef G_OS_WIN32 font_desc = pango_font_description_from_string ("MS Gothic 18"); #else font_desc = pango_font_description_from_string ("Sans 18"); #endif gtk_widget_modify_font (karea, font_desc); gtk_box_pack_start (GTK_BOX (vbox), karea, TRUE, TRUE, 0); gtk_widget_show (karea); /* Buttons */ label = gtk_label_new ("\xe5\xbc\x95"); /* We have to set the alignment here, since GTK+ will fail * to get the width of the string appropriately... */ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_widget_modify_font (label, font_desc); gtk_widget_show (label); lookup_button = button = gtk_button_new (); gtk_container_add (GTK_CONTAINER (button), label); g_signal_connect (button, "clicked", G_CALLBACK (look_up_callback), NULL); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); label = gtk_label_new ("\xe6\x88\xbb"); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_widget_modify_font (label, font_desc); gtk_widget_show (label); undo_button = button = gtk_button_new (); gtk_container_add (GTK_CONTAINER (button), label); g_signal_connect (button, "clicked", G_CALLBACK (undo_callback), NULL); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); label = gtk_label_new ("\xe6\xb6\x88"); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_widget_modify_font (label, font_desc); gtk_widget_show (label); clear_button = button = gtk_button_new (); gtk_container_add (GTK_CONTAINER (button), label); g_signal_connect (button, "clicked", G_CALLBACK (clear_callback), NULL); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); gtk_widget_show(window); pango_font_description_free (font_desc); init_engine(); update_sensitivity (); gtk_main(); return 0; }