亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? gamedev_net - the simple directmedia layer from a win32 perspective, part 2 sdl video.htm

?? 游戲開(kāi)發(fā)數(shù)據(jù)結(jié)構(gòu)Data Structures for Game Programmers The Goodies Directory contains all sorts of stuff. For
?? HTM
?? 第 1 頁(yè) / 共 4 頁(yè)
字號(hào):
    <TD>The surface will be used as a destination for OpenGL rendering.</TD></TR>
  <TR>
    <TD>SDL_RESIZABLE*</TD>
    <TD>(Windowed mode only) the window is resizable.</TD></TR>
  <TR>
    <TD>SDL_HWACCEL</TD>
    <TD>The surface will use hardware accelerated blitting.</TD></TR>
  <TR>
    <TD>SDL_SRCCOLORKEY</TD>
    <TD>The surface has a color key.</TD></TR>
  <TR>
    <TD>SDL_RLEACCEL</TD>
    <TD>The surface is used for run-length-encoded blits.</TD></TR>
  <TR>
    <TD>SDL_SRCALPHA</TD>
    <TD>The surface has an alpha component.</TD></TR>
  <TR>
    <TD>SDL_PREALLOC</TD>
    <TD>The surface came to be from a pre-allocated array of pixel 
  data.</TD></TR></TBODY></TABLE>
