当前位置: 首页>>代码示例>>C++>>正文


C++ set_color_depth函数代码示例

本文整理汇总了C++中set_color_depth函数的典型用法代码示例。如果您正苦于以下问题:C++ set_color_depth函数的具体用法?C++ set_color_depth怎么用?C++ set_color_depth使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了set_color_depth函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
allegro_init();
install_mouse();
install_keyboard();
set_color_depth(16);
set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0);
buffer = create_bitmap( 640, 480);
show_mouse(buffer);
	while(!key[KEY_ESC])
		{	
		shape_menu();
		get_mouse_info();
		circle_fill();
		
			if(cursor_x<=110&&cursor_y<=40)
			{
			circle_empty();
			}
			else if(cursor_x<=110&&cursor_y>=60||cursor_y<=120)
			{
			circle_fill();
			}
		}

return 0;   
}
开发者ID:abhaysood,项目名称:Projects,代码行数:27,代码来源:paint.c

示例2: draw_matrix

void draw_matrix(matrix_t *m, char *name, char *dirname){
    	
	allegro_init();
    	set_color_depth( 16 );
	BITMAP * obrazek1 = NULL;
	obrazek1 = create_bitmap( m->cn*10, m->rn*10 );
	if( !obrazek1 )
	{
	    set_gfx_mode( GFX_TEXT, 0, 0, 0, 0 );
	    allegro_message( "nie mogę załadować obrazka 1 !" );
	    allegro_exit();
	}
	clear_to_color( obrazek1, makecol( 255, 255, 255 ) );
	int i,j;
	for (i = 0; i < m->rn; i++) 
    		for (j = 0; j < m->cn ; j++)
				if(m->e[i*m->cn+j]==1)
					rectfill( obrazek1, j*10, i*10,  (j*10)+10,(i*10)+10,makecol( 0, 0, 0 ) );
	
	chdir(dirname);
	save_bitmap(name, obrazek1, default_palette);	
	chdir(PARENT_DIRECTORY);	
	
	destroy_bitmap( obrazek1 );
	allegro_exit();

}
开发者ID:amoratka,项目名称:automat_life,代码行数:27,代码来源:draw.c

示例3: main

int main(){
    
    declarevalues();
 
 
    allegro_init();
    install_keyboard();
    install_mouse();
    set_color_depth(32);
    set_gfx_mode(GFX_AUTODETECT_WINDOWED, Screen.getwidth(), Screen.getheight(), 0, 0);
    
    buffer = create_bitmap(Screen.getwidth(), Screen.getheight());


Loadproperties();


while (!key[KEY_ESC]) // Here is the game loop.
{

    declarearray();
    create_world();
     
     
     circlefill(buffer, mouse_x, mouse_y, 5, makecol(255, 0, 0));
    
    
        textprintf_ex(buffer, font, 10, 10, makecol(255, 100, 200), -1, "%s", testchar.testname.c_str() );
        
               
    blit(buffer, screen, 0, 0, 0, 0, Screen.getwidth(), Screen.getheight());
    clear_bitmap(buffer);
}   
    return 0;   
}   
开发者ID:itgsod-erik-rosto,项目名称:rpg_game,代码行数:35,代码来源:main.cpp

