2014-02-14 19 views
0

我有下面的代碼演示了我的問題。Awx與Directx 9 HWND不起作用

#include <windows.h> 
#include <d3d9.h> 

#include <Awesomium/WebCore.h> 
#include <Awesomium/BitmapSurface.h> 
#include <Awesomium/STLHelpers.h> 

// globals 
LPDIRECT3D9  g_pDirect3D = NULL; 
LPDIRECT3DDEVICE9 g_pDirect3D_Device = NULL; 

#define WIDTH 800 
#define HEIGHT 600 
#define URL  "http://www.google.com" 


LRESULT WINAPI WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); 



int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nShow) 
{ 
MSG msg; 

WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_VREDRAW|CS_HREDRAW|CS_OWNDC, 
    WndProc, 0, 0, hInstance, NULL, NULL, (HBRUSH)(COLOR_WINDOW+1), 
    NULL, "DX9_TUTORIAL1_CLASS", NULL}; 

RegisterClassEx(&wc); 

HWND hMainWnd = CreateWindow("DX9_TUTORIAL1_CLASS", 
    "Game's UI QA Awesomium", 
    WS_OVERLAPPEDWINDOW, 100, 100, WIDTH, HEIGHT, 
    NULL, NULL, hInstance, NULL); 

// Init the Awesomium objects 
Awesomium::WebCore* webCore =  Awesomium::WebCore::Initialize(Awesomium::WebConfig()); 
Awesomium::WebView* webView = webCore->CreateWebView(WIDTH, HEIGHT, 0, Awesomium::kWebViewType_Window); 
webView->set_parent_window(hMainWnd); 
webView->LoadURL((const Awesomium::WebURL)Awesomium::WSLit(URL)); 

// Wait for our WebView to finish loading 
while (webView->IsLoading()) { 
    webCore->Update(); 
} 

// Sleep a bit and update once more to give scripts and plugins 
// on the page a chance to finish loading. 
Sleep(300); 
webCore->Update(); 

// Init the D3D9 objects 
g_pDirect3D = Direct3DCreate9(D3D_SDK_VERSION); 

D3DPRESENT_PARAMETERS PresentParams; 
memset(&PresentParams, 0, sizeof(D3DPRESENT_PARAMETERS)); 

PresentParams.Windowed = TRUE; 
PresentParams.SwapEffect = D3DSWAPEFFECT_DISCARD; 

g_pDirect3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hMainWnd, 
    D3DCREATE_SOFTWARE_VERTEXPROCESSING, &PresentParams, 
    &g_pDirect3D_Device); 


ShowWindow(hMainWnd, nShow); 
UpdateWindow(hMainWnd); 

while(GetMessage(&msg, NULL, 0, 0)) 
{ 
    TranslateMessage(&msg); 
    DispatchMessage(&msg); 
} 

return(0); 
} 


LRESULT WINAPI WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 
{ 
switch(msg) 
{ 
case WM_DESTROY: 
    PostQuitMessage(0); 
    return(0); 
case WM_PAINT: 
    //g_pDirect3D_Device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0); 
    //g_pDirect3D_Device->Present(NULL, NULL, NULL, NULL); 

    //ValidateRect(hwnd, NULL); 
    return(0); 
} 

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

的事情是,我不能夠顯示谷歌的網頁窗口內的渲染,我想知道我在做什麼錯了,因爲我已經做了我可以在看到同樣的事情教程。

特別這一個:http://wiki.awesomium.com/general-use/introduction-to-web-views.html

你的輸入將不勝感激!! 謝謝!

回答

0

事實證明,我已經在項目目錄中添加了所有的.DLL文件,但不是awesomium_process.exe,它永久停留在加載階段。