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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

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

?? 游戲開發(fā)數(shù)據(jù)結構Data Structures for Game Programmers The Goodies Directory contains all sorts of stuff. For
?? HTM
?? 第 1 頁 / 共 4 頁
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0057)http://www.gamedev.net/reference/articles/article1603.asp -->
<HTML><HEAD><TITLE>GameDev.net - The Simple DirectMedia Layer from a WIN32 Perspective, Part 2: SDL Video</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 6.00.2716.2200" name=GENERATOR><LINK 
href="GameDev_net - The Simple DirectMedia Layer from a WIN32 Perspective, Part 2 SDL Video_files/reference.css" 
type=text/css rel=STYLESHEET><LINK href="/pics/gdicon.png" type=image/png 
rel=icon>
<META DESCRIPTION=""></HEAD>
<BODY text=#000000 vLink=#666699 aLink=#000000 link=#666699 bgColor=#ffffff 
background="GameDev_net - The Simple DirectMedia Layer from a WIN32 Perspective, Part 2 SDL Video_files/watermark.gif">
<TABLE cellSpacing=0 cellPadding=5 width="100%" border=0>
  <TBODY>
  <TR>
    <TD class=tblhdr>The Simple DirectMedia Layer from a WIN32 Perspective, 
      Part 2: SDL Video</TD>
    <TD class=tblhdr align=right><IMG height=16 
      src="GameDev_net - The Simple DirectMedia Layer from a WIN32 Perspective, Part 2 SDL Video_files/littleg.gif" 
      width=16 align=absBottom>&nbsp;<A href="http://www.gamedev.net/"><SPAN 
      style="COLOR: white; TEXT-DECORATION: none">GameDev.net</A></SPAN></TD></TR>
  <TR>
    
    <TD noWrap align=right><B>See Also:</B> <BR><A 
      href="http://www.gamedev.net/reference/list.asp?categoryid=78#179">Featured 
      Articles:Featured Articles</A> <BR><A 
      href="http://www.gamedev.net/reference/list.asp?categoryid=45#188">Game 
      Programming:Simple DirectMedia Layer</A> </TD></TR></TBODY></TABLE>
<P align=center><SPAN class=title>The Simple DirectMedia Layer from a WIN32 
Perspective</SPAN> <BR><SPAN class=subtitle>Part 2: SDL Video</SPAN> <BR><SPAN 
class=author>by <A href="mailto:ernestpazera@hotmail.com">Ernest Pazera</A> 
<BR>December 5, 2001</SPAN></P>
<H1>Mission Statement</H1>
<P>Graphics make the game/application. There is no question about this. In 
WIN32, if you intend to do 2D graphics, you normally have two choices: GDI or 
DirectDraw. GDI is slow as hell, and DirectDraw is MicroSoft specific. Porting 
an application that uses either GDI or DirectDraw to a non-WIN32 platform can be 
painful.</P>
<P>One of your other options is SDL's video component. Keep in mind that SDL can 
only be used (by itself) for 2D graphics. If you want 3D graphics, though, SDL 
works well with OpenGL. For the purposes of this article, we are going to talk 
only about SDL's 2D graphical capabilities.</P>
<P>Here are the TGOs*(Topical Guide Objectives) for this article.</P>
<P>
<TABLE cellSpacing=0 cellPadding=2>
  <TBODY>
  <TR>
    <TD>TGO-02-A</TD>
    <TD>Know the basic structures SDL uses for doing graphics</TD></TR>
  <TR>
    <TD>TGO-02-B</TD>
    <TD>Know how to get information from the SDL video subsystem.</TD></TR>
  <TR>
    <TD>TGO-02-C</TD>
    <TD>Know how to create and destroy various types of SDL surfaces</TD></TR>
  <TR>
    <TD>TGO-02-D</TD>
    <TD>Know how to work with SDL surfaces</TD></TR>
  <TR>
    <TD>TGO-02-D1</TD>
    <TD>Know how to do filled rectangles</TD></TR>
  <TR>
    <TD>TGO-02-D2</TD>
    <TD>Know how to get and set pixels</TD></TR>
  <TR>
    <TD>TGO-02-D3</TD>
    <TD>Know how to blit from one surface to another</TD></TR>
  <TR>
    <TD>TGO-02-D4</TD>
    <TD>Know how to use color keys</TD></TR>
  <TR>
    <TD>TGO-02-D5</TD>
    <TD>Know how to clip output</TD></TR></TBODY></TABLE>
