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


C++ SDL_ListModes函数代码示例

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


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

示例1: AddSupportedModesForBPP

void AddSupportedModesForBPP(GraphicsDevice *device, int bpp)
{
	SDL_Rect** modes;
	SDL_PixelFormat fmt;
	int i;
	memset(&fmt, 0, sizeof fmt);
	fmt.BitsPerPixel = (Uint8)bpp;

	modes = SDL_ListModes(&fmt, SDL_FULLSCREEN);
	if (modes == (SDL_Rect**)0)
	{
		return;
	}
	if (modes == (SDL_Rect**)-1)
	{
		return;
	}

	for (i = 0; modes[i]; i++)
	{
		int validScaleFactors[] = { 1, 2, 3, 4 };
		int j;
		for (j = 0; j < 4; j++)
		{
			int scaleFactor = validScaleFactors[j];
			int w, h;
			if (modes[i]->w % scaleFactor || modes[i]->h % scaleFactor)
			{
				continue;
			}
			if (modes[i]->w % 4)
			{
				// TODO: why does width have to be divisible by 4? 1366x768 doesn't work
				continue;
			}
			w = modes[i]->w / scaleFactor;
			h = modes[i]->h / scaleFactor;
			if (w < 320 || h < 240)
			{
				break;
			}
			AddGraphicsMode(device, w, h, scaleFactor);
		}
	}
}
开发者ID:kodephys,项目名称:cdogs-sdl,代码行数:45,代码来源:grafx.c

示例2: sizeof

int CGraphics_SDL::GetVideoModes(CVideoMode *pModes, int MaxModes)
{
	int NumModes = sizeof(g_aFakeModes)/sizeof(CVideoMode);
	SDL_Rect **ppModes;

	if(g_Config.m_GfxDisplayAllModes)
	{
		int Count = sizeof(g_aFakeModes)/sizeof(CVideoMode);
		mem_copy(pModes, g_aFakeModes, sizeof(g_aFakeModes));
		if(MaxModes < Count)
			Count = MaxModes;
		return Count;
	}
	
	// TODO: fix this code on osx or windows
		
	ppModes = SDL_ListModes(NULL, SDL_OPENGL|SDL_GL_DOUBLEBUFFER|SDL_FULLSCREEN);
	if(ppModes == NULL)
	{
		// no modes
		NumModes = 0;
	}
	else if(ppModes == (SDL_Rect**)-1)
	{
		// all modes
	}
	else
	{
		NumModes = 0;
		for(int i = 0; ppModes[i]; ++i)
		{
			if(NumModes == MaxModes)
				break;
			pModes[NumModes].m_Width = ppModes[i]->w;
			pModes[NumModes].m_Height = ppModes[i]->h;
			pModes[NumModes].m_Red = 8;
			pModes[NumModes].m_Green = 8;
			pModes[NumModes].m_Blue = 8;
			NumModes++;
		}
	}
	
	return NumModes;
}
开发者ID:CoolerMAN,项目名称:tdtw,代码行数:44,代码来源:graphics.cpp

示例3: GHOST_ASSERT

GHOST_TSuccess GHOST_DisplayManagerSDL::getNumDisplaySettings(GHOST_TUns8 display,
        GHOST_TInt32& numSettings) const
{
    GHOST_ASSERT(display < 1, "Only single display systems are currently supported.\n");
    int i;
    SDL_Rect **vidmodes;

    vidmodes = SDL_ListModes(NULL, SDL_HWSURFACE | SDL_OPENGL |
                             SDL_FULLSCREEN | SDL_HWPALETTE);
    if (!vidmodes) {
        fprintf(stderr, "Could not get available video modes: %s.\n",
                SDL_GetError());
        return GHOST_kFailure;
    }
    for (i = 0; vidmodes[i]; i++);
    numSettings = GHOST_TInt32(i);

    return GHOST_kSuccess;
}
开发者ID:ruesp83,项目名称:Blender---AMA,代码行数:19,代码来源:GHOST_DisplayManagerSDL.cpp