示例4: set_color_depth

 void RGBHistogram::display() {
   #ifdef ALLEGRO
   int winwid=640,winhei=480;
   set_color_depth(24);
   allegrosetup(winwid,winhei);
   PALETTE pal;
   generate_332_palette(pal);
   set_palette(pal);
   float rot=pi/4,elev=pi/8,rotspeed=pi/64;
   int smallize=largest();
   PPsetup(winwid,winhei,3);
   BITMAP *b=create_bitmap(winwid,winhei);
   do {
     clear(b);
     Matrix m1=Matrix();
     m1.makerotation(V3d(0,1,0),rot);
     Matrix m2=Matrix();
     m2.makerotation(V3d(1,0,0),elev);
     for (int i=0;i<quant;i++) {
       for (int j=0;j<quant;j++) {
         for (int k=0;k<quant;k++) {
           V3d c=V3d(i,j,k);
           c=c/c.getlongestside();
           c=c*(float)rgb[i][j][k]/smallize*255;
           // c=c*255;
           c.chop(0,255);
           if (c.getlongestside()>64) {
             V3d v=2*(V3d(i,j,k)/quant-V3d(.5,.5,.5));
             // v=V3d::rotate(v,V3d(0,1,0),rot);
             // v=V3d::rotate(v,V3d(1,0,0),elev);
             v=m1*v;
             v=m2*v;
             V3d u=v+V3d(.02,0,0);
             int x,y,rx,dx;
             PPgetscrpos(v,&x,&y);
             PPgetscrpos(u,&rx,&dx);
             dx=rx-x;
             circle(b,x,y,dx,makecol(c.x,c.y,c.z));
           }
         }
       }
     }
     blit(b,screen,0,0,0,0,winwid,winhei);
     if (key[KEY_LEFT])
       rot-=rotspeed;
     if (key[KEY_RIGHT])
       rot+=rotspeed;
     if (key[KEY_UP])
       elev-=rotspeed;
     if (key[KEY_DOWN])
       elev+=rotspeed;
     if (key[KEY_Z])
       smallize=smallize*1.2;
     if (key[KEY_X])
       smallize=smallize/1.2;
   } while (!key[KEY_ESC]);
   #endif
 }
开发者ID:10crimes,项目名称:code,代码行数:58,代码来源:rgbhist.c

示例5: configAll

void configAll(){
	allegro_init();
	install_timer();
	install_sound(DIGI_AUTODETECT,MIDI_AUTODETECT,"OK");
	install_keyboard();
	set_color_depth(32);
	set_gfx_mode(GFX_AUTODETECT_FULLSCREEN,1000,800,0,0);
	formation();
}
开发者ID:narukaioh,项目名称:Space-Invaders,代码行数:9,代码来源:main.c

示例6: textgfx_init

void textgfx_init()
{
#ifdef UNIX
	strcpy(_xwin.application_name, "vitetris");
	strcpy(_xwin.application_class, "Vitetris");
#endif
	if (install_allegro(SYSTEM_AUTODETECT, &errno, NULL) != 0)
		exit(1);
#ifdef UNIX
	sigaction(SIGINT, NULL, &allegro_sigint_handler);
	signal(SIGINT, sigint_handler);
#endif
	load_pc8x16_font();
	set_window_title(VITETRIS_VER);
	set_close_button_callback(close_btn);
#ifndef UNIX
	/* Seems to cause seg fault later quite randomly on Linux  */
	int depth = desktop_color_depth();
	if (depth != 0)
		set_color_depth(depth);
#endif
	virt_screen = set_screen(getopt_int("", "fullscreen"));
	lang |= LATIN1;
	if (!font8x16) {
		font8x16 = font;
		textgfx_flags |= ASCII;
	}
	setattr_normal();
#if WIN32 && !ALLEGRO_USE_CONSOLE
	if (exists("stdout.tmp")) {
		FILE *fp;
		freopen("stdout2.tmp", "w", stdout);
		fp = fopen("stdout.tmp", "r");
		if (fp) {
			char line[80];
			int i;
			for (i=0; i < 25 && fgets(line, 80, fp); i++) {
				setcurs(0, i);
				i += printline(line);	
			}
			fclose(fp);
			if (i) {
				refreshscreen();
				if (!strncmp(line, "Press ", 6)) {
					install_keyboard();
					clear_keybuf();
					readkey();
					remove_keyboard();
				}
			}
		}
		freopen("stdout.tmp", "w", stdout);
		delete_file("stdout2.tmp");
	}
#endif
}
开发者ID:gsrr,项目名称:Python,代码行数:56,代码来源:allegro.c

示例7: w

