Nisi rekao koji graficki API bi da koristis ili si mislio nesto od biblioteka sto je vec Srki spomenuo?
"Win32 project" nema veze sa "Formama" sto si ih mozda susretao u VB-u, C#, NET familijama jezika, koji ti nude predefinisane/templejt/wizard generated projekte.
Recimo ako ces da radis crtanje sa DirectX-om (ne znam za OpenGL) onda ti treba handle klijenstkog prostora nekog prozora da bi uopste mogao i da pocnes. Izaberes "Win32 project" pa izaberes "Empty project" i polako ubacujes svoj kod.
Ovo ti je minimum za kreiranje prozora na kome ces da crtas:
#include <Windows.h>
HWND hwnd = nullptr;
bool run = true;
const SIZE DRAW_BOARD_DIM = { 200, 200 };
LRESULT CALLBACK MyWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_KEYUP:
{
if(wParam == VK_ESCAPE)
{
run = false;
}
return 0;
}break;
case WM_CLOSE:
{
run = false;
return 0;
}break;
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}break;
// ... hendluj ostale poruke koje ti trebaju
};
return DefWindowProc(hWnd, msg, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASS wndClass;
memset(&wndClass, 0, sizeof(WNDCLASS));
wndClass.hInstance = GetModuleHandle(0);
wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = reinterpret_cast<WNDPROC>( MyWindowProc );
wndClass.lpszClassName = TEXT("SimpleClass");
wndClass.hbrBackground = GetSysColorBrush(COLOR_BACKGROUND);
if(0 == RegisterClass(&wndClass))
{
MessageBox(0, TEXT("RegisterClass() failed!"), 0, 0);
return EXIT_FAILURE;
}
DWORD style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPSIBLINGS | WS_MINIMIZEBOX | WS_VISIBLE;
// Centrira prozor na sredinu desktopa
RECT clientSize;
clientSize.top = 0;
clientSize.left = 0;
clientSize.right = DRAW_BOARD_DIM.cx;
clientSize.bottom = DRAW_BOARD_DIM.cy;
AdjustWindowRect(&clientSize, style, FALSE);
int realWidth = clientSize.right - clientSize.left;
int realHeight = clientSize.bottom - clientSize.top;
int windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2;
int windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2;
// kreira prozor
hwnd = CreateWindow(
TEXT("SimpleClass"), TEXT("Simple"), style,
windowLeft, windowTop, realWidth, realHeight,
NULL, NULL, GetModuleHandle(0), NULL);
if(nullptr == hwnd)
{
MessageBox(0, TEXT("CreateWindow() failed!"), 0, 0);
return EXIT_FAILURE;
}
ShowWindow(hwnd, SW_SHOW);
UpdateWindow(hwnd);
// glavna petlja
while(run)
{
MSG msg = {0};
while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
// ... ovde crtas
}
return EXIT_SUCCESS;
}
|