示例4: GLimp_DetectAvailableModes

/*
===============
GLimp_DetectAvailableModes
===============
*/
static void GLimp_DetectAvailableModes(void)
{
	char            buf[MAX_STRING_CHARS] = { 0 };
	SDL_Rect      **modes;
	int             numModes;
	int             i;

	modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);

	if(!modes)
	{
		ri.Printf(PRINT_WARNING, "Can't get list of available modes\n");
		return;
	}

	if(modes == (SDL_Rect **) - 1)
	{
		ri.Printf(PRINT_ALL, "Display supports any resolution\n");
		return;					// can set any resolution
	}

	for(numModes = 0; modes[numModes]; numModes++);

	if(numModes > 1)
		qsort(modes + 1, numModes - 1, sizeof(SDL_Rect *), GLimp_CompareModes);

	for(i = 0; i < numModes; i++)
	{
		const char     *newModeString = va("%ux%u ", modes[i]->w, modes[i]->h);

		if(strlen(newModeString) < (int)sizeof(buf) - strlen(buf))
			Q_strcat(buf, sizeof(buf), newModeString);
		else
			ri.Printf(PRINT_WARNING, "Skipping mode %ux%x, buffer too small\n", modes[i]->w, modes[i]->h);
	}

	if(*buf)
	{
		buf[strlen(buf) - 1] = 0;
		ri.Printf(PRINT_ALL, "Available modes: '%s'\n", buf);
		ri.Cvar_Set("r_availableModes", buf);
	}
}
开发者ID:otty,项目名称:cake3,代码行数:48,代码来源:sdl_vid.c

示例5: SDL_GetVideoInfo

VideoQueryResult CApplication::GetVideoResolutionList(std::vector<Math::IntPoint> &resolutions,
                                                      bool fullScreen, bool resizeable)
{
    resolutions.clear();

    const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
    if (videoInfo == nullptr)
        return VIDEO_QUERY_ERROR;

    Uint32 videoFlags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE;

    // Use hardware surface if available
    if (videoInfo->hw_available)
        videoFlags |= SDL_HWSURFACE;
    else
        videoFlags |= SDL_SWSURFACE;

    // Enable hardware blit if available
    if (videoInfo->blit_hw)
        videoFlags |= SDL_HWACCEL;

    if (resizeable)
        videoFlags |= SDL_RESIZABLE;

    if (fullScreen)
        videoFlags |= SDL_FULLSCREEN;


    SDL_Rect **modes = SDL_ListModes(NULL, videoFlags);

    if (modes == reinterpret_cast<SDL_Rect **>(0) )
        return VIDEO_QUERY_NONE; // no modes available

    if (modes == reinterpret_cast<SDL_Rect **>(-1) )
        return VIDEO_QUERY_ALL; // all resolutions are possible


    for (int i = 0; modes[i] != NULL; ++i)
        resolutions.push_back(Math::IntPoint(modes[i]->w, modes[i]->h));

    return VIDEO_QUERY_OK;
}
开发者ID:pol51,项目名称:colobot,代码行数:42,代码来源:app.cpp

示例6: resol_enter

static int resol_enter(struct state *st, struct state *prev)
{
    if (!st_back)
    {
        /* Note the parent screen if not done yet. */

        st_back = prev;
    }

    back_init("back/gui.png");

    modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);

    if (modes == (SDL_Rect **) -1)
        modes = NULL;

    audio_music_fade_to(0.5f, "bgm/inter.ogg");

    return resol_gui();
}
开发者ID:salvy,项目名称:Neverball-svn,代码行数:20,代码来源:st_resol.c

示例7: SDL_ListModes