SCREEN::SCREEN(int width, int height, bool windowed, bool db, bool videobuf_tiles) : w(width), h(height), doublebuffer(db)
{
    if (!doublebuffer) { // page flipping
        // set graphics mode
        set_color_depth(32);
        if (set_gfx_mode((windowed ? GFX_AUTODETECT_WINDOWED : GFX_AUTODETECT_FULLSCREEN), width, height, width, height * 2) != 0) { // get video memory now (smart drivers)
            printf("warning: set_gfx_mode(): %s\n", allegro_error);
            if (set_gfx_mode((windowed ? GFX_AUTODETECT_WINDOWED : GFX_AUTODETECT_FULLSCREEN), width, height, 0, 0) != 0) { // just open screen now and hope we can get the video memory later (DirectX)
                printf("warning: set_gfx_mode(%dx%d): %s\n", width, height, allegro_error);
                panic("failed to open screen with requested resolution");
            }
        }

        // get video memory
        video_page[0] = create_video_bitmap(width, height);
        video_page[1] = create_video_bitmap(width, height);
        if (videobuf_tiles) video_page[2] = create_video_bitmap(width + 2 * WORLD_RENDER_BORDER_SIZE, height + 2 * WORLD_RENDER_BORDER_SIZE);
        else video_page[2] = NULL;

        // error
        if (!video_page[0] || !video_page[1]) panic("unable to acquire sufficient video memory for requested resolution");
        if (!video_page[2] && videobuf_tiles) printf("unable to acquire video memory for tile background; using a memory bitmap instead");

        // set current screen
        video_page_offscreen = 0;
        offscreen = video_page[video_page_offscreen];

        // flip page
        flip_page();
    }
    else { // double buffering
        set_color_depth(32);
        if (set_gfx_mode((windowed ? GFX_AUTODETECT_WINDOWED : GFX_AUTODETECT_FULLSCREEN), width, height, 0, 0) != 0) { // double buffering
            printf("warning: set_gfx_mode(%dx%d): %s\n", width, height, allegro_error);
            panic("failed to open screen with requested resolution");
        }
        video_page[0] = create_bitmap(width, height);
        video_page[1] = NULL;
        video_page[2] = NULL;
        offscreen = video_page[0];
    }
    gui_set_screen(offscreen); // for the allegro gui routines
}
开发者ID:destrojan,项目名称:wotwar,代码行数:43,代码来源:screen.cpp

示例8: inicio

void inicio(){

		  allegro_init();
		  install_keyboard();
		  set_color_depth(16);
		  set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0);
		  im_tortuga = load_bitmap("tortuga.bmp", NULL); // carga la imagen
		  buffer = create_bitmap(800,600);
		  buffer2 = create_bitmap(800,600);
}
开发者ID:jacedo,项目名称:logo,代码行数:10,代码来源:Entorno.cpp

示例9: main

int main() 
{	
	allegro_init();
	install_keyboard();
	
	set_color_depth(32);
	set_gfx_mode(GFX_AUTODETECT_WINDOWED, width, height, 0, 0);
	
		bialy=makecol(200,200,200);
	czarny=makecol(0,0,0);//ustawienie kodow kolorow
	
	BITMAP *buffer = create_bitmap(width, height);
	clear_to_color(buffer, bialy);
	
	x=width/2;
	y=height/2;//ustawienie mrowki w centrum
	direction=0;//mrowka zwrocona poczatkowo w gore
	
            while (!keypressed()) {             
                  
                  if(getpixel(buffer,x,y)==bialy)//jesli mrowka znajduje sie na polu bialym
                  {
                  //allegro_message("BIALY"); 
                  direction = (direction+3)%4;//obrot w lewo
                  rectfill(buffer,x-0.5*a,y-0.5*a,x+0.5*a,y+0.5*a,czarny);//zamalowanie pola na czarno                                          
                  }
                  else{
                  direction = (direction+5)%4;//obrot w prawo
                  rectfill(buffer,x-0.5*a,y-0.5*a,x+0.5*a,y+0.5*a,bialy);//zamalowanie pola na bialo
                  }
                  
                   x += a*moves[direction][0];
                  y += a*moves[direction][1];//przesuniecie mrowki w zadanym kierunku
                  
                  strcpy(napis,"X: ");
                  strcat(napis,itoa(x,str,10));
                  strcat(napis," Y: ");
                  strcat(napis,itoa(y,str,10));
                  strcat(napis," D: ");
                  strcat(napis,itoa(direction,str,10));
                   textout_centre_ex(buffer, font, napis,
                        SCREEN_W / 2, 0,
                        makecol(255, 0, 0), makecol(0, 0, 0));
                  
                  if(x<0.5*a || y<0.5*a || x>width-0.5*a || y>height-0.5*a)break;
                  //ochrona przed wyjsciem mrowki poza ramy ekranu
                  
                  blit(buffer, screen, 0, 0, 0, 0, 640, 700);//wklejenie bufora na ekran
                  rest(10);//odczekanie pomiêdzy kolejnym ruchem
            }
	readkey();
	destroy_bitmap(buffer);
	
	return 0;
}
开发者ID:Robikos,项目名称:Old-Portfolio,代码行数:55,代码来源:main.c

