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


C++ SDL_UpdateWindowSurface函数代码示例

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


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

示例1: GetStreamStrcInfo

void CLS_DlgStreamPusher::FillDisplayRect()
{
	struct_stream_info* streamInfo = GetStreamStrcInfo();
	if (NULL == streamInfo){
		TRACE("NULL == streamInfo");
		return;
	}

	streamInfo->m_screen_surface = SDL_GetWindowSurface(streamInfo->m_show_screen);
	if (NULL == streamInfo->m_screen_surface){
		TRACE("NULL == streamInfo->m_screen_surface");
		return;
	}

	//背景色
	int bgcolor = SDL_MapRGB(streamInfo->m_screen_surface->format, 0x00, 0x00, 0x00);
	fill_rec(streamInfo->m_screen_surface, m_pStreamInfo->m_xleft, m_pStreamInfo->m_ytop, m_pStreamInfo->m_width, m_pStreamInfo->m_height,bgcolor);

	if (SDL_UpdateWindowSurface(streamInfo->m_show_screen) != 0){
		TRACE("SDL_UpdateWindowSurface ERR");
	}
}
开发者ID:KingYoung87,项目名称:video_audio_pro,代码行数:22,代码来源:CLS_DlgStreamPusher.cpp

示例2: lesson06

void lesson06() {
    //Start up SDL and create window
    if (!init_with_image()) {
        printf("Failed to initialize!\n");
    }
    else {
        //Load media
        if (!loadMediaLocal()) {
            printf("Failed to load media!\n");
        }
        else {
            //Main loop flag
            bool quit = false;

            //Event handler
            SDL_Event e;

            //While application is running
            while (!quit) {
                //Handle events on queue
                while (SDL_PollEvent(&e) != 0) {
                    //User requests quit
                    if (e.type == SDL_QUIT) {
                        quit = true;
                    }
                }

                //Apply the PNG image
                SDL_BlitSurface(gPNGSurface, NULL, gScreenSurface, NULL);

                //Update the surface
                SDL_UpdateWindowSurface(gWindow);
            }
        }
    }

    //Free resources and close SDL
    close();
}
开发者ID:AntonioCS,项目名称:LazyFooSDLv2,代码行数:39,代码来源:lesson06.c

示例3: main

int main(int argc, char* argv[]) {

	// SDL init
	SDL_Window *mainWindow;

	SDL_Init(SDL_INIT_VIDEO);
	mainWindow = SDL_CreateWindow("Tests OpenGL", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN);
	SDL_Surface* window_s = SDL_GetWindowSurface(mainWindow);
	int screen_bg_color = Graphic_base::Color::format32_rgb(100, 100, 100);
	Graphic_base::Surface windows_surf(window_s->pixels, window_s->w, window_s->h, screen_bg_color);

	// Initializing global variables
	init();

	// Loop
	int quit = 0;
	SDL_Event event;
	while(!quit) {
		// Traitement des évènements
		if(SDL_WaitEvent(&event))
			if(process_event(&event, windows_surf))
				quit = 1;
		while(SDL_PollEvent(&event))
			if(process_event(&event, windows_surf))
				quit = 1;

		draw_screen(windows_surf);

        SDL_UpdateWindowSurface(mainWindow);
		SDL_Delay(10);
	}

	delete f;
	printf("Freeing done.\n");

	SDL_DestroyWindow(mainWindow);
	SDL_Quit();
	return 0;
}
开发者ID:Stratus51,项目名称:Math-function-template,代码行数:39,代码来源:main.cpp

示例4: loop

void loop(){
	iteration++;
	f=(iteration%200)/200.0;
	// f1=
	for(int x=1;x<SCREEN_WIDTH-1;x++){
		for(int y=1;y<SCREEN_HEIGHT-1;y++){
			uint c=calc(x,y);
			// if(c!=0)
			dot(x,y,c);
		}
	}
	for(int x=SCREEN_WIDTH-1;x>0;x--){
		for(int y=SCREEN_HEIGHT-1;y>0;y--){
			uint c=calc(x,y);
			// if(c!=0)
			dot(x,y,c);
		}
	}
	
	SDL_PumpEvents();
	if (state[SDL_SCANCODE_RETURN]||state[SDL_SCANCODE_ESCAPE])exit(0);
	
	// SDL_Event test_event;
	// SDL_KeyboardEvent key;
	// while(SDL_PollEvent(&test_event)) {
	// 	switch(test_event.type) {
	// 		case SDL_KEYDOWN:
	// 		key=test_event;
	// 		if(key.keysym.sym==SDLK_ESCAPE)exit(0);
	// 		// case SDL_MOUSEMOTION:
	// 		break;
	// 	    default:
	// 		break;
	// 	}
	// }
	SDL_UpdateWindowSurface(window);
	// SDL_Delay(10);	
}
开发者ID:pannous,项目名称:game-of-colors,代码行数:38,代码来源:game_of_colors.c

示例5: main