VIDEOMODE_resolution_t *PLATFORM_AvailableResolutions(unsigned int *size)
{
	SDL_Rect **modes = SDL_ListModes(NULL, SDL_FULLSCREEN);
	VIDEOMODE_resolution_t *resolutions;
	unsigned int num_modes;
	unsigned int i;
	if (modes == (SDL_Rect**)0 || modes == (SDL_Rect**)-1)
		return NULL;
	/* Determine number of available modes. */
	for (num_modes = 0; modes[num_modes] != NULL; ++num_modes);

	resolutions = Util_malloc(num_modes * sizeof(VIDEOMODE_resolution_t));
	for (i = 0; i < num_modes; i++) {
		resolutions[i].width = modes[i]->w;
		resolutions[i].height = modes[i]->h;
	}
	*size = num_modes;

	return resolutions;
}
开发者ID:dabonetn,项目名称:atari800-rpi,代码行数:20,代码来源:video.c

示例8: SDL_ListModes

QStringList SDLInteraction::getResolutions() const
{
    QStringList result;

    SDL_Rect **modes;

    modes = SDL_ListModes(NULL, SDL_FULLSCREEN);

    if((modes == (SDL_Rect **)0) || (modes == (SDL_Rect **)-1))
    {
        result << "640x480";
    } else
    {
        for(int i = 0; modes[i]; ++i)
            if ((modes[i]->w >= 640) && (modes[i]->h >= 480))
                result << QString("%1x%2").arg(modes[i]->w).arg(modes[i]->h);
    }

    return result;
}
开发者ID:hkardes,项目名称:hedgewars-accessible,代码行数:20,代码来源:SDLs.cpp

示例9: GetAvailableVideoModes

std::vector<VideoMode> GetAvailableVideoModes()
{
	std::vector<VideoMode> modes;
	//querying modes using the current pixel format
	//note - this has always been sdl_fullscreen, hopefully it does not matter
	SDL_Rect **sdlmodes = SDL_ListModes(NULL, SDL_HWSURFACE | SDL_FULLSCREEN);

	if (sdlmodes == 0)
		OS::Error("Failed to query video modes");

	if (sdlmodes == reinterpret_cast<SDL_Rect **>(-1)) {
		// Modes restricted. Fall back to 800x600
		modes.push_back(VideoMode(800, 600));
	} else {
		for (int i=0; sdlmodes[i]; ++i) {
			modes.push_back(VideoMode(sdlmodes[i]->w, sdlmodes[i]->h));
		}
	}
	return modes;
}
开发者ID:jaj22,项目名称:pioneer,代码行数:20,代码来源:Graphics.cpp

示例10: PrintAttributes

	void PrintAttributes(void)
	{
		int value;

		// current resolution
		SDL_Surface *surface = SDL_GetVideoSurface();
		SDL_PixelFormat *format = surface->format;
		DebugPrint("\nCurrent: %dx%d %dbpp\n", surface->w, surface->h, format->BitsPerPixel);

		// get fullscreen resolutions
		DebugPrint("\nResolutions:\n");
		SDL_Rect **modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
		for (SDL_Rect **mode = modes; *mode != NULL; ++mode)
			DebugPrint("%dx%d\n", (*mode)->w, (*mode)->h);

		const char *attrib[] =
		{
			"SDL_GL_RED_SIZE",
			"SDL_GL_GREEN_SIZE",
			"SDL_GL_BLUE_SIZE",
			"SDL_GL_ALPHA_SIZE",
			"SDL_GL_BUFFER_SIZE",
			"SDL_GL_DOUBLEBUFFER",
			"SDL_GL_DEPTH_SIZE",
			"SDL_GL_STENCIL_SIZE",
			"SDL_GL_ACCUM_RED_SIZE",
			"SDL_GL_ACCUM_GREEN_SIZE",
			"SDL_GL_ACCUM_BLUE_SIZE",
			"SDL_GL_ACCUM_ALPHA_SIZE",
			"SDL_GL_STEREO",
			"SDL_GL_MULTISAMPLEBUFFERS",
			"SDL_GL_MULTISAMPLESAMPLES",
			"SDL_GL_ACCELERATED_VISUAL",
			"SDL_GL_SWAP_CONTROL"
		};
		for (int i = 0; i < SDL_arraysize(attrib); ++i)
		{
			SDL_GL_GetAttribute( SDL_GLattr(i), &value );
			DebugPrint( "%s: %d\n", attrib[i], value);
		}
	}
