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

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

?? gamedev_net - the simple directmedia layer from a win32 perspective, part 1 setting up your system for sdl.htm

?? 游戲開發數據結構Data Structures for Game Programmers The Goodies Directory contains all sorts of stuff. For
?? HTM
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0057)http://www.gamedev.net/reference/articles/article1598.asp -->
<HTML><HEAD><TITLE>GameDev.net - The Simple DirectMedia Layer from a Win32 Perspective, Part 1: Setting Up Your System for SDL</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 1 Setting Up Your System for SDL_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 1 Setting Up Your System for SDL_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 1: Setting Up Your System for SDL</TD>
    <TD class=tblhdr align=right><IMG height=16 
      src="GameDev_net - The Simple DirectMedia Layer from a Win32 Perspective, Part 1 Setting Up Your System for SDL_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 1: Setting Up Your System for 
SDL</SPAN> <BR><SPAN class=author>by <A 
href="mailto:ernestpazera@hotmail.com">Ernest S. Pazera</A> <BR>November 19, 
2001</SPAN> 
<H1>Mission Statement</H1>
<P>Lots of people dislike DirectX, for one reason or another. Some say it is too 
complicated, others don't like being locked into a single development platform. 
For whatever reason, people look for alternatives. For a long time, the 
alternatives available have been a bunch of separate systems that were not built 
to work together in the same way that DirectX's components do. However, there is 
SDL, the Simple DirectMedia Layer. It is a cross-platform library for creating 
multi-media applications. For our purposes, this means games. Since it is 
cross-platform, and I mean TRULY cross platform, it doesn't matter what platform 
you are developing on. If you develop carefully, you will be able to take the 
exact same source code onto a different platform, and it will compile and work 
in exactly the same manner. 
<P>The mission of this article is to get you up and running in SDL on the WIN32 
platform. For a long time, I have been primarily a WIN32 programmer, and while 
this might change in the future, I know that many of you are also WIN32 
programmers, so we at least have that in common. During this article, we won't 
do a whole heck of a lot. We'll get SDL installed and a simple example program 
that shows a blank window. Believe it or not, that is the hardest part of SDL 
development. The rest is incredibly easy. 
<P>So, to begin, here are the Topical Guide Objectives for this article: 
<P>
<TABLE cellSpacing=0 cellPadding=2 border=0>
  <TBODY>
  <TR>
    <TD>TGO-01-A&nbsp;&nbsp;&nbsp;</TD>
    <TD>Know where to get SDL.</TD></TR>
  <TR>
    <TD>TGO-01-B</TD>
    <TD>Know how to set up Visual C++ 6.0 for SDL development.</TD></TR>
  <TR>
    <TD>TGO-01-C</TD>
    <TD>Know how to start an SDL based project in Visual C++ 6.0.</TD></TR>
  <TR>
    <TD>TGO-01-D</TD>
    <TD>Make a very simple program to test your setup.</TD></TR>
  <TR>
    <TD>TGO-01-E</TD>
    <TD>Make a very simplistic program with SDL</TD></TR></TBODY></TABLE>