int main( int argc, char* args[] )
{
    if( !init() )
    {
        printf( "Failed to initialize!\n" );
    }
    else
    {
        if( !loadMedia() )
        {
            printf( "Failed to load media!\n" );
        }
        else
        {
            SDL_BlitSurface( gHelloWorld, NULL, gScreenSurface, NULL );
            SDL_UpdateWindowSurface(gWindow);
            SDL_Delay(2000);
        }
    }
    close();

    return 0;
}
开发者ID:Finalgamer14,项目名称:SDL-BMP-load,代码行数:23,代码来源:main.cpp

示例6: renderAll

void renderAll(Game& game) {
    SDL_RenderClear(game.renderer);

    if (game.bonusItem.alive)
        renderItem(game.renderer, game.bonusItem);

    for (unsigned int i = 0; i < game.daMissiles.size(); i++)
        renderMissile(game.renderer, game.daMissiles[i]);
    for (unsigned int i = 0; i < game.daEnemies.size(); i++)
        renderEnemy(game.renderer, game.daEnemies[i]);
    for (unsigned int i = 0; i < game.daBlasts.size(); i++)
        renderBlast(game.renderer, game.daBlasts[i]);

    if (game.daBox.alive)
        renderBox(game.renderer, game.daBox);

    for (unsigned int i = 0; i < game.lives.size(); i++)
        renderBlast(game.renderer, game.lives[i]);

    renderScore(game);

    SDL_UpdateWindowSurface(game.window);
}
开发者ID:JabberSnatch,项目名称:daBox,代码行数:23,代码来源:GameVariables.cpp

示例7: lesson02

void lesson02() {
    //Start up SDL and create window
    if (!init()) {
        printf("Failed to initialize!\n");
    }
    else {
        //Load media
        if (!loadMedia(resources_path("images/hello_world.bmp"))) {
            printf("Failed to load media!\n");
        }
        else {
            //Apply the image
            SDL_BlitSurface(gXOut, NULL, gScreenSurface, NULL);
            //Update the surface
            SDL_UpdateWindowSurface(gWindow);
            //Wait two seconds
            SDL_Delay(2000);
        }
    }

    //Free resources and close SDL
    close();
}
开发者ID:AntonioCS,项目名称:LazyFooSDLv2,代码行数:23,代码来源:lesson02.c

示例8: main

int main() {
    if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_EVENTS ) < 0 ) {
        printf( "Failed to initialize SDL: %s\n", SDL_GetError() );
        return 0;
    }

    SDL_Window* window = SDL_CreateWindow( "Let's Rock!", NULL, NULL, WIN_W, WIN_H, SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_SHOWN );

    if ( window == NULL ) {
        printf( "Failed to create SDL Window: %s\n", SDL_GetError() );
        return 0;
    }

    backBuffer = SDL_GetWindowSurface( window );
    srand( time( NULL ) );

    if ( !loadFiles() ) {
        printf( "Failed to load files!\n" );
        freeFiles();
        SDL_Quit();
        return 0;
    }

    /*
    ex1();
    ex2();
    */
    ex3();
    while ( runEventLoop() ) {
        SDL_UpdateWindowSurface( window );
        SDL_Delay( 20 );
    }

    SDL_DestroyWindow( window );
    SDL_Quit();
    return 0;
}
开发者ID:aranasaurus,项目名称:bamgp-exercises,代码行数:37,代码来源:main.cpp

示例9: main

int main()
{
    if(!init())
    {
	std::cout << "Failed to initialize!" << std::endl;
    }
    else
    {
	if(!loadMedia())
	{
	    std::cout << "Failed to load media!" << std::endl;
	}
	else
	{
	    bool quit = false;
	    SDL_Event event;
	    while(!quit)
	    {
		while(SDL_PollEvent(&event) != 0)
		{
		    if(event.type = SDL_QUIT)
		    {
		        quit = true;
		    }
		}

		SDL_BlitSurface(hello_world, nullptr, screen_surface, nullptr);

		SDL_UpdateWindowSurface(window);

		SDL_Delay(2000);
	    }
	}
    }
    close();
    return 0;
}
开发者ID:robotxet,项目名称:cppbits,代码行数:37,代码来源:main.cpp

示例10: printf

Game::Game()
{
	this->mainWindow = NULL;
	this->mainSurface = NULL;
	if (SDL_Init(SDL_INIT_VIDEO) < 0) {
		printf("SDL could not initialize! SDL_Error: %s\n", SDL_GetError());
	}
	this->mainWindow = SDL_CreateWindow(
		"Alone",
		SDL_WINDOWPOS_UNDEFINED,
		SDL_WINDOWPOS_UNDEFINED,
		1280,
		720,
		SDL_WINDOW_SHOWN
	);

	if (this->mainWindow == NULL) {
		printf("Window could not be reated SDL_Error: %s\n", SDL_GetError());
		this->crashGame();
	}

	// set to fullscreen windowed
	//SDL_SetWindowFullscreen(this->mainWindow, 0);
	this->mainSurface = SDL_GetWindowSurface(this->mainWindow);
	
	inputManager *ctrl = new inputManager();
	this->inputController = ctrl;

	//Get window surface
	SDL_Surface *screenSurface = SDL_GetWindowSurface(this->mainWindow);

	//Fill the surface white
	SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));

	//Update the surface
	SDL_UpdateWindowSurface(this->mainWindow);
}
开发者ID:landongn,项目名称:Alone,代码行数:37,代码来源:game.cpp

