hi!
i want to make a software-renderer, like the one i did before in an other programming language. this time, i'll do it in C++. the problem is: how do i draw pixels on the window (FAST) ?
something like a pointer to the screen buffer would be nice
thanks for helping.
Code:#include <windows.h> LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow) { WNDCLASS wc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hInstance = hInstance; wc.lpfnWndProc = WndProc; wc.lpszClassName = TEXT("MainWindow"); wc.lpszMenuName = 0; wc.style = CS_HREDRAW | CS_VREDRAW; RegisterClass(&wc); HWND hwnd = CreateWindow( TEXT("MainWindow"), TEXT("Test"), WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, 100, 100, 640, 480, NULL, NULL, hInstance, NULL ); ShowWindow(hwnd, iCmdShow); MSG msg; while (GetMessage(&msg, NULL, 0, 0 )) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { switch (message) { case WM_PAINT: HDC hdc; PAINTSTRUCT ps; hdc = BeginPaint(hwnd, &ps); for (int y = 0; y < 480; y++) { for (int x = 0; x < 640; x++) { SetPixel(hdc, x, y, 0xffffff); } } EndPaint(hwnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hwnd, message, wparam, lparam); }



LinkBack URL
About LinkBacks




