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

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

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

?? 好書,關于游戲開發數據結構的,還有一些實用例子
?? 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在线看国产| 成人综合婷婷国产精品久久蜜臀 | 国产999精品久久久久久绿帽| 成人综合激情网| 欧美丝袜自拍制服另类| 精品国产乱码久久久久久免费| 中文字幕永久在线不卡| 乱一区二区av| 卡一卡二国产精品| 色婷婷久久久亚洲一区二区三区| 欧美欧美欧美欧美| 国产精品色呦呦| 男男成人高潮片免费网站| av中文字幕亚洲| 精品三级在线观看| 婷婷丁香久久五月婷婷| 99久久免费精品| 国产人成亚洲第一网站在线播放| 亚洲国产精品一区二区久久恐怖片| 国产精品99久久久久久有的能看| 欧美精品三级日韩久久| 亚洲欧美日韩在线播放| 国产精品一区二区久激情瑜伽| 欧美调教femdomvk| 伊人性伊人情综合网| 成人美女视频在线观看18| 精品美女被调教视频大全网站| 亚洲午夜久久久久久久久久久| 国产成人精品亚洲午夜麻豆| 久久免费国产精品| 蜜桃视频在线观看一区二区| 欧美精品tushy高清| 看电影不卡的网站| 在线综合视频播放| 亚洲成av人片在线观看无码| 色综合色狠狠综合色| 中文字幕一区二区在线观看| 国产高清久久久久| 国产精品国产三级国产普通话蜜臀| 成人少妇影院yyyy| 亚洲激情av在线| 欧美精品色综合| 极品尤物av久久免费看| 久久精品亚洲精品国产欧美kt∨| 国产精品一区二区久久不卡| 中文字幕一区二区在线观看| 欧美性淫爽ww久久久久无| 日韩综合小视频| 久久久99精品久久| 97久久精品人人做人人爽50路| 一区二区三区在线免费播放| 欧美丰满美乳xxx高潮www| 久久精品99国产精品日本| 国产欧美综合色| 色成年激情久久综合| 日韩福利视频导航| 国产女人aaa级久久久级| 色乱码一区二区三区88| 日本美女一区二区三区视频| 日本一区二区三区视频视频| 欧美优质美女网站| 精品在线观看免费| 亚洲欧美激情插| 精品久久久久久久久久久院品网| 91在线丨porny丨国产| 秋霞午夜鲁丝一区二区老狼| 国产精品视频一二三| 欧美疯狂性受xxxxx喷水图片| 国产69精品久久99不卡| 亚洲成人一区在线| 国产日韩高清在线| 欧美日韩一卡二卡三卡| 国产精品中文欧美| 亚洲一二三区视频在线观看| 国产婷婷一区二区| 欧美一区二区三区不卡| 成人av网站免费观看| 久久国产精品一区二区| 亚洲人成网站影音先锋播放| 日韩精品中文字幕一区| 欧美日韩一区中文字幕| 99视频精品在线| 国产精品综合网| 日本亚洲视频在线| 亚洲最大成人综合| 国产精品免费aⅴ片在线观看| 欧美日韩亚洲另类| 99久久精品国产一区二区三区 | 精品国内片67194| 色哟哟国产精品| 波多野结衣中文一区| 久久97超碰色| 免费不卡在线观看| 亚洲国产精品精华液网站| 亚洲视频你懂的| 中文字幕在线不卡一区| 国产亚洲综合性久久久影院| 欧美电影一区二区三区| 欧美色手机在线观看| 99精品在线免费| 99在线精品免费| 国产成人av一区| 国产成人啪免费观看软件| 国产综合色视频| 久久电影国产免费久久电影| 日韩专区中文字幕一区二区| 午夜伦理一区二区| 亚洲成av人综合在线观看| 亚洲一区二区欧美激情| 亚洲午夜精品在线| 午夜精品福利在线| 午夜av区久久| 日韩—二三区免费观看av| 五月天国产精品| 久久丁香综合五月国产三级网站| 精品一区二区三区香蕉蜜桃| 久久国产视频网| 国产乱码字幕精品高清av| 粉嫩欧美一区二区三区高清影视| 粉嫩在线一区二区三区视频| aaa亚洲精品一二三区| 91色porny| 欧美日韩精品电影| 欧美成人国产一区二区| 久久综合色综合88| 欧美国产在线观看| 中文字幕永久在线不卡| 亚洲天堂福利av| 亚洲成人福利片| 另类小说一区二区三区| 国产福利不卡视频| 91蜜桃免费观看视频| 欧美日韩亚洲综合一区| 精品国产乱子伦一区| 亚洲国产精品成人久久综合一区| 亚洲视频一区二区在线| 日韩高清在线观看| 国产一区二区三区综合| 99精品热视频| 91精品国产欧美一区二区| 国产精品婷婷午夜在线观看| 亚洲制服丝袜一区| 国产制服丝袜一区| 色综合欧美在线| 欧美大片国产精品| 亚洲日本乱码在线观看| 日韩精品国产精品| 大胆欧美人体老妇| 欧美日本在线一区| 国产精品乱子久久久久| 日韩精品免费专区| av在线不卡观看免费观看| 欧美精品高清视频| 国产欧美一区二区三区沐欲| 亚欧色一区w666天堂| 懂色av一区二区三区蜜臀| 91麻豆精品国产| 综合激情网...| 激情成人综合网| 欧美日韩综合在线| 国产精品久久久久精k8 | 亚洲精品免费在线观看| 美国三级日本三级久久99| 91蜜桃免费观看视频| 国产亚洲欧洲一区高清在线观看| 性欧美疯狂xxxxbbbb| 成人免费毛片a| 精品国产乱码久久久久久1区2区 | 中文字幕中文乱码欧美一区二区| 丝袜美腿一区二区三区| 99久久久国产精品| 精品国产一区二区精华| 亚洲va国产va欧美va观看| 波多野结衣中文字幕一区| 2021国产精品久久精品| 免费欧美日韩国产三级电影| 色婷婷综合久久久中文一区二区| 国产欧美视频一区二区| av电影在线观看一区| 精品福利视频一区二区三区| 亚洲成a人片在线不卡一二三区 | 91精品在线观看入口| 亚洲美女精品一区| 成人免费高清视频| 中文字幕乱码久久午夜不卡| 国产精品77777| 国产日产欧美一区| 国产馆精品极品| 欧美精品一区视频| 美女在线视频一区| 欧美一区二区三区免费观看视频| 日韩中文字幕不卡| 91精品在线免费| 久久99精品久久久久久国产越南| 日韩视频国产视频| 久久精品国内一区二区三区| 精品国产乱码久久久久久久久| 激情成人综合网| 国产肉丝袜一区二区|