<P>*only the display surface may have these flags</P>
<P>The format member is a pointer to an SDL_PixelFormat structure that describes 
the pixel format for this surface.</P>
<P>The w and h members describe the width and height of the surface.</P>
<P>The pitch contains the number of bytes per scan line for the surface. Video 
cards being what they are, this value is often not the same as the BytesPerPixel 
times the width.</P>
<P>The pixels is a pointer to pixel data for the surface. It is used to read or 
write pixels to and from the surface.</P>
<P>The clip_rect member is an SDL_Rect that describes the clipping area of the 
surface. Any writing outside of this area will not be shown.</P>
<P>And finally, refcount is a reference count. When a surface is created, it is 
set to one. You can increment it manually. It is decremented whenever the 
surface is freed. Once it reaches 0, the surface is deleted from memory. This 
member is sort of like using AddRef for COM objects.</P>
<P>IMPORTANT NOTE: with the exception of refcount and the data pointed to by 
pixels, these members should not by modified by you directly. There are 
functions for dealing with and changing most of them.</P>
<H2>SDL_VideoInfo</H2>
<P>The last structure we're going to look at is SDL_VideoInfo. As you might 
expect, it contains information about the video display on the machine it is 
running on. Here's what it looks like:</P>
<BLOCKQUOTE><PRE class=code>typedef struct{
  Uint32 hw_available:1;
  Uint32 wm_available:1;
  Uint32 blit_hw:1;
  Uint32 blit_hw_CC:1;
  Uint32 blit_hw_A:1;
  Uint32 blit_sw:1;
  Uint32 blit_sw_CC:1;
  Uint32 blit_sw_A:1;
  Uint32 blit_fill:1;
  Uint32 video_mem;
  SDL_PixelFormat *vfmt;
} SDL_VideoInfo;
</PRE></BLOCKQUOTE>
<P>The closest equivalent in DirectDraw is the DDCAPS structure. SDL_VideoInfo, 
however, is much easier to read. Most of the members are single bits, and a 
value of 0 means that the feature in question is not supported, and 1 means that 
the feature is supported.</P>
<P>The hw_available indicates that you may create hardware surfaces, which 
naturally will be faster than software surface.</P>
<P>The wm_available indicates that a window manager is available. In WIN32, one 
is, but for other platforms, one might not be. The window manager is another 
subsystem of SDL that deals with some pretty basic settings for a window (if you 
are using windowed mode versus fullscreen).</P>
<P>The blit_hw, blit_hw_CC, and blit_hw_A all deal with the availability of 
hardware acceleration for blits between surface stored in hardware. The blit_hw 
bit specifies that generic hardware to hardware blits are accelerated, 
blit_hw_CC specifies that hardware to hardware colorkeyed blits are accelerated, 
and blit_hw_A specifies that hardware to hardware alpha blits are 
accelerated.</P>
<P>The blit_sw, blit_sw_CC, and blit_sw_A are much the same as the blit_hw 
members, except that they specify the capabilities for software to hardware 
blits instead.</P>
<P>The blit_fill member specifies that color fill operations are 
accelerated.</P>
<P>The video_mem contains, in kilobytes, the amount of video RAM for the 
system.</P>
<P>The vfmt member is a pointer to an SDL_PixelFormat. Depending on when you 
call it, it will contain either the "best" video format (the one with the most 
capabilities), or the current video format (depending on if you have already set 
up your display surface or not).</P>
<H1>Video Information (TGO-02-B)</H1>
<P>The beautiful thing about SDL is that you don't have to gather any 
information about the video subsystem before using it if you don't want to. SDL 
will emulate anything you want. Of course, emulation is slower, but it 
guarantees that your application will run on any platform that has an SDL 
implementation.</P>
<P>However, if you do want information about the video system, there are a few 
functions that you can use. The first of these is SDL_GetVideoInfo.</P>
<BLOCKQUOTE><PRE class=code>SDL_VideoInfo *SDL_GetVideoInfo(void);
</PRE></BLOCKQUOTE>
<P>This function returns a pointer to an SDL_VideoInfo structure. It takes no 
parameters. DO NOT FREE THE POINTER RETURNED FROM THIS FUNCTION!</P>
<P>In order to be effective, you have to call SDL_GetVideoInfo after you have 
initialized the SDL video subsystem. Typically, initialization of SDL is the 
first line in the program. The line looks like this:</P>
<BLOCKQUOTE><PRE class=code>SDL_Init ( SDL_INIT_VIDEO ) ;
</PRE></BLOCKQUOTE>
<P>This single line sets up the video system and the even system (which is 
another topic altogether). After this call, you can call SDL_GetVideoInfo, and 
get information about the best pixel format to use for your system, provided you 
call it before you call SDL_SetVideoMode. Calling SDL_GetVideoInfo after this 
call, you will get the information about the current display mode.</P>
<P>Another thing you can look at, if you really want to, is the name of the 
video driver (it probably won't help you much, but its something to look at, I 
guess). You can retrieve it with the SDL_VideoDriverName function.</P>
<BLOCKQUOTE><PRE class=code>char *SDL_VideoDriverName(char *namebuf, int maxlen);
</PRE></BLOCKQUOTE>
<P>This function takes two parameters, a pointer to a string (namebuf), and an 
int specifying the maximum length of the string to copy (including the 
null-terminator). The value returned is the namebuf pointer if this function is 
successful, and NULL if it fails. It will only fail if you haven't initialized 
the video subsystem. The name of the video driver isn't particularly useful, but 
you might want it for some sort of log file for diagnostic purposes.</P>
<P>This next call is useful if you are targeting full screen applications. The 
function is called SDL_ListModes, and it looks like the following.</P>
<BLOCKQUOTE><PRE class=code>SDL_Rect **SDL_ListModes(SDL_PixelFormat *format, Uint32 flags);
</PRE></BLOCKQUOTE>
<P>This function takes a pointer to an SDL_PixelFormat (or NULL to simply use 
the value retrieved by SDL_GetVideoInfo ( )-&gt;vfmt), and a combination of 
flags ( the same flags that are value for SDL_Surfaces). It spits out an array 
of SDL_Rect pointers that describe the various video modes that have the 
specified format and support the flag specified. If, for example, you need a 
hardware surface with double buffering, you would call SDL_ListModes in the 
following manner.</P>
<BLOCKQUOTE><PRE class=code>SDL_Rect** pModeRects = SDL_ListModes ( NULL , SDL_HWSURFACE |  SDL_DOUBLEBUF ) ;
</PRE></BLOCKQUOTE>
<P>Some special notes about SDL_ListModes. First, it is a NULL terminated list 
of SDL_Rect* variables. Second, if all video modes accept the flag, this 
function will return -1 rather than a pointer. Third, if no video modes accept 
the flag, this function will return NULL. So, this function might be a little 
cumbersome to use.</P>
<P>A different, more directly useful function, SDL_VideoModeOK.</P>
<BLOCKQUOTE><PRE class=code>int SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags);
</PRE></BLOCKQUOTE>
<P>This function takes the width, height, bits per pixel, and flags for a 
potential display surface, and determines if the match up of these values is 
acceptable for the display hardware. Even if they are not, you can still use the 
same parameters to create your display surface, and SDL will emulate for 
you.</P>
<P>If this function returns 0, then no bpp value will work for the flags 
specified. If the return value is non-zero, then it represents the nearest bpp 
that will accept the flags specified. It is best to pick one of the standard 
mode sizes (640x480, 800x600, 1024x768) when picking mode sizes if you are doing 
a full screen application. If you aren't, and the video hardware don't support 
that particular mode, SDL will again emulate it, by placing it on the next 
larger supported size, and limiting output to a rectangle in the middle of the 
screen. So, if you went for a 512x384 mode (which is supported on quite a bit of 
hardware), and the video hardware didn't support it, SDL will throw you into a 
640x480 mode, and place all output in the middle 512x384.</P>
<P>But enough of examining video capabilities... on to creating surfaces!</P>
<H1>Creating and Destroying Surfaces (TGO-02-C)</H1>
<P>Surfaces are the most important part of using SDL's video subsystem. Without 
them, there'd be nothing to see, and how good is an application you can't see? 
(Apologies to ZForm, LLC, whose clients can't read this article anyway--they 
make software for the blind).</P>
<P>The first surface you should create in any SDL based application is the 
display surface. You can create it with the SDL_SetVideoMode function.</P>
<BLOCKQUOTE><PRE class=code>SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags);
</PRE></BLOCKQUOTE>
<P>This function takes a width, height, bits per pixel, and flags, and spits out 
a pointer to an SDL_Surface. This pointer is to the display surface/primary 
surface. If you are doing a full-screen application, you will probably want to 
check out the modes with SDL_ListModes and/or SDL_VideoModeOK, but if you don't 
that's OK.</P>
<P>If you aren't doing a full-screen application, then you should specify 0 for 
bpp, and have SDL_ANYFORMAT as part of your flags. This makes SDL use the 
current format of the display, which makes life easier for you. In windowed 
mode, you can use whatever width and height you like. In WIN32, this will give 
you a window that has a client area of the size you requested.</P>
<P>After calling SDL_SetVideoMode, don't call SDL_FreeSurface on this pointer. 
SDL cleans up the display surface during SDL_Quit, so you don't have to worry 
about it.</P>
<P>In fact, you don't even have to store this pointer anywhere if you don't want 
to. You can use SDL_GetVideoSurface (it takes no parameters) to retrieve a 
pointer to the display surface.</P>
<P>Of course, you'll need more than simply a display surface to make your game, 
unless you plan on making a game with nothing but pixel plotting and filling 
rectangles. You'll need other surfaces as well.</P>
<P>To create a blank surface of a particular size and format, you call 
SDL_CreateRGBSurface.</P>
<BLOCKQUOTE><PRE class=code>SDL_Surface *SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth,
                                  Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
