• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 16,  comments - 81,  trackbacks - 0
             

            Lesson 2: 走向全屏

            From

            http://www.directxtutorial.com/tutorial9/b-direct3dbasics/dx9b2.aspx#still

            Translated By----Double One(王大寶)   dfghj77777@gmail.com
            Finished At 20101215

            筆者:自第一篇發(fā)出以來,已過一月。最近忙,翻譯有些耽擱,接下來我會(huì)保證一周至少一篇 ,謝謝大家的支持。

            課程概述

            Making your game fullscreen is easy, but requires changing a few details of the program, as well as adding a couple lines of code.

            In this lesson we will cover two things.  First, we will go over how to globalize your screen resolution and why you would do this.  Second, we'll cover the mechanics of making a window go into fullscreen mode.

            其實(shí)全屏化很容易,改幾行代碼就好,來死狗(Let’s Go)。

            在這一課中我們將介紹兩件事情。首先,我們將研究怎樣改變你的屏幕分辨率以及為什么要這么做。其次呢,我們捎帶介紹一下使窗口進(jìn)入全屏模式的機(jī)制原理。

            設(shè)置屏幕尺寸

            Throughout your DirectX experience and in game programming you will come across many functions and structs that demand to know your screen size.  This can become a hassle when you decide to change the resolution later, and especially when you decide to change it during run-time.  For right now, we will cover a simple method to standardize your screen size across your program.

            在你的DirectX或者游戲編程經(jīng)歷里你一定會(huì)碰到許多函數(shù)和結(jié)構(gòu)體管你要屏幕尺寸,是的,這也許并不困難。可是當(dāng)你要更改分辨率時(shí)麻煩就來了,尤其是你非得在運(yùn)行的時(shí)候這么干。現(xiàn)在,哥將給你介紹一個(gè)簡(jiǎn)單的方法來規(guī)范你的程序的屏幕大小,這個(gè)方法非常簡(jiǎn)單,但是非常的實(shí)用,而且,它只要九——百——九——十——八,還猶豫什么,趕緊往下看吧。

             

            First, we must add two directives to the top of our program.  These represent the screen width and the screen height.

            首先,我們?cè)诔绦蜷_頭添加兩個(gè)指令。這些代表了屏幕的寬度和屏幕的高度。

            1// define the screen resolution
            2#define SCREEN_WIDTH  800
            3#define SCREEN_HEIGHT 600
            4

             

            The next step is to go through your program to where you indicate the width and height of your window.  Up to this point in the tutorial, you only have one, although we will come across another in a minute.  Do this to the code (changes in bold):

            接下來,來到聲明窗口寬度和高度的地方。本教程到目前為止,只有一個(gè)聲明的地方,注意粗體那行:

             1hWnd = CreateWindowEx(NULL,
             2                          L"WindowClass",
             3                          L"Our Direct3D Program",
             4                          WS_OVERLAPPEDWINDOW,
             5                          300300,
             6                     SCREEN_WIDTH, SCREEN_HEIGHT,    // 設(shè)置新的尺寸 
             7NULL,
             8                          NULL,
             9                          hInstance,
            10                          NULL);
            11
             

            In a later lesson we will cover how to maintain screen size throughout your game after changing it during runtime.

            There are specific resolutions that are available on most PCs, the most common of which can be seen in this table.

            在后面的課上,我們將討論如在運(yùn)行過程中改變屏幕尺寸后繼續(xù)游戲。
            這兒有張常見的分辨率表可以參考一下。

             

            [Table 2.1 - Common Screen Resolutions]更多信息請(qǐng)猛擊我

            Resolution

            Pixels

            Widescreen

            800 x 600

            480,000

            No

            1024 x 768

            786,432

            No

            1152 x 864

            995,328

            No

            1280 x 1024

            1,310,720

            No

            1600 x 1200

            1,920,000

            No

            1440 x 900

            1,296,000

            Yes

            1680 x 1050

            1,764,000

            Yes

            1920 x 1080

            2,073,600

            Yes

            1920 x 1200

            2,304,000

            Yes



             

            變成全屏模式

            When changing to full screen you are doing several things.  First, your are telling Windows not to apply any of the standard Windows borders to your window.  Second, you are telling Windows to have your window overlap all other things on the screen, including the start menu.  Third, you are telling DirectX to change the resolution of the monitor to your set preference.  Finally, although less importantly, you are telling Windows to leave the window background color up to you.

            The first two of these are handled by changing some CreateWindowEx() parameters.  The changes we need to make are shown here.

            切換到全屏的時(shí)候你要做這么幾件事兒。首先,你告訴Windows不要添加任何標(biāo)準(zhǔn)的Windows窗口邊框。其次,你告訴不要把其他Windows窗口蓋在我們的全屏游戲上,包括開始菜單。再次,你告訴DirectX的把顯示器的分辨率設(shè)置成我們要的值。最后,盡管這條不是那么重要,你得告訴Windows離開窗口時(shí)的背景色。
            前兩個(gè)處理通過改變一些CreateWindowEx()的參數(shù)。改動(dòng)如下。

             1hWnd = CreateWindowEx(NULL,
             2                          L"WindowClass",
             3                          L"Our Direct3D Program",
             4                          WS_EX_TOPMOST | WS_POPUP,    // fullscreen values
             5                          00,    // the starting x and y positions should be 0
             6                          SCREEN_WIDTH, SCREEN_HEIGHT,
             7                          NULL,
             8                          NULL,
             9                          hInstance,
            10                          NULL);
            11

             

            Here we set the starting x and y positions to 0.  We also changed the previous parameter to "WS_EX_TOPMOST | WS_POPUP".  The WS_EX_TOPMOST is self-explanatory, and makes the window overlap everything else.  The WS_POPUP is less self-explanatory, but what it does is tell Windows to remove all borders of any kind, including the rounded-edge top that you see in Windows XP.

            在這里,我們?cè)O(shè)置xy的初始位置為0。我們還改變了第四個(gè)參數(shù),將其設(shè)置為了“WS_EX_TOPMOST | WS_POPUP” WS_EX_TOPMOST顧名思義就是讓我們的全屏程序在桌面最頂層。WS_POPUP的作用是告訴Windows以消除任何形式的所有邊界,包括圓形的邊緣等窗口邊框,總之就是你所看到過的全屏游戲那樣。

             

            There is also a member of the WINDOWCLASSEX struct that we need to take out.  This leaves the background color untouched, which means it won't be visible as window for a second or two before the game starts (important to making your game look professional).

            還有一個(gè)WINDOWCLASSEX結(jié)構(gòu)的成員,我們需要把它拿掉。它的作用是設(shè)置窗口背景色不,而這會(huì)使游戲全屏?xí)r屏幕閃爍幾下(把它拿掉會(huì)讓您的游戲看起來專業(yè)得多)。

            1 wc.hbrBackground = NULL;//(HBRUSH)COLOR_WINDOW;
             

            Next, we have to tell DirectX about our new screen resolution.  We do this by making a few changes to the d3dpp struct we built in the last lesson.  Let's look at what they are before we see what they do.

            下一步,我們來告訴DirectX一個(gè)新的屏幕分辨率。我們通過對(duì)上一課中創(chuàng)建的d3dpp結(jié)構(gòu)體進(jìn)行一些小小的改變來完成這項(xiàng)工作。下面讓我們看看具體代碼吧

             

             1D3DPRESENT_PARAMETERS d3dpp;    // create a struct to hold various device information
             2
             3    ZeroMemory(&d3dpp, sizeof(d3dpp));    // clear out the struct for use
             4    d3dpp.Windowed = FALSE;    // program fullscreen, not windowed
             5    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;    // discard old frames
             6    d3dpp.hDeviceWindow = hWnd;    // set the window to be used by Direct3D
             7    d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;    // set the back buffer format to 32-bit
             8    d3dpp.BackBufferWidth = SCREEN_WIDTH;    // set the width of the buffer
             9    d3dpp.BackBufferHeight = SCREEN_HEIGHT;    // set the height of the buffer
            10


             

            Let's examine these new back buffer related variables.

            下面我來解釋一下這些新的后臺(tái)緩沖相關(guān)變量

             

            d3dpp.BackBufferFormat

            This member is used to tell Direct3D what kind of pixels should be displayed.  There are six types that can be used here, but two of them are older types (16-bit) and not generally used anymore.  There are several 32-bit types that we can use.  We'll use the D3DFMT_X8R8G8B8.  See the table for a description along with some other values than can be used here (definitely not all of them).

            這個(gè)成員變量是用來告訴Direct3D什么樣的像素會(huì)被顯示。可分為六種 ,但其中兩大類型太老了(16),一般不到。有4個(gè)32位的類型,我們可以使用。本課將使用D3DFMT_X8R8G8B8。想知道具體這個(gè)四個(gè)類型,可以看看下面的表。

             

            [Table 2.2 - Some Back Buffer Formats]

            描述

            D3DFMT_A8R8G8B8

            This is a 32-Bit pixel format, with 256 levels (8 bits) of red, green, blue and alpha (semi-transparency).

            這是一個(gè)32位的像素格式。有256級(jí)(8bit)的紅,綠,藍(lán)以及透明通道。

            D3DFMT_X8R8G8B8

            This is similar to A8R8G8B8, with the one difference being that it does not support alpha, even though there are 8 bits to represent this.

            這個(gè)和上一個(gè)很類似,唯一的不同就是這個(gè)不支持透明

            D3DFMT_A2R10G10B10

            This is a 32-Bit pixel format, with only two bits of alpha, but 10 bits (1024 levels) of each red, green and blue.

            還是一個(gè)32位的像素格式。2bit的透明通道,10bit1024級(jí))的紅綠藍(lán)通道。

            D3DFMT_A16B16G16R16

            64-BIT COLOR!  If you have the capability to run 64-bit color, I'd recommend playing around with this to see how it works.
            64bit
            的!哦這太棒了。如果你可以運(yùn)行64位的顏色,我強(qiáng)烈推薦你使用這個(gè)
            This value has 16 bits for each component (65536 levels compared to the current measly 256!)

            紅綠藍(lán)加透明各占16bit65536級(jí))。

             

            BackBufferWidth and BackBufferHeight

            These two members indicate the width and height of the back buffer.  Painfully simple.

            這兩個(gè)成員變量表明后備緩沖區(qū)的寬度和高度。相當(dāng)簡(jiǎn)單

            最終成品

            So, there isn't much to change.  Let's take a look at the whole picture and see what is different and what is the same.

            所以,其實(shí)沒改動(dòng)多少。讓我們看一看整個(gè)代碼,并對(duì)比上一課什么是不同的,什么是一樣的。


             

            There isn't really a point in me showing a screenshot of this program's result, because it would just be a blue rectangle.  Your program should look like that: a blue rectangle with a mouse pointer in the middle.

            我沒有做截圖,因?yàn)樗皇且粋€(gè)藍(lán)色的長(zhǎng)方形。你的程序應(yīng)該也看起來像他一樣:藍(lán)色的長(zhǎng)方形充鼠標(biāo)指針在中間。

            總結(jié)

            Great!  We now have a simple platform on which to build games.

            Before you go on, I recommend doing the following exercise to gain familiarity with the code in this program:

            Change the resolution of the program until you are familiar with the various resolutions selectable.

            When you're ready to go on, let's hit the next lesson!

            太棒了!我們現(xiàn)在有一個(gè)簡(jiǎn)單的平臺(tái)做游戲。  

            在你接著干之前,我建議做做這幾個(gè)練習(xí)一遍更好地熟悉Direct3D:  

            改變程序的分辨率,直到你熟悉各種各樣可選擇的分辨率。

            當(dāng)你準(zhǔn)備好了,我們開始下一個(gè)教程。

             

            Next Lesson:  An Overview of the Third Dimension

            下一課:三維的概述

             

            GO! GO! GO!

             

            posted on 2010-12-15 23:54 叫我老王吧 閱讀(2380) 評(píng)論(0)  編輯 收藏 引用 所屬分類: DierectXC++
            <2010年12月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            常用鏈接

            留言簿(4)

            隨筆分類

            隨筆檔案

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            国产成人精品久久一区二区三区av| 无码国产69精品久久久久网站| 久久99精品久久久久久hb无码 | 久久99精品久久久久久| 久久AV高清无码| 久久99精品国产麻豆婷婷| 久久久久亚洲av综合波多野结衣| 亚洲精品乱码久久久久久蜜桃图片| www久久久天天com| 伊人久久大香线蕉无码麻豆 | 亚洲人成精品久久久久| WWW婷婷AV久久久影片| 中文字幕无码av激情不卡久久| 一本久久a久久精品vr综合| 日本免费一区二区久久人人澡 | 91久久福利国产成人精品| 国产精品久久久久久五月尺| 97精品久久天干天天天按摩| 久久精品极品盛宴观看| 91精品免费久久久久久久久| 无码久久精品国产亚洲Av影片| 精品久久久久久无码人妻蜜桃| 亚洲国产精品无码久久SM| 久久精品国产第一区二区| 国产精品久久网| 久久99精品久久久久久久不卡| 亚洲国产高清精品线久久| 91精品国产高清久久久久久91| 久久人人爽人人爽人人片AV不 | 国产精品久久久久无码av| 精品久久久一二三区| 久久精品国产欧美日韩| 7777久久亚洲中文字幕| 久久精品国产亚洲AV无码偷窥| 99蜜桃臀久久久欧美精品网站| 香蕉久久夜色精品国产2020| 激情久久久久久久久久| 久久青青草原精品国产不卡| 久久久久国产精品| 中文字幕亚洲综合久久2| 91精品国产91热久久久久福利|