<H1>Getting SDL(TGO-01-A)</H1>
<P>Naturally, the first part of the process is to download SDL. You can find it 
at <A href="http://www.libsdl.org/">http://www.libsdl.org/</A>. At the time of 
this writing, the most current version of the API is 1.2.3, and that is the 
version this article deals with. On the SDL site, you want to download the 
development libraries for WIN32. The site is well laid out, and it should be 
really easy for you to find it. They distribute the API as a zip file, so you'll 
need a copy of WinZip or some other type of archive utility to extract the 
files. Once you have it downloaded, unzip it somewhere, and take a look at the 
contents. 
<P>In the folder you unzip to, there are three subfolders: docs, include, and 
lib. These are fairly obvious, and we'll take a look at them a little later. 
<P>There are also a number of files, like Bugs, Copying, Readme, and so forth. 
You should take the time to read all of these, especially Bugs and Copying. SDL 
is released under the LGPL license, and if you intend to use SDL for creating 
applications that you wish to sell, you'll need to follow the license. See <A 
href="http://www.gnu.org/">http://www.gnu.org/</A> for more information on the 
LGPL. 
<H1>Setting up Visual C++(TGO-01-B)</H1>
<P>The API comes with good documentation for setting up projects in WIN32 with 
SDL, but the docs lack just a little bit in that you have to go through the 
entire setup EVERY TIME you want to make an SDL base project. Well, you don't 
have to. There are some things that you only need to do once, and other things 
that you have to do for each project (which we shall cover in TGO-01-C). 
<P>The tasks you only have to do once are to set up the include path and library 
path for your development environment. In VC++6 you simply call up 
Tools-&gt;Options..., select the Directories tab, and add the appropriate 
directories to the Include Files and Library Files list and you are done. You 
will never ever have to do this again unless you uninstall VC++. 
<H1>Setting up an SDL Project(TGO-01-C)</H1>
<P>To set up a project to use SDL, you will have to go through a few steps every 
time. This isn't terribly uncommon-- you have to do the same thing if you are 
using DirectX. The type of project you want to create is a WIN32 Application, 
and have it start with an empty project. 
<P>Select the Project-&gt;Settings... menu item, and select the "C/C++" tab of 
the dialog that comes up. In the top combo box (with the word "Category" next to 
it on the left), select "Code Generation". Next, go over to the combo box 
entitled "Use Run-Time Library", and select "Multithreaded DLL". 
<P>Still in the Settings dialog, move over to the "Link" tab. In the "General" 
category, you want to edit the content of the "Object/Library Modules" text box. 
At the beginning of this text box, add "SDLmain.lib" and "SDL.lib". 
<P>Now click OK. The last step is to copy SDL.dll from the lib directory of SDL 
into the directory of your project. Without this dll, your application won't 
work. 
<P>And you are done with the SDL set up for this project. Every time you want to 
create a project using SDL, you have to do this. It's not too much, really. 
<H1>Testing the Environment(TGO-01-D)</H1>
<P>Now you've got the development environment set, and the project set, and it's 
time to test everything out to make sure it works. Create a new .cpp file for 
the project called main.cpp, and add the following code. 
<BLOCKQUOTE><PRE class=code>#include "SDL.h"
int main ( int argc , char* argv [] )
{
  return ( 0 ) ;
}
</PRE></BLOCKQUOTE>
<P>The first question to pop into your head is likely "Where did WinMain go?" 
This is a WIN32 Application, after all, and in WIN32 Applications, we always 
have to put in a WinMain, right? Well, no. In the .lib files that come with SDL 
all of the platform dependent stuff like WinMain are taken care of. The entry 
point for all SDL based applications will be main. Also, you will never want to 
include windows.h into any of your projects, because to do so would make it 
platform dependent, which nullifies one of the main goals of using SDL in the 
first place. 
<P>So, of course, this program does approximately nothing, but it is good for 
testing out the development environment. Attempt to compile and run this code. 
If it works, you know you've set up the environment and project successfully. If 
it doesn't, you forgot to do something. Don't be surprised when you run the 
application and nothing happens. Nothing is SUPPOSED to happen. As long as you 
don't get some sort of run-time error, you're OK. 
<H1>A Simple SDL Application (TGO-01-E)</H1>
<P>Delete everything in main.cpp, and replace it with the following code: 
<BLOCKQUOTE><PRE class=code>#include "SDL.h"
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 ( 512 , 384 , 0, SDL_ANYFORMAT ) ;
  //declare event variable
  SDL_Event event ;
  //message pump
  for ( ; ; )
  {
    //look for an event
    if ( SDL_PollEvent ( &amp;event ) )
    {
      //an event was found
      if ( event.type == SDL_QUIT ) break ;
    }
  }//end of message pump
  //done
  return ( 0 ) ;
}
</PRE></BLOCKQUOTE>
<P>Compile this and run it (we'll go though each of the lines in a moment). If 
you've done everything correctly, you will be met with a blank, black window 
with "SDL_App" in the title bar. You can move this window around, and hit the X 
button in the corner to close it. It is a pretty minimal application, but it's a 
lot easier than the equivalent WIN32 application that uses DirectX, I guarantee. 

<P>Now for a bit of explanation. We'll start with the first line of the program. 

<BLOCKQUOTE><PRE class=code>SDL_Init ( SDL_INIT_VIDEO ) ;
</PRE></BLOCKQUOTE>
<P>As you might imagine, SDL_Init is used to initialize the various subsystems 
of SDL. In this case, we are only initializing the video subsystem. Calling 
SDL_Init is akin to making use of an IDirectDraw or IDirectSound object, all 
rolled into one. 
<BLOCKQUOTE><PRE class=code>atexit ( SDL_Quit ) ;
</PRE></BLOCKQUOTE>
<P>If you've never used the atexit function before, it sets up another function 
to be called when the program terminates. This is an old C function that was 
used before C++ came around and made garbage collection a bit easier with the 
use of destructors. This line sets up SDL_Quit to be called after the program 
has terminated. SDL_Quit uninitializes all of SDL for you, so you don't have to. 
Alternately, you could call SDL_Quit at the end of your program, and you would 
accomplish the same thing. SDL_Quit is akin to calling IDirectDraw::Release and 
IDirectSound::Release all in one. 
<BLOCKQUOTE><PRE class=code>SDL_Surface* pSurface = SDL_SetVideoMode ( 512 , 384 , 0, SDL_ANYFORMAT ) ;
</PRE></BLOCKQUOTE>
<P>It's only the third line of the program, and already we are setting up the 
video mode. In a normal WIN32 program, we wouldn't even be half way through 
setting up our WNDCLASSEX structure. Without over explaining, SDL_Surface is a 
structure that abstracts a rectangular set of pixels on which you can draw. It 
is roughly akin to an HDC or an IDirectDrawSurface. The SDL_SetVideoMode 
function sets up your display. Despite the functions name, it doesn't always set 
a different display mode, and it certainly doesn't in this case. The parameters 
are width, height, bits per pixel, and flags. In this case, I am creating a 
512x384 surface, but I have a 0 for the bits per pixel. This is because I am 
using the SDL_ANYFORMAT flag. With this flag, the current format of the display 
is taken as the format for the surface, so it doesn't really matter what is 
placed into the third parameter. I could indeed specify a number for this 
parameter and leave off the SDL_ANYFORMAT flag, and SDL would accommodate me by 
giving me a surface in the format I requested, regardless of the screen's 
format. This isn't a good idea, because it requires SDL to "fake" the format if 
it doesn't match the screen's format. So, if you are making a windowed 
application, use the SDL_ANYFORMAT flag. 
<BLOCKQUOTE><PRE class=code>SDL_Event event ;
//message pump
for ( ; ; )
{
  //look for an event
  if ( SDL_PollEvent ( &amp;event ) )
  {
    //an event was found
    if ( event.type == SDL_QUIT ) break ;
  }
}//end of message pump
</PRE></BLOCKQUOTE>
<P>We will take a look at the rest of the code (minus the line with return on 
it... I assume you know what THAT does) all at once. SDL_Event is another SDL 
structure. This time, it abstracts events, something you are likely more than 
used to in WIN32 programming. Like WIN32, SDL is event driven, and so we have a 
message pump. The SDL message pump is a lot simpler than the equivalent WIN32 
message pump, of course. 
<P>Some folks prefer while(1) for their message pump, but I'm one of those who 
prefer for(;;). I feel it more accurately describes what I'm doing. Both 
statements are equivalent, of course, so it doesn't really matter which way you 
do it. 
<P>The SDL_PollEvent function checks for a event in the queue. If there is no 
message waiting, it returns 0. If a message is waiting, it returns 1, and copies 
the event into the parameter passed to it, in this case the variable I have so 
aptly named "event". 
<P>Only if SDL_PollEvent returns non-zero (i.e. an event has occurred) does the 
next line get called. In this case, the type member of SDL_Event is checked to 
see if it is SDL_QUIT, which is the event for exiting the application. If this 
has happened, we break out of the message pump loop and proceed to exit the 
application. 
<H1>Summary</H1>
<P>So, is everything about SDL this easy? Yes, pretty much. As I said earlier, 
the hardest part is setting up the environment. After that, everything is mostly 
the same as a regular WIN32 application, just with different functions. The key 
is that this API is called the SIMPLE DirectMedia Layer. From here, I suggest 
taking a look at some of the SDL docs and playing around with the API, at least 
until someone convinces me to get off my duff and write another tutorial. 
<P align=center><B><A 
href="http://www.gamedev.net/community/forums/topic.asp?key=featart&amp;uid=1598&amp;forum_id=35&amp;Topic_Title=The+Simple+DirectMedia+Layer+from+a+Win32+Perspective%2C+Part+1%3A+Setting+Up+Your+System+for+SDL">Discuss 
this article in the forums</A></B></P>
<P><BR><SPAN class=maintext-2>Date this article was posted to GameDev.net: 
<B>12/4/2001</B> <BR>(Note that this date does not necessarily correspond to the 
date the article was written)</SPAN> 
<P align=center>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人福利在线看| 国产乱码精品一区二区三区五月婷| 亚洲精品一区二区三区香蕉| 欧美影院午夜播放| 在线视频国内自拍亚洲视频| 一本一本大道香蕉久在线精品| 91在线观看高清| 99re亚洲国产精品| 在线观看视频欧美| 欧美日韩国产美女| 欧美大片日本大片免费观看| 91精品国产乱码久久蜜臀| 欧美一区二区在线播放| 日韩欧美久久久| 国产日产欧美一区| 国产精品国产三级国产aⅴ原创| 中文字幕在线免费不卡| 夜夜揉揉日日人人青青一国产精品| 亚洲嫩草精品久久| 午夜精品久久久久久久蜜桃app| 图片区小说区国产精品视频| 久久国产精品72免费观看| 国产精品综合二区| 99国产精品视频免费观看| 欧美日韩美女一区二区| 亚洲精品一线二线三线| 成人欧美一区二区三区视频网页| 亚洲自拍偷拍av| 国内精品久久久久影院薰衣草| 成人av网址在线| 这里只有精品视频在线观看| 久久久www成人免费毛片麻豆| 尤物av一区二区| 久久国产欧美日韩精品| 91亚洲精品一区二区乱码| 日韩欧美色综合| 亚洲最大成人综合| 韩国女主播一区| 欧美日韩国产高清一区| 亚洲国产成人自拍| 青青草国产成人av片免费| 粉嫩绯色av一区二区在线观看| 色八戒一区二区三区| 国产亚洲视频系列| 日本在线不卡视频一二三区| 色综合久久天天综合网| 2020日本不卡一区二区视频| 亚洲成人av一区| 91在线无精精品入口| 久久午夜免费电影| 美女脱光内衣内裤视频久久影院| 97久久超碰精品国产| 久久色中文字幕| 日本不卡一二三区黄网| 欧美午夜一区二区三区| 国产精品麻豆久久久| 国内精品第一页| 日韩精品在线一区| 秋霞国产午夜精品免费视频| 91久久精品一区二区三| 一区二区中文视频| 波多野结衣91| 中日韩av电影| 高清国产一区二区三区| 久久久久成人黄色影片| 狠狠久久亚洲欧美| 日韩欧美亚洲一区二区| 麻豆精品在线看| 日韩精品自拍偷拍| 韩国女主播一区| 国产亚洲一二三区| 风流少妇一区二区| 国产精品久久久久影院| 成人国产免费视频| 亚洲另类在线制服丝袜| 色综合久久久久| 一区二区免费视频| 欧美午夜理伦三级在线观看| 亚洲第一激情av| 欧美精品乱码久久久久久按摩| 午夜欧美在线一二页| 精品视频免费看| 男男视频亚洲欧美| 欧美mv和日韩mv国产网站| 国产精品一区久久久久| 国产精品久久久久久久久久免费看| 成人黄色一级视频| 一区二区三区精品| 91精品国产高清一区二区三区| 丝袜美腿亚洲一区| 久久久综合激的五月天| 成人av在线电影| 亚洲国产精品影院| 日韩欧美区一区二| 不卡的av网站| 午夜欧美在线一二页| 精品国产免费久久| 91蜜桃网址入口| 青青草原综合久久大伊人精品 | 亚洲午夜精品在线| 欧美一区二区三区男人的天堂| 精品亚洲免费视频| 国产精品国产三级国产aⅴ原创| 欧洲在线/亚洲| 欧美a级一区二区| 国产日产精品一区| 56国语精品自产拍在线观看| 国产一区不卡视频| 亚洲精品亚洲人成人网| 日韩小视频在线观看专区| 懂色一区二区三区免费观看 | 日韩影视精彩在线| 日本一区二区三区在线观看| 色素色在线综合| 狠狠久久亚洲欧美| 亚洲成人午夜影院| 久久久亚洲精品一区二区三区| 色综合天天综合网天天狠天天| 日本在线不卡视频| 亚洲欧美成人一区二区三区| 欧美mv日韩mv国产网站app| 欧美亚洲国产一区二区三区va| 狠狠色丁香婷婷综合久久片| 亚洲电影欧美电影有声小说| 国产精品毛片久久久久久久 | 高清av一区二区| 免费成人在线网站| 亚洲成av人片一区二区梦乃 | 美国三级日本三级久久99| 日韩一区日韩二区| 国产日韩欧美a| 欧美r级在线观看| 日韩一区二区不卡| 欧美日韩情趣电影| 色琪琪一区二区三区亚洲区| 丁香天五香天堂综合| 秋霞午夜av一区二区三区| 亚洲成人av免费| 婷婷激情综合网| 亚洲一区二区视频| 一区二区三区四区激情| 亚洲另类在线一区| 亚洲色图都市小说| 亚洲欧美日韩国产成人精品影院| 国产亚洲1区2区3区| 久久一夜天堂av一区二区三区| 日韩视频在线你懂得| 日韩午夜在线观看视频| 欧美一区二区三区喷汁尤物| 欧美日韩国产区一| 日韩三区在线观看| 欧美成人a在线| 欧美xfplay| 久久精品夜色噜噜亚洲aⅴ| 久久蜜臀中文字幕| 久久久亚洲国产美女国产盗摄| 国产亚洲精品超碰| 国产精品国产三级国产aⅴ入口| 日韩理论片网站| 亚洲在线视频一区| 石原莉奈一区二区三区在线观看| 性久久久久久久久久久久| 男男gaygay亚洲| 国产精品一区二区三区乱码| 国产成人小视频| 91视频国产资源| 欧美三级资源在线| 精品少妇一区二区三区视频免付费| 日韩欧美aaaaaa| 国产精品第一页第二页第三页| 亚洲欧洲99久久| 午夜视频在线观看一区二区| 精品亚洲国内自在自线福利| 国产成人亚洲精品青草天美| 91小视频免费看| 91麻豆精品国产91久久久更新时间 | 国产亚洲女人久久久久毛片| 国产精品福利一区二区三区| 亚洲大片精品永久免费| 精一区二区三区| 99精品国产91久久久久久| 69p69国产精品| 国产清纯在线一区二区www| 亚洲主播在线播放| 国产一区二区三区| 精品视频999| 国产精品无遮挡| 日韩精彩视频在线观看| 岛国精品一区二区| 欧美一级一级性生活免费录像| 国产人妖乱国产精品人妖| 三级在线观看一区二区| www.欧美日韩| 精品裸体舞一区二区三区| 亚洲三级视频在线观看| 国产麻豆成人传媒免费观看| 欧美日韩国产不卡| 亚洲欧美偷拍卡通变态| 国产精品一二一区| 日韩一二三四区|