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


C++ SDL_SetWindowTitle函数代码示例

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


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

示例1: SDL_WM_SetCaption

void
SDL_WM_SetCaption(const char *title, const char *icon)
{
    if (wm_title) {
        SDL_free(wm_title);
    }
    if (title) {
        wm_title = SDL_strdup(title);
    } else {
        wm_title = NULL;
    }
    SDL_SetWindowTitle(SDL_VideoWindow, wm_title);
}
开发者ID:Blitzoreo,项目名称:pcsx2-online,代码行数:13,代码来源:SDL_compat.c

示例2: window_getFps

int window_getFps(void) {
	static int second;
	if (second != time(NULL)) {
		fpsNumber = fpsCounter;
		fpsCounter = 0;
		char *title = malloc(strlen(mainTitle)+20);
		sprintf(title, "%s | %d FPS", mainTitle, fpsNumber);
		SDL_SetWindowTitle(windowMain, title);
		free(title);
		second = time(NULL);
	}
	return fpsNumber;
}
开发者ID:Firew0lf,项目名称:Engine,代码行数:13,代码来源:window.c

示例3: SDL_LockTexture

//-----------------------------------------------------------------------------
void AdScreen::Present(void) {
    int pitch;
    void* pixels;

    SDL_LockTexture(s_pTexture, NULL, &pixels, &pitch);

    SDL_ConvertPixels(
        s_pScreen->w,
        s_pScreen->h,
        s_pScreen->format->format,
        s_pScreen->pixels,
        s_pScreen->pitch,
        SDL_PIXELFORMAT_RGBA8888,
        pixels, pitch
    );

    SDL_UnlockTexture(s_pTexture);

    SDL_RenderCopy(GetRenderer(), s_pTexture, NULL, NULL);
    SDL_RenderPresent(GetRenderer());

    s_iFrames++;

    s_uiCurrentCount = SDL_GetPerformanceCounter();
    s_uiDiffCount    = (s_uiCurrentCount-s_uiLastCount);
    s_uiCountFreq    = SDL_GetPerformanceFrequency();

    s_fElapsedTime = ((float) s_uiDiffCount/(float) s_uiCountFreq);

    if((1.0f/60.0f)-s_fElapsedTime > 0) {
        // NOTE: without this there seems to be a more consistent framerate
        // but on older computers sometimes the vsync doesn't work right
        //SDL_Delay((uint32_t) (1000.0f*((1.0f/60.0f)-s_fElapsedTime)));

        s_fTotTime += 1.0f/60.0f;
    } else {
        s_fTotTime += s_fElapsedTime;
    }

    s_uiLastCount = s_uiCurrentCount;

    if(s_fTotTime >= 1.0f) {
        char strTitle[0x20] = "";
        sprintf(strTitle, "%s, FPS: %d", WINDOW_TITLE, s_iFrames);

        SDL_SetWindowTitle(GetWindow(), strTitle);

        s_fTotTime  = 0;
        s_iFrames = 0;
    }
}
开发者ID:srmeier,项目名称:Avocado,代码行数:52,代码来源:AdScreen.cpp

示例4: strdup

void SDLHardwareRenderDevice::updateTitleBar() {
	if (title) free(title);
	title = NULL;
	if (titlebar_icon) SDL_FreeSurface(titlebar_icon);
	titlebar_icon = NULL;

	if (!window) return;

	title = strdup(msg->get(WINDOW_TITLE).c_str());
	titlebar_icon = IMG_Load(mods->locate("images/logo/icon.png").c_str());

	if (title) SDL_SetWindowTitle(window, title);
	if (titlebar_icon) SDL_SetWindowIcon(window, titlebar_icon);
}
开发者ID:cllpyl,项目名称:flare-engine,代码行数:14,代码来源:SDLHardwareRenderDevice.cpp

示例5: ex3

void ex3() {
    SDL_SetWindowTitle( SDL_GL_GetCurrentWindow(), "ex3" );
    SDL_Rect sprite1;
    SDL_Rect sprite2;

    sprite1.x = WIN_W/2;
    sprite1.y = WIN_H/2;
    sprite2.x = sprite1.x + 10;
    sprite2.y = sprite1.y + 10;

    SDL_BlitSurface( Background, NULL, backBuffer, NULL );
    SDL_BlitSurface( SpriteImage, NULL, backBuffer, &sprite1 );
    SDL_BlitSurface( SpriteImage, NULL, backBuffer, &sprite2 );
}
开发者ID:aranasaurus,项目名称:bamgp-exercises,代码行数:14,代码来源:main.cpp

