• <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>

            天行健 君子當自強而不息

            主窗口和DirectInput的封裝

            注:GE是GameEngine的縮寫。

            GE_APP類解決應用程序的窗口創建問題,為了突出消息處理,這個類并沒有更抽象地將窗口程序的消息循環體代碼進行封裝。因此,這里的應用程序架構是創建窗口(包括注冊窗口類,創建窗口,顯示窗口,設置窗口回調函數的默認處理),然后繼續使用消息循環體,讀取鍵盤和鼠標的輸入等,進行一幀的渲染或其他處理。

            命名約定:
            (1)類采用大寫和下劃線,如 GE_APP。
            (2)類里面的成員變量如果是private或者protected類型,采用下劃線開始,緊接著小寫字母,如 _data。
            (3)類里面的成員變量如果是public類型,采用m_開始, 緊接著小寫字母,如m_data。
            (4)類里面的方法如果是private或者protected類型,采用下劃線開始,緊接著大寫字母,如 _Func()。
            (5)類里面的方法如果是public類型,采用大寫字母開始,如 Func()。
            (6)不管是變量還是函數都不采用大小寫混合命名,而采用下劃線,以更有利于閱讀。
            (7)目前編譯器的及時信提示功能已經十分強大,這里將不采用匈牙利命名法,以免影響代碼閱讀。

            由于本人水平有限,代碼中可能有錯誤,如若發現,敬請指出。



            源碼下載

            需要在工程中設置鏈接dxguid.lib和dinput8.lib。

            首先定義1個頭文件GE_COMMON.h,來包含公用的頭文件。

            GE_COMMON.h
            /*************************************************************************************
             [Include File]

             PURPOSE: 
                Include Common header files.
            ************************************************************************************
            */

            #ifndef GAME_ENGINE_COMMON_H
            #define GAME_ENGINE_COMMON_H

            #define DIRECTINPUT_VERSION 0x0800  // let compile shut up

            #include 
            <windows.h>
            #include 
            <tchar.h>
            #include 
            <string.h>
            #include 
            <stdio.h>

            #include 
            <d3d9.h>
            #include 
            <d3dx9.h>
            #include 
            <dinput.h>
            #include 
            <dsound.h>

            #define Safe_Release(object) if((object) != NULL) { (object)->Release(); (object)=NULL; }

            #endif

            接著定義GE_APP.h
            /*************************************************************************************
             [Include File]

             PURPOSE: 
                Create Game Main Window Framework.
            ************************************************************************************
            */

            #ifndef GAME_ENGINE_APP_H
            #define GAME_ENGINE_APP_H

            #include 
            "GE_COMMON.h"

            #define WINDOW_CLASS_NAME       "MY_GAME"

            class GE_APP
            {
            private:
                HWND _wnd;
                WNDCLASSEX _wnd_class;

            public:
                GE_APP()    {};
                
            ~GE_APP()    {};

                WNDCLASSEX Get_Window_Class()       { 
            return _wnd_class; }
                HWND Get_Window_Handle()            { 
            return _wnd; }

                
            bool Create_Window(LPCTSTR win_title, HINSTANCE instance, int cmd_show);
                
            static LRESULT CALLBACK Window_Proc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam);

            private:
                ATOM _Reg_Window_Class(HINSTANCE instance);
            };

            #endif

            GE_APP.cpp
            /*************************************************************************************
             [Implement File]

             PURPOSE: 
                Create Game Main Window Framework.
            ************************************************************************************
            */

            #include 
            "GE_COMMON.h"
            #include 
            "GE_APP.h"

            //------------------------------------------------------------------------------------
            // Create a window by specified title and show type.
            //------------------------------------------------------------------------------------
            bool GE_APP::Create_Window(LPCTSTR win_title, HINSTANCE instance, int cmd_show)
            {
                
            // regiter window class
                _Reg_Window_Class(instance);

                
            // create a window
                _wnd = CreateWindow(WINDOW_CLASS_NAME, win_title, WS_SYSMENU | WS_CAPTION | WS_VISIBLE,
                                    CW_USEDEFAULT, 
            0, CW_USEDEFAULT, 0, NULL, NULL, instance, NULL);
                
                
            if(_wnd == NULL)
                    
            // create failed
                    return false;

                
            // sets the specified window's show state 
                ShowWindow(_wnd, cmd_show);
                
            // updates the client area of the specified window
                UpdateWindow(_wnd);

                
            return true;
            }

            //------------------------------------------------------------------------------------
            // Registers a window class for subsequent use in calls to the CreateWindow 
            // or CreateWindowEx function. 
            //
            // If the function succeeds, the return value is a class atom that uniquely 
            // identifies the class being registered.
            // If the function fails, the return value is zero. 
            //------------------------------------------------------------------------------------
            ATOM GE_APP::_Reg_Window_Class(HINSTANCE instance)
            {
                _wnd_class.cbSize          
            = sizeof(WNDCLASSEX);
                _wnd_class.style           
            = CS_HREDRAW | CS_VREDRAW;
                _wnd_class.lpfnWndProc     
            = (WNDPROC) Window_Proc;
                _wnd_class.cbClsExtra      
            = 0;
                _wnd_class.cbWndExtra      
            = 0;
                _wnd_class.hInstance       
            = instance;
                _wnd_class.hIcon           
            = 0;
                _wnd_class.hCursor         
            = LoadCursor(NULL, IDC_ARROW);
                _wnd_class.hbrBackground   
            = (HBRUSH) GetStockObject(BLACK_BRUSH);
                _wnd_class.lpszMenuName    
            = 0;
                _wnd_class.lpszClassName   
            = WINDOW_CLASS_NAME;
                _wnd_class.hIconSm         
            = NULL;

                
            return RegisterClassEx(&_wnd_class);  
            }

            //--------------------------------------------------------------------------
            // Callback function, handle message return by windows.
            //--------------------------------------------------------------------------
            LRESULT CALLBACK GE_APP::Window_Proc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam)
            {
                
            switch(msg)
                {
                
            case WM_DESTROY:
                    PostQuitMessage(
            0);
                    
            break;
                }

                
            return DefWindowProc(wnd, msg, wParam, lParam);
            }

            現在封裝DirectInput。

            GE_INPUT.h
            /*************************************************************************************
             [Include File]

             PURPOSE: 
                Create Game Input handle module.
            ************************************************************************************
            */

            #ifndef GAME_ENGINE_INPUT_H
            #define GAME_ENGINE_INPUT_H

            #include 
            "GE_COMMON.h"

            #define ITEMS_NUM   10

            static LPDIRECTINPUT8 g_directinput = NULL;

            BOOL CALLBACK Enum_Joystick(LPCDIDEVICEINSTANCE device_instance, LPVOID data);

            class GE_INPUT
            {
            private:
                
            bool _use_joystick;

                LPDIRECTINPUTDEVICE8 _keyboard;
                LPDIRECTINPUTDEVICE8 _mouse;
                LPDIRECTINPUTDEVICE8 _joystick;

                
            char _key_buffer[256];                          // keyboad buffer (immediate mode)
                DIDEVICEOBJECTDATA _mouse_buffer[ITEMS_NUM];    // mouse data buffer (buffer mode)
                DIJOYSTATE2 _joystick_buffer;                   // joystick buffer (immediate mode)

                
            long _left_mouse_move_x, _left_mouse_move_y;    // mouse move coordinate

            public:
                GE_INPUT();
                
            ~GE_INPUT();

                
            void Create_Input(HINSTANCE instance, HWND hwnd, int min = -100int max = 100
                    
            int dead_zone = 20bool use_joystick = false);

                
            bool Read_Keyboard();
                
            bool Read_Mouse();
                
            bool Read_Joystick();
                
            bool Is_LButton_Pressed();
                
            bool Is_RButton_Pressed();    
                
            bool Is_MButton_Pressed();

                
            // Judge which key user has been pressed
                bool Is_Key_Pressed(int key)    { return (_key_buffer[key] & 0x80 ? true : false); }

                
            long Get_Mouse_Move_X() { return _left_mouse_move_x; }
                
            long Get_Mouse_Move_Y() { return _left_mouse_move_y; }

                
            // Judge which joystick button has been pressed
                bool Is_JSButton_Pressed(int button)
                {
                    
            return (_joystick_buffer.rgbButtons[button] & 0x80? true : false;
                }

            private:
                
            bool _Create_Directinput(HINSTANCE instance);
                
            bool _Create_Keyboard(HWND hwnd);
                
            bool _Create_Mouse(HWND hwnd);
                
            bool _Create_Joystick(HWND hwnd, int min, int max, int dead_zone);
                
            void _Release_Input();
            };

            #endif

            GE_INPUT.cpp
            /*************************************************************************************
             [Implement File]

             PURPOSE: 
                Create Game Input handle module.
            ************************************************************************************
            */

            #include 
            "GE_COMMON.h"
            #include 
            "GE_INPUT.h"

            //------------------------------------------------------------------------------------
            // Constructor, initialize data.
            //------------------------------------------------------------------------------------
            GE_INPUT::GE_INPUT()
            {
                _use_joystick 
            = false;
                _keyboard 
            = NULL;
                _mouse    = NULL;
                _joystick = NULL;
                _left_mouse_move_x 
            = 0;
                _left_mouse_move_y 
            = 0;
            }

            //------------------------------------------------------------------------------------
            // Destructor, Release input resource.
            //------------------------------------------------------------------------------------
            GE_INPUT::~GE_INPUT()
            {
                _Release_Input();
            }

            //------------------------------------------------------------------------------------
            // Release all input resource.
            //------------------------------------------------------------------------------------
            void GE_INPUT::_Release_Input()
            {
                
            // Releases access to keyboard
                if(_keyboard)
                    _keyboard
            ->Unacquire();

                
            // Releases access to mouse
                if(_mouse)
                    _mouse
            ->Unacquire();

                
            // Releases access to joystick
                if(_use_joystick && (_joystick != NULL))
                    _joystick
            ->Unacquire();

                
            // release keyboard and mouse
                Safe_Release(_keyboard);
                Safe_Release(_mouse);
                
                
            // release joystick
                if(_use_joystick)
                    Safe_Release(_joystick);

                Safe_Release(g_directinput);
            }

            //------------------------------------------------------------------------------------
            // Create directinput, include keybrad, mouse, joystick.
            //------------------------------------------------------------------------------------
            void GE_INPUT::Create_Input(HINSTANCE instance, HWND hwnd, int min, int max, int dead_zone, bool use_joystick)
            {
                _Create_Directinput(instance);

                _Create_Keyboard(hwnd);
                _Create_Mouse(hwnd);

                
            if(use_joystick)
                    _Create_Joystick(hwnd, min, max, dead_zone);
            }

            //------------------------------------------------------------------------------------
            // Creates a Microsoft DirectInput object.
            //------------------------------------------------------------------------------------
            bool GE_INPUT::_Create_Directinput(HINSTANCE instance)
            {
                
            if(FAILED(DirectInput8Create(instance, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**&g_directinput, NULL)))
                {
                    MessageBox(NULL, 
            "Create Directinput object failed.""ERROR", MB_OK | MB_ICONINFORMATION);
                    
            return false;
                }

                
            return true;
            }

            //------------------------------------------------------------------------------------
            // Create keyboard device.
            //------------------------------------------------------------------------------------
            bool GE_INPUT::_Create_Keyboard(HWND hwnd)
            {
                
            // create keyboard device
                if(FAILED(g_directinput->CreateDevice(GUID_SysKeyboard, &_keyboard, NULL)))
                {
                    MessageBox(NULL, 
            "DirectInput interface create failed.""ERROR", MB_OK | MB_ICONINFORMATION);
                    
            return false;
                }

                
            // Sets the data format for the Microsoft DirectInput device.
                if(FAILED(_keyboard->SetDataFormat(&c_dfDIKeyboard)))
                {
                    MessageBox(NULL, 
            "Set data format with keyboard read mode failed.""ERROR", MB_OK | MB_ICONINFORMATION);
                    
            return false;
                }
                
                
            // Establishes the cooperative level for this instance of the device. 
                
            // The cooperative level determines how this instance of the device interacts with other instances
                
            // of the device and the rest of the system.
                if(FAILED(_keyboard->SetCooperativeLevel(hwnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE)))
                {
                    MessageBox(NULL, 
            "Set cooperative Leve failed.""ERROR", MB_OK | MB_ICONINFORMATION);
                    
            return false;
                }

                
            // Obtains access to the keyboard device
                if(FAILED(_keyboard->Acquire()))
                {
                    MessageBox(NULL, 
            "Acquire keyboard access failed.""ERROR", MB_OK | MB_ICONINFORMATION);
                    
            return false;
                }

                
            // zero keyboard buffer
                ZeroMemory(_key_buffer, sizeof(char* 256);

                
            return true;
            }

            //------------------------------------------------------------------------------------
            // Read keyboard data from buffer.
            //------------------------------------------------------------------------------------
            bool GE_INPUT::Read_Keyboard()
            {
                
            if(DIERR_INPUTLOST == _keyboard->GetDeviceState(sizeof(_key_buffer), (LPVOID) _key_buffer))
                {
                    
            // re-acquire access to keyboard
                    _keyboard->Acquire();

                    
            if(FAILED(_keyboard->GetDeviceState(sizeof(_key_buffer), (LPVOID) _key_buffer)))
                        
            return false;
                }

                
            return true;
            }

            //------------------------------------------------------------------------------------
            // Create mouse device.
            //------------------------------------------------------------------------------------
            bool GE_INPUT::_Create_Mouse(HWND hwnd)
            {
                
            // create mouse input device
                if(FAILED(g_directinput->CreateDevice(GUID_SysMouse, &_mouse, NULL)))
                {
                    MessageBox(NULL, 
            "Create mouse input device failed.""ERROR", MB_OK | MB_ICONINFORMATION);
                    
            return false;
                }

                
            // set data format for mouse
                if(FAILED(_mouse->SetDataFormat(&c_dfDIMouse)))
                {
                    MessageBox(NULL, 
            "Set mouse data format failed.""ERROR", MB_OK | MB_ICONINFORMATION);
                    
            return false;
                }

                
            // set cooperative level for mouse
                if(FAILED(_mouse->SetCooperativeLevel(hwnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE)))
                {
                    MessageBox(NULL, 
            "Set mouse cooperative level failed.""ERROR", MB_OK | MB_ICONINFORMATION);
                    
            return false;
                }

                
            // set property for mouse
                DIPROPDWORD device_prop;

                device_prop.diph.dwSize       
            = sizeof(DIPROPDWORD);
                device_prop.diph.dwHeaderSize 
            = sizeof(DIPROPHEADER);
                device_prop.diph.dwObj        
            = 0;
                device_prop.diph.dwHow        
            = DIPH_DEVICE;
                device_prop.dwData            
            = ITEMS_NUM;

                
            if(FAILED(_mouse->SetProperty(DIPROP_BUFFERSIZE, &device_prop.diph)))
                {
                    MessageBox(NULL, 
            "Set property for mouse failed.""ERROR", MB_OK | MB_ICONINFORMATION);
                    
            return false;
                }

                
            // get access to mouse
                if(FAILED(_mouse->Acquire()))
                {
                    MessageBox(NULL, 
            "Get access to mouse failed.""ERROR", MB_OK | MB_ICONINFORMATION);
                    
            return false;
                }

                
            return true;
            }

            //------------------------------------------------------------------------------------
            // Read data from mouse buffer.
            //------------------------------------------------------------------------------------
            bool GE_INPUT::Read_Mouse()
            {
                DWORD read_num 
            = 1;

                
            // zero mouse buffer before reading data 
                ZeroMemory(_mouse_buffer, sizeof(DIDEVICEOBJECTDATA) * ITEMS_NUM);

                
            // read all mouse data from buffer
                for(int i = 0; i < ITEMS_NUM; i++)
                {
                    
            if(DIERR_INPUTLOST == _mouse->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), &_mouse_buffer[i], &read_num, 0))
                    {
                        _mouse
            ->Acquire();

                        
            if(FAILED(_mouse->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), &_mouse_buffer[i], &read_num, 0)))
                            
            return false;
                    }

                    
            if(_mouse_buffer[i].dwOfs == DIMOFS_X)
                        _left_mouse_move_x 
            += _mouse_buffer[i].dwData;

                    
            if(_mouse_buffer[i].dwOfs == DIMOFS_Y)
                        _left_mouse_move_y 
            += _mouse_buffer[i].dwData;        
                }

                
            return true;
            }

            //------------------------------------------------------------------------------------
            // Judge whether left mouse button has been pressed.
            //------------------------------------------------------------------------------------
            bool GE_INPUT::Is_LButton_Pressed()
            {
                
            for(int i = 0; i < ITEMS_NUM; i++)
                {
                    
            if((_mouse_buffer[i].dwOfs == DIMOFS_BUTTON0) && (_mouse_buffer[i].dwData & 0x80))
                        
            return true;
                }

                
            return false;
            }

            //------------------------------------------------------------------------------------
            // Judge whether right mouse button has been pressed.
            //------------------------------------------------------------------------------------
            bool GE_INPUT::Is_RButton_Pressed()
            {
                
            for(int i = 0; i < ITEMS_NUM; i++)
                {
                    
            if((_mouse_buffer[i].dwOfs == DIMOFS_BUTTON1) && (_mouse_buffer[i].dwData & 0x80))
                        
            return true;
                }

                
            return false;
            }

            //------------------------------------------------------------------------------------
            // Judge whether mouse wheel has been pressed.
            //------------------------------------------------------------------------------------
            bool GE_INPUT::Is_MButton_Pressed()
            {
                
            for(int i = 0; i < ITEMS_NUM; i++)
                {
                    
            if((_mouse_buffer[i].dwOfs == DIMOFS_BUTTON2) && (_mouse_buffer[i].dwData & 0x80))
                        
            return true;
                }

                
            return false;
            }

            //------------------------------------------------------------------------------------
            // Create joystick.
            //------------------------------------------------------------------------------------
            bool GE_INPUT::_Create_Joystick(HWND hwnd, int min, int max, int dead_zone)
            {
                
            // Enumerates all joystick that have been installed successfully
                if(FAILED(g_directinput->EnumDevices(DI8DEVCLASS_GAMECTRL, Enum_Joystick, &_joystick, DIEDFL_ATTACHEDONLY)))
                {
                    MessageBox(NULL, 
            "Enumerate joystick failed.""ERROR", MB_OK | MB_ICONINFORMATION);
                    
            return false;
                }

                
            if(_joystick == NULL)
                {
                    MessageBox(NULL, 
            "There is no joystick has been installed.""ERROR", MB_OK | MB_ICONINFORMATION);
                    
            return false;
                }

                
            // set data format for mouse
                if(FAILED(_mouse->SetDataFormat(&c_dfDIJoystick2)))
                {
                    MessageBox(NULL, 
            "Set joystick data format failed.""ERROR", MB_OK | MB_ICONINFORMATION);
                    
            return false;
                }

                
            // set cooperative level for mouse
                if(FAILED(_mouse->SetCooperativeLevel(hwnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE)))
                {
                    MessageBox(NULL, 
            "Set joystick cooperative level failed.""ERROR", MB_OK | MB_ICONINFORMATION);
                    
            return false;
                }

                
            // set property for mouse
                DIPROPRANGE device_prop;

                device_prop.diph.dwSize       
            = sizeof(DIPROPRANGE);
                device_prop.diph.dwHeaderSize 
            = sizeof(DIPROPHEADER);
                device_prop.diph.dwObj        
            = 0;
                device_prop.diph.dwHow        
            = DIPH_DEVICE;
                device_prop.lMin              
            = min;
                device_prop.lMax              
            = max;

                
            if(FAILED(_joystick->SetProperty(DIPROP_RANGE, &device_prop.diph)))
                {
                    MessageBox(NULL, 
            "Set property range for joystick failed.""ERROR", MB_OK | MB_ICONINFORMATION);
                    
            return false;
                }

                
            // set dead zone for joystick
                DIPROPDWORD dead_zone_prop;

                dead_zone_prop.diph.dwSize       
            = sizeof(DIPROPDWORD);
                dead_zone_prop.diph.dwHeaderSize 
            = sizeof(DIPROPHEADER);
                dead_zone_prop.diph.dwObj        
            = 0;
                dead_zone_prop.diph.dwHow        
            = DIPH_DEVICE;
                dead_zone_prop.dwData            
            = 100 * dead_zone;DIPROP_DEADZONE;

                
            if(FAILED(_joystick->SetProperty(DIPROP_DEADZONE, &dead_zone_prop.diph)))
                {
                    MessageBox(NULL, 
            "Set dead zone for joystick failed.""ERROR", MB_OK | MB_ICONINFORMATION);
                    
            return false;
                }

                
            // zero joystick buffer
                ZeroMemory(&_joystick, sizeof(DIJOYSTATE2));
                
                
            return true;
            }

            //------------------------------------------------------------------------------------
            // Read data from joystick.
            //------------------------------------------------------------------------------------
            bool GE_INPUT::Read_Joystick()
            {
                
            // get access to joystick
                if(FAILED(_joystick->Acquire()))
                    
            return false;

                
            // polling joystick to retrieve data
                if(FAILED(_joystick->Poll()))
                    
            return false;

                
            // get joystick current state
                if(DIERR_INPUTLOST == _joystick->GetDeviceState(sizeof(DIJOYSTATE2), &_joystick_buffer))
                {
                    
            // re-acquire access to joystick
                    _joystick->Acquire();

                    
            if(FAILED(_joystick->GetDeviceState(sizeof(DIJOYSTATE2), &_joystick_buffer)))
                        
            return false;
                }

                
            return true;
            }

            //------------------------------------------------------------------------------------
            // Application-defined callback function that receives Microsoft DirectInput devices 
            // as a result of a call to the IDirectInput8::EnumDevices method.
            //------------------------------------------------------------------------------------
            BOOL CALLBACK Enum_Joystick(LPCDIDEVICEINSTANCE device_instance, LPVOID data)
            {
                LPDIRECTINPUTDEVICE8
            * diDevice = (LPDIRECTINPUTDEVICE8*) data;

                
            if(FAILED(g_directinput->CreateDevice(device_instance->guidInstance, diDevice, NULL)))
                    
            return DIENUM_CONTINUE;

                
            return DIENUM_STOP;
            }

            測試程序,由于身邊沒有游戲手柄,所以無法測試關于Joystick的代碼,這個測試程序存在一些BUG,但大體能用。
            /*************************************************************************************
             [Implement File]

             PURPOSE: 
                Test Window Framework.
            ************************************************************************************
            */

            #define DIRECTINPUT_VERSION 0x0800

            #include 
            <stdio.h>
            #include 
            "GE_APP.h"
            #include 
            "GE_INPUT.h"

            #pragma warning(disable : 
            4996)

            int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR cmd_line, int cmd_show)
            {
                GE_APP ge_app;
                GE_INPUT ge_input;

                MSG msg 
            = {0};
                TCHAR temp_text[
            50= {0};
                POINT curr_pos; 
            // current mouse cursor position

                
            // create window
                if(! ge_app.Create_Window("Test Window Frame", instance, cmd_show))
                    
            return false;

                HWND hwnd 
            = ge_app.Get_Window_Handle();
                HDC hdc 
            = GetDC(hwnd);

                
            // create directinput
                ge_input.Create_Input(instance, hwnd, -10010020true);

                SetWindowPos(hwnd, 
            00,0,0,0, SWP_NOSIZE);
                SetCursorPos(
            00);

                
            while(msg.message != WM_QUIT)
                {
                    
            if(PeekMessage(&msg, NULL, 0,0 , PM_REMOVE))
                    {
                        TranslateMessage(
            &msg);
                        DispatchMessage(
            &msg);
                    }
                    
            else
                    {
                        
            // read data from keyboard buffer
                        if(ge_input.Read_Keyboard())
                        {
                            
            if(ge_input.Is_Key_Pressed(DIK_A))
                                MessageBox(NULL, 
            "Key A is pressed.""Hint", MB_OK | MB_ICONINFORMATION);

                            
            if(ge_input.Is_Key_Pressed(DIK_F) && ge_input.Is_Key_Pressed(DIK_LCONTROL))
                                MessageBox(NULL, 
            "Ctrl+F is pressed.""Hint", MB_OK | MB_ICONINFORMATION);

                            
            if(ge_input.Is_Key_Pressed(DIK_ESCAPE))
                                PostQuitMessage(
            0);
                        }

                        
            // read mouse input
                        if(ge_input.Read_Mouse())
                        {
                            GetCursorPos(
            &curr_pos);
                            ScreenToClient(hwnd, 
            &curr_pos);

                            
            if(ge_input.Is_LButton_Pressed())
                            {
                                sprintf(temp_text, 
            "LEFT(%d, %d)", ge_input.Get_Mouse_Move_X(), ge_input.Get_Mouse_Move_Y());
                                TextOut(hdc, curr_pos.x, curr_pos.y, temp_text, lstrlen(temp_text));
                            }

                            
            if(ge_input.Is_RButton_Pressed())
                            {
                                sprintf(temp_text, 
            "RIGHT(%d, %d)", ge_input.Get_Mouse_Move_X(), ge_input.Get_Mouse_Move_Y());
                                TextOut(hdc, curr_pos.x, curr_pos.y, temp_text, lstrlen(temp_text));
                            }
                        }
                    }
                }

                UnregisterClass(WINDOW_CLASS_NAME, instance);

                
            return true;
            }

            posted on 2007-05-07 01:42 lovedday 閱讀(1639) 評論(0)  編輯 收藏 引用 所屬分類: ■ DirectX 9 Program

            公告

            導航

            統計

            常用鏈接

            隨筆分類(178)

            3D游戲編程相關鏈接

            搜索

            最新評論

            久久久久久无码Av成人影院| 亚洲第一永久AV网站久久精品男人的天堂AV | 精品久久久久久国产| 中文字幕亚洲综合久久| 亚洲伊人久久成综合人影院 | 久久婷婷五月综合97色| 99久久精品国产一区二区| 亚洲?V乱码久久精品蜜桃| 久久99国内精品自在现线| 久久久久综合中文字幕| 久久精品人人槡人妻人人玩AV| 9999国产精品欧美久久久久久| 欧美精品乱码99久久蜜桃| 欧美激情精品久久久久| 伊人久久久AV老熟妇色| 久久久久一本毛久久久| 91精品国产综合久久精品| 一本久久a久久精品综合夜夜| 婷婷久久精品国产| 国产精品青草久久久久福利99 | 色88久久久久高潮综合影院| 久久久精品日本一区二区三区 | 久久婷婷五月综合国产尤物app| 亚洲午夜精品久久久久久浪潮 | 久久大香萑太香蕉av| 久久久WWW成人| 99久久无码一区人妻| 国产精品久久久久久影院| 无码人妻久久一区二区三区免费| 久久综合久久性久99毛片| 青青久久精品国产免费看| 国产精品美女久久久网AV| 国产精品99久久久久久猫咪| 久久精品国内一区二区三区| 久久精品国产91久久综合麻豆自制 | 久久国产劲爆AV内射—百度| 三级片免费观看久久| 香蕉久久影院| 久久久久久综合网天天| 亚洲精品乱码久久久久久按摩| 久久久SS麻豆欧美国产日韩|