示例10: TCaptureWorkerForm

void __fastcall TMainCaptureForm::FormCreate(TObject *Sender)
{

	CaptureWorkerForm = new TCaptureWorkerForm(this);
	CaptureWorkerForm1 = new TCaptureWorkerForm(this);
	CaptureWorkerForm2 = new TCaptureWorkerForm(this);
	CaptureWorkerForm3 = new TCaptureWorkerForm(this);
     MainCaptureForm->Caption = UnicodeString("CES Video Stream, version ") + getVersion();
	//There has to be some option other than silent failure and dialog box, but I haven't found it yet.
	//	_control87(MCW_EM, MCW_EM);  //Turn off FPU generated floating point exceptions. Threads still fail however.
	_control87( 0x1372, 0x137F ); //turns on dialog exceptions, but not in TThread. Exceptions in TThread cause the thread to die.


	pBmpRec=new Graphics::TBitmap;
	pBmpRec-> LoadFromFile("Rec.bmp");
	pBmpRecGr=new Graphics::TBitmap;
	pBmpRecGr-> LoadFromFile("Rec-gr.bmp");
	pBmpPau=new Graphics::TBitmap;
	pBmpPau->LoadFromFile("Pau.bmp");
	pBmpPauGr=new Graphics::TBitmap;
	pBmpPauGr->LoadFromFile("Pau-gr.bmp");

	//set default output folder to c:\Users\currentUser\Desktop\capture
 //	char pathC[MAX_PATH];
 //	SHGetSpecialFolderPath(NULL, pathC, CSIDL_DESKTOP, 1);
 //	edOutput->Text = UnicodeString(pathC) + "\\capture";

	frameThread = NULL;
	frameThread1 = NULL;
	frameThread2 = NULL;
	frameThread3 = NULL;
	hMutex = CreateMutex(0,false,0);
	hMutex1 = CreateMutex(0,false,0);
	hMutex2 = CreateMutex(0,false,0);
	hMutex3 = CreateMutex(0,false,0);
	BitBtnStop->Enabled = false;
	FrameDivisorEditChange(this);
	SpatialDivisorEditChange(this);



	allegro_init();
	set_gdi_color_format();
	set_color_depth(CDEPTH);

	nFrames=0;
	SetToVideoMode();

	   // let's refresh the controls according to the TVideoGrabber's states
   AssignListToComboBox (cbVideoInputDevice, CaptureWorkerForm->VideoGrabber->VideoDevices, CaptureWorkerForm->VideoGrabber->VideoDevice);
   AssignListToComboBox (cbVideoInputDevice1, CaptureWorkerForm1->VideoGrabber->VideoDevices, CaptureWorkerForm1->VideoGrabber->VideoDevice);
   AssignListToComboBox (cbVideoInputDevice2, CaptureWorkerForm2->VideoGrabber->VideoDevices, CaptureWorkerForm2->VideoGrabber->VideoDevice);
   AssignListToComboBox (cbVideoInputDevice3, CaptureWorkerForm3->VideoGrabber->VideoDevices, CaptureWorkerForm3->VideoGrabber->VideoDevice);

}
开发者ID:cboulay,项目名称:labstreaminglayer,代码行数:55,代码来源:UMainCapture.cpp