示例6: sprintf

void Game::UpdateTitleAsFps(float w8){

    if (nextUpdate <= SDL_GetTicks()){
        char Buff[100];
        FPS = frames;
        sprintf(Buff,"%s (FPS: %f) = %f  = %f",title,frames*1000.0/(1000.0-(SDL_GetTicks()-olt)),GetDeltaTime(),w8);
        SDL_SetWindowTitle(window, Buff);
        olt = SDL_GetTicks()+1000;
        nextUpdate = olt;
        updateFPS=true;
        frames = 0;
    }else{
        updateFPS= false;
    }
}
开发者ID:mockthebear,项目名称:bearshader,代码行数:15,代码来源:gamebase.cpp

示例7: sdl2_gfx_frame

static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width,
      unsigned height, uint64_t frame_count,
      unsigned pitch, const char *msg, video_frame_info_t *video_info)
{
   sdl2_video_t *vid = (sdl2_video_t*)data;
   char title[128];

   if (vid->should_resize)
      sdl_refresh_viewport(vid);

   if (frame && video_info->libretro_running)
   {
      static struct retro_perf_counter sdl_copy_frame = {0};

      SDL_RenderClear(vid->renderer);
      sdl_refresh_input_size(vid, false, vid->video.rgb32, width, height, pitch);

      performance_counter_init(sdl_copy_frame, "sdl_copy_frame");
      performance_counter_start_plus(video_info->is_perfcnt_enable, sdl_copy_frame);

      SDL_UpdateTexture(vid->frame.tex, NULL, frame, pitch);

      performance_counter_stop_plus(video_info->is_perfcnt_enable, sdl_copy_frame);
   }

   SDL_RenderCopyEx(vid->renderer, vid->frame.tex, NULL, NULL, vid->rotation, NULL, SDL_FLIP_NONE);

#ifdef HAVE_MENU
   menu_driver_frame(video_info);
#endif

   if (vid->menu.active)
      SDL_RenderCopy(vid->renderer, vid->menu.tex, NULL, NULL);

   if (msg)
      sdl2_render_msg(vid, msg);

   SDL_RenderPresent(vid->renderer);

   title[0] = '\0';

   video_driver_get_window_title(title, sizeof(title));

   if (title[0])
      SDL_SetWindowTitle(vid->window, title);

   return true;
}
开发者ID:dankcushions,项目名称:RetroArch,代码行数:48,代码来源:sdl2_gfx.c

示例8: CaptionError

//Show the error in the caption
//With the message and the code
void Error::CaptionError(std::string message, int code,SDL_Window* win)
{
#ifdef ERROR
	std::string str=message;
	if (code!=0)//Add code if non-zero
	{
		str+="   ";
		std::stringstream integer;
		if (code<0){integer<<"-";code=-code;}  
		integer<<code;
		str+=integer.str();
	}
	if (win!=0)
	{SDL_SetWindowTitle(win,message.c_str());};
#endif
}; 
开发者ID:ZealousV,项目名称:ART,代码行数:18,代码来源:SDLFramework.cpp

示例9: progressive_render