</PRE></BLOCKQUOTE>
<P>To this function, you supply a size (height, width, depth--bpp), and masks 
for red, green, blue, and alpha, along with some flags, and this function gives 
you a pointer to a newly created surface that matches your specifications. 
Typically, you will want to use the same depth and masks as for the display 
surface, but even if you don't, SDL will be able to copy from one to the other, 
but it'll be a little slower. The only valid flags for SDL_CreateRGBSurface are 
SDL_HWSURFACE , SDL_SWSURFACE , SDL_SRCCOLORKEY, and SDL_SRCALPHA. </P>
<P>If this function fails, it returns NULL.</P>
<P>Another function for creating surfaces is SDL_CreateRGBSurfaceFrom. This 
function is much the same as SDL_CreateRGBSurface.</P>
<BLOCKQUOTE><PRE class=code>SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch,
                                      Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
</PRE></BLOCKQUOTE>
<P>The notable differences are the lack of a flags parameter (the surface exists 
in system RAM), and the addition of the pixels parameter and the pitch 
parameter. The pixels parameter is a pointer to pixel data to use for this 
surface, and pitch is how many bytes exist in each scan line, which does not 
have to be width times depth. The other parameters are the same as for 
SDL_CreateRGBSurface. If this function fails, it returns NULL.</P>
<P>Something to keep in mind if you are using SDL_CreateRGBSurfaceFrom: the 
pixels parameter should not be freed until you have freed the surface, since the 
pixel data you supply to this function is the actual pixel data used by the 
surface. It does not make a copy.</P>
<P>The final function for creating a surface is SDL_LoadBMP. This is a damn 
handy function. It loads in a standard windows .bmp file onto a surface, and 
returns the new surface.</P>
<BLOCKQUOTE><PRE class=code>SDL_Surface *SDL_LoadBMP(const char *file);
</PRE></BLOCKQUOTE>
<P>This function takes a single parameter, a pointer to a string containing the 
name of the file you wish to load. It returns the newly created surface, or NULL 
if there is an error.</P>
<P>The SDL_LoadBMP function is a godsend. If you've worked with either 
DirectDraw or GDI, you know how much of a pain it can be to get a stupid bitmap 
loaded. In SDL, its only a single function call! If that's not reason enough to 
move to SDL... I don't know what is.</P>
<P>There are two more really cool functions that you can use to create surfaces, 
but they are used more for pixel format conversion rather than creating 
something in their own right. They take an already existing surface and create a 
new surface, with the same contents, but a different pixel format.</P>
<P>The first of these is SDL_ConvertSurface.</P>
<BLOCKQUOTE><PRE class=code>SDL_Surface *SDL_ConvertSurface(SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags ) ;
</PRE></BLOCKQUOTE>
<P>The parameters are fairly straightforward. You give this function a pointer 
to a surface that you need converted, a pointer to the format you want it 
converted to, and a combinatin of flags ( these flag are the same as those used 
in other surface creation functions). This function creates a surface in the 
requested format, with the requested flags (if possible), and gives you back a 
pointer to a new surface. If this function fails, it'll give you NULL.</P>
<P>The second of these is SDL_DisplayFormat.</P>
<BLOCKQUOTE><PRE class=code>SDL_Surface *SDL_DisplayFormat(SDL_Surface *surface);
</PRE></BLOCKQUOTE>
<P>This function takes a surface, and converts it to the display format, so that 
you can make better use of hardware acceleration, if it exists. It returns a 
pointer to the newly converted surface, or NULL if it fails.</P>
<P>Typically, after calling SDL_ConvertSurface or SDL_DisplayFormat to convert a 
surface, you will want to destroy the old, pre-converted, surface.</P>
<P>Speaking of destroying surfaces, doing so is also quite easy. You simply call 
SDL_FreeSurface.</P>
<BLOCKQUOTE><PRE class=code>void SDL_FreeSurface(SDL_Surface *surface);
</PRE></BLOCKQUOTE>
<P>This function takes a pointer to a surface, and returns no values. The 
surface's refcount member is decremented, and if the refcount reaches 0, then 
the surface is deleted.</P>
<H1>Using SDL Video (TGO-02-D)</H1>
<P>To start with, recall the example we ended with last time (or at least 
something very close):</P>
<BLOCKQUOTE><PRE class=code>#include "SDL.h"

