000
14.09.2009, 22:17 Uhr
nuhp
|
hallo seit fünf stunden komm ich zwar immer n kleinen schritt weiter, aber dass das bild angezeigt wird klappt einfach nicht. ich finde meinen fehler nicht. ich wär äußerst dankbar für ne antwort. hier der kot:
C++: |
#include <windows.h> #include <tchar.h> #include <d3dx9.h> #include <d3d9.h> #pragma comment(lib, "d3dx9.lib") #pragma comment(lib, "d3d9.lib") static TCHAR szWindowClass[] = _T("ding"); static TCHAR szTitle[] = _T("teil"); HINSTANCE hInst; void render(); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); IDirect3DDevice9* g_pd3dDevice; IDirect3DSurface9* g_Surface; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { IDirect3D9* g_pD3D = Direct3DCreate9(D3D_SDK_VERSION); WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION)); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = NULL; wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION)); if (!RegisterClassEx(&wcex)) { MessageBox(NULL, _T("Call to RegisterClassEx failed."), _T("Fehler"), NULL); return 1; } hInst = hInstance; HWND hWnd = CreateWindow( szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 700, 700, NULL, NULL, hInstance, NULL ); if (!hWnd) { MessageBox(NULL, _T("Call to CreateWindow failed."), _T("gz"), NULL); return 1; } D3DPRESENT_PARAMETERS d3dpp; ZeroMemory(&d3dpp, sizeof(d3dpp)); d3dpp.Windowed = true; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferCount = 1; if(FAILED(g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice) )) { return E_FAIL; } if(NULL == g_pd3dDevice) MessageBox(0, _T("wtf"), _T("?"), 0); g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0xFF, 0, 0), 1.0f, 0); D3DXIMAGE_INFO infos; if(D3D_OK != D3DXGetImageInfoFromFile(_T("C:\\Users\\0\\Desktop\\win32test\\Debug\\gz.bmp"), &infos) ) { MessageBox(0, _T("D3DXGetImageInfoFromFile failed."), _T("ende"), 0); return 0; } if(D3D_OK != g_pd3dDevice->CreateOffscreenPlainSurface( infos.Width, infos.Height, infos.Format, D3DPOOL_DEFAULT, &g_Surface, NULL ) ) { MessageBox(0, _T("CreateOffscreenPlainSurface failed."), _T("ende"), 0); return 0; } D3DXLoadSurfaceFromFile( g_Surface, NULL, NULL, _T("C:\\Users\\0\\Desktop\\win32test\\Debug\\gz.bmp"), NULL, D3DX_FILTER_NONE, 0xFF000000, NULL ); ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); MSG msg; //while (GetMessage(&msg, NULL, 0, 0)) //{ // TranslateMessage(&msg); // DispatchMessage(&msg); //} GetMessage(&msg, NULL, 0, 0); while(msg.message != WM_QUIT) { if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else { render(); } } g_pD3D->Release(); // MessageBox(0, _T("ende"), _T("ende"), 0); return (int) msg.wParam; } void render() { static bool firstTime = true; if(g_pd3dDevice == NULL) { MessageBox(0, _T("Device ist NULL"), _T(""), 0); return; } LPDIRECT3DSURFACE9 BackBuffer = NULL; g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 255, 255), 1.0f, 0); if(SUCCEEDED(g_pd3dDevice->BeginScene())) { if(firstTime) { MessageBox(0, _T("success"), _T(""), 0); firstTime = false; } g_pd3dDevice->GetBackBuffer ( 0, 0, D3DBACKBUFFER_TYPE_MONO, &BackBuffer ); g_pd3dDevice->UpdateSurface( g_Surface, NULL, BackBuffer, NULL ); if(BackBuffer != NULL) { //MessageBox(0, _T("BackBuffer ungleich NULL"), _T(""), 0); BackBuffer->Release(); } g_pd3dDevice->EndScene(); g_pd3dDevice->Present(NULL, NULL, NULL, NULL); } } LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; HDC hdc; TCHAR greeting[] = _T("Hello, World!");
switch (message) { //case WM_PAINT: // hdc = BeginPaint(hWnd, &ps); // TextOut(hdc, // 5, 5, // greeting, _tcslen(greeting)); // EndPaint(hWnd, &ps); // break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); break; } return 0; }
|
Bearbeitung: |
Code-Tags durch cpp-Tags ersetzt.
|
Dieser Post wurde am 14.09.2009 um 23:41 Uhr von Hans editiert. |