<P>*About TGOs: The concept of TGOs I borrowed from the United States Navy. In 
training programs, the specific knowledge that you are responsible for having 
are all listed in a book of Topical Guide Objectives. This book is referred to 
as the "Topical Guide". TGOs are good for both the reader and the author, as it 
lets the reader know exactly what he or she will be learning at a glance, and it 
reminds the author exactly what he will be covering.</P>
<H1>Basic Structures (TGO-02-A)</H1>
<P>As of version 1.2.3 of SDL, there are seven structures in the library that 
deal with the video subsystem. These are SDL_Rect, SDL_Color, SDL_Palette, 
SDL_PixelFormat, SDL_Surface, SDL_VideoInfo, and SDL_Overlay. Most of them do 
exactly what you'd expect them to do. We're going to cover the first six of 
these (leaving out SDL_Overlay).</P>
<H2>SDL_Rect</H2>
<P>SDL_Rect is one of the simpler structures. As you probably guessed, it 
abstracts a rectangular area on the screen. Here's what it looks like:</P>
<BLOCKQUOTE><PRE class=code>typedef struct{
  Sint16 x, y;
  Uint16 w, h;
} SDL_Rect;
</PRE></BLOCKQUOTE>
<P>This is a pretty standard rectangle structure, unless of course you are used 
to working with the WIN32 RECT structure. The x and y members contain the upper 
left hand corner. The w and h members contain the width and height. All of these 
members measure units in pixels (and never anything but pixels).</P>
<P>A brief note about some of the odd looking types used in SDL: because it is 
cross platform, the writers of SDL had to make some integral types that would be 
the same size no matter what platform they were used on. Considering differences 
between platforms and the size of the int type, they came up with things like 
Sint16 and Uint16, there are a number of types like these. They all take the 
form:</P>
<BLOCKQUOTE><PRE class=code>[S|U]int[n]
</PRE></BLOCKQUOTE>
<P>In front of the type name, you will see either an S or a U. S stands for 
"signed" and U stands for "unsigned". n is a number, either 8, 16, or 32.</P>
<P>In the case of SDL_Rect, x and y are Sint16s, and so they range from -32768 
to +32767, which is more than enough to deal with rectangular areas of the 
screen. The w and h members are Uint16s, and so can range from 0 to 65535. 
Notice that these are always non-negative, since you cannot have a rectangle 
with a negative width or height (unlike in the WIN32 RECT structure).</P>
<P>A point (x,y) lies within a rectangle (rect) if the all of the following are 
true:</P>
<BLOCKQUOTE><PRE class=code>x &gt;= rect.x
y &gt;= rect.y
x &lt; ( rect.x + rect.w )
y &lt; ( rect.y + rect.h )
</PRE></BLOCKQUOTE>
<P>If a rectangles w or h members are 0, it is an empty rectangle, and it 
contains no points whatsoever. There are absolutely no functions whatsoever for 
working with SDL_Rects (like the ones they have for WIN32 RECTs, like OffsetRect 
or UnionRect or IntersectRect), so if you need them, you have to make them 
yourself.</P>
<H2>SDL_Color</H2>
<P>The second structure is just as simple. SDL_Color abstracts an RGB color 
value in an independent way. Here's what it looks like:</P>
<BLOCKQUOTE><PRE class=code>typedef struct{
  Uint8 r;
  Uint8 g;
  Uint8 b;
  Uint8 unused;
} SDL_Color;
</PRE></BLOCKQUOTE>
<P>SDL_Color is a lot like the WIN32 PALETTEENTRY or RGBQUAD structure. It 
contains four Uint8 values (bytes), and each member can range from 0 to 255. The 
r, g, and b members represent a colors red, green, and blue value. The unused 
member is just that--unused. Just sort of pretend it doesn't exist.</P>
<P>No functions exist for working with the SDL_Color structure either. If you 
want them, you can make your own, or just work with the members themselves. I 
personally like wrapping SDL_Color into a class.</P>
<H2>SDL_Palette</H2>
<P>In theory, the use of palettes has gone the way of the dinosaur. Still, there 
are times when they are useful, and so SDL has them. Palettes in SDL are 
strictly 8 bit palettes, for 256 different colors. However, you can make a 
palette whatever size you like, for example you could make one 256 color master 
palette, and then 8 different 8 color palettes that you use for palette 
animation and overwrite only a certain portion of the actual palette with those 
eight colors.</P>
<P>The SDL_Palette structure is pretty simple:</P>
<BLOCKQUOTE><PRE class=code>typedef struct{
  int ncolors;
  SDL_Color *colors;
} SDL_Palette;
</PRE></BLOCKQUOTE>
<P>The ncolors member is the number of colors in the palette. The colors member 
is a pointer to an array of SDL_Color values. You have to work with these 
members manually, allocating and deallocating colors, setting them, and so on. 
SDL doesn't include any functions for working with palettes, other than those 
that set the palette entries for a surface.</P>
<P>SDL_Palette is roughly akin to IDirectDrawPalette, but without any of the 
encapsulation. </P>
<H2>SDL_PixelFormat</H2>
<P>This structure is highly useful. It is similar in purpose to the 
DDPIXELFORMAT structure of DirectDraw. It describes everything you'd ever want 
to know about how pixels are represented for a particular surface. Here's what 
it looks like:</P>
<BLOCKQUOTE><PRE class=code>typedef struct{
  SDL_Palette *palette;
  Uint8  BitsPerPixel;
  Uint8  BytesPerPixel;
  Uint32 Rmask, Gmask, Bmask, Amask;
  Uint8  Rshift, Gshift, Bshift, Ashift;
  Uint8  Rloss, Gloss, Bloss, Aloss;
  Uint32 colorkey;
  Uint8  alpha;
} SDL_PixelFormat;
</PRE></BLOCKQUOTE>
<P>Everything you want to know about a pixel format is right here. First, the 
palette member is a pointer to an SDL_Palette, if the format has one. If not, 
this member will be NULL.</P>
<P>Next, BitsPerPixel and BytesPerPixel specify how many bits and bytes are per 
pixel for this format (kind of obvious from the name, no?).</P>
<P>The next group of members are Rmask, Gmask, Bmask, and Amask. These are the 
bit masks in the pixel format for each of the color components, Rmask for red, 
Gmask for green, Bmask for blue, and Amask for alpha. These are useful for using 
the &amp; operator to isolate certain color components.</P>
<P>The next group, Rshift, Gshift, Bshift, and Ashift specify the bit position 
in the pixel that begins the color component in question. After you take a pixel 
value and &amp; with the Rmask value, you can &gt;&gt; by the Rshift value to 
get it in the lowest bits of the variable.</P>
<P>Rloss, Gloss, Bloss, and Aloss is another group of members used for color 
conversion. These members contain the number of bits that are lost when starting 
from an 8 bit value. After you have &amp; by the Rmask, and &gt;&gt; by the 
Rshift, you can &lt;&lt; by Rloss, and you'll have a value in the range of 0 to 
255 for your red component. This makes color conversion to and from SDL_Color 
values really easy.</P>
<BLOCKQUOTE><PRE class=code>//color is an SDL_Color, and format is an SDL_PixelFormat
//convert color to native format
Uint32 native = 0 ;
Uint32 red , green , blue ;
red = color.r &gt;&gt; format.Rloss ;
green = color.g &gt;&gt; format.Gloss ;
blue = color.b &gt;&gt; format.Bloss ;
red &lt;&lt;= format.Rshift ;
green &lt;&lt;= format.Gshift ;
blue &lt;&lt;= format.Bshift ;

