{"id":446475,"date":"2025-01-30T21:01:30","date_gmt":"2025-01-30T21:01:30","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=446475"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2025-01-30T21:01:30","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=446475","title":{"rendered":"<span>\u041f\u0438\u0448\u0435\u043c \u043b\u0435\u0433\u0430\u0441\u0438 \u0441 \u043d\u0443\u043b\u044f \u043d\u0430 \u0421++, \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u044f \u043f\u043e\u0434\u043e\u0437\u0440\u0435\u043d\u0438\u0435 \u0443 \u0441\u0430\u043d\u0438\u0442\u0430\u0440\u043e\u0432. 05 \u2014 GDI \u0440\u0435\u043d\u0434\u0435\u0440<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e, \u0425\u0430\u0431\u0440\u0430\u0432\u0447\u0430\u043d\u0435!<\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0440\u0435\u043f\u0430\u00a0<a href=\"https:\/\/github.com\/JordanCpp\/RetroFan\" rel=\"noopener noreferrer nofollow\">RetroFan<\/a>.  <\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u0443\u0445\u043d\u0435\u0442 \u0441\u0442\u0440\u043e\u0447\u043a\u0430\u043c\u0438 \u043a\u043e\u0434\u0430. \u042f \u0432\u0441\u0442\u0440\u043e\u0438\u043b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a. \u0422\u0430\u043a \u043a\u0430\u043a \u044f \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u0438\u0439 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u041c\u043d\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0438\u0434\u0435\u043e\u043b\u043e\u0433\u0438\u044f \u043f\u0440\u0438\u043d\u044f\u0442\u0430\u044f \u0432 Windows, libc \u0438\u043b\u0438 SDL2. \u041f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442 \u0435\u0451 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043e\u0434\u0443 \u043e\u0448\u0438\u0431\u043a\u0438, \u0442\u043e \u0434\u043b\u044f \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e GetLastError.<\/p>\n<p>\u0418 \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435 \u043f\u043b\u043e\u0445, \u043d\u043e \u043c\u0435\u043d\u044f \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u0442 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0414\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u043a\u043b\u0430\u0441\u0441 <a href=\"https:\/\/github.com\/JordanCpp\/RetroFan\/blob\/master\/LDL\/source\/Result.cpp\" rel=\"noopener noreferrer nofollow\">Result<\/a>.<\/p>\n<pre><code class=\"cpp\">namespace LDL { class Result { public: Result(); bool Ok(); const std::string&amp; Message(); void Message(const std::string&amp; message); void Message(const std::string&amp; message, const std::string&amp; detail); void Clear(); private: void Assert(const std::string&amp; message); bool        _ok; std::string _message; }; }<\/code><\/pre>\n<p>\u0418 \u0443\u0436\u0435 \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u044e \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0442\u0435\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u043a\u043b\u0430\u0441\u0441 \u043e\u043a\u043d\u0430.<\/p>\n<pre><code class=\"cpp\">LDL::Result result; LDL::Window window(result, LDL::Vec2i(0, 0), LDL::Vec2i(800, 600));      if (!result.Ok())     {         result.Message(); \/\/\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438     }<\/code><\/pre>\n<p>\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u0441\u0451, \u0447\u0442\u043e \u0443\u0433\u043e\u0434\u043d\u043e. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 WinAPI \u043f\u0440\u0438 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0438 \u043b\u0438\u043d\u0438\u0438. \u041d\u043e \u044f \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u0447\u0442\u043e \u043d\u0438\u043a\u043e\u043c\u0443 \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043e\u043a \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0438\u0433\u0440, \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u0440\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u043e\u0438\u043d\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0430 \u0438\u0433\u0440\u0443 \u0438\u043b\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c. <\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0442\u0430\u043a\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442.<\/p>\n<pre><code class=\"cpp\">void Result::Message(const std::string&amp; message) { _ok = false;  _message = message;  Assert(_message); }   void Result::Assert(const std::string&amp; message) { puts(message.c_str()); abort(); }<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432 result \u0431\u044b\u043b\u0430 \u0437\u0430\u043f\u0438\u0441\u044c \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435, \u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0435\u0451 \u0438 \u043f\u0440\u0435\u043a\u0440\u0430\u0449\u0430\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041f\u043b\u044e\u0441\u044b \u0443 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u0435\u0441\u0442\u044c, \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430. \u0412 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044e \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c, \u0435\u0441\u043b\u0438 \u043e\u043f\u0446\u0438\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u0432\u0441\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0430\u0441\u0441\u0435\u0440\u0442\u0438\u043c, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438.<\/p>\n<p>\u041e\u0431\u0435\u0440\u043d\u0443\u043b \u0444\u0443\u043d\u043a\u0446\u0438\u044e Windows GetLastError \u0432 \u043a\u043b\u0430\u0441\u0441.<\/p>\n<pre><code class=\"cpp\">const std::string&amp; WindowError::GetErrorMessage() {     DWORD ident = GetLastError();     assert(ident != 0);      LPSTR buffer = NULL;      size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, ident, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&amp;buffer, 0, NULL);      _message.append(buffer, size);      LocalFree(buffer);      return _message; }<\/code><\/pre>\n<p>\u0418 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043a\u0438 WinApi \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">_activePalette = CreatePalette(&amp;gdiPalette.logPalette);  if (_activePalette == NULL) { _result.Message(_windowError.GetErrorMessage()); }<\/code><\/pre>\n<p>_result \u0438 _windowError \u044d\u0442\u043e \u0447\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0432\u0438\u0433\u0430\u0435\u043c\u0441\u044f \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0440\u0435\u043d\u0434\u0435\u0440\u0430. \u041f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043f\u043e WinApi:) \u0418 \u0435\u0441\u043b\u0438 \u0437\u0430\u0431\u0435\u0436\u0430\u0442\u044c \u0432\u043f\u0435\u0440\u0435\u0434, \u0437\u0430\u0434\u0443\u043c\u0430\u043d\u043d\u043e\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u042f \u0441\u043e\u0437\u0434\u0430\u043b \u0434\u0432\u0430 \u0440\u0435\u043d\u0434\u0435\u0440\u0430 \u0434\u043b\u044f GDI.<\/p>\n<ol>\n<li>\n<p>\u0420\u0435\u043d\u0434\u0435\u0440 \u0443\u043c\u0435\u044e\u0449\u0438\u0439 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c RGB\/A \u0438 \u043f\u0430\u043b\u0438\u0442\u0440\u043e\u0432\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u044f \u0438\u0445 \u0432 RGB.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0435\u043d\u0434\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u044f\u0449\u0438\u0439 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043f\u0430\u043b\u0438\u0442\u0440\u043e\u0432\u044b\u043c\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<\/li>\n<\/ol>\n<p><strong>RGB \u0440\u0435\u043d\u0434\u0435\u0440.<\/strong><\/p>\n<p>\u041a\u043e\u0434 \u043b\u0435\u0436\u0438\u0442 \u0432 <a href=\"https:\/\/github.com\/JordanCpp\/RetroFan\/blob\/master\/LDL\/source\/Windows\/GdiRndr.cpp\" rel=\"noopener noreferrer nofollow\">GdiRndr.cpp<\/a><\/p>\n<pre><code class=\"cpp\">namespace LDL { class GdiTexture;  class GdiRender { public: GdiRender(Result&amp; result, MainWindow&amp; window); GdiRender(Result&amp; result, MainWindow&amp; window, const Palette&amp; palette); ~GdiRender(); const Palette&amp; GetPalette(); const Color&amp; GetColor(); void SetColor(const Color&amp; color); void SetColor(uint8_t index); void Begin(); void End(); void Clear(); void Line(const Vec2i&amp; first, const Vec2i&amp; last); void Fill(const Vec2i&amp; pos, const Vec2i&amp; size); void Draw(GdiTexture* texture, const Vec2i&amp; dstPos, const Vec2i&amp; dstSize, const Vec2i&amp; srcPos, const Vec2i&amp; srcSize); void Draw(GdiTexture* texture, const Vec2i&amp; pos); void Draw(GdiTexture* texture, const Vec2i&amp; pos, const Vec2i&amp; size); const HDC Hdc(); private: MainWindow&amp; _window; BaseRender  _baseRender; Result&amp;     _result; WindowError _windowError; Palette     _palette; }; }<\/code><\/pre>\n<p>\u041d\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"https:\/\/github.com\/JordanCpp\/RetroFan\/blob\/febc3c767464cc5dc130efb648565baa9bcb8127\/LDL\/source\/Windows\/GdiRndr.cpp#L98\" rel=\"noopener noreferrer nofollow\">Draw<\/a>. \u0414\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d\u0430, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 \u0451\u0435 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438.<\/p>\n<pre><code class=\"cpp\">void GdiRender::Draw(GdiTexture* texture, const Vec2i&amp; dstPos, const Vec2i&amp; dstSize, const Vec2i&amp; srcPos, const Vec2i&amp; srcSize) { assert(texture != NULL);  HDC hdcm = CreateCompatibleDC(_window.Hdc());  if (hdcm == NULL) { _result.Message(_windowError.GetErrorMessage()); } else { HGDIOBJ object = SelectObject(hdcm, texture-&gt;Bitmap());  if (object == NULL) { _result.Message(_windowError.GetErrorMessage()); } else { if (texture-&gt;GetColorKey().Used()) { Color color = texture-&gt;GetColorKey().GetColor();  if (TransparentBlt(_window.Hdc(), dstPos.x, dstPos.y, dstSize.x, dstSize.y, hdcm, srcPos.x, srcPos.y, srcSize.x, srcSize.y, RGB(color.r, color.g, color.b)) == FALSE) { _result.Message(_windowError.GetErrorMessage()); } } else { if (StretchBlt(_window.Hdc(), dstPos.x, dstPos.y, dstSize.x, dstSize.y, hdcm, srcPos.x, srcPos.y, srcSize.x, srcSize.y, SRCCOPY) == FALSE) { _result.Message(_windowError.GetErrorMessage()); } }  DeleteDC(hdcm); } } }<\/code><\/pre>\n<p>\u0412\u0441\u0435\u0433\u043e 40 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430, \u0432\u0441\u0435\u0445 \u0442\u0438\u043f\u043e\u0432 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0441 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c\u044e. \u0413\u043b\u0430\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0435 \u0437\u0430 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u044d\u0442\u043e:<\/p>\n<p><a href=\"https:\/\/vsokovikov.narod.ru\/New_MSDN_API\/Bitmaps\/fn_transparentblt.htm\" rel=\"noopener noreferrer nofollow\">TransparentBlt<\/a> &#8212; \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0438 \u0438\u0437 \u043e\u0437\u0443 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0446\u0432\u0435\u0442\u0430 \u0430\u043b\u044c\u0444\u044b.<\/p>\n<p><a href=\"https:\/\/vsokovikov.narod.ru\/New_MSDN_API\/Bitmaps\/fn_stretchblt.htm\" rel=\"noopener noreferrer nofollow\">StretchBlt<\/a> &#8212; \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0438 \u0438\u0437 \u043e\u0437\u0443 \u0431\u0435\u0437 \u0443\u0447\u0435\u0442\u0430 \u0430\u043b\u044c\u0444\u044b.<\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 Windows 95, 98. \u0414\u043b\u044f Windows 3.1 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0439\u0442\u0438 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0443. \u041d\u0443 \u0438 \u0435\u0449\u0451 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0435 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435. \u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0438 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442\u044b.<\/p>\n<p>\u041e\u0431\u0435\u0440\u043d\u0443\u043b API GDI \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0432 \u0441\u0432\u043e\u0438 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0435 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b. \u041a\u043b\u0430\u0441\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c.<\/p>\n<pre><code class=\"cpp\">namespace LDL { class GdiRender;  class GdiTexture { public: GdiTexture(Result&amp; result, GdiRender* render, const Vec2i&amp; size, uint8_t bpp, uint8_t* pixels); GdiTexture(Result&amp; result, GdiRender* render, const Vec2i&amp; size, uint8_t bpp, uint8_t* pixels, const Color&amp; color); GdiTexture(Result&amp; result, GdiRender* render, const Vec2i&amp; size, uint8_t* pixels); ~GdiTexture(); const ColorKey&amp; GetColorKey() const; const Vec2i&amp; Size(); const HBITMAP Bitmap(); private: Vec2i       _size; GdiRender*  _render; HBITMAP     _bitmap; ColorKey    _colorKey; Result&amp;     _result; WindowError _windowError; }; }<\/code><\/pre>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f:<\/p>\n<pre><code class=\"cpp\">GdiTexture::GdiTexture(Result&amp; result, GdiRender* render, const Vec2i&amp; size, uint8_t bpp, uint8_t* pixels) :     _size(size),     _render(render),     _bitmap(NULL),     _result(result) {     assert(render != NULL);     assert(size.x &gt; 0);     assert(size.y &gt; 0);     assert(bpp == 3 || bpp == 4);     assert(pixels != NULL);      uint8_t* dstPixels = NULL;      _bitmap = CreateDib(_render-&gt;Hdc(), _size, bpp, (void**)&amp;dstPixels);      if (_bitmap == NULL)     {         _result.Message(_windowError.GetErrorMessage());     }     else     {         PixelConverter conv;         conv.RgbToBgr(_size, bpp, pixels);          size_t bytes = _size.x * _size.y * bpp;         memcpy(dstPixels, pixels, bytes);          conv.BgrToRgb(_size, bpp, pixels);     } }<\/code><\/pre>\n<p>\u0422\u0435\u043a\u0441\u0442\u0443\u0440\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 RGB \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439. \u0422\u0430\u043a\u043e\u0439 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043b\u044e\u0431\u044b\u043c\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438 \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439. \u0415\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u043c\u043e\u043c\u0435\u043d\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043d\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f, \u043d\u043e \u0432 \u0440\u0435\u0430\u043b\u0438\u044f\u0445 \u0435\u0434\u0438\u043d\u043e\u0433\u043e API \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0441\u0438\u0441\u0442\u0435\u043c, \u043f\u043e \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u041f\u0440\u0438 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443, \u0434\u043b\u044f Windows \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c RGB \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 BGR \u0438 \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443. \u0418 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u043f\u0430\u0434\u0430\u0442\u044c. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044f\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 Windows \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 BGR.<\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0430\u043b\u0438\u0442\u0440\u043e\u0432\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439. \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e RGB \u0440\u0435\u043d\u0434\u0435\u0440\u0430, \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043f\u0430\u043b\u0438\u0442\u0440\u043e\u0432\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f \u043f\u0430\u043b\u0438\u0442\u0440\u044b \u0432 RGB \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"cpp\">GdiTexture::GdiTexture(Result&amp; result, GdiRender* render, const Vec2i&amp; size, uint8_t* pixels) :     _size(size),     _render(render),     _bitmap(NULL),     _result(result) {     assert(render != NULL);     assert(size.x &gt; 0);     assert(size.y &gt; 0);     assert(pixels != NULL);      uint8_t* dstPixels = NULL;      _bitmap = CreateDib(_render-&gt;Hdc(), _size, _render-&gt;GetPalette(), (void**)&amp;dstPixels);       if (_bitmap == NULL)     {         _result.Message(_windowError.GetErrorMessage());     }     else     {         size_t bytes = _size.x * _size.y;         memcpy(dstPixels, pixels, bytes);     } }<\/code><\/pre>\n<p>\u041f\u0430\u043b\u0438\u0442\u0440\u0430 \u043e\u0434\u043d\u0430 \u043d\u0430 \u0440\u0435\u043d\u0434\u0435\u0440 \u0438 \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 Render. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0434\u0438\u043d\u044b\u0439 API \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0442\u0438\u043f\u043e\u0432 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0440\u0435\u043d\u0434\u0435\u0440\u043e\u043c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0430\u043b\u0438\u0442\u0440\u044b \u0438 \u044d\u0442\u043e\u0442 \u0436\u0435 \u0440\u0435\u043d\u0434\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u0436\u0435\u043b\u0435\u0437\u0435 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u044f \u043f\u0430\u043b\u0438\u0442\u0440\u0443 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0435\u0439 \u0432 RGB.<\/p>\n<p><strong>\u0420\u0435\u043d\u0434\u0435\u0440 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0430\u043b\u0438\u0442\u0440\u044b.<\/strong><\/p>\n<p>\u041a\u043e\u0434 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <a href=\"https:\/\/github.com\/JordanCpp\/RetroFan\/blob\/master\/LDL\/source\/Windows\/GdiPRndr.cpp\" rel=\"noopener noreferrer nofollow\">GdiPRndr.cpp<\/a><\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u043d\u0434\u0435\u0440 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0431\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u044b Windows, \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043f\u0430\u043b\u0438\u0442\u0440\u0443 \u0434\u043b\u044f \u043e\u043a\u043d\u0430<\/p>\n<pre><code class=\"cpp\">GdiPaletteRender::GdiPaletteRender(Result&amp; result, MainWindow&amp; window, const Palette&amp; palette) : _window(window), _palette(palette), _hdcm(NULL), _result(result) { GdiPalette gdiPalette; GdiFill(gdiPalette, _palette);  _activePalette = CreatePalette(&amp;gdiPalette.logPalette);  if (_activePalette == NULL) { _result.Message(_windowError.GetErrorMessage()); } }<\/code><\/pre>\n<p>\u041f\u0430\u043b\u0438\u0442\u0440\u043e\u0432\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a.<\/p>\n<pre><code class=\"cpp\">GdiPaletteTexture::GdiPaletteTexture(Result&amp; result, GdiPaletteRender* render, const Vec2i&amp; size, uint8_t* pixels) :     _size(size),     _render(render),     _bitmap(NULL),     _result(result) {     assert(render != NULL);     assert(size.x &gt; 0);     assert(size.y &gt; 0);     assert(pixels != NULL);      uint8_t* dstPixels = NULL;      _bitmap = CreateDib(_render-&gt;Hdc(), _size, _render-&gt;GetPalette(), (void**)&amp;dstPixels);      if (_bitmap == NULL)     {         _result.Message(_windowError.GetErrorMessage());     }     else     {         size_t bytes = _size.x * _size.y;         memcpy(dstPixels, pixels, bytes);     } }<\/code><\/pre>\n<p>\u0422\u0435\u043a\u0441\u0442\u0443\u0440\u0430 \u0445\u0440\u0430\u043d\u0438\u0442 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043d\u0430 \u043f\u0430\u043b\u0438\u0442\u0440\u0443 RGB. \u0418 \u043f\u0440\u0438 \u0432\u044b\u0432\u043e\u0434\u0430 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 rgb \u0446\u0432\u0435\u0442. <\/p>\n<p>\u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0432 \u043c\u043e\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u044d\u0442\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043e\u0434\u043d\u043e\u0439 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u043b\u0438\u0442\u0440\u044b \u0434\u043b\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0430. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e, \u0447\u0442\u043e \u0431\u044b \u0435\u0434\u0438\u043d\u044b\u0439 API \u043c\u043e\u0433 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430 \u043b\u044e\u0431\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, OpenGL, DirectX, Vulkan. \u0412 \u043d\u043e\u0432\u044b\u0445 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0445 API \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043f\u0430\u043b\u0438\u0442\u0440\u044b.<\/p>\n<p>\u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0432 DOS&#8217;\u0435 \u043f\u0430\u043b\u0438\u0442\u0440\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438, \u0447\u0435\u043c \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b. \u041d\u0430 OpenGL, \u044d\u0442\u043e \u043d\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430 \u0441\u0442\u0430\u0440\u044b\u0445 \u0438 \u043d\u043e\u0432\u044b\u0445 \u041f\u041a, \u0435\u0434\u0438\u043d\u0430\u044f \u043f\u0430\u043b\u0438\u0442\u0440\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u044d\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u043d\u043e\u0432\u044b\u0445 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0445 API, \u0430 \u043d\u0430 \u0441\u0442\u0430\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430\u0442\u0438\u0432\u043d\u043e.<\/p>\n<p>\u0410, \u0447\u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u044d\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f, \u0434\u0430\u0436\u0435 \u0434\u043b\u044f \u0441\u043e\u0444\u0442\u0430 \u0438 \u0438\u0433\u0440, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u0445 \u043f\u0430\u043b\u0438\u0442\u0440\u044b. \u0418\u0433\u0440\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430\u0442\u0438\u0432\u043d\u043e \u043d\u0430 \u0441\u0442\u0430\u0440\u043e\u043c \u0436\u0435\u043b\u0435\u0437\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0435 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u043d\u0430 \u043d\u043e\u0432\u043e\u043c. \u041d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e, \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0441 \u043d\u0443\u0436\u043d\u044b\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u043e\u043c.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 <a href=\"https:\/\/github.com\/JordanCpp\/RetroFan\/blob\/master\/LDL_Pal.cpp\" rel=\"noopener noreferrer nofollow\">LDL_Pal.cpp<\/a><\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">#define LDL_RENDER_NATIVE_PALETTE #include &lt;LDL\/LDL.hpp&gt; #include &lt;vector&gt;  int main() { LDL::Palette palette;  palette.Set(0, LDL::Color(0, 0, 0)); palette.Set(1, LDL::Color(255, 255, 255)); palette.Set(2, LDL::Color(255, 0, 0)); palette.Set(3, LDL::Color(0, 255, 0)); palette.Set(4, LDL::Color(0, 0, 255)); palette.Set(5, LDL::Color(255, 255, 0)); palette.Set(6, LDL::Color(0, 255, 255));  LDL::Result result; LDL::Window window(result, LDL::Vec2i(0, 0), LDL::Vec2i(800, 600)); LDL::Render render(result, window, palette);  LDL::Event report;  const size_t imgSize = 100 * 100;  std::vector&lt;uint8_t&gt; buffer1(imgSize, 5); std::vector&lt;uint8_t&gt; buffer2(imgSize, 3);  LDL::Texture img1(result, &amp;render, LDL::Vec2i(100, 100), &amp;buffer1[0]); LDL::Texture img2(result, &amp;render, LDL::Vec2i(100, 100), &amp;buffer2[0]);  while (window.Running()) { while (window.GetEvent(report)) { if (report.Type == LDL::Event::IsQuit) { window.StopEvent(); } }  render.Begin();  render.SetColor(4); render.Fill(LDL::Vec2i(25, 25), LDL::Vec2i(100, 100));  render.Draw(&amp;img1, LDL::Vec2i(0, 0)); render.Draw(&amp;img2, LDL::Vec2i(150, 150));  render.End();  window.Update(); window.PollEvents(); }  return 0; }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0430\u043b\u0438\u0442\u0440\u0443 \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u043d\u0434\u0435\u0440.<\/p>\n<pre><code class=\"cpp\">LDL::Palette palette;  palette.Set(0, LDL::Color(0, 0, 0)); palette.Set(1, LDL::Color(255, 255, 255)); palette.Set(2, LDL::Color(255, 0, 0)); palette.Set(3, LDL::Color(0, 255, 0)); palette.Set(4, LDL::Color(0, 0, 255)); palette.Set(5, LDL::Color(255, 255, 0)); palette.Set(6, LDL::Color(0, 255, 255));  LDL::Result result; LDL::Window window(result, LDL::Vec2i(0, 0), LDL::Vec2i(800, 600)); LDL::Render render(result, window, palette);<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0441 \u043f\u0430\u043b\u0438\u0442\u0440\u043e\u0439<\/p>\n<pre><code class=\"cpp\">const size_t imgSize = 100 * 100;  std::vector&lt;uint8_t&gt; buffer1(imgSize, 5); std::vector&lt;uint8_t&gt; buffer2(imgSize, 3);  LDL::Texture img1(result, &amp;render, LDL::Vec2i(100, 100), &amp;buffer1[0]); LDL::Texture img2(result, &amp;render, LDL::Vec2i(100, 100), &amp;buffer2[0]);<\/code><\/pre>\n<p>\u0412\u044b\u0432\u043e\u0434\u0438\u043c \u044d\u0442\u0443 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d.<\/p>\n<pre><code class=\"cpp\">render.Draw(&amp;img1, LDL::Vec2i(0, 0)); render.Draw(&amp;img2, LDL::Vec2i(150, 150));<\/code><\/pre>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c, \u0434\u0432\u0430 \u0440\u0430\u0437\u043d\u043e\u0446\u0432\u0435\u0442\u043d\u044b\u0445 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0438\u0445 \u0446\u0432\u0435\u0442\u0430 \u0432 \u043f\u0430\u043b\u0438\u0442\u0440\u0435. \u0414\u043b\u044f \u0438\u0433\u0440 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a \u0436\u0435, \u043f\u0440\u043e\u0441\u0442\u043e \u0446\u0432\u0435\u0442\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438 \u0441\u043f\u0440\u0430\u0439\u0442\u044b \u043e\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u044b\u0435.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/046\/826\/b18\/046826b1867e7fb3e2cae5cf4041d0d7.png\" width=\"786\" height=\"593\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/046\/826\/b18\/046826b1867e7fb3e2cae5cf4041d0d7.png\"\/><\/figure>\n<p>\u041a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u043a\u0438 \u044d\u0442\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e, \u043d\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0441\u0451 \u0436\u0435 \u043e\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u0443\u044e \u0433\u0440\u0430\u0444\u0438\u043a\u0443. \u0412\u044b \u0445\u043e\u0447\u0435\u0442\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0443, \u043e\u043d\u0430 \u0435\u0441\u0442\u044c \u0443 \u043c\u0435\u043d\u044f \ud83d\ude42<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430 \u0442\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u043a\u0430\u0440\u0442\u044b.<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">#include &lt;LDL\/LDL.hpp&gt; #include &lt;vector&gt; #include &lt;time.h&gt; #include \"Isometrc.hpp\"  #if (_MSC_VER &lt;= 1200)     #define STBI_NO_THREAD_LOCALS     #define STBI_NO_SIMD #endif  #define STB_IMAGE_IMPLEMENTATION #include \"stb_image.h\"  const LDL::Vec2i tileSize = LDL::Vec2i(128, 64); const LDL::Vec2i mapSize  = LDL::Vec2i(7, 7); const LDL::Vec2i startPos = LDL::Vec2i(300, 50);  int Random(int min, int max) { return min + (rand() % (max - min + 1)); }  int main() { srand((uint32_t)time(NULL));  LDL::Result result; LDL::Window window(result, LDL::Vec2i(0, 0), LDL::Vec2i(800, 600)); LDL::Render render(result, window);     LDL::Event  report;  stbi_set_flip_vertically_on_load(true);  int width, height, channels; unsigned char* pixels = stbi_load(\"SeasonsTiles.png\", &amp;width, &amp;height, &amp;channels, STBI_default); LDL::Texture tiles(result, &amp;render, LDL::Vec2i(width, height), channels, pixels, LDL::Color(0, 0, 0)); stbi_image_free(pixels);  Isometric isometric;  std::vector&lt;int&gt; tilesX; std::vector&lt;int&gt; tilesY;  tilesX.resize(mapSize.x * mapSize.y); tilesY.resize(mapSize.x * mapSize.y);  for (size_t i = 0; i &lt; mapSize.x * mapSize.y; i++) { tilesX[i] = Random(0, 7); tilesY[i] = Random(0, 5); }  while (window.Running()) { while (window.GetEvent(report)) { if (report.Type == LDL::Event::IsQuit) { window.StopEvent(); } }  render.Begin();  size_t j = 0;  for (size_t rows = 0; rows &lt; mapSize.x; rows++) { for (size_t cols = 0; cols &lt; mapSize.y; cols++) { int x = (int)cols * tileSize.x \/ 2; int y = (int)rows * tileSize.y;  LDL::Vec2i pt = isometric.CartesianToIsometric(LDL::Vec2i(x, y));  int tx = tileSize.x * tilesX[j]; int ty = tileSize.y * tilesY[j]; j++;  render.Draw(&amp;tiles, LDL::Vec2i(startPos.x + pt.x, startPos.y + pt.y), tileSize, LDL::Vec2i(tx, ty), tileSize); } }  render.End();  window.Update(); window.PollEvents(); }      return 0; } <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/592\/613\/ede\/592613edecfcc76dd04fd714a8c9b6ee.png\" width=\"786\" height=\"593\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/592\/613\/ede\/592613edecfcc76dd04fd714a8c9b6ee.png\"\/><\/figure>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u0432\u0430\u043c \u0431\u044b\u043b\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430. \u042f \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u0447\u0442\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437 \u043e \u0441\u0442\u0430\u0440\u044b\u0445 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f\u0445 \u044d\u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u041d\u043e \u0437\u043d\u0430\u0435\u0442\u0435, \u0432 \u044d\u0442\u043e\u043c \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u043e\u0435 \u043e\u0447\u0430\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u0412\u0435\u0434\u044c \u044d\u0442\u0438 API \u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044b, \u0437\u0430\u0440\u043e\u0436\u0434\u0430\u043b\u0438\u0441\u044c \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u0433\u0434\u0430 \u041f\u041a \u043e\u0431\u043b\u0430\u0434\u0430\u043b\u0438 \u0441\u043c\u0435\u0448\u043d\u044b\u043c\u0438 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0430\u043c\u0438 \u043f\u043e \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u043c\u0435\u0440\u043a\u0430\u043c.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/29b\/178\/be7\/29b178be75a85238a3e0f238cfe87938.png\" width=\"1200\" height=\"628\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/29b\/178\/be7\/29b178be75a85238a3e0f238cfe87938.png\"\/><\/figure>\n<p>\u041e\u0446\u0435\u043d\u0438\u0442\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u0442\u0440\u0430\u0433\u0435\u0434\u0438\u0438, \u043a\u0430\u043a\u0430\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441\u0435\u0439\u0447\u0430\u0441 \u0438 \u0442\u043e\u0433\u0434\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f83\/c9a\/7d6\/f83c9a7d6326bb99463377a96c3ba6a8.png\" width=\"1274\" height=\"730\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f83\/c9a\/7d6\/f83c9a7d6326bb99463377a96c3ba6a8.png\"\/><\/figure>\n<p>\u0410 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u0438, \u0438\u0433\u0440, \u0441\u043e\u0444\u0442\u0430, \u0434\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0443 \u043f\u043e\u043d\u0430\u0436\u043e\u0440\u0438\u0441\u0442\u0435\u0435 -:)<\/p>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u0440\u0435\u043d\u0434\u0435\u0440 \u0441\u0442\u0430\u043b \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0435\u043d. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u043f\u0438\u0448\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0440\u0435\u043d\u0434\u0435\u0440\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 XLib. \u0424\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0443\u0441\u043f\u0435\u0432\u0430\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0438 \u0432\u0441\u0451 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>\u0418 \u0443\u0436\u0435 \u043f\u043e\u0441\u043b\u0435, \u0434\u0432\u0438\u043d\u0435\u043c\u0441\u044f \u043f\u043e\u043a\u043e\u0440\u044f\u0442\u044c \u0440\u0435\u043d\u0434\u0435\u0440\u044b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0431\u0443\u0444\u0435\u0440\u0430 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 \u041e\u0417\u0423 \u0441 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0438\u043b\u0430\u043c\u0438 \u0426\u041f, OpenGL \u0438 \u0442. \u0434.<\/p>\n<p>\u0417\u0430 \u043a\u0443\u043b\u0438\u0441\u0430\u043c\u0438, \u043f\u043e\u043a\u0430 \u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e LDL \u043d\u0430 Windows 3.1. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u0441\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0438\u043c\u0435\u043d\u0443\u044e\u0442\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u0432 8 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. \u0425\u043e\u0447\u0435\u0442\u0441\u044f \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043d\u0430\u0442\u0438\u0432\u043d\u043e. <\/p>\n<p>\u0411\u0443\u0434\u0443 \u0440\u0430\u0434 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c, \u0441\u043e\u0432\u0435\u0442\u0430\u043c, \u043a\u0440\u0438\u0442\u0438\u043a\u0435 \u0438 \u043f\u043e\u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\n<p><strong>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435:<\/strong><\/p>\n<p>\u0423\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434 <strong>Windows 3.1<\/strong>, \u043d\u043e \u043f\u043e\u043a\u0430 \u0431\u0435\u0437 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0432\u043e\u0434 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043e\u0432.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/abd\/562\/1d1\/abd5621d1810e540a2eb2d60e10aab31.png\" width=\"641\" height=\"524\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/abd\/562\/1d1\/abd5621d1810e540a2eb2d60e10aab31.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4c7\/daf\/922\/4c7daf922d888afc955f7426cf445571.png\" width=\"638\" height=\"527\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4c7\/daf\/922\/4c7daf922d888afc955f7426cf445571.png\"\/><\/figure>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/877542\/\"> https:\/\/habr.com\/ru\/articles\/877542\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e, \u0425\u0430\u0431\u0440\u0430\u0432\u0447\u0430\u043d\u0435!<\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0440\u0435\u043f\u0430\u00a0<a href=\"https:\/\/github.com\/JordanCpp\/RetroFan\" rel=\"noopener noreferrer nofollow\">RetroFan<\/a>.  <\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u0443\u0445\u043d\u0435\u0442 \u0441\u0442\u0440\u043e\u0447\u043a\u0430\u043c\u0438 \u043a\u043e\u0434\u0430. \u042f \u0432\u0441\u0442\u0440\u043e\u0438\u043b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a. \u0422\u0430\u043a \u043a\u0430\u043a \u044f \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u0438\u0439 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u041c\u043d\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0438\u0434\u0435\u043e\u043b\u043e\u0433\u0438\u044f \u043f\u0440\u0438\u043d\u044f\u0442\u0430\u044f \u0432 Windows, libc \u0438\u043b\u0438 SDL2. \u041f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442 \u0435\u0451 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043e\u0434\u0443 \u043e\u0448\u0438\u0431\u043a\u0438, \u0442\u043e \u0434\u043b\u044f \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e GetLastError.<\/p>\n<p>\u0418 \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435 \u043f\u043b\u043e\u0445, \u043d\u043e \u043c\u0435\u043d\u044f \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u0442 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0414\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u043a\u043b\u0430\u0441\u0441 <a href=\"https:\/\/github.com\/JordanCpp\/RetroFan\/blob\/master\/LDL\/source\/Result.cpp\" rel=\"noopener noreferrer nofollow\">Result<\/a>.<\/p>\n<pre><code class=\"cpp\">namespace LDL { class Result { public: Result(); bool Ok(); const std::string&amp; Message(); void Message(const std::string&amp; message); void Message(const std::string&amp; message, const std::string&amp; detail); void Clear(); private: void Assert(const std::string&amp; message); bool        _ok; std::string _message; }; }<\/code><\/pre>\n<p>\u0418 \u0443\u0436\u0435 \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u044e \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0442\u0435\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u043a\u043b\u0430\u0441\u0441 \u043e\u043a\u043d\u0430.<\/p>\n<pre><code class=\"cpp\">LDL::Result result; LDL::Window window(result, LDL::Vec2i(0, 0), LDL::Vec2i(800, 600));      if (!result.Ok())     {         result.Message(); \/\/\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438     }<\/code><\/pre>\n<p>\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u0441\u0451, \u0447\u0442\u043e \u0443\u0433\u043e\u0434\u043d\u043e. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 WinAPI \u043f\u0440\u0438 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0438 \u043b\u0438\u043d\u0438\u0438. \u041d\u043e \u044f \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u0447\u0442\u043e \u043d\u0438\u043a\u043e\u043c\u0443 \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043e\u043a \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0438\u0433\u0440, \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u0440\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u043e\u0438\u043d\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0430 \u0438\u0433\u0440\u0443 \u0438\u043b\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c. <\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0442\u0430\u043a\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442.<\/p>\n<pre><code class=\"cpp\">void Result::Message(const std::string&amp; message) { _ok = false;  _message = message;  Assert(_message); }   void Result::Assert(const std::string&amp; message) { puts(message.c_str()); abort(); }<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432 result \u0431\u044b\u043b\u0430 \u0437\u0430\u043f\u0438\u0441\u044c \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435, \u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0435\u0451 \u0438 \u043f\u0440\u0435\u043a\u0440\u0430\u0449\u0430\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041f\u043b\u044e\u0441\u044b \u0443 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u0435\u0441\u0442\u044c, \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430. \u0412 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044e \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c, \u0435\u0441\u043b\u0438 \u043e\u043f\u0446\u0438\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u0432\u0441\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0430\u0441\u0441\u0435\u0440\u0442\u0438\u043c, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438.<\/p>\n<p>\u041e\u0431\u0435\u0440\u043d\u0443\u043b \u0444\u0443\u043d\u043a\u0446\u0438\u044e Windows GetLastError \u0432 \u043a\u043b\u0430\u0441\u0441.<\/p>\n<pre><code class=\"cpp\">const std::string&amp; WindowError::GetErrorMessage() {     DWORD ident = GetLastError();     assert(ident != 0);      LPSTR buffer = NULL;      size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, ident, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&amp;buffer, 0, NULL);      _message.append(buffer, size);      LocalFree(buffer);      return _message; }<\/code><\/pre>\n<p>\u0418 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043a\u0438 WinApi \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">_activePalette = CreatePalette(&amp;gdiPalette.logPalette);  if (_activePalette == NULL) { _result.Message(_windowError.GetErrorMessage()); }<\/code><\/pre>\n<p>_result \u0438 _windowError \u044d\u0442\u043e \u0447\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0432\u0438\u0433\u0430\u0435\u043c\u0441\u044f \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0440\u0435\u043d\u0434\u0435\u0440\u0430. \u041f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043f\u043e WinApi:) \u0418 \u0435\u0441\u043b\u0438 \u0437\u0430\u0431\u0435\u0436\u0430\u0442\u044c \u0432\u043f\u0435\u0440\u0435\u0434, \u0437\u0430\u0434\u0443\u043c\u0430\u043d\u043d\u043e\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u042f \u0441\u043e\u0437\u0434\u0430\u043b \u0434\u0432\u0430 \u0440\u0435\u043d\u0434\u0435\u0440\u0430 \u0434\u043b\u044f GDI.<\/p>\n<ol>\n<li>\n<p>\u0420\u0435\u043d\u0434\u0435\u0440 \u0443\u043c\u0435\u044e\u0449\u0438\u0439 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c RGB\/A \u0438 \u043f\u0430\u043b\u0438\u0442\u0440\u043e\u0432\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u044f \u0438\u0445 \u0432 RGB.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0435\u043d\u0434\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u044f\u0449\u0438\u0439 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043f\u0430\u043b\u0438\u0442\u0440\u043e\u0432\u044b\u043c\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<\/li>\n<\/ol>\n<p><strong>RGB \u0440\u0435\u043d\u0434\u0435\u0440.<\/strong><\/p>\n<p>\u041a\u043e\u0434 \u043b\u0435\u0436\u0438\u0442 \u0432 <a href=\"https:\/\/github.com\/JordanCpp\/RetroFan\/blob\/master\/LDL\/source\/Windows\/GdiRndr.cpp\" rel=\"noopener noreferrer nofollow\">GdiRndr.cpp<\/a><\/p>\n<pre><code class=\"cpp\">namespace LDL { class GdiTexture;  class GdiRender { public: GdiRender(Result&amp; result, MainWindow&amp; window); GdiRender(Result&amp; result, MainWindow&amp; window, const Palette&amp; palette); ~GdiRender(); const Palette&amp; GetPalette(); const Color&amp; GetColor(); void SetColor(const Color&amp; color); void SetColor(uint8_t index); void Begin(); void End(); void Clear(); void Line(const Vec2i&amp; first, const Vec2i&amp; last); void Fill(const Vec2i&amp; pos, const Vec2i&amp; size); void Draw(GdiTexture* texture, const Vec2i&amp; dstPos, const Vec2i&amp; dstSize, const Vec2i&amp; srcPos, const Vec2i&amp; srcSize); void Draw(GdiTexture* texture, const Vec2i&amp; pos); void Draw(GdiTexture* texture, const Vec2i&amp; pos, const Vec2i&amp; size); const HDC Hdc(); private: MainWindow&amp; _window; BaseRender  _baseRender; Result&amp;     _result; WindowError _windowError; Palette     _palette; }; }<\/code><\/pre>\n<p>\u041d\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"https:\/\/github.com\/JordanCpp\/RetroFan\/blob\/febc3c767464cc5dc130efb648565baa9bcb8127\/LDL\/source\/Windows\/GdiRndr.cpp#L98\" rel=\"noopener noreferrer nofollow\">Draw<\/a>. \u0414\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d\u0430, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 \u0451\u0435 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438.<\/p>\n<pre><code class=\"cpp\">void GdiRender::Draw(GdiTexture* texture, const Vec2i&amp; dstPos, const Vec2i&amp; dstSize, const Vec2i&amp; srcPos, const Vec2i&amp; srcSize) { assert(texture != NULL);  HDC hdcm = CreateCompatibleDC(_window.Hdc());  if (hdcm == NULL) { _result.Message(_windowError.GetErrorMessage()); } else { HGDIOBJ object = SelectObject(hdcm, texture-&gt;Bitmap());  if (object == NULL) { _result.Message(_windowError.GetErrorMessage()); } else { if (texture-&gt;GetColorKey().Used()) { Color color = texture-&gt;GetColorKey().GetColor();  if (TransparentBlt(_window.Hdc(), dstPos.x, dstPos.y, dstSize.x, dstSize.y, hdcm, srcPos.x, srcPos.y, srcSize.x, srcSize.y, RGB(color.r, color.g, color.b)) == FALSE) { _result.Message(_windowError.GetErrorMessage()); } } else { if (StretchBlt(_window.Hdc(), dstPos.x, dstPos.y, dstSize.x, dstSize.y, hdcm, srcPos.x, srcPos.y, srcSize.x, srcSize.y, SRCCOPY) == FALSE) { _result.Message(_windowError.GetErrorMessage()); } }  DeleteDC(hdcm); } } }<\/code><\/pre>\n<p>\u0412\u0441\u0435\u0433\u043e 40 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430, \u0432\u0441\u0435\u0445 \u0442\u0438\u043f\u043e\u0432 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0441 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c\u044e. \u0413\u043b\u0430\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0435 \u0437\u0430 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u044d\u0442\u043e:<\/p>\n<p><a href=\"https:\/\/vsokovikov.narod.ru\/New_MSDN_API\/Bitmaps\/fn_transparentblt.htm\" rel=\"noopener noreferrer nofollow\">TransparentBlt<\/a> &#8212; \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0438 \u0438\u0437 \u043e\u0437\u0443 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0446\u0432\u0435\u0442\u0430 \u0430\u043b\u044c\u0444\u044b.<\/p>\n<p><a href=\"https:\/\/vsokovikov.narod.ru\/New_MSDN_API\/Bitmaps\/fn_stretchblt.htm\" rel=\"noopener noreferrer nofollow\">StretchBlt<\/a> &#8212; \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0438 \u0438\u0437 \u043e\u0437\u0443 \u0431\u0435\u0437 \u0443\u0447\u0435\u0442\u0430 \u0430\u043b\u044c\u0444\u044b.<\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 Windows 95, 98. \u0414\u043b\u044f Windows 3.1 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0439\u0442\u0438 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0443. \u041d\u0443 \u0438 \u0435\u0449\u0451 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0435 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435. \u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0438 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442\u044b.<\/p>\n<p>\u041e\u0431\u0435\u0440\u043d\u0443\u043b API GDI \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0432 \u0441\u0432\u043e\u0438 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0435 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b. \u041a\u043b\u0430\u0441\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c.<\/p>\n<pre><code class=\"cpp\">namespace LDL { class GdiRender;  class GdiTexture { public: GdiTexture(Result&amp; result, GdiRender* render, const Vec2i&amp; size, uint8_t bpp, uint8_t* pixels); GdiTexture(Result&amp; result, GdiRender* render, const Vec2i&amp; size, uint8_t bpp, uint8_t* pixels, const Color&amp; color); GdiTexture(Result&amp; result, GdiRender* render, const Vec2i&amp; size, uint8_t* pixels); ~GdiTexture(); const ColorKey&amp; GetColorKey() const; const Vec2i&amp; Size(); const HBITMAP Bitmap(); private: Vec2i       _size; GdiRender*  _render; HBITMAP     _bitmap; ColorKey    _colorKey; Result&amp;     _result; WindowError _windowError; }; }<\/code><\/pre>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f:<\/p>\n<pre><code class=\"cpp\">GdiTexture::GdiTexture(Result&amp; result, GdiRender* render, const Vec2i&amp; size, uint8_t bpp, uint8_t* pixels) :     _size(size),     _render(render),     _bitmap(NULL),     _result(result) {     assert(render != NULL);     assert(size.x &gt; 0);     assert(size.y &gt; 0);     assert(bpp == 3 || bpp == 4);     assert(pixels != NULL);      uint8_t* dstPixels = NULL;      _bitmap = CreateDib(_render-&gt;Hdc(), _size, bpp, (void**)&amp;dstPixels);      if (_bitmap == NULL)     {         _result.Message(_windowError.GetErrorMessage());     }     else     {         PixelConverter conv;         conv.RgbToBgr(_size, bpp, pixels);          size_t bytes = _size.x * _size.y * bpp;         memcpy(dstPixels, pixels, bytes);          conv.BgrToRgb(_size, bpp, pixels);     } }<\/code><\/pre>\n<p>\u0422\u0435\u043a\u0441\u0442\u0443\u0440\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 RGB \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439. \u0422\u0430\u043a\u043e\u0439 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043b\u044e\u0431\u044b\u043c\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438 \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439. \u0415\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u043c\u043e\u043c\u0435\u043d\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043d\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f, \u043d\u043e \u0432 \u0440\u0435\u0430\u043b\u0438\u044f\u0445 \u0435\u0434\u0438\u043d\u043e\u0433\u043e API \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0441\u0438\u0441\u0442\u0435\u043c, \u043f\u043e \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u041f\u0440\u0438 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443, \u0434\u043b\u044f Windows \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c RGB \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 BGR \u0438 \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443. \u0418 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u043f\u0430\u0434\u0430\u0442\u044c. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044f\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 Windows \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 BGR.<\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0430\u043b\u0438\u0442\u0440\u043e\u0432\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439. \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e RGB \u0440\u0435\u043d\u0434\u0435\u0440\u0430, \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043f\u0430\u043b\u0438\u0442\u0440\u043e\u0432\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f \u043f\u0430\u043b\u0438\u0442\u0440\u044b \u0432 RGB \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"cpp\">GdiTexture::GdiTexture(Result&amp; result, GdiRender* render, const Vec2i&amp; size, uint8_t* pixels) :     _size(size),     _render(render),     _bitmap(NULL),     _result(result) {     assert(render != NULL);     assert(size.x &gt; 0);     assert(size.y &gt; 0);     assert(pixels != NULL);      uint8_t* dstPixels = NULL;      _bitmap = CreateDib(_render-&gt;Hdc(), _size, _render-&gt;GetPalette(), (void**)&amp;dstPixels);       if (_bitmap == NULL)     {         _result.Message(_windowError.GetErrorMessage());     }     else     {         size_t bytes = _size.x * _size.y;         memcpy(dstPixels, pixels, bytes);     } }<\/code><\/pre>\n<p>\u041f\u0430\u043b\u0438\u0442\u0440\u0430 \u043e\u0434\u043d\u0430 \u043d\u0430 \u0440\u0435\u043d\u0434\u0435\u0440 \u0438 \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 Render. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0434\u0438\u043d\u044b\u0439 API \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0442\u0438\u043f\u043e\u0432 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0440\u0435\u043d\u0434\u0435\u0440\u043e\u043c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0430\u043b\u0438\u0442\u0440\u044b \u0438 \u044d\u0442\u043e\u0442 \u0436\u0435 \u0440\u0435\u043d\u0434\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u0436\u0435\u043b\u0435\u0437\u0435 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u044f \u043f\u0430\u043b\u0438\u0442\u0440\u0443 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0435\u0439 \u0432 RGB.<\/p>\n<p><strong>\u0420\u0435\u043d\u0434\u0435\u0440 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0430\u043b\u0438\u0442\u0440\u044b.<\/strong><\/p>\n<p>\u041a\u043e\u0434 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <a href=\"https:\/\/github.com\/JordanCpp\/RetroFan\/blob\/master\/LDL\/source\/Windows\/GdiPRndr.cpp\" rel=\"noopener noreferrer nofollow\">GdiPRndr.cpp<\/a><\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u043d\u0434\u0435\u0440 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0431\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u044b Windows, \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043f\u0430\u043b\u0438\u0442\u0440\u0443 \u0434\u043b\u044f \u043e\u043a\u043d\u0430<\/p>\n<pre><code class=\"cpp\">GdiPaletteRender::GdiPaletteRender(Result&amp; result, MainWindow&amp; window, const Palette&amp; palette) : _window(window), _palette(palette), _hdcm(NULL), _result(result) { GdiPalette gdiPalette; GdiFill(gdiPalette, _palette);  _activePalette = CreatePalette(&amp;gdiPalette.logPalette);  if (_activePalette == NULL) { _result.Message(_windowError.GetErrorMessage()); } }<\/code><\/pre>\n<p>\u041f\u0430\u043b\u0438\u0442\u0440\u043e\u0432\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a.<\/p>\n<pre><code class=\"cpp\">GdiPaletteTexture::GdiPaletteTexture(Result&amp; result, GdiPaletteRender* render, const Vec2i&amp; size, uint8_t* pixels) :     _size(size),     _render(render),     _bitmap(NULL),     _result(result) {     assert(render != NULL);     assert(size.x &gt; 0);     assert(size.y &gt; 0);     assert(pixels != NULL);      uint8_t* dstPixels = NULL;      _bitmap = CreateDib(_render-&gt;Hdc(), _size, _render-&gt;GetPalette(), (void**)&amp;dstPixels);      if (_bitmap == NULL)     {         _result.Message(_windowError.GetErrorMessage());     }     else     {         size_t bytes = _size.x * _size.y;         memcpy(dstPixels, pixels, bytes);     } }<\/code><\/pre>\n<p>\u0422\u0435\u043a\u0441\u0442\u0443\u0440\u0430 \u0445\u0440\u0430\u043d\u0438\u0442 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043d\u0430 \u043f\u0430\u043b\u0438\u0442\u0440\u0443 RGB. \u0418 \u043f\u0440\u0438 \u0432\u044b\u0432\u043e\u0434\u0430 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 rgb \u0446\u0432\u0435\u0442. <\/p>\n<p>\u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0432 \u043c\u043e\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u044d\u0442\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043e\u0434\u043d\u043e\u0439 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u043b\u0438\u0442\u0440\u044b \u0434\u043b\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0430. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e, \u0447\u0442\u043e \u0431\u044b \u0435\u0434\u0438\u043d\u044b\u0439 API \u043c\u043e\u0433 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430 \u043b\u044e\u0431\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, OpenGL, DirectX, Vulkan. \u0412 \u043d\u043e\u0432\u044b\u0445 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0445 API \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043f\u0430\u043b\u0438\u0442\u0440\u044b.<\/p>\n<p>\u041a<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-446475","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/446475","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=446475"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/446475\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=446475"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=446475"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=446475"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}