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


C++ SDL_CreateThread函数代码示例

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


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

示例1: SDL_CreateThread

void MoSyncThread::start(int (SDLCALL * func)(void*), void* arg) {
	mThread = SDL_CreateThread(func, arg);
	_ASSERT(mThread);
}
开发者ID:AliSayed,项目名称:MoSync,代码行数:4,代码来源:Thread.cpp

示例2: video_thr


//.........这里部分代码省略.........
		if (iRet < 0) {
			TRACE("Could not open output URL '%s'", pThis->m_cstrPushAddr);
			goto END;
		}
	}

	iRet = avformat_write_header(pRtmpFmtCtx, NULL);
	if (iRet < 0) {
		TRACE("Error occurred when opening output URL\n");
		goto END;
	}

	start_time = av_gettime();

	//获取视频的宽与高
	iVideo_Height = pCodecContext->height;//strct_streaminfo->m_height;//
	iVideo_Width = pCodecContext->width;//strct_streaminfo->m_width;//
	TRACE("video_thr--video_height[%d],video_width[%d]", iVideo_Height
	, iVideo_Width);

	strct_streaminfo->m_pVideoPacket = (AVPacket*)av_malloc(sizeof(AVPacket));

	strct_streaminfo->m_pVideoFrame = av_frame_alloc();
	strct_streaminfo->m_pVideoFrameYUV = av_frame_alloc();
	strct_streaminfo->m_pVideoOutBuffer = (uint8_t *)av_malloc(avpicture_get_size(AV_PIX_FMT_YUV420P, iVideo_Width, iVideo_Height));
	avpicture_fill((AVPicture *)strct_streaminfo->m_pVideoFrameYUV, strct_streaminfo->m_pVideoOutBuffer, AV_PIX_FMT_YUV420P, iVideo_Width, iVideo_Height);
	strct_streaminfo->m_video_sws_ctx = sws_getContext(iVideo_Width, iVideo_Height, pCodecContext->pix_fmt,
		iVideo_Width, iVideo_Height, AV_PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL);
	if (NULL == strct_streaminfo->m_video_sws_ctx){
		TRACE("NULL == strct_streaminfo->m_video_sws_ctx\n");
		goto END;
	}

	strct_streaminfo->m_video_refresh_tid = SDL_CreateThread(video_refresh_thread, NULL, strct_streaminfo);

	//从摄像头获取数据
	for (;;){
		AVStream *in_stream, *out_stream;
		SDL_WaitEvent(&event);
		if (event.type == FF_VIDEO_REFRESH_EVENT){
			if (av_read_frame(pFmtCtx, strct_streaminfo->m_pVideoPacket) >= 0){
				if (strct_streaminfo->m_pVideoPacket->pts == AV_NOPTS_VALUE){
					//Write PTS  
					AVRational time_base1 = pFmtCtx->streams[iVideoIndex]->time_base;
					//Duration between 2 frames (us)  
					int64_t calc_duration = (double)AV_TIME_BASE / av_q2d(pFmtCtx->streams[iVideoIndex]->r_frame_rate);
					//Parameters  
					strct_streaminfo->m_pVideoPacket->pts = (double)(frame_index*calc_duration) / (double)(av_q2d(time_base1)*AV_TIME_BASE);
					strct_streaminfo->m_pVideoPacket->dts = strct_streaminfo->m_pVideoPacket->pts;
					strct_streaminfo->m_pVideoPacket->duration = (double)calc_duration / (double)(av_q2d(time_base1)*AV_TIME_BASE);
				}

				if (strct_streaminfo->m_pVideoPacket->stream_index == iVideoIndex){

					AVRational time_base = pFmtCtx->streams[iVideoIndex]->time_base;
					AVRational time_base_q = { 1, AV_TIME_BASE };
					int64_t pts_time = av_rescale_q(strct_streaminfo->m_pVideoPacket->dts, time_base, time_base_q);
					int64_t now_time = av_gettime() - start_time;
					if (pts_time > now_time)
						av_usleep(pts_time - now_time);

					in_stream = pFmtCtx->streams[strct_streaminfo->m_pVideoPacket->stream_index];
					out_stream = pRtmpFmtCtx->streams[strct_streaminfo->m_pVideoPacket->stream_index];
					/* copy packet */
					//转换PTS/DTS(Convert PTS/DTS)  
					strct_streaminfo->m_pVideoPacket->pts = av_rescale_q_rnd(strct_streaminfo->m_pVideoPacket->pts, in_stream->time_base, out_stream->time_base, (AVRounding)(AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX));
开发者ID:KingYoung87,项目名称:video_audio_pro,代码行数:67,代码来源:CLS_DlgStreamPusher.cpp

示例3: main

int main( int argc, char* argv[] )
{
    SDL_Event event;
    Uint32 u;
    Uint32 v;
    int i;
    int w = W;
    int h = H;
    int multis = MULTIS;
    int threads = THREADS;
    int photons = PHOTONS;
    unsigned seed = (unsigned)-1;
    bool preview = true;

    NICEME;

    // Process cmd line args
    for(i=1; i<argc; i++)
    {
        if( argv[i][0]=='-' ) switch( argv[i][1] )
            {
            case 'w':
                w = atoi(argv[i]+2);
                break;
            case 'h':
                h = atoi(argv[i]+2);
                break;
            case 'm':
                multis = atoi(argv[i]+2);
                break;
            case 't':
                threads = atoi(argv[i]+2);
                break;
            case 'p':
                photons = atoi(argv[i]+2);
                break;
            case '-':
                printf( "Usage: [OPTION]... [SEED]\nRender ray-traced 3D images generated randomly with seed number SEED.\n\n  option default description\n  -wNUM  %7d Set image output width to NUM\n  -hNUM  %7d Set image output height to NUM\n  -mNUM  %7d Set multisampling level to NUM (level 2 recommended)\n  -tNUM  %7d Parallelize with NUM threads\n  -pNUM  %7d Simulate lighting with NUM million photons!\n",W,H,MULTIS,THREADS,PHOTONS ), exit(0);
            default:
                fprintf( stderr, "Halt! -%c isn't one of my options!\nUse --help for help.\n", argv[i][1] ), exit(-1);
            }
        else if( seed==(unsigned)-1 )
        {
            seed = atoi(argv[i]);
            if( !seed )
                fprintf( stderr, "Halt! SEED ought to be a positive number, not %s\n", argv[i] ), exit(-1);
        }
        else
            fprintf( stderr, "Halt! I'm confused by cmd line argument #%d: %s\n", i, argv[i] ), exit(-1);
    }
    if( w<1 ) w=W;
    if( h<1 ) h=H;
    if( multis<1 ) multis=MULTIS;
    if( threads<1 ) threads=THREADS;
    if( photons<1 ) photons=PHOTONS;

    // Use time as seed if not otherwise specified
    if( seed==(unsigned)-1 )
        seed = (unsigned)time(NULL);

    // Init SDL
    if( SDL_Init( SDL_INIT_TIMER|SDL_INIT_AUDIO|SDL_INIT_VIDEO ) < 0 || !SDL_GetVideoInfo() )
        return 0;

    // Create Window
    SetVideo( w, h );
    SDL_WM_SetCaption("PixelMachine", NULL);

    pinfo = SDL_GetVideoInfo();

    // font init
    SJF_Init(pinfo);

    //ui setup
    ui.init();
    h_menu = ui.new_control(0,0,0,0);
    h_render = ui.new_control(h_menu,80,15,SJUIF_EXTENDSV);
    ui.set_caption(h_menu,"Click to render...");
    ui.set_caption(h_render,"Loading");

    //pm preview render setup
    pixelmachine = new PIXELMACHINE;
    pixelmachine->init(seed,100,75,1,threads,(photons?1:0));
    thread = SDL_CreateThread(run_pixel_machine,NULL);

    // MAIN LOOP
    while( 1 )
    {
        while( SDL_PollEvent(&event) ) switch(event.type)
            {
            case SDL_VIDEOEXPOSE:
                ;
                break;
            case SDL_VIDEORESIZE:
                SetVideo( event.resize.w, event.resize.h );
                break;
            case SDL_MOUSEBUTTONDOWN:
                if( preview )
                {
                    //pm full render go!
//.........这里部分代码省略.........
开发者ID:qiqisteve,项目名称:pixelmachine,代码行数:101,代码来源:main.cpp

示例4: main


//.........这里部分代码省略.........

    /* Start our scripting engine. */
    InitScripting();
    if (LoadGameScript("pw.tcl") != 0) {
	fprintf(stderr, "Exiting due to script error.\n");
	exit(EXIT_FAILURE);
    }

    /* Fire up SDL. */
    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
	printf("Unable to initialize SDL: %s\n", SDL_GetError());
	exit(EXIT_FAILURE);
    }
    atexit(SDL_Quit);
	
    /* Set an appropriate 16-bit video mode. */
    if (SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 16,
			 (hwsurface ? SDL_HWSURFACE : SDL_SWSURFACE) |
			 (doublebuf ? SDL_DOUBLEBUF : 0) |
			 (fullscreen ? SDL_FULLSCREEN : 0)) == NULL) {
	printf("Unable to set video mode: %s\n", SDL_GetError());
	exit(EXIT_FAILURE);
    }
	
    /* Save the screen pointer for later use. */
    screen = SDL_GetVideoSurface();
	
    /* Set the window caption to the name of the game. */
    SDL_WM_SetCaption("Penguin Warrior", "Penguin Warrior");
	
    /* Hide the mouse pointer. */
    SDL_ShowCursor(0);

    /* Initialize the status display. */
    if (InitStatusDisplay() < 0) {
	printf("Unable to initialize status display.\n");
	exit(EXIT_FAILURE);
    }
		
    /* Start the OpenAL-based audio system. */
    InitAudio();

    /* Initialize music and give the music system a file. */
    InitMusic();
    if (LoadMusic("reflux.ogg") < 0) {
	/* If that failed, don't worry about it. */
	printf("Unable to load reflux.ogg.\n");
    }

    /* Load the game's data into globals. */
    LoadGameData();

    /* Initialize the background starfield. */
    InitBackground();

    /* Start the network thread. */
    if (game_type == GAME_NETWORK) {
	network_thread = SDL_CreateThread(NetworkThread, NULL);
	if (network_thread == NULL) {
	    printf("Unable to start network thread: %s\n",
		   SDL_GetError());
	    exit(EXIT_FAILURE);
	}
    }
	
    /* Play! */
    InitPlayer(&player);
    InitPlayer(&opponent);
    PlayGame();

    /* Kill the network thread. */
    if (game_type == GAME_NETWORK) {
	SDL_KillThread(network_thread);
    }

    /* Close the network connection. */
    if (game_type == GAME_NETWORK)
	CloseNetgameLink(&netlink);

    /* Unhide the mouse pointer. */
    SDL_ShowCursor(1);
	
    /* Clean up the status display. */
    CleanupStatusDisplay();

    /* Unload data. */
    UnloadGameData();
	
    /* Shut down our scripting engine. */
    CleanupScripting();

    /* Get rid of the mutex. */
    SDL_DestroyMutex(player_mutex);

    /* Shut down audio. */
    CleanupMusic();
    CleanupAudio();

    return 0;
}
开发者ID:leventguel,项目名称:c-lang-exercises,代码行数:101,代码来源:main.c

示例5: SDL_CreateThread

		Thread *CreateThread(int (*fn)(void *), void *data)
		{
			return SDL_CreateThread(fn, data);
		}
开发者ID:losinggeneration,项目名称:sdl4cpp,代码行数:4,代码来源:SDL4Cpp_mt.cpp

示例6: SDL_CreateThread

void GameScreen::Update(int delta)
{
    if (!caseIsReady && gCaseFilePath.length() > 0)
    {
        SDL_CreateThread(GameScreen::LoadCaseStatic, "LoadCaseThread", new LoadCaseParameters(gCaseFilePath));
        gCaseFilePath = "";
    }

    if (isFinishing)
    {
        if (Case::GetInstance()->GetIsUnloaded())
        {
            ResourceLoader::GetInstance()->SnapLoadStepQueue();

            while (ResourceLoader::GetInstance()->HasLoadStep())
            {
                ResourceLoader::GetInstance()->TryRunOneLoadStep();
            }

            ResourceLoader::GetInstance()->UnloadCase();
            Case::DestroyInstance();
            caseIsReady = false;
            isFinishing = false;

            // If the case file path contains a path, then we're loading a new case,
            // so we only want to do go back to the title screen if it doesn't.
            if (gCaseFilePath.length() == 0)
            {
                Game::GetInstance()->PrepareMenuMode();
                isFinished = true;
                nextScreenId = TITLE_SCREEN_ID;
            }
        }

        return;
    }

    if (!caseIsReady)
    {
        timeSinceLastLoadingDotsUpdate += delta;

        while (timeSinceLastLoadingDotsUpdate > LoadingDotsUpdateDelayMs)
        {
            timeSinceLastLoadingDotsUpdate -= LoadingDotsUpdateDelayMs;
            numLoadingDots++;

            if (numLoadingDots > 3)
            {
                numLoadingDots = 1;
            }
        }

        return;
    }
    else if (Case::GetInstance()->IsLoading())
    {
        if (Case::GetInstance()->GetWantsToLoadResources())
        {
            Case::GetInstance()->LoadResources();
            startedLoadingResources = true;
        }
        else if (startedLoadingResources && !ResourceLoader::GetInstance()->HasLoadStep() && !ResourceLoader::GetInstance()->HasImageTexturesToLoad())
        {
            Case::GetInstance()->SetIsLoadingSprites(false);
            startedLoadingResources = false;
        }

        return;
    }

    if (caseNeedsReset)
    {
        Case::GetInstance()->Reset();
        Case::GetInstance()->Begin();
        caseNeedsReset = false;
    }

    if (Case::GetInstance()->GetIsFinished())
    {
        stopMusic();
        isFinishing = true;
        SDL_CreateThread(GameScreen::UnloadCaseStatic, "UnloadCaseThread", this);
        return;
    }

    Case::GetInstance()->Update(delta);
}
开发者ID:mbasaglia,项目名称:my-little-investigations,代码行数:87,代码来源:GameScreen.cpp

示例7: GLimp_SpawnRenderThread

/*
===============
GLimp_SpawnRenderThread
===============
*/
qboolean GLimp_SpawnRenderThread(void (*function) (void))
{
	static qboolean warned = qfalse;

	if(!warned)
	{
		Com_Printf("WARNING: You enable r_smp at your own risk!\n");
		warned = qtrue;
	}

#if !defined(MACOS_X) && !defined(WIN32) && !defined (SDL_VIDEO_DRIVER_X11)
	return qfalse;				/* better safe than sorry for now. */
#endif

	if(renderThread != NULL)	/* hopefully just a zombie at this point... */
	{
		Com_Printf("Already a render thread? Trying to clean it up...\n");
		GLimp_ShutdownRenderThread();
	}

	smpMutex = SDL_CreateMutex();
	if(smpMutex == NULL)
	{
		Com_Printf("smpMutex creation failed: %s\n", SDL_GetError());
		GLimp_ShutdownRenderThread();
		return qfalse;
	}

	renderCommandsEvent = SDL_CreateCond();
	if(renderCommandsEvent == NULL)
	{
		Com_Printf("renderCommandsEvent creation failed: %s\n", SDL_GetError());
		GLimp_ShutdownRenderThread();
		return qfalse;
	}

	renderCompletedEvent = SDL_CreateCond();
	if(renderCompletedEvent == NULL)
	{
		Com_Printf("renderCompletedEvent creation failed: %s\n", SDL_GetError());
		GLimp_ShutdownRenderThread();
		return qfalse;
	}

	renderThreadFunction = function;
	renderThread = SDL_CreateThread(GLimp_RenderThreadWrapper, NULL);
	if(renderThread == NULL)
	{
		ri.Printf(PRINT_ALL, "SDL_CreateThread() returned %s", SDL_GetError());
		GLimp_ShutdownRenderThread();
		return qfalse;
	}
	else
	{
		// tma 01/09/07: don't think this is necessary anyway?
		//
		// !!! FIXME: No detach API available in SDL!
		//ret = pthread_detach( renderThread );
		//if ( ret ) {
		//ri.Printf( PRINT_ALL, "pthread_detach returned %d: %s", ret, strerror( ret ) );
		//}
	}

	return qtrue;
}
开发者ID:redrumrobot,项目名称:dretchstorm,代码行数:70,代码来源:sdl_glimp.c

示例8: CDecoder

void CImageClient::run(CRawImage *im)
{
    image  = im;
    codec = new CDecoder(imageSem,im);
    thread = SDL_CreateThread(StartThread,static_cast<void*>(this));
}
开发者ID:bushuhui,项目名称:ardroneToolkit,代码行数:6,代码来源:ardrone_CImageClient.cpp

示例9: fn_

thread::thread(const std::string& name, boost::function<void()> fn) 
	: fn_(fn), thread_(SDL_CreateThread(call_boost_function, name.c_str(), new boost::function<void()>(fn_)))
{}
开发者ID:kimsama,项目名称:frogatto,代码行数:3,代码来源:thread.cpp

示例10: SDL_CreateThread

void Personaje::caminar(unsigned int destX, unsigned int destY){
  if ( thrAccion ) SDL_KillThread(thrAccion);
  this->destX=destX;
  this->destY=destY;
  this->thrAccion = SDL_CreateThread(Personaje::entCaminar,this);
}
开发者ID:germanp,项目名称:Cavernization,代码行数:6,代码来源:personaje.cpp

示例11: main

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

	/* Enable standard application logging */
    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);

    success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
                "Simple MessageBox",
                "This is a simple error MessageBox",
                NULL);
    if (success == -1) {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
        quit(1);
    }

    success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
                "Simple MessageBox",
                "This is a simple MessageBox with a newline:\r\nHello world!",
                NULL);
    if (success == -1) {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
        quit(1);
    }

    /* Google says this is Traditional Chinese for "beef with broccoli" */
    success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
                "UTF-8 Simple MessageBox",
                "Unicode text: '牛肉西蘭花' ...",
                NULL);
    if (success == -1) {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
        quit(1);
    }

    /* Google says this is Traditional Chinese for "beef with broccoli" */
    success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
                "UTF-8 Simple MessageBox",
                "Unicode text and newline:\r\n'牛肉西蘭花'\n'牛肉西蘭花'",
                NULL);
    if (success == -1) {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
        quit(1);
    }

    button_messagebox(NULL);

    /* Test showing a message box from a background thread.

       On Mac OS X, the video subsystem needs to be initialized for this
       to work, since the message box events are dispatched by the Cocoa
       subsystem on the main thread.
     */
    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video subsystem: %s\n", SDL_GetError());
        return (1);
    }
    {
        int status = 0;
        SDL_Event event;
        intptr_t eventNumber = SDL_RegisterEvents(1);
        SDL_Thread* thread = SDL_CreateThread(&button_messagebox, "MessageBox", (void*)eventNumber);

        while (SDL_WaitEvent(&event))
        {
            if (event.type == eventNumber) {
                break;
            }
        }

        SDL_WaitThread(thread, &status);

        SDL_Log("Message box thread return %i\n", status);
    }

    /* Test showing a message box with a parent window */
    {
        SDL_Event event;
        SDL_Window *window = SDL_CreateWindow("Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, 0);

        success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
                    "Simple MessageBox",
                    "This is a simple error MessageBox with a parent window",
                    window);
        if (success == -1) {
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
            quit(1);
        }

        while (SDL_WaitEvent(&event))
        {
            if (event.type == SDL_QUIT || event.type == SDL_KEYUP) {
                break;
            }
        }
    }

    SDL_Quit();
    return (0);