uint32_t progressive_render(int32_t quality, int64_t bytes_read) {
    while (drawing) {SDL_Delay(50);}
    drawing = 1;
    printf("%lli bytes read, rendering at quality=%.2f%%\n",(unsigned long long int) bytes_read, 0.01*quality);
    animation = (flif_decoder_num_images(d) > 1);
    FLIF_IMAGE* image = flif_decoder_get_image(d, 0);
    if (!image) { printf("Error: No decoded image found\n"); return 1; }
    uint32_t w = flif_image_get_width(image);
    uint32_t h = flif_image_get_height(image);
    if (!window) { printf("Error: Could not create window\n"); return 2; }
    SDL_SetWindowSize(window,w,h);
    char title[100];
    sprintf(title,"%ix%i FLIF image [read %lli bytes, quality=%.2f%%]",w,h,(unsigned long long int) bytes_read, 0.01*quality);
    SDL_SetWindowTitle(window,title);
    for (int f = 0; f< flif_decoder_num_images(d); f++) {
        FLIF_IMAGE* image = flif_decoder_get_image(d, f);
        if (!image) { printf("Error: No decoded image found\n"); return 1; }
        uint32_t w = flif_image_get_width(image);
        uint32_t h = flif_image_get_height(image);
        frame_delay[f] = flif_image_get_frame_delay(image);
        if (!surf[f]) surf[f] = SDL_CreateRGBSurface(0,w,h,32,0x000000FF,0x0000FF00,0x00FF0000,0xFF000000);
        if (!surf[f]) { printf("Error: Could not create surface\n"); return 1; }
        if (!tmpsurf) tmpsurf = SDL_CreateRGBSurface(0,w,h,32,0x000000FF,0x0000FF00,0x00FF0000,0xFF000000);
        if (!tmpsurf) { printf("Error: Could not create surface\n"); return 1; }
        char* pp =(char*) tmpsurf->pixels;
        for (uint32_t r=0; r<h; r++) {
            flif_image_read_row_RGBA8(image, r, pp, w * sizeof(RGBA));
            pp += tmpsurf->pitch;
        }
        if (flif_image_get_nb_channels(image) > 3) {
          if (!bgsurf) {
            bgsurf = SDL_CreateRGBSurface(0,w,h,32,0x000000FF,0x0000FF00,0x00FF0000,0xFF000000);
            // Draw checkerboard background for image with alpha channel
            SDL_Rect sq; sq.w=20; sq.h=20;
            for (sq.y=0; sq.y<h; sq.y+=sq.h) for (sq.x=0; sq.x<w; sq.x+=sq.w)
              SDL_FillRect(bgsurf,&sq,((sq.y/sq.h + sq.x/sq.w)&1 ? 0xFF606060 : 0xFFA0A0A0));
          }
          SDL_BlitSurface(bgsurf,NULL,surf[f],NULL);
        }
        SDL_BlitSurface(tmpsurf,NULL,surf[f],NULL);
    }
    drawing = 0;
    draw_image();
//    SDL_Delay(1000);
    if (quit) return 0; // stop decoding
    return quality + 1000; // call me back when you have at least 10.00% better quality
}
开发者ID:mkadunc,项目名称:FLIF,代码行数:47,代码来源:viewflif.c

示例10: memset

struct renderstate *renderstateInit(const char *title, int width, int height)
{

	// int i;
	struct renderstate *render =
	    (struct renderstate *)malloc(sizeof(struct renderstate));

	memset(render, 0, sizeof(struct renderstate));

	if (SDL_Init(SDL_INIT_EVERYTHING)) {
		return 0;
	}

	if (TTF_Init() == -1) {
		return 0;
	}

	if (SDL_CreateWindowAndRenderer
	    (width, height,
	     SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN,
	     &render->window, &render->renderer) != 0) {
		return 0;
	}

	SDL_SetWindowTitle(render->window, title);
	SDL_GL_SetSwapInterval(1);

	render->font_small = TTF_OpenFont("font.ttf", 8);
	render->font_large = TTF_OpenFont("font.ttf", 12);
	if (render->font_small == 0 || render->font_large == 0) {
		return 0;
	}

	render->points =
	    (SDL_Point *) malloc(sizeof(SDL_Point) * width * height);
	render->scale = 1.0f;
	render->xPos = 0;
	render->yPos = 0;
	render->width = width;
	render->height = height;
	render->frames = 0;
	render->fps = 0;
	render->last_frame = SDL_GetTicks();

	return render;
}
开发者ID:AndrewBurian,项目名称:ParticlePhysics,代码行数:46,代码来源:render.c

示例11: SDL_SetWindowTitle

	void graphics_system::end(float delta_time) noexcept {
		const auto smooth_factor = 0.1f;
		static auto delta_time_smoothed = 0.f;
		static auto time_since_last_fps_output = 0.f;

		delta_time_smoothed = ( 1.0f - smooth_factor) * delta_time_smoothed + smooth_factor * delta_time;

		time_since_last_fps_output += delta_time;
		if(time_since_last_fps_output >= 1.0f){
			time_since_last_fps_output = 0.0f;
			std::ostringstream osstr;
			osstr << name_ << " (" << (int((1.0f / delta_time_smoothed) * 10.0f) / 10.0f) << " FPS, ";
			osstr << (int(delta_time_smoothed * 10000.0f) / 10.0f) << " ms / frame)";
			SDL_SetWindowTitle(window_.get(), osstr.str().c_str());
		}
		SDL_GL_SwapWindow(window_.get());
	}