示例11: mLevel

Game::Game()
:mPauseButtonPressed(false),
mLevel(NULL)
{
    allegro_init();
    install_keyboard();
    install_mouse();
	
    set_window_title("Dr. Madness Or: How Fluffy Love Learned to Stop "
                      "Worrying and Love The Bomb");

    int driver = GFX_AUTODETECT_FULLSCREEN;

    set_color_depth(32);
    if (set_gfx_mode(driver, 640, 480, 0, 0) < 0) {
	    set_color_depth(24);
	    if (set_gfx_mode(driver, 640, 480, 0, 0) < 0) {
		    set_color_depth(16);
		    if (set_gfx_mode(driver, 640, 480, 0, 0) < 0) {
			    set_color_depth(15);
			    if (set_gfx_mode(driver, 640, 480, 0, 0) < 0) 
                {
					throw DBSH07_EXCEPTION("Unable to set graphics mode.");
			    }
		    }
	    }
    }

	install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL);

    initTimer();

    mScreenBuffer = create_bitmap(640, 480);
	mBuffer = create_bitmap(320, 240);

    mSplashScreen = new SplashScreen();
	mEnding = new Ending();
	initGui();
	initMusic();

    setState(SPLASHSCREEN);
}
开发者ID:weimingtom,项目名称:db-speedhack07,代码行数:42,代码来源:game.cpp

示例12: main

int
main(void)
{
	BITMAP *bmp;

	allegro_init();
	install_keyboard();
	
	jpgalleg_init();

	set_color_depth(32);
	if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0)) {
		set_color_depth(16);
		if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0)) {
			set_color_depth(15);
			if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0)) {
				allegro_message("Unable to init truecolor 640x480 gfx mode: %s", allegro_error);
				return -1;
			}
		}
	}
	
	clear(screen);
	bmp = load_bitmap("cat.tga", NULL);
	if (!bmp) {
		set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
		allegro_message("Error loading cat.tga\n");
		return -1;
	}
	blit(bmp, screen, 0, 0, 0, 0, bmp->w, bmp->h);
	
	readkey();
	
	if (save_jpg("savedcat.jpg", bmp, NULL)) {
		set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
		allegro_message("Error saving savedcat.jpg (error code %d)\n", jpgalleg_error);
		return -1;
	}
	destroy_bitmap(bmp);
	
	return 0;
}
开发者ID:ChristophGuillermet,项目名称:WHITECAT_opensource,代码行数:42,代码来源:ex3.c

示例13: main