示例11: SDL_BlitSurface

void Controller::intro()
{
	bool endIntro = false;

	LTimer timer; // a limit timer

	if (loadGlobal.getgQuit() == false)
	{
		SDL_BlitSurface(loadGlobal.getIntroBG(), NULL, loadGlobal.getgScreenSurface(), NULL);
		SDL_UpdateWindowSurface(loadGlobal.getgWindow());
	}

	timer.start_timer();

	while ((endIntro == false) && (loadGlobal.getgQuit() == false))
	{
		if (SDL_PollEvent(&loadGlobal.getEvent()))
		{
			if (loadGlobal.getEvent().key.keysym.sym == SDLK_ESCAPE)
			{
				loadGlobal.setgQuit(true);
			}
			endIntro = true;
		}
		if (loadGlobal.getEvent().type == SDL_QUIT)
		{
			loadGlobal.setgQuit(true);
		}
		//if time is up
		if (timer.get_ticks() > 2000)
		{
			//end the intro
			endIntro = true;
		}
	}
}
开发者ID:Enph,项目名称:ToN_SDL,代码行数:36,代码来源:controller.cpp

示例12: main

int main() {
  bool l_quit = false;
  SDL_Event l_event;

  if(!init()){
    printf("Failed to initialize!\n");
  } else {
    if(!loadMedia()) {
      printf("Failed to load media!\n");
    } else {
      while(!l_quit) {
	while(SDL_PollEvent(&l_event) != 0) {
	  if(l_event.type == SDL_QUIT) {
	    l_quit = true;
	  }
	}
	SDL_BlitSurface(g_pngSurface, NULL, g_screenSurface, NULL);
	SDL_UpdateWindowSurface(g_window);
      }
    }
  }
  close();
  return 0;
}
开发者ID:wedemalm,项目名称:lazyfoo,代码行数:24,代码来源:SDL_image.cpp

示例13: KTP_Credit

void KTP_Credit()
{
	printf("KTP_Credit\n");

	SDL_Surface * pScreenSurface = SDL_GetWindowSurface(g_Window);
	SDL_Surface * pBGImage;

	pBGImage = IMG_Load("./Image/BackgroundCredit.png");
	SDL_BlitSurface(pBGImage, NULL, pScreenSurface, NULL);

	while (1)
	{
		SDL_Event iCredit;
		SDL_PollEvent(&iCredit);
		SDL_UpdateWindowSurface(g_Window);
		if (iCredit.type == SDL_KEYDOWN)
		{
			puts("Credit_returned!");
			SDL_FreeSurface(pBGImage);
			SDL_FreeSurface(pScreenSurface);
			return;
		}
	}
}
开发者ID:SilverJun,项目名称:Keep_The_Phone,代码行数:24,代码来源:KTP_Credit.cpp

示例14: window_update

void window_update() {
	SDL_BlitScaled(window.screen, NULL, SDL_GetWindowSurface(window.id), NULL);

	SDL_UpdateWindowSurface(window.id);

	SDL_Event event;
	while (SDL_PollEvent(&event)) {
		switch (event.type) {
			case SDL_KEYDOWN:
				joypad_keydown(event.key.keysym.sym);
				break;
			case SDL_KEYUP:
				joypad_keyup(event.key.keysym.sym);
				break;
			case  SDL_QUIT:
				//exit
				emulator_stop();
				break;
			case SDL_CONTROLLERDEVICEADDED:
				SDL_GameControllerOpen(event.cdevice.which);
				break;
			case SDL_CONTROLLERDEVICEREMOVED:
				break;
			case SDL_CONTROLLERDEVICEREMAPPED:
				break;
			case SDL_CONTROLLERBUTTONDOWN:
				joypad_buttondown(event.cbutton.button);
				break;
			case SDL_CONTROLLERBUTTONUP:
				joypad_buttonup(event.cbutton.button);
				break;
		default:
			break;
		}
	}
}
开发者ID:aHeraud,项目名称:Gameboy-Emulator,代码行数:36,代码来源:window.c

示例15: main

int main(int argc, char* argv[])
{
	int result = 0;

	// Perform Initialisation
	if (!Init())
	{
		std::cout << "Error: Initialisation failed" << std::endl;
		result = 1;
	}
	else
	{
		// Load any media
		if (!LoadData())
		{
			std::cout << "Error: Media loading failed" << std::endl;
			result = 1;
		}
		else
		{
			// Blit the image to the screen surface
			SDL_BlitSurface(gImage, NULL, gScreen, NULL);

			// Update the window surface
			SDL_UpdateWindowSurface(gWindow);

			// Delay so that we can see the image appear
			SDL_Delay(2000);
		}
	}

	// Deinit and cleanup
	CleanUp();

	return result;
}
开发者ID:Zammalad,项目名称:SDL_Tutorials,代码行数:36,代码来源:main.cpp


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