createwindows.cpp
来自「用directx实现的天空盒 使用纹理贴图」· C++ 代码 · 共 85 行
CPP
85 行
#include "header.h"
#include "D3DInit.h"
CD3DInit* g_D3DInit = new CD3DInit();
long FAR PASCAL WindowProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_KEYDOWN:
switch(wParam)
{
case VK_ESCAPE:
PostMessage(hWnd, WM_CLOSE, 0, 0);
break;
}
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
MSG msg;
HWND hWnd;
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = NULL;
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "createwindows";
RegisterClass(&wc);
hWnd = CreateWindowEx( WS_EX_TOPMOST,
"createwindows",
"window title",
WS_OVERLAPPEDWINDOW,
50,
50,
800,
600,
NULL,
NULL,
hInstance,
NULL);
if(!hWnd)
{
return FALSE;
}
g_D3DInit->GameInit(hWnd);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
while(true)
{
if(PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
{
if(msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
g_D3DInit->Render();
}
}
DEL(g_D3DInit);
return 1;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?