//.........这里部分代码省略.........
开发者ID:nint22,项目名称:RayCaster,代码行数:101,代码来源:testmessage.c

示例12: SDL_CreateThread

void Drawing::nonBlockingShowWindow() {
	SDL_Thread * thread = SDL_CreateThread( Drawing::showWindowThread, "show window", this);
}
开发者ID:aswmtjdsj,项目名称:Ray-Tracing-CPU,代码行数:3,代码来源:Drawing.cpp

示例13: stream_component_open

int stream_component_open(VideoState *is, int stream_index)
{
    AVFormatContext *pFormatCtx = is->pFormatCtx;
    AVCodecContext *codecCtx;
    AVCodec *codec;
    SDL_AudioSpec wanted_spec, spec;

    if(stream_index < 0 || stream_index >= pFormatCtx->nb_streams)
    {
        return -1;
    }

    // Get a pointer to the codec context for the video stream
    codecCtx = pFormatCtx->streams[stream_index]->codec;

    if(codecCtx->codec_type == CODEC_TYPE_AUDIO)
    {
        // Set audio settings from codec info
        wanted_spec.freq = codecCtx->sample_rate;
        wanted_spec.format = AUDIO_S16SYS;
        wanted_spec.channels = codecCtx->channels;
        wanted_spec.silence = 0;
        wanted_spec.samples = SDL_AUDIO_BUFFER_SIZE;
        wanted_spec.callback = audio_callback;
        wanted_spec.userdata = is;

        if(SDL_OpenAudio(&wanted_spec, &spec) < 0)
        {
            fprintf(stderr, "SDL_OpenAudio: %s\n", SDL_GetError());
            return -1;
        }
        is->audio_hw_buf_size = spec.size;
    }
    codec = avcodec_find_decoder(codecCtx->codec_id);

    if(!codec || (avcodec_open(codecCtx, codec) < 0))
    {
        fprintf(stderr, "Unsupported codec!\n");
        return -1;
    }

    switch(codecCtx->codec_type)
    {
    case CODEC_TYPE_AUDIO:
        is->audioStream = stream_index;
        is->audio_st = pFormatCtx->streams[stream_index];
        is->audio_buf_size = 0;
        is->audio_buf_index = 0;
        memset(&is->audio_pkt, 0, sizeof(is->audio_pkt));
        packet_queue_init(&is->audioq);
        SDL_PauseAudio(0);
        break;
    case CODEC_TYPE_VIDEO:
        is->videoStream = stream_index;
        is->video_st = pFormatCtx->streams[stream_index];

        is->frame_timer = (double)av_gettime() / 1000000.0;
        is->frame_last_delay = 40e-3;
        is->video_current_pts_time = av_gettime();

        packet_queue_init(&is->videoq);
        is->video_tid = SDL_CreateThread(video_thread, is);
        codecCtx->get_buffer = our_get_buffer;
        codecCtx->release_buffer = our_release_buffer;
        break;
    default:
        break;
    }
    return 0;
}
开发者ID:xindawndev,项目名称:cxl-yeti,代码行数:70,代码来源:SDL_MPEG.cpp

