Hello everyone, I am returning to C++ to start programming some games again, and I don't know how to set the ClientSize of a form from this context. Here is the source code...
Code:
#include <windows.h>
#include <d3d9.h>
const int XRESOLUTION = 640;
const int YRESOLUTION = 480;
LPDIRECT3D9 g_pDirect3D = NULL;
LPDIRECT3DDEVICE9 g_pDirect3D_Device = NULL;
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);
// this sets the form size including the borders
HWND hMainWnd = CreateWindow("DX9_TUTORIAL1_CLASS", "DirectX 9 Bare Bones Tutorial 1", WS_OVERLAPPEDWINDOW, 100, 100, 300, 6, NULL, NULL, hInstance, NULL);
// here I would fix the ClientSize, if I knew how... and maybe a CenterToScreen() call, but I can't get that to work either
// create the DirectX device(s)
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:
g_pDirect3D_Device->Release();
g_pDirect3D->Release();
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
void prepareScene() {
g_pDirect3D_Device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0);
}
void finishScene() {
g_pDirect3D_Device->Present(NULL, NULL, NULL, NULL);
}
Another less important question: Why is the IntelliSense with the 2008 Visual C++ Express Edition environment so much slower (or completely non responsive) as opposed to the C# version?