//convert native pixel to SDL_Color
red = native &amp; format.Rmask ;
green = native &amp; format.Gmask ;
blue = native &amp; format.Bmask ;
red &gt;&gt;= format.Rshift ;
green &gt;&gt;= format.Gshift ;
blue &gt;&gt;= format.Bshift ;
red &lt;&lt;= format.Rloss ;
green &lt;&lt;= format.Gloss ;
blue &lt;&lt;= format.Bloss ;
color.r = red ;
color.g = green ;
color.b = blue ;
</PRE></BLOCKQUOTE>
<P>Pretty simple, right? Don't worry too much about this code, though. SDL 
provides functions that will do these things for you.</P>
<P>The colorkey member of SDL_PixelFormat stores the transparent color for the 
format. This color is in the native pixel format, not as an SDL_Color.</P>
<P>Finally, the alpha member is an eight bit value that stores an overall alpha 
value for the surface.</P>
<H1>SDL_Surface</H1>
<P>Just like the IDirectDrawSurface object in DirectDraw and the HDC in GDI, the 
SDL_Surface is the most important structure in the SDL video subsystem. It 
abstracts a rectangular area of pixel data. Here's what it looks like:</P>
<BLOCKQUOTE><PRE class=code>typedef struct SDL_Surface {
  Uint32 flags;
  SDL_PixelFormat *format;
  int w, h;
  Uint16 pitch;
  void *pixels;
  SDL_Rect clip_rect;
  int refcount;
} SDL_Surface;
</PRE></BLOCKQUOTE>
<P>There are actually more members than this, but they should not be publicly 
accessed, and so are not shown.</P>
<P>The flags member contains a combination of bit flags that describe what type 
of surface this is. These flags are listed and briefly explained in table 1.</P>
<TABLE cellSpacing=0 cellPadding=3 width=590 border=1>
  <TBODY>
  <TR>
    <TD class=tblhdr colSpan=2>Table 1: Surface Flags</TD></TR>
  <TR vAlign=top>
    <TD class=tblhdr width="30%">Flag</TD>
    <TD class=tblhdr width="70%">Meaning</TD></TR>
  <TR vAlign=top>
    <TD>SDL_SWSURFACE</TD>
    <TD>Surface exists in software (non-video RAM)</TD></TR>
  <TR>
    <TD>SDL_HWSURFACE</TD>
    <TD>Surface exists in video RAM.</TD></TR>
  <TR>
    <TD>SDL_ASYNCBLIT</TD>
    <TD>Blits occur asynchronously.</TD></TR>
  <TR>
    <TD>SDL_ANYFORMAT*</TD>
    <TD>This flag specifies to use whatever the current display format is for 
      the display surface. Typically, this is used when making a windowed SDL 
      application.</TD></TR>
  <TR>
    <TD>SDL_HWPALETTE</TD>
    <TD>The surface makes use of a hardware palette.</TD></TR>
  <TR>
    <TD>SDL_DOUBLEBUF*</TD>
    <TD>The surface is double buffered (i.e. a flipping chain).</TD></TR>
  <TR>
    <TD>SDL_FULLSCREEN*</TD>
    <TD>The surface is full screen.</TD></TR>
  <TR>
    <TD>SDL_OPENGL*</TD>
    <TD>The surface will be used as a destination for OpenGL rendering.</TD></TR>
  <TR>
    <TD>SDL_OPENGLBLIT*</TD>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