开发者ID:Fissuras,项目名称:videoventure,代码行数:41,代码来源:PrintAttributes.cpp

示例11: SDL_GetVideoInfo

//! \return Pointer to a list with all video modes supported
video::IVideoModeList* CIrrDeviceSDL::getVideoModeList()
{
	if (!VideoModeList.getVideoModeCount())
	{
		// enumerate video modes.
		const SDL_VideoInfo *vi = SDL_GetVideoInfo();
		SDL_Rect **modes = SDL_ListModes(vi->vfmt, SDL_Flags);
		if (modes != 0)
		{
			if (modes == (SDL_Rect **)-1)
				os::Printer::log("All modes available.\n");
			else
			{
				for (u32 i=0; modes[i]; ++i)
					VideoModeList.addMode(core::dimension2d<s32>(modes[i]->w, modes[i]->h), vi->vfmt->BitsPerPixel);
			}
		}
	}

	return &VideoModeList;
}
开发者ID:AwkwardDev,项目名称:pseuwow,代码行数:22,代码来源:CIrrDeviceSDL.cpp

示例12: PrintAvailableResolutions

void PrintAvailableResolutions()
{
	// Get available fullscreen/hardware modes
	SDL_Rect** modes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_OPENGL);
	if (modes == (SDL_Rect**)0) {
		LOG("Supported Video modes: No modes available!");
	} else if (modes == (SDL_Rect**)-1) {
		LOG("Supported Video modes: All modes available.");
	} else {
		char buffer[1024];
		unsigned char n = 0;
		for (int i = 0; modes[i]; ++i) {
			n += SNPRINTF(&buffer[n], 1024-n, "%dx%d, ", modes[i]->w, modes[i]->h);
		}
		// remove last comma
		if (n >= 2) {
			buffer[n - 2] = '\0';
		}
		LOG("Supported Video modes: %s", buffer);
	}
}
开发者ID:lordelven,项目名称:spring,代码行数:21,代码来源:myGL.cpp

示例13: SdlGraphicsManager

OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager(uint desktopWidth, uint desktopHeight, SdlEventSource *eventSource)
    : SdlGraphicsManager(eventSource), _lastVideoModeLoad(0), _hwScreen(nullptr), _lastRequestedWidth(0), _lastRequestedHeight(0),
      _graphicsScale(2), _ignoreLoadVideoMode(false), _gotResize(false), _wantsFullScreen(false), _ignoreResizeEvents(0),
      _desiredFullscreenWidth(0), _desiredFullscreenHeight(0) {
	// Setup OpenGL attributes for SDL
	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

	// Retrieve a list of working fullscreen modes
	const SDL_Rect *const *availableModes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
	if (availableModes != (void *)-1) {
		for (;*availableModes; ++availableModes) {
			const SDL_Rect *mode = *availableModes;

			_fullscreenVideoModes.push_back(VideoMode(mode->w, mode->h));
		}

		// Sort the modes in ascending order.
		Common::sort(_fullscreenVideoModes.begin(), _fullscreenVideoModes.end());
	}

	// In case SDL is fine with every mode we will force the desktop mode.
	// TODO? We could also try to add some default resolutions here.
	if (_fullscreenVideoModes.empty() && desktopWidth && desktopHeight) {
		_fullscreenVideoModes.push_back(VideoMode(desktopWidth, desktopHeight));
	}

	// Get information about display sizes from the previous runs.
	if (ConfMan.hasKey("last_fullscreen_mode_width", Common::ConfigManager::kApplicationDomain) && ConfMan.hasKey("last_fullscreen_mode_height", Common::ConfigManager::kApplicationDomain)) {
		_desiredFullscreenWidth  = ConfMan.getInt("last_fullscreen_mode_width", Common::ConfigManager::kApplicationDomain);
		_desiredFullscreenHeight = ConfMan.getInt("last_fullscreen_mode_height", Common::ConfigManager::kApplicationDomain);
	} else {
		// Use the desktop resolutions when no previous default has been setup.
		_desiredFullscreenWidth  = desktopWidth;
		_desiredFullscreenHeight = desktopHeight;
	}
}
开发者ID:jaeyeonkim,项目名称:scummvm-kor,代码行数:40,代码来源:openglsdl-graphics.cpp

