котвася
14-02-2010, 16:35
не получается, набираю по примеру в книге.
Вот:
отчет прикрепил
#include "stdafx.h"
//-------------------
char szWindowClass[] = "Direct3DTemplateProj";
char szTitle[] = "Direct3d Demo by Michael Flenov";
//--------------------
IDirect3D9 *pD3D = NULL;
IDirect3DDevice9 *pD3DDevice = NULL;
int iWidth = 800;
int iHeight = 600;
//--------------------
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nShowCmd);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
bool Init(HWND hWnd);
void GraphEngine();
//--------------------
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nShowCmd)
{
WNDCLASSEX wcex;
MSG msg;
HWND hWnd;
CoInitialize(NULL);
//-------------------
wcex.cbSize = sizeof(wcex);
wcex.style = CS_CLASSDC;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInst;
wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = NULL;
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wcex))
return FALSE;
//----------------------
hWnd = CreateWindow(szWindowClass, szTitle, WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, iWidth, iHeight, NULL, NULL, hInst, NULL);
if(!hWnd)
return FALSE;
//----------------------
ShowWindow(hWnd, SW_NORMAL);
UpdateWindow(hWnd);
//----------------------
if(Init(hWnd) == TRUE)
{
while(true)
{
if(PeekMessage(&msg, NULL,NULL,NULL,PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
if(msg.message == WM_QUIT) break;
}
GraphEngine();
}
}
//----------------------------
if(pD3DDevice) {pD3DDevice = NULL; pD3DDevice = NULL;}
if(pD3D) {pD3D = NULL; pD3D = NULL;}
CoUninitialize();
return 0;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
bool Init(HWND hWnd)
{
if(DX3DInitZ(&pD3D, &pD3DDevice, hWnd,iWidth,iHeight,FALSE) != S_OK)
{
MessageBox(hWnd, "DirectX Initialize Error","Error",MB_OK);
return FALSE;
}
return TRUE;
}
void GraphEngine()
{
pD3DDevice->Clear(0,NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1.0f,0);
if(SUCCEEDED(pD3DDevice->BeginScene()))
{
pD3DDevice->EndScene();
}
pD3DDevice->Present(NULL,NULL,NULL,NULL);
}
Вот:
отчет прикрепил
#include "stdafx.h"
//-------------------
char szWindowClass[] = "Direct3DTemplateProj";
char szTitle[] = "Direct3d Demo by Michael Flenov";
//--------------------
IDirect3D9 *pD3D = NULL;
IDirect3DDevice9 *pD3DDevice = NULL;
int iWidth = 800;
int iHeight = 600;
//--------------------
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nShowCmd);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
bool Init(HWND hWnd);
void GraphEngine();
//--------------------
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nShowCmd)
{
WNDCLASSEX wcex;
MSG msg;
HWND hWnd;
CoInitialize(NULL);
//-------------------
wcex.cbSize = sizeof(wcex);
wcex.style = CS_CLASSDC;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInst;
wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = NULL;
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wcex))
return FALSE;
//----------------------
hWnd = CreateWindow(szWindowClass, szTitle, WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, iWidth, iHeight, NULL, NULL, hInst, NULL);
if(!hWnd)
return FALSE;
//----------------------
ShowWindow(hWnd, SW_NORMAL);
UpdateWindow(hWnd);
//----------------------
if(Init(hWnd) == TRUE)
{
while(true)
{
if(PeekMessage(&msg, NULL,NULL,NULL,PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
if(msg.message == WM_QUIT) break;
}
GraphEngine();
}
}
//----------------------------
if(pD3DDevice) {pD3DDevice = NULL; pD3DDevice = NULL;}
if(pD3D) {pD3D = NULL; pD3D = NULL;}
CoUninitialize();
return 0;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
bool Init(HWND hWnd)
{
if(DX3DInitZ(&pD3D, &pD3DDevice, hWnd,iWidth,iHeight,FALSE) != S_OK)
{
MessageBox(hWnd, "DirectX Initialize Error","Error",MB_OK);
return FALSE;
}
return TRUE;
}
void GraphEngine()
{
pD3DDevice->Clear(0,NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1.0f,0);
if(SUCCEEDED(pD3DDevice->BeginScene()))
{
pD3DDevice->EndScene();
}
pD3DDevice->Present(NULL,NULL,NULL,NULL);
}