本文整理汇总了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");
}
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
}
}
示例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;
}
示例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;
}
}
}
示例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;
}
}
}
示例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;
}