Код: Выделить всё
#include <windows.h>
#include <d3d9.h>
LPDIRECT3D9 pDirect3D = NULL;
LPDIRECT3DDEVICE9 pDirect3DDevice = NULL;
HRESULT IntialDirect3D(HWND hwnd)
{
if (NULL == (pDirect3D = Direct3DCreate9(D3D_SDK_VERSION)))
return E_FAIL;
D3DDISPLAYMODE Display;
if (FAILED(pDirect3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &Display)))
return E_FAIL;
D3DPRESENT_PARAMETERS Direct3DParametr;
ZeroMemory(&Direct3DParametr,sizeof(Direct3DParametr));
Direct3DParametr.Windowed = TRUE;
Direct3DParametr.SwapEffect = D3DSWAPEFFECT_DISCARD;
Direct3DParametr.BackBufferFormat = Display.Format;
if (FAILED(pDirect3D-> CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL, hwnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
&Direct3DParametr, &pDirect3DDevice)))
return E_FAIL;
return S_OK;
}
VOID RenderingDirect3D()
{
if(pDirect3DDevice == NULL)
return;
pDirect3DDevice -> Clear( 0, NULL,D3DCLEAR_TARGET, D3DCOLOR_XRGB(255, 255, 50), 1.0f,0);
pDirect3DDevice -> BeginScene();
pDirect3DDevice -> EndScene();
pDirect3DDevice -> Present(NULL, NULL, NULL, NULL);
VOID DeleteDirect3D()
{
if (pDirect3DDevice != NULL)
pDirect3DDevice -> Release();
if (pDirect3D != NULL)
pDirect3D -> Release();
}
LRESULT CALLBACK MainWinProc( HWND hwnd,
UINT msg,
WPARAM wparam,
LPARAM lparam)
{
switch(msg)
{
case WM_PAINT:
RenderingDirect3D();
ValidateRect(hwnd, NULL);
break;
case WM_DESTROY:
{
DeleteDirect3D();
PostQuitMessage(0);
return(0);
} break;
}
return (DefWindowProc(hwnd, msg, wparam, lparam));
}
int WINAPI WinMain( HINSTANCE hinstance,
HINSTANCE hprevinstance,
LPSTR lpcmdline,
int ncmdshow)
{
WNDCLASSEX windowsclass;
HWND hwnd;
MSG msg;
windowsclass.cbSize = sizeof(WNDCLASSEX);
windowsclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
windowsclass.lpfnWndProc = MainWinProc;
windowsclass.cbClsExtra = 0;
windowsclass.cbWndExtra = 0;
windowsclass.hInstance = hinstance;
windowsclass.hIcon = LoadIcon(hinstance, IDI_APPLICATION);
windowsclass.hCursor = LoadCursor(NULL, IDC_ARROW);
windowsclass.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
windowsclass.lpszMenuName = NULL;
windowsclass.lpszClassName = "WINDOWSCLASS";
windowsclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if (!RegisterClassEx(&windowsclass))
return(0);
if (!(hwnd = CreateWindowEx(NULL,
"WINDOWSCLASS",
"Îêíî äëÿ DirectX ",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
200,200,
800,600,
NULL,
NULL,
hinstance,
NULL)))
if (SUCCEEDED(InitialDirect3D(hwnd)))
{
ShowWindow(hwnd, SW_SHOWDEFAULT);
UpdateWindow(hwnd);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
}
Ошибки вот:
E:\Visual C++\3dokno\main.cpp(61) : error C2601: 'DeleteDirect3D' : local function definitions are illegal
E:\Visual C++\3dokno\main.cpp(75) : error C2601: 'MainWinProc' : local function definitions are illegal
E:\Visual C++\3dokno\main.cpp(104) : error C2601: 'WinMain' : local function definitions are illegal
E:\Visual C++\3dokno\main.cpp(152) : fatal error C1004: unexpected end of file found
пожалуста подскажите целый день мучаюсь