enum {
  SCREENWIDTH = 512,
  SCREENHEIGHT = 384,
  SCREENBPP = 0,
  SCREENFLAGS = SDL_ANYFORMAT
} ;

int main( int argc, char* argv[] )
{
  //initialize systems
  SDL_Init ( SDL_INIT_VIDEO ) ;

  //set our at exit function
  atexit ( SDL_Quit ) ;

  //create a window
  SDL_Surface* pSurface = SDL_SetVideoMode ( SCREENWIDTH , SCREENHEIGHT ,
                                             SCREENBPP , SCREENFLAGS ) ;

  //declare event variable
  SDL_Event event ;

  //message pump
  for ( ; ; )
  {
    //look for an event

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产亚洲欧美色| 国产精品综合av一区二区国产馆| 亚洲午夜久久久久久久久久久| 亚洲精品国久久99热| 亚洲一卡二卡三卡四卡无卡久久 | 在线精品视频一区二区三四| 欧美亚日韩国产aⅴ精品中极品| 91视频国产观看| 成人午夜激情在线| 欧美视频日韩视频| 精品国产乱码久久久久久牛牛 | 免费精品视频最新在线| 久久99蜜桃精品| 顶级嫩模精品视频在线看| 91首页免费视频| 欧美妇女性影城| 精品成人一区二区三区四区| 欧美xxx久久| 国产精品免费视频观看| 亚洲综合色在线| 蜜臀久久久99精品久久久久久| 国产福利一区在线| 99精品久久免费看蜜臀剧情介绍| 欧美精品在线视频| 欧美videos大乳护士334| 国产精品成人一区二区艾草| 日韩国产在线观看一区| 国产精品一二三四五| 色老头久久综合| 欧美日本国产一区| 国产精品久久久久影院| 天天综合网天天综合色| 成人听书哪个软件好| 7777精品伊人久久久大香线蕉最新版 | 国内久久精品视频| 成人av影视在线观看| 欧美精品高清视频| 欧美激情在线免费观看| 日韩精品一二三区| 99久久精品免费看| 欧美色精品在线视频| 日本一区二区在线不卡| 日韩经典一区二区| 91在线一区二区三区| 91精品国产91久久久久久一区二区 | 一区二区欧美精品| 麻豆精品国产91久久久久久| 成人免费毛片高清视频| 欧美日韩免费一区二区三区视频| 欧美草草影院在线视频| 亚洲国产成人va在线观看天堂| 大桥未久av一区二区三区中文| 欧美精品在线一区二区三区| 亚洲欧美色一区| 国产精品99久久久久久似苏梦涵| 欧美无人高清视频在线观看| 欧美国产欧美亚州国产日韩mv天天看完整 | 亚洲欧美福利一区二区| 国产二区国产一区在线观看| 91精品国产综合久久久蜜臀图片| 亚洲欧洲日韩在线| 国产精品一线二线三线| 91精品国模一区二区三区| 亚洲激情综合网| 国产精品一二一区| 欧美精品一区二区三区视频| 亚洲va国产va欧美va观看| 风流少妇一区二区| 亚洲嫩草精品久久| 色综合久久66| 久久久三级国产网站| 青青草精品视频| 欧美日韩精品三区| 亚洲一区二区视频在线观看| 91视频免费看| 国产精品成人免费在线| 成人一区二区三区视频在线观看| 亚洲精品一区二区三区蜜桃下载 | 欧美性生活一区| 一区二区三区精品在线观看| 在线精品视频一区二区| 午夜久久电影网| 欧美岛国在线观看| 国产主播一区二区三区| 中日韩av电影| 色综合天天综合色综合av| 亚洲午夜久久久久久久久久久| 欧美日韩高清在线| 六月丁香婷婷色狠狠久久| 精品电影一区二区三区| 成人少妇影院yyyy| 一级精品视频在线观看宜春院| 欧美色手机在线观看| 久久久www免费人成精品| 秋霞国产午夜精品免费视频| 91精品国产入口| 九色porny丨国产精品| 欧美一区二区三区在线视频| 日韩二区在线观看| 精品少妇一区二区三区在线播放| 蜜桃精品在线观看| 久久久久久亚洲综合影院红桃| 播五月开心婷婷综合| 夜夜精品视频一区二区| 日韩午夜小视频| 成人黄色免费短视频| 无吗不卡中文字幕| 久久亚洲一区二区三区四区| 91亚洲国产成人精品一区二三| 亚洲永久免费视频| 欧美成人aa大片| 91麻豆蜜桃一区二区三区| 亚洲不卡一区二区三区| 久久久亚洲国产美女国产盗摄 | 亚洲国产高清不卡| 91麻豆自制传媒国产之光| 日韩二区三区在线观看| 国产精品无码永久免费888| 欧美中文字幕一二三区视频| 国产一区二区三区四| 99久久久无码国产精品| 午夜国产精品影院在线观看| 久久九九影视网| 欧美日韩一区三区四区| 国产成人精品一区二| 天天av天天翘天天综合网色鬼国产| 国产欧美在线观看一区| 欧美卡1卡2卡| 97se亚洲国产综合自在线不卡| 日本特黄久久久高潮| 亚洲天堂网中文字| 欧美精品一区二区高清在线观看| 日本精品一区二区三区高清 | 国产精品久久久久婷婷| 日韩一区二区麻豆国产| 色综合欧美在线视频区| 国产精品自拍av| 亚洲gay无套男同| 国产精品福利电影一区二区三区四区| 日韩免费视频一区| 欧美久久久久久久久久| 91免费国产在线| 国产精品白丝jk黑袜喷水| 欧美aaaaaa午夜精品| 亚洲综合无码一区二区| 亚洲欧洲av色图| 日本一区二区三区视频视频| 日韩你懂的电影在线观看| 欧美三级在线播放| 99精品欧美一区二区三区小说| 国产乱国产乱300精品| 久久精品国产澳门| 日韩电影免费在线看| 亚洲地区一二三色| 亚洲欧美日韩久久精品| 国产精品国产自产拍高清av| 国产喷白浆一区二区三区| 日韩精品最新网址| 91精品国产综合久久久蜜臀粉嫩| 欧美系列在线观看| 日本丶国产丶欧美色综合| 99久久精品免费看国产| 不卡的av网站| 国产一区二区精品在线观看| 精品中文av资源站在线观看| 午夜视频在线观看一区二区三区| 亚洲精品水蜜桃| 一区二区三区日韩欧美精品| 国产精品理论片| 亚洲欧洲色图综合| 国产精品久久久一本精品| 中文子幕无线码一区tr| 国产女主播一区| 国产丝袜欧美中文另类| 国产午夜精品美女毛片视频| 久久久久综合网| 国产偷国产偷精品高清尤物 | av高清不卡在线| 国产激情视频一区二区三区欧美| 韩国成人精品a∨在线观看| 久久草av在线| 国产精品影音先锋| 丁香亚洲综合激情啪啪综合| 成人网在线播放| 成人av网站免费观看| 97se狠狠狠综合亚洲狠狠| 日本久久一区二区三区| 欧美三区在线观看| 日韩午夜电影av| 久久一留热品黄| 日本一区二区三区视频视频| 中文字幕色av一区二区三区| 一区二区三区在线观看国产| 亚洲国产视频网站| 奇米影视一区二区三区小说| 激情久久久久久久久久久久久久久久| 国产一区视频导航| 99精品久久只有精品| 欧美日韩激情一区二区| 制服丝袜av成人在线看|