我是靠谱客的博主 简单猎豹,最近开发中收集的这篇文章主要介绍SDL_SetVideoMode函数,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

SDL_SetVideoMode函数:

设置显示卡的显示模式:宽度、高度和像素的位数。

定义:

#include "SDL.h"
SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags);

例子:

#include "SDL.h"

 

const int WINDOW_WIDTH = 640;

const int WINDOW_HEIGHT = 480;

const char* WINDOW_TITLE = "SDL Start";

 

int main(int argc, char **argv)

{

   SDL_Init( SDL_INIT_VIDEO );

 

   SDL_Surface* screen = SDL_SetVideoMode( WINDOW_WIDTH, WINDOW_HEIGHT, 0,

      SDL_HWSURFACE | SDL_DOUBLEBUF );

   SDL_WM_SetCaption( WINDOW_TITLE, 0 );

 

   SDL_Quit();

 

   return 0;

}

Set up a video mode with the specified width, height and bits-per-pixel.

If bpp is 0, it is treated as the current display bits per pixel.

The flags parameter is the same as the flags field of the SDL_Surface structure. OR'd combinations of the following values are valid.

SDL_SWSURFACECreate the video surface in system memory
SDL_HWSURFACECreate the video surface in video memory
SDL_ASYNCBLITEnables the use of asynchronous updates of the display surface. This will usually slow down blitting on single CPU machines, but may provide a speed increase on SMP systems.
SDL_ANYFORMATNormally, if a video surface of the requested bits-per-pixel (bpp) is not available, SDL will emulate one with a shadow surface. Passing SDL_ANYFORMAT prevents this and causes SDL to use the video surface, regardless of its pixel depth.
SDL_HWPALETTEGive SDL exclusive palette access. Without this flag you may not always get the the colors you request with SDL_SetColors or SDL_SetPalette.
SDL_DOUBLEBUFEnable hardware double buffering; only valid with SDL_HWSURFACE. Calling SDL_Flip will flip the buffers and update the screen. All drawing will take place on the surface that is not displayed at the moment. If double buffering could not be enabled then SDL_Flip will just perform a SDL_UpdateRect on the entire screen.
SDL_FULLSCREENSDL will attempt to use a fullscreen mode. If a hardware resolution change is not possible (for whatever reason), the next higher resolution will be used and the display window centered on a black background.
SDL_OPENGLCreate an OpenGL rendering context. You should have previously set OpenGL video attributes with SDL_GL_SetAttribute.
SDL_OPENGLBLITCreate an OpenGL rendering context, like above, but allow normal blitting operations. The screen (2D) surface may have an alpha channel, and SDL_UpdateRects must be used for updating changes to the screen surface. NOTE: This option is kept for compatibility only, and is not recommended for new code.
SDL_RESIZABLECreate a resizable window. When the window is resized by the user a SDL_VIDEORESIZE event is generated and SDL_SetVideoMode can be called again with the new size.
SDL_NOFRAMEIf possible, SDL_NOFRAME causes SDL to create a window with no title bar or frame decoration. Fullscreen modes automatically have this flag set.

Note: Whatever flags SDL_SetVideoMode could satisfy are set in the flags member of the returned surface.

Note: The bpp parameter is the number of bits per pixel, so a bpp of 24 uses the packed representation of 3 bytes/pixel. For the more common 4 bytes/pixel mode, use a bpp of 32. Somewhat oddly, both 15 and 16 will request a 2 bytes/pixel mode, but different pixel formats.



老蔡学堂


蔡军生

最后

以上就是简单猎豹为你收集整理的SDL_SetVideoMode函数的全部内容,希望文章能够帮你解决SDL_SetVideoMode函数所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(48)

评论列表共有 0 条评论

立即
投稿
返回
顶部