int main( void )
{
    int depth;   /* represents color depth */

    /* first, set up Allegro and the graphics mode */
    allegro_init(); /* initialize Allegro */
    install_keyboard(); /* install the keyboard for Allegro to use */
    install_sound( DIGI_AUTODETECT, MIDI_AUTODETECT, NULL );

    depth = desktop_color_depth();  /* find out what color depth is on our computer */
    if (depth == 0)
        depth = 32;
    set_color_depth( depth ); /* set the color depth to depth used by our computer */

    set_gfx_mode( GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0 ); /* set graphics mode */
    ball = load_bitmap( "ball.bmp", NULL ); /* load the ball bitmap */
    bar = load_bitmap( "bar.bmp", NULL); /* load the bar bitmap */
    buffer = create_bitmap(SCREEN_W, SCREEN_H);/* create buffer */
    boing = load_sample( "boing.wav" ); /* load the sound file */
    pongFont = load_font( "pongfont.pcx", NULL, NULL ); /* load the font */
    ball_x = SCREEN_W / 2; /* give the ball its initial x-coordinate */
    ball_y = SCREEN_H / 2; /* give the ball its initial y-coordinate */
    barL_y = SCREEN_H / 2; /* give left paddle its initial y-coordinate */
    barR_y = SCREEN_H / 2; /* give right paddle its initial y-coordinate */
    scoreL = 0; /* set left player’s score to 0 */
    scoreR = 0; /* set right player’s score to 0 */
    srand( time( NULL ) ); /* seed the random function ... */
    direction = rand() % 4; /* and then make a random initial direction */

    while ( !key[KEY_ESC] )/* until the escape key is pressed ... */
    {
        moveBall(); /* move the ball */
        respondToKeyboard(); /* respond to keyboard input */
        /* now, perform double buffering */
        clear_to_color( buffer, makecol( 255, 255, 255 ) );
        blit( ball, buffer, 0, 0, ball_x, ball_y, ball->w, ball->h );
        blit( bar, buffer, 0, 0, 0, barL_y, bar->w, bar->h );
        blit( bar, buffer, 0, 0, 620, barR_y, bar->w, bar->h );
        /* draw text onto the buffer */
        textprintf_ex( buffer, pongFont, 75, 0, makecol( 0, 0, 0 ),
                       -1, "Left Player Score: %d", scoreL );
        textprintf_ex( buffer, pongFont, 400, 0, makecol( 0, 0, 0 ),
                       -1, "Right Player Score: %d", scoreR );
        blit( buffer, screen, 0, 0, 0, 0, buffer->w, buffer->h );
        clear_bitmap( buffer );
    } /* end while */

    destroy_bitmap( ball ); /* destroy the ball bitmap */
    destroy_bitmap( bar ); /* destroy the bar bitmap */
    destroy_bitmap( buffer ); /* destroy the buffer bitmap */
    destroy_sample( boing ); /* destroy the boing sound file */
    destroy_font( pongFont ); /* destroy the font */
    return 0;
} /* end function main */
开发者ID:rjgodia30,项目名称:bcit-courses,代码行数:54,代码来源:fig15_12.c

示例14: init

    /**
     * Initialises the Allegro application. This function creates the global
     * Gui object that can be populated by various examples.
     */
    void init()
    {
        // We simply initialise Allegro as we would do with any Allegro application.
        allegro_init();

        int bpp = desktop_color_depth();
        if (bpp == 0)
        {
            bpp = 16;
        }

        set_color_depth(bpp);

        if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0))
        {
            if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0))
            {
                throw FCN_EXCEPTION("Unable to set graphics mode");
            }
        }

        screenBuffer = create_bitmap(SCREEN_W, SCREEN_H);

        if (screenBuffer == NULL)
        {
            throw FCN_EXCEPTION("Unable to create a screen buffer");
        }

        install_keyboard();
        install_mouse();
        install_timer();

        // Now it's time to initialise the Guichan Allegro back end.

        imageLoader = new fcn::AllegroImageLoader();
        // The ImageLoader Guichan should use needs to be passed to the Image object
        // using a static function.
        fcn::Image::setImageLoader(imageLoader);
        graphics = new fcn::AllegroGraphics();
        // Set the target for the graphics object to be the doublebuffer
        // for the screen. Drawing to the screen directly is not a good
        // idea, as it will produce flicker, unless you use page flipping.
        graphics->setTarget(screenBuffer);
        input = new fcn::AllegroInput();

        // Now we create the Gui object to be used with this Allegro application.
        globals::gui = new fcn::Gui();
        // The Gui object needs a Graphics to be able to draw itself and an Input
        // object to be able to check for user input. In this case we provide the
        // Gui object with Allegro implementations of these objects hence making Guichan
        // able to utilise Allegro.
        globals::gui->setGraphics(graphics);
        globals::gui->setInput(input);
    }
开发者ID:Beliaar,项目名称:fifechan,代码行数:58,代码来源:allegro.hpp

示例15: S9xTextMode

void S9xTextMode ()
{
    if (!in_text_mode)
    {
	set_color_depth (8);
	remove_keyboard ();
	remove_mouse ();
	set_gfx_mode (GFX_TEXT, 0, 0, 0, 0);
	in_text_mode = TRUE;
    }
}
开发者ID:alesegdia,项目名称:snes-sdk,代码行数:11,代码来源:msdos.cpp


注:本文中的set_color_depth函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。