示例14: gr_list_modes

// returns possible (fullscreen) resolutions if any.
int gr_list_modes( u_int32_t gsmodes[] )
{
	SDL_Rect** modes;
	int i = 0, modesnum = 0;
#ifdef OGLES
	int sdl_check_flags = SDL_FULLSCREEN; // always use Fullscreen as lead.
#else
	int sdl_check_flags = SDL_OPENGL | SDL_FULLSCREEN; // always use Fullscreen as lead.
#endif

	if (sdl_no_modeswitch) {
		/* TODO: we could use the tvservice to list resolutions on the RPi */
		return 0;
	}

	modes = SDL_ListModes(NULL, sdl_check_flags);

	if (modes == (SDL_Rect**)0) // check if we get any modes - if not, return 0
		return 0;


	if (modes == (SDL_Rect**)-1)
	{
		return 0; // can obviously use any resolution... strange!
	}
	else
	{
		for (i = 0; modes[i]; ++i)
		{
			if (modes[i]->w > 0xFFF0 || modes[i]->h > 0xFFF0 // resolutions saved in 32bits. so skip bigger ones (unrealistic in 2010) (changed to 0xFFF0 to fix warning)
				|| modes[i]->w < 320 || modes[i]->h < 200) // also skip everything smaller than 320x200
				continue;
			gsmodes[modesnum] = SM(modes[i]->w,modes[i]->h);
			modesnum++;
			if (modesnum >= 50) // that really seems to be enough big boy.
				break;
		}
		return modesnum;
	}
}
开发者ID:CDarrow,项目名称:DXX-Retro,代码行数:41,代码来源:gr.c

示例15: Game_reshape

void Game_reshape(Game *g) {

    glEnable(GL_TEXTURE_2D);
    glEnable(GL_BLEND);
    glBlendFunc(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA);
    glBlendColor(1.f, 1.f, 1.f, 1.f);

    if(g->fullscreen) {
        /* La doc ne dit pas s'il faut libérer le tableau à la fin. */
        SDL_Rect **modes = SDL_ListModes(NULL, SDL_FULLSCREEN);
        switch((intptr_t)modes) {
        case  0: /* Aucun mode n'est disponible. */ break;
        case -1: /* Tout mode peut convenir. */ break;
        /* Dans les deux cas ci-dessus, on peut toujours 
         * passer en fullscreen, mais c'est juste moche. */
        default: /* On a une liste de modes. */
            g->old_window_size.x = g->window_size.x;
            g->old_window_size.y = g->window_size.y;
            g->window_size.x = modes[0]->w;
            g->window_size.y = modes[0]->h;
            break;
        }
    } else if(g->old_window_size.x) {
        g->window_size.x = g->old_window_size.x;
        g->window_size.y = g->old_window_size.y; 
        g->old_window_size.x = 0;
    }
    if(!SDL_SetVideoMode(
            g->window_size.x, 
            g->window_size.y, 
            g->bits_per_pixel, 
            SDL_OPENGL | SDL_DOUBLEBUF | SDL_RESIZABLE
            |(g->fullscreen ? SDL_FULLSCREEN : 0))) {
        fprintf(stderr, "SDL_SetVideoMode() failed :\n\t%s\n Exitting.\n",
                        SDL_GetError());
        exit(EXIT_FAILURE);
    }
    Game_resizeViewports(g);
    Game_resizeSprites(g);
}
开发者ID:datross,项目名称:hovercraft,代码行数:40,代码来源:Game_graphics.c


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