Esempio n. 1
0
File: xui.c Progetto: choueric/tools
int XuiMainLoop(CALLBACK_FUNC *cb, void *data)
{
	XEvent e;
	int ok = 0;

	while (1) {
		XNextEvent(Dsp, &e);
		if (e.type == Expose) {
			init_draw(Num);
		} else if (e.type ==  KeyPress) {
			break;
		} else if (ok == 0 && e.type == ButtonPress) {
			if (IsAuto) {
				while (ok == 0)
					ok = cb(data);
			} else {
				ok = cb(data);
			}
		}
	}

	return 0;
}
Esempio n. 2
0
int		main(int argc, char **argv)
{
	int		fd;
	t_coord	*coord;
	t_param	*param;

	if (argc != 2)
	{
		ft_putstr("fdf error ! You must give only one argument.\n");
		exit(2);
	}
	fd = open(argv[1], O_RDONLY);
	error_handler(fd);
	coord = (t_coord*)malloc(sizeof(t_coord));
	param = (t_param*)malloc(sizeof(t_param));
	param->matrix = matrix_init(fd, param);
	init_draw(param, coord);
	mlx_expose_hook(param->win, expose_function, param);
	mlx_key_hook(param->win, key_function, param);
	free(coord);
	mlx_loop(param->mlx);
	return (0);
}
Esempio n. 3
0
void GlobalInitialize()
{
    InitCommonControls(); 

/*	if(SDL_WasInit(SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_VIDEO) == 0)
	{
		if (SDL_InitSubSystem(SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_VIDEO) < 0)
			report_error("Couldn't init SDL");
	}
*/
		
	if(SDL_Init(SDL_INIT_EVERYTHING)<0) 
        report_error("Couldn't init SDL");
	
   if (!Sound_Init()) report_error("Couldn't init SDL_Sound");


	if(SDLNet_Init()<0)	report_error("Couldn't init SDL_Net");

	GLOBAL.os_version=check_OS();


    TTY.ThreadExitEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
    if (TTY.ThreadExitEvent == NULL)
        report_error("CreateEvent (Thread exit event)");       

	init_devicetype();
	TTY.COMDEV=INVALID_HANDLE_VALUE;
	TTY.CONNECTED=FALSE;
	TTY.read_pause=TRUE;
	TTY.amount_to_write=0;
	TTY.writeMutex=	CreateMutex( NULL, FALSE, NULL ); 

	TTY.FLOW_CONTROL=0;

	PACKET.readstate=0;
	PACKET.info=0;
	PACKET.requestedinfo=0;

	GLOBAL.objects=0;	actobject=NULL; actconnect=NULL;
	GLOBAL.tool_left=400;GLOBAL.tool_top=100;
	GLOBAL.tool_right=800;GLOBAL.tool_bottom=400;
	GLOBAL.anim_left=20;GLOBAL.anim_right=420;
	GLOBAL.anim_top=350;GLOBAL.anim_bottom=700;
	GLOBAL.design_left=20;GLOBAL.design_right=500;
	GLOBAL.design_top=20;GLOBAL.design_bottom=400;
	GLOBAL.startup=0; GLOBAL.autorun=0; GLOBAL.configfile[0]=0;
	GLOBAL.syncloss=0;
	GLOBAL.dialog_interval=DIALOG_UPDATETIME;
	GLOBAL.draw_interval=DRAW_UPDATETIME;
	GLOBAL.neurobit_available=0;
	GLOBAL.emotiv_available=0;
	GLOBAL.use_cv_capture=0;
	strcpy(GLOBAL.emotivpath,"C:\\Program Files (x86)\\Emotiv Development Kit_v1.0.0.3-PREMIUM");

	GLOBAL.loading=false;
	GLOBAL.read_tcp=0;
	GLOBAL.packet_parsed=0;
	GLOBAL.actcolumn=0;
	GLOBAL.running=false;
	GLOBAL.showdesign=TRUE;
	GLOBAL.showtoolbox=-1;
	GLOBAL.session_length=0;
	GLOBAL.session_start=0;
	GLOBAL.session_end=0;
	GLOBAL.session_loop =0 ;
	GLOBAL.session_sliding=0;

	GLOBAL.main_maximized=0;
	GLOBAL.minimized=0;
	GLOBAL.run_exception=0;
	GLOBAL.fly=0;

	GLOBAL.P3ALC1=12;
	GLOBAL.P3ALC2=12;

	TIMING.timerid=0;

	CAPTFILE.filetype=FILE_INTMODE;
	CAPTFILE.filehandle=INVALID_HANDLE_VALUE;
	CAPTFILE.file_action=0;
	CAPTFILE.do_read=0;
	CAPTFILE.do_write=0;
	CAPTFILE.length=0;
	CAPTFILE.start=0;
	strcpy(CAPTFILE.filename,"none");

	ghWndAnimation=NULL;
    ghWndToolbox=NULL;
    ghWndSettings=NULL;
    ghWndDesign=NULL;
	copy_object=NULL;

	init_draw();
	init_midi();

	load_settings();
	
	TIMING.timerid=0;
	TIMING.pause_timer=0;
	init_system_time();

	write_logfile("application init successful.");
    return ;
}
Esempio n. 4
0
void gwave_main(void *p, int argc, char **argv)
{
	int c;
	int i;
	int nobacktrace = 0;

	/* In guile-1.5 and later, need to use scm_primitive_eval_x
	 * in order to change modules so that our C primitives
	 * registered below become globals, instead of hidden away
	 * in the guile-user module
	 */
	{
		SCM exp = scm_c_read_string("(define-module (guile))");
		scm_primitive_eval_x(exp);
	}

	init_scwm_guile();
	init_gtkmisc();
	init_gwave();
	init_cmd();
	init_wavewin();
	init_wavelist();
	init_wavepanel();
	init_event();
	init_draw();
	
	gtk_init(&argc, &argv);

	prog_name = argv[0];

	/* simple pre-processing of debugging options that we need to set up
	 * before we get into guile.   These options cannot be bundled.
	 * Most of the general user options are handled in std-args.scm  */
	for(i = 1; i < argc; i++) {
		if(strcmp(argv[i], "-n") == 0) {
			nobacktrace = 1;
		} else if (strcmp(argv[i], "-v") == 0) {
			v_flag = 1;
		} else if (strcmp(argv[i], "-x") == 0) {
			x_flag = 1;
			SCM_SETCDR(scm_gwave_debug, SCM_BOOL_T);
		}
	}

	gtk_rc_parse_string(gwave_base_gtkrc);
	gtk_rc_parse("gwave.gtkrc");
//	assert( SCM_CONSP(scm_gwave_tooltips) );

#ifdef GUILE_GTK_EXTRA_LOADPATH
	scm_c_eval_string("(set! %load-path (cons \"" GUILE_GTK_EXTRA_LOADPATH "\" %load-path))");
#endif

	/* the default for this seems to have changed between guile-1.3
	   and guile-1.3.2;  only the first clause is needed when 
	   we drop support for guile-1.3.2 */
	if (!nobacktrace) {
		scm_c_eval_string("(debug-enable 'debug)(debug-enable 'backtrace) (read-enable 'positions)");
	} /* else {
	scm_c_eval_str("(debug-disable 'debug)(read-disable 'positions)");
	}*/

	/* the compiled-in initial scheme code comes from minimal.scm,
	   built into init_scheme_string.c by the Makefile
	   Among other things, it finds and loads system and user .gwaverc
	   files.
	*/
	{ /* scope */
		extern char *init_scheme_string;
		SCM res;
		if(v_flag) {fprintf(stderr, "running init_scheme_string\n");}
		res = scwm_safe_eval_str(init_scheme_string);
		if(v_flag) {
			printf("result="); fflush(stdout);
			scm_display(res, scm_cur_outp);
			printf("\n"); fflush(stdout);
		}
                if(!SCM_NFALSEP(res)) {
                        fprintf(stderr, "gwave: aborting due to errors.\n");
                        exit(1);
                }

	} /* end scope */

	wtable = g_new0(WaveTable, 1);
	wtable->cursor[0] = g_new0(VBCursor, 1);
	wtable->cursor[1] = g_new0(VBCursor, 1);
	wtable->srange = g_new0(SelRange, 1);
	wtable->npanels = 0;
	wtable->panels = NULL;

	setup_colors(wtable);
	setup_waveform_window();

	xg_init(NULL);  /* X-server interprocess communication for Gtk+ */

	gtk_main();
	exit(0);
}
Esempio n. 5
0
void PARTICLE::Load()
{
	int i;
	
	if (loaded)
	{
		for (i = 0; i < PARTICLE_TEXTURES; i++)
		{
			glDeleteTextures( PARTICLE_TEXTURES, &(texture[i]) );
		}
		glDeleteLists(drawlist, 1);
		drawlist = 0;
	}
	
	for (i = 0; i < MAX_PARTICLES; i++)
	{
		particle[i].active = false;
	}
	
	//load textures
	char fname[64];
	for (i = 0; i < PARTICLE_TEXTURES; i++)
	{
		sprintf(fname, "smoke/particle%i.png", i);
		if (!texture[i])
			texture[i] = utility.TexLoad(fname, GL_RGBA, false);
	}
	
	//create display list
	if (!drawlist)
	{
		drawlist = glGenLists(1);
		glNewList (drawlist, GL_COMPILE);
		
		for (i = 0; i <= NUM_ROTATIONS; i++)
		{
			float thisrot = 90.0 / (float) NUM_ROTATIONS;
			thisrot *= i;
			
			glPushMatrix();
			glRotatef(thisrot,0,1,0);
			//glRotatef(p.rotation,0,0,1);
			init_draw();
			glPopMatrix();
			
			//cout << thisrot << " ";
			
			/*glPushMatrix();
			glRotatef(90,1,0,0);
			glRotatef(p.rotation,0,0,1);
			glCallList(drawlist);
			glPopMatrix();*/
		}
		
		glEndList ();
	}
	
	curtime = 0;
	
	loaded = true;
}
Esempio n. 6
0
void	
mainproc(void *arg)
{	
  int	i, j;
  int	cont_no = 0;
  int	error, readerror;
  u8	bitpattern;
  u16	button = 0, oldbutton = 0, newbutton = 0; 
  u32	stat;
  char 	console_text[50];

  osCreateMesgQueue(&pifMesgQueue, pifMesgBuf, NUM_MESSAGE);
  osSetEventMesg(OS_EVENT_SI, &pifMesgQueue, dummyMessage);

  osContInit(&pifMesgQueue, &bitpattern, &contstat[0]);
  for (i = 0; i < MAXCONTROLLERS; i++) {
    if ((bitpattern & (1<<i)) &&
       ((contstat[i].type & CONT_TYPE_MASK) == CONT_TYPE_NORMAL)) {
      controller[i] = CONT_VALID;
    } else {
      controller[i] = CONT_INVALID;
    }
  }
  
  osCreateMesgQueue(&dmaMessageQ, dmaMessageBuf, 1);

  pi_handle = osCartRomInit();
  pi_ddrom_handle = osDriveRomInit();
  
  bzero(blockData, 0x1000);
  readerror = -1;

  init_draw();

  setcolor(0,255,0);
  draw_puts("If you see this for a long period of time,\nsomething f****d up. Sorry.");
  
  LeoCJCreateLeoManager((OSPri)OS_PRIORITY_LEOMGR-1, (OSPri)OS_PRIORITY_LEOMGR, LeoMessages, NUM_LEO_MESGS);
  LeoResetClear();

  setbgcolor(15,15,15);
  clear_draw();
  
  setcolor(0,255,0);
  draw_puts("\f\n    64DD IPL dumper v0.01b by LuigiBlood & marshallh\n    ----------------------------------------\n");
  setcolor(255,255,255);
  draw_puts("    PRESS START TO DUMP");

  while(1) {
    osContStartReadData(&pifMesgQueue);
    osRecvMesg(&pifMesgQueue, NULL, OS_MESG_BLOCK);
    osContGetReadData(&contdata[0]);
    if (contdata[cont_no].errno & CONT_NO_RESPONSE_ERROR) {
      button = oldbutton;
    } else {
      oldbutton = button;
      button = contdata[cont_no].button;
    }
    newbutton = ~oldbutton & button;
    
    if (newbutton & START_BUTTON)
    {
        //DUMP!!
        
        //64drive, enable write to SDRAM/ROM
		  srand(osGetCount()); // necessary to generate unique short 8.3 filenames on memory card
        ciEnableRomWrites();

        draw_puts("\f\n\n\n\n\n    Let's dump! Don't turn off the console!\n\n");
        
        osInvalDCache((void *)&blockData, (s32) 0x1000); 
        dmaIoMesgBuf.hdr.pri = OS_MESG_PRI_NORMAL;
        dmaIoMesgBuf.hdr.retQueue = &dmaMessageQ;
        dmaIoMesgBuf.dramAddr = &blockData;
        dmaIoMesgBuf.devAddr = IPLoffset;
        dmaIoMesgBuf.size = 0x1000;
        
        for (IPLoffset = 0; IPLoffset < 0x400000; IPLoffset += 0x1000)
        {
          //read 64DD IPL
          osWritebackDCacheAll();
 
          dmaIoMesgBuf.hdr.pri = OS_MESG_PRI_NORMAL;
          dmaIoMesgBuf.hdr.retQueue = &dmaMessageQ;
          dmaIoMesgBuf.dramAddr = (void *)&blockData;
          dmaIoMesgBuf.devAddr = 0xA6000000 + IPLoffset;
          dmaIoMesgBuf.size = 0x1000;
                               
          osEPiStartDma(pi_ddrom_handle, &dmaIoMesgBuf, OS_READ);
          osRecvMesg(&dmaMessageQ, NULL, OS_MESG_BLOCK);
         
          //Write to 64drive
          osWritebackDCacheAll();
 
          dmaIoMesgBuf.hdr.pri = OS_MESG_PRI_NORMAL;
          dmaIoMesgBuf.hdr.retQueue = &dmaMessageQ;
          dmaIoMesgBuf.dramAddr = (void *)&blockData;
          dmaIoMesgBuf.devAddr = 0xB0000000 + IPLoffset;
          dmaIoMesgBuf.size = 0x1000;
                               
          osEPiStartDma(pi_handle, &dmaIoMesgBuf, OS_WRITE);
          osRecvMesg(&dmaMessageQ, NULL, OS_MESG_BLOCK);
        }
		  
		  //DONE!! NOW WRITE TO SD
		  fat_start();
        
        draw_puts("\n    - DONE !!\n");
		
        for(;;);
    }
  }
}
Esempio n. 7
0
File: tst_clt.c Progetto: iveney/cts
void draw_case(FILE * pFig){
	init_draw(pFig);
	draw_blockages(pFig);
	draw_sinks(pFig);
}
Esempio n. 8
0
void	init_struct(t_all *all)
{
  init_mlx(all);
  init_draw(all);
}
Esempio n. 9
0
void graphicsMenu(world * gameWorld, char *server_ip)
{
    int in_menu = 1;
    int mouse_pressed = 0;
    int menu_choice = 0;

    //fps
    struct timer_t2 fps;

    printf("Before trying to load the menu in load manu\n");
    init_draw();
    //load menu
    if ( load_menu("menu/main_menu_background.png",
              "menu/play_inactiv.png",
              "menu/options_inactiv.png",
              "menu/editor_inactiv.png",
              "menu/exit_inactiv.png",
              "menu/back_inactiv.png",
              SCREEN_WIDTH,
              SCREEN_HEIGHT)
        == -1)
    {
        clean_up();
        printf("couldn't read texture, quitting\n");
        exit(-3);
    }
    load_level();

    printf("After load menu\n");

    //wait for user to continue or exit
    while( in_menu != 0 )
    {
        //Start the frame timer
        timer_start(&fps);
        //While there are events to handle
        while( SDL_PollEvent( &event ) )
        {

            if( event.type == SDL_QUIT )
            {
                //exit
                clean_up();
                exit(0);
            }

            if (mouse_pressed != 1)
            {
                mouse_over_menu(event.button.x, event.button.y);
            }

            if( event.type == SDL_MOUSEBUTTONDOWN)
            {
                switch(event.button.button)
                {
                    case SDL_BUTTON_LEFT:
                        mouse_pressed = mouse_down_menu(event.button.x, event.button.y);
                        break;
                }
            }

            //is mousebuttom being pressed
            if( event.type == SDL_MOUSEBUTTONUP)
            {
                switch(event.button.button)
                {
                    case SDL_BUTTON_LEFT:
                        menu_choice = press_menu(event.button.x, event.button.y);
                        break;
                }
            }
        }
        //draw menu
        drawMenu(SCREEN_WIDTH, SCREEN_HEIGHT);

        switch(menu_choice)
        {
            case 1:
                printf("quitting menu, trying to play\n");
                in_menu = 0;
                drawLoadScr(SCREEN_WIDTH, SCREEN_HEIGHT);
                break;
            case 2:
                menu_choice = 0;
                options(server_ip);
                break;
            case 3:
                menu_choice = 0;
                editor(gameWorld);
                break;
            case 4:
                clean_up();
                exit(0);
                break;
            default:
                break;
        }

        if( timer_get_ticks(&fps) < 1000 / FRAMES_PER_SECOND )
        {
            //delay the as much time as we need to get desired frames per second
            SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - timer_get_ticks(&fps) );
        }
    }
}
Esempio n. 10
0
File: gui.c Progetto: treejames/xv6
void
draw_window(struct Window* window)
{
  unsigned int x = window->Pos_x;
  unsigned int y = window->Pos_y;
  int icon_no = window->Cur_icon;
  int i, j;
  for(i = 0; i < WindowWidth; i++)
  {
    draw_point(i + x, y, 0);
    draw_point(i + x, WindowHeight - 1 + y, 0);
    for(j = 1; j < 20; j++)
      draw_point(i + x, j + y, 0x5ACB);
    for(j = 2; j <= 20; j++)
      draw_point(i + x, y + WindowHeight - j, 0x5ACB);
  }
  for(j = 0; j < WindowHeight; j++)
  {
    draw_point(x, j + y, 0);
    draw_point(WindowWidth - 1 + x, j + y, 0);
  }
  for(i = 3; i < 18; i++)
  {
    for(j = 3; j < 18; j++)
    {
      if(window_button_x[i-3][j-3] != 2016)
        draw_point(i + x, j + y, window_button_x[i-3][j-3]);
    }
  }

  int offset = 25;
  switch(icon_no)
  {
    case ICON_FINDER:
      draw_string(x + offset, y + 2, "FINDER", FONT_COLOR);
      InitFolder(window);
      break;
    case ICON_PHOTO:
      draw_string(x + offset, y + 2, "PHOTO", FONT_COLOR);
      init_photo(x, y);
      break;
    case ICON_TEXT:
      draw_string(x + offset, y + 2, "TEXT", FONT_COLOR);
      init_text(x, y);
      break;
    case ICON_GAME:
      draw_string(x + offset, y + 2, "GAME", FONT_COLOR);
      initGameWindow(x, y);
      break;
    case ICON_DRAW:
      draw_string(x + offset, y + 2, "DRAW", FONT_COLOR);
      init_draw(x, y);
      break;
    case ICON_SETTING:
      draw_string(x + offset, y + 2, "SETTING", FONT_COLOR);
      init_setting(x, y);
      break;
    case 8:
      draw_string(x + offset, y + 2, "FINDER", FONT_COLOR);
      InitFolder(window);
      break;
    case 9:
      draw_string(x + offset, y + 2, "FINDER", FONT_COLOR);
      InitFolder(window);
      break;
  }

  draw_string(x + 590, y + 380, "@meizhi", 0xFFFF);
}