示例14: return

WZ_THREAD *wzThreadCreate(int (*threadFunc)(void *), void *data)
{
	return (WZ_THREAD *)SDL_CreateThread(threadFunc, "wzThread", data);
}
开发者ID:Mailaender,项目名称:warzone2100,代码行数:4,代码来源:main_sdl.cpp

示例15: printf

bool GameManager::init()
{
	// success flag
	auto success = true;

	// init SDL video and audio
	if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0)
	{
		printf("SDL could not initialize SDL ERROR: %s\n", SDL_GetError());
		success = false;
	}
	else
	{
		//Set texture filtering to linear
		if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"))
		{
			printf("Warning: Linear texture filtering not enabled!");
		}

		// create the window
		window.window = SDL_CreateWindow("Breakout",
			SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
			SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN
			);

		if (window.window == nullptr) {
			printf("Window could not be created SDL ERROR: %s\n", SDL_GetError());
			success = false;

		}
		else
		{
			// create the renderer for the window
			gRenderer = SDL_CreateRenderer(window.window, -1, SDL_RENDERER_ACCELERATED);

			if (gRenderer == nullptr)
			{
				printf("Renderer could not be created SDL ERROR %s\n", SDL_GetError());
				success = false;
			}
			else
			{
				// init png loading
				int imgFlags = IMG_INIT_PNG;

				if (!(IMG_Init(imgFlags) & imgFlags))
				{
					printf("SDL_Image could not be initalized, SDL_Image ERROR: %s\n", IMG_GetError());
					success = false;
				}
				else {
					// init SDL_mixer
					success = bgMusic.init();
				}
			}
		}
	}

	//Initialize SDL_ttf
	if (TTF_Init() == -1)
	{
		printf("SDL_ttf could not initialize! SDL_ttf Error: %s\n", TTF_GetError());
		success = false;
	}

	// Initalizing default constructor of pieces, utilizing copy and move constructors
	Piece defaultInit;
	for (auto i = 0; i < PIECES; i++)
	{
		pieces.push_back(defaultInit);
	}

	// initialize the pieces level 0
	initBlocks(pieces, level);

	threadID = SDL_CreateThread(threading_.threadedFunction, "PrintingThread", static_cast<void*>(&ball));
	threadRunning = true;

	return success;
}
开发者ID:PG4400-Innlevering-1,项目名称:Breakout,代码行数:80,代码来源:GameManager.cpp


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