美国毛片一区二区三区| 在线观看一区二区精品视频| 日韩一级二级三级| 亚洲国产精品一区二区www | 日本精品免费观看高清观看| 亚洲图片激情小说| av中文字幕亚洲| ㊣最新国产の精品bt伙计久久| 东方aⅴ免费观看久久av| 国产精品视频线看| 91麻豆自制传媒国产之光| 樱花影视一区二区| 欧美日韩激情在线| 麻豆免费精品视频| 国产欧美日韩麻豆91| 99久久er热在这里只有精品15| 亚洲欧美日韩在线不卡| 欧美日韩三级在线| 美国精品在线观看| 国产精品久久久久久一区二区三区| 成人污污视频在线观看| 亚洲精品日日夜夜| 日韩欧美中文一区| 岛国av在线一区| 亚洲动漫第一页| 精品国产1区2区3区| 91偷拍与自偷拍精品| 午夜精品视频在线观看| 久久综合九色综合久久久精品综合| 成人av在线资源网站| 亚洲一二三专区| 久久日一线二线三线suv| a美女胸又www黄视频久久| 亚州成人在线电影| 久久久精品黄色| 欧美中文一区二区三区| 美日韩一区二区| 亚洲日本一区二区三区| 日韩欧美国产三级电影视频| 成人在线视频首页| 丝袜诱惑亚洲看片| 国产精品久久久久久久久免费丝袜| 欧美人伦禁忌dvd放荡欲情| 国产激情精品久久久第一区二区| 亚洲精品欧美专区| 久久综合久久鬼色| 欧美日本一区二区三区| 成人美女在线视频| 蜜桃av噜噜一区| 亚洲一区二区三区自拍| 国产欧美日韩三级| 精品国产91洋老外米糕| 欧美三级在线视频| 99精品久久免费看蜜臀剧情介绍| 精品中文字幕一区二区 | 亚洲成在线观看| 国产欧美日本一区二区三区| 在线播放亚洲一区| 日本精品视频一区二区| 综合久久久久久| 亚洲欧美日韩成人高清在线一区| 欧美一个色资源| 91麻豆国产在线观看| 韩国v欧美v日本v亚洲v| 亚洲成av人片在线观看| 亚洲免费成人av| 国产欧美日韩激情| 2欧美一区二区三区在线观看视频| 欧美亚一区二区| 波多野洁衣一区| 丁香激情综合国产| 国产精品911| 国内精品久久久久影院一蜜桃| 日韩有码一区二区三区| 午夜精品久久久久久久蜜桃app| 亚洲欧洲综合另类在线| 中文字幕一区av| 国产精品成人一区二区艾草| 亚洲国产成人午夜在线一区| 久久久99精品免费观看| 精品国产精品网麻豆系列| 欧美刺激脚交jootjob| 日韩一区二区精品在线观看| 日韩色视频在线观看| 欧美日韩国产成人在线免费| 色妞www精品视频| 91啦中文在线观看| 色综合久久中文字幕综合网 | 久久久久久久综合日本| 精品国产乱码久久久久久蜜臀 | 一区二区三区国产豹纹内裤在线| 亚洲欧洲精品成人久久奇米网| 久久老女人爱爱| 久久精品亚洲精品国产欧美| 久久精品免视看| 国产精品久久福利| 中文字幕二三区不卡| 国产精品成人一区二区三区夜夜夜 | 国产v综合v亚洲欧| av在线不卡观看免费观看| 在线看不卡av| 欧美男人的天堂一二区| 日韩精品一区二区三区swag| 久久综合狠狠综合久久激情 | 久久久国产精品午夜一区ai换脸| 久久久国际精品| 国产精品视频一区二区三区不卡| 一区二区中文视频| 亚洲一区在线观看免费| 蜜桃av噜噜一区| 成人福利视频网站| 欧美三级日韩三级国产三级| 欧美一区二区国产| 中文字幕电影一区| 亚洲福利视频一区| 国产一区视频在线看| 99v久久综合狠狠综合久久| 欧洲激情一区二区| 亚洲精品在线免费观看视频| 国产精品久久久久久久久免费相片| 亚洲一区二区三区视频在线 | 欧美日韩久久一区二区| 在线播放中文字幕一区| 国产视频亚洲色图| 亚洲综合清纯丝袜自拍| 国产麻豆成人精品| 欧美日韩一级黄| 国产精品国产自产拍高清av| 天天影视涩香欲综合网| 成人av网址在线观看| 91精品国产综合久久香蕉麻豆| 国产嫩草影院久久久久| 五月天久久比比资源色| 国产成人午夜精品影院观看视频| 欧美色倩网站大全免费| 国产区在线观看成人精品| 日日摸夜夜添夜夜添国产精品| 成人毛片老司机大片| 欧美一区二区三区四区高清| 国产精品丝袜久久久久久app| 日韩精品亚洲一区二区三区免费| 成人激情av网| 精品少妇一区二区三区免费观看| 伊人性伊人情综合网| 国内精品伊人久久久久影院对白| 91福利国产成人精品照片| 久久久青草青青国产亚洲免观| 亚洲电影一区二区| 99re这里只有精品6| 久久久久久久久岛国免费| 日韩精品一区第一页| 99天天综合性| 国产亚洲欧洲997久久综合| 亚洲国产中文字幕| 福利一区在线观看| 欧美精品一区二区在线观看| 免费成人美女在线观看| 欧美精品精品一区| 午夜视频一区二区三区| 91国在线观看| 亚洲综合在线视频| 一本色道久久综合精品竹菊| 欧美国产欧美综合| 国产美女在线精品| 久久婷婷国产综合精品青草| 久久精品国产精品青草| 欧美日本高清视频在线观看| 中文字幕永久在线不卡| 精品一区二区三区久久| 91精品国产品国语在线不卡| 日韩黄色免费电影| 欧美精品 国产精品| 天天影视色香欲综合网老头| 欧美日韩一区 二区 三区 久久精品| 亚洲欧美二区三区| 91麻豆高清视频| 亚洲欧美日韩国产另类专区| 色狠狠一区二区| 婷婷六月综合亚洲| 欧美日韩精品一区二区三区蜜桃| 亚洲国产日韩a在线播放性色| 欧美中文一区二区三区| 成人亚洲一区二区一| 国产精品视频yy9299一区| 99久久久国产精品免费蜜臀| 国产欧美一区二区精品性色超碰| 国产成人精品亚洲777人妖| 国产精品美女久久久久久久| 9i在线看片成人免费| 亚洲综合免费观看高清完整版在线| 色88888久久久久久影院按摩| 亚洲一区国产视频| 日韩一区二区免费高清| 盗摄精品av一区二区三区| 亚洲精品美腿丝袜| 7777精品伊人久久久大香线蕉 | 老司机精品视频线观看86| 久久久亚洲午夜电影| 91视频在线看| 日本成人在线网站|