Нарисовать необработанный массив пикселей в окне (C++ WinAPI)C++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Нарисовать необработанный массив пикселей в окне (C++ WinAPI)

Сообщение Anonymous »


I have two buffers, both of the same size and type (uint32_t*). These buffers are supposed to represent the front and back buffers of a rendering/drawing system. They store 32-bit pixel data.

I declare and initialize these buffers using;

private: ... uint32_t* frontBuf; uint32_t* backBuf; size_t gbufSize; ... public: void Initialize() { ... // prepare for rendering gbufSize = sizeof(uint32_t) * w * h; backBuf = (uint32_t*)malloc(gbufSize); frontBuf = (uint32_t*)malloc(gbufSize); ... } I also get the output, window and device handles for the console in the Initialize() method using:

// get handles cwd = GetDC(GetConsoleWindow()); chd = GetStdHandle(STD_OUTPUT_HANDLE); cwn = GetConsoleWindow(); I then have a few drawing methods, like a SetPixel method:

size_t GFlatten(int x, int y) { return y * h + x; } void GSetPixel(int x, int y, uint32_t color) { backBuf[GFlatten(x, y)] = color; } And finally, I have a GSwap method. This method is supposed to swap the pointers of the buffers, clear the new back buffer and copy the front buffer to the screen.

The first two work (I think), but I have no idea how to implement the 3rd one (copying to the screen). I would prefer to not use any external libraries.

Code for GSwap method:

void GSwap() { // swap pointers uint32_t* frontTmp = frontBuf; frontBuf = backBuf; backBuf = frontTmp; // clear new back buffer memset(backBuf, 0, gbufSize); // draw on screen /* ??? */ } The full code: Pastebin


Источник: https://stackoverflow.com/questions/706 ... w-c-winapi
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»