开发者ID:Berling,项目名称:behaviour_trees,代码行数:17,代码来源:graphics_system.cpp

示例12: swap_buffers

 void swap_buffers(std::shared_ptr<TGAImage> &pImage)
 {
     std::swap(pImage, m_pImage);
     if (!m_pImage)
     {
         init_framebuffer();
     }
     else
     {
         ++m_framesCount;
         int averageFrameTime = (SDL_GetTicks() - m_startTicks) / m_framesCount;
         char title[1024];
         sprintf(title, "Rendered %d frames, average time %d ms", m_framesCount, averageFrameTime);
         SDL_SetWindowTitle(m_pWindow, title);
         SDL_UpdateWindowSurface(m_pWindow);
     }
 }
开发者ID:RoadToExclusivity,项目名称:PP,代码行数:17,代码来源:sdlwindow.cpp

示例13: lock

bool
window::set_title(const std::string &str)
{
  {
    std::lock_guard<std::mutex> lock(m_lock);
    SDL_SetWindowTitle(m_sdl_window, str.c_str());
  }
  
  if(get_title() != str)
  {
    assert(false);
    sdl::log_debug_error_check();
    return false;
  }
	
	return true;
}
开发者ID:PhilCK,项目名称:sdl-wrapper,代码行数:17,代码来源:window.cpp

示例14: ex2

void ex2() {
    SDL_SetWindowTitle( SDL_GL_GetCurrentWindow(), "ex2" );
    SDL_Color c;
    c.r = 40;
    c.g = 225;
    c.b = 40;
    c.a = 255;

    SDL_Rect rects[10];

    for ( int i = 0; i < 10; i++ ) {
        SDL_Rect r;
        r.x = rand()%WIN_W;
        r.y = rand()%WIN_H;
        r.w = 50;
        r.h = 100;

        bool colliding = false;
        for ( int j = i-1; j >= 0; j-- ) {
            SDL_Rect r2 = rects[j];
            int cx1 = r.x + (r.w/2);
            int cx2 = r2.x + (r2.w/2);
            int cy1 = r.y + (r.y/2);
            int cy2 = r2.y + (r2.y/2);

            int xDist = abs( cx1 - cx2 );
            int yDist = abs( cy1 - cy2 );
            int touchDistX = (r.w/2) + (r2.w/2);
            int touchDistY = (r.h/2) + (r2.h/2);

            if ( xDist <= touchDistX || yDist <= touchDistY ) {
                colliding = true;
                break;
            }
        }

        if ( colliding ) {
            i--;
        } else {
            rects[i] = r;
        }
    }

    SDL_FillRects( backBuffer, rects, 10, SDL_MapRGB( backBuffer->format, c.r, c.g, c.b ) );
}
开发者ID:aranasaurus,项目名称:bamgp-exercises,代码行数:45,代码来源:main.cpp

示例15: sdl2_gfx_frame

static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width,
                           unsigned height, unsigned pitch, const char *msg)
{
   char buf[128];
   sdl2_video_t *vid = (sdl2_video_t*)data;
   runloop_t *runloop = rarch_main_get_ptr();
   driver_t *driver = driver_get_ptr();

   if (vid->should_resize)
      sdl_refresh_viewport(vid);

   if (frame)
   {
      sdl_refresh_input_size(vid, false, vid->video.rgb32, width, height, pitch);

      RARCH_PERFORMANCE_INIT(sdl_copy_frame);
      RARCH_PERFORMANCE_START(sdl_copy_frame);

      SDL_UpdateTexture(vid->frame.tex, NULL, frame, pitch);

      RARCH_PERFORMANCE_STOP(sdl_copy_frame);
   }

   SDL_RenderCopyEx(vid->renderer, vid->frame.tex, NULL, NULL, vid->rotation, NULL, SDL_FLIP_NONE);

#ifdef HAVE_MENU
   if (runloop->is_menu)
      menu_driver_frame();
#endif

   if (vid->menu.active)
      SDL_RenderCopy(vid->renderer, vid->menu.tex, NULL, NULL);

   if (msg)
      sdl2_render_msg(vid, msg);

   SDL_RenderPresent(vid->renderer);

   if (video_monitor_get_fps(buf, sizeof(buf), NULL, 0))
      SDL_SetWindowTitle(vid->window, buf);

   vid->frame_count++;

   return true;
}
开发者ID:AirBrowse,项目名称:RetroArch,代码行数:45,代码来源:sdl2_gfx.c


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