<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778678</guid>
        <pubDate>Thu, 20 Sep 2018 12:29:07 +0000</pubDate>
        <title>В чём секрет glut?</title>
        <link>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778678</link>
        <description><![CDATA[ЫукпШ: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=413528&view=findpost&p=3778450'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>k.sovailo &#064; <time class="tag-quote__quoted-time" datetime="2018-09-18T22:46:42+03:00">18.09.18, 19:46</time></span><div class='quote '>Не работает. Если создавать битмап в контексте окна, тоже не работает. Я правильно понял?</div></div><br>
Трудно мне без отладки по тексту сказать точно, где ошибка.<br>
я делал так:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">//..</div><div class="code_line">&nbsp;HDC d_c &nbsp; = ::CreateDC(_T(&quot;DISPLAY&quot;),NULL,NULL,NULL);</div><div class="code_line">&nbsp;HDC memdc = ::CreateCompatibleDC &nbsp;(d_c);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;RECT rc; &nbsp;::GetWindowRect (::GetDesktopWindow(), &amp;rc); </div><div class="code_line">&nbsp;</div><div class="code_line">// размер скрина:</div><div class="code_line">&nbsp;int sizex &nbsp;= (rc.right &nbsp; - rc.left) ;</div><div class="code_line">&nbsp;int sizey &nbsp;= (rc.bottom &nbsp;- rc.top) &nbsp;;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;HBITMAP hbit = ::CreateCompatibleBitmap (d_c, sizex, sizey); &nbsp;::SelectObject (memdc, hbit);</div><div class="code_line">&nbsp;HBRUSH brush = ::CreateSolidBrush &nbsp;(someColor); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ::SelectObject (memdc, brush); </div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;::PatBlt(memdc,0,0,sizex,sizey,PATCOPY); // закрасить memdc кистью brush цвета someColor</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;::DeleteDC(d_c);</div><div class="code_line">//...</div><div class="code_line">&nbsp;</div><div class="code_line">// в результате получили memdc размером с экран.</div><div class="code_line">// зачищенный цветом &nbsp;&quot;someColor&quot;.</div><div class="code_line">// функциями GDI там можно рисовать что угодно. Можно читать/писать посредством &quot;BitBlt&quot; любыми кусками.</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script><br>
<br>
Понятно, что лучше все эти объекты обернуть классами, поскольку попытка следить за ними &quot;вручную&quot;<br>
скорее всего закончится утечкой ресурсов. Исходник в таком виде я представил для примера.<br>
-----<br>
Хочу заметить, что всё это имеет конкретное практическое применение.<br>
Например, что делать, если рисование картинки занимает 1 секунду (или больше)?<br>
Если сделать это из оконной процедуры, тогда на это время всё управление приложением<br>
будет парализовано, в том числе перерисовка экрана. При этом сам вывод картинки<br>
на экран (даже самый большой) может составить 1 [мс] или меньше.<br>
Рисовать имиджи можно и в другом потоке. <br>
Поэтому разделение этих 2-х операций весьма перспективное мероприятие.]]></description>
        <author>ЫукпШ</author>
        <category>C/C++: Прочее</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778671</guid>
        <pubDate>Thu, 20 Sep 2018 11:16:52 +0000</pubDate>
        <title>В чём секрет glut?</title>
        <link>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778671</link>
        <description><![CDATA[k.sovailo: Я тут провёл ещё несколько попыток и понял, что лучше доверить эту работу freeglut. Закончилось на том, что я подкорректировал код, добавил getHWND() и написал функцию динамического подключения freeglut.dll. Спасибо за внимание.]]></description>
        <author>k.sovailo</author>
        <category>C/C++: Прочее</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778450</guid>
        <pubDate>Tue, 18 Sep 2018 19:46:42 +0000</pubDate>
        <title>В чём секрет glut?</title>
        <link>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778450</link>
        <description><![CDATA[k.sovailo: <strong class='tag-b'>ЫукпШ</strong><br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">app.windowDC = GetDC(app.hWnd);</div><div class="code_line">SetOGLPixelFormat(app.windowDC));//pfd и всё остальное - в этой функции</div><div class="code_line">app.bufferDC = CreateCompatibleDC(app.windowDC);</div><div class="code_line">app.hBuffer = CreateCompatibleBitmap(app.bufferDC, 800, 600);</div><div class="code_line">SetOGLPixelFormat(app.bufferDC);</div><div class="code_line">SelectObject(app.bufferDC, app.hBuffer);//советовали на одном форуме</div><div class="code_line">wglMakeCurrent(app.bufferDC, NULL);//советовали на другом форуме</div><div class="code_line">app.hglrc = wglCreateContext(app.bufferDC);//возвращает 0</div></ol></div></div></div></div><br>
<br>
Не работает. Если создавать битмап в контексте окна, тоже не работает. Я правильно понял?]]></description>
        <author>k.sovailo</author>
        <category>C/C++: Прочее</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778417</guid>
        <pubDate>Tue, 18 Sep 2018 13:32:28 +0000</pubDate>
        <title>В чём секрет glut?</title>
        <link>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778417</link>
        <description><![CDATA[ЫукпШ: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=413528&view=findpost&p=3778318'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>k.sovailo &#064; <time class="tag-quote__quoted-time" datetime="2018-09-18T08:38:26+00:00">18.09.18, 08:38</time></span><div class='quote '><strong class='tag-b'>ЫукпШ</strong>, я ковырялся-ковырялся, но так и не смог сделать ещё один буфер. wglCreateContext напрочь отказывается создавать контекст, если ей передают hDc чего-то, кроме формы.</div></div><br>
Вот, я посмотрел.<br>
Ты используешь :<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">class Application</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;public:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;HINSTANCE hInstance;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;HWND hWnd;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;HDC windowDC;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;HGLRC hglrc;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;LPCTSTR classname;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;WNDCLASS wndclass;</div><div class="code_line">};</div></ol></div></div></div></div><br>
Если в структуру подставить HDC какого-нибудь memdc ?<br>
Созданного на WINAPI.<br>
Всё должно работать.<br>
А потом в WM_PAINT просто выполним &quot;BitBlt&quot; в соответствии с размерами прямоугольника,<br>
передаваемого в Paint - структуре.]]></description>
        <author>ЫукпШ</author>
        <category>C/C++: Прочее</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778318</guid>
        <pubDate>Tue, 18 Sep 2018 08:38:26 +0000</pubDate>
        <title>В чём секрет glut?</title>
        <link>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778318</link>
        <description><![CDATA[k.sovailo: <strong class='tag-b'>ЫукпШ</strong>, я ковырялся-ковырялся, но так и не смог сделать ещё один буфер. wglCreateContext напрочь отказывается создавать контекст, если ей передают hDc чего-то, кроме формы. Пробовал с HBITMAP, пробовал с Gdiplus::Bitmap и Gdiplus::Graphics, не работает. Не могу применить ваш совет.<br>
<br>
Уточнил флаги, которые использует freeglut, лучше не стало. Хотя у меня такое чувство, что это какой-то обманный манёвр. Потому что freeglut сначала создаёт контекст и сразу же высвобождает, а потом создаёт его только где-то в дебрях (отслеживал отладчиком), кода которых у меня нет. Так что придётся либо писать 64-битную программу с freeglut, либо 32-битную с glut и таскать библиотеки, либо ковыряться дальше. В каждом варианте свои минусы.<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">#include &#60;windows.h&#62;</div><div class="code_line">#include &#60;gl/GL.h&#62;</div><div class="code_line">#define _USE_MATH_DEFINES &nbsp;</div><div class="code_line">#include &#60;cmath&#62;</div><div class="code_line">#pragma comment(lib, &quot;opengl32.lib&quot;)</div><div class="code_line">&nbsp;</div><div class="code_line">#define CLASSNOTREGISTERED 1</div><div class="code_line">#define WINDOWNOTCREATED 2</div><div class="code_line">#define MESSAGENOTGOT 3</div><div class="code_line">#define OGLCONTEXNOTCREATED 4</div><div class="code_line">#define OGLCONTEXNOTMADECURRENT 5</div><div class="code_line">#define PIXELFORMATNOTSET 6</div><div class="code_line">&nbsp;</div><div class="code_line">class Application</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;public:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;HINSTANCE hInstance;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;HWND hWnd;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;HDC windowDC;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;HGLRC hglrc;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;LPCTSTR classname;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;WNDCLASS wndclass;</div><div class="code_line">};</div><div class="code_line">&nbsp;</div><div class="code_line">Application app;</div><div class="code_line">float angle = 1.0;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">void DrawScreen()</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);</div><div class="code_line">&nbsp;&nbsp; &nbsp;glBegin(GL_TRIANGLES);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;glColor3f(1.0, 0.0, 0.0);</div><div class="code_line">&nbsp;&nbsp; &nbsp;glVertex3f(0.5*sin(angle), 0.5*cos(angle), 0.0);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;glColor3f(0.0, 1.0, 0.0);</div><div class="code_line">&nbsp;&nbsp; &nbsp;glVertex3f(0.5*sin(angle + 2 * M_PI / 3), 0.5*cos(angle + 2 * M_PI / 3), 0.0);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;glColor3f(0.0, 0.0, 1.0);</div><div class="code_line">&nbsp;&nbsp; &nbsp;glVertex3f(0.5*sin(angle + 4 * M_PI / 3), 0.5*cos(angle + 4 * M_PI / 3), 0.0);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;glEnd();</div><div class="code_line">&nbsp;&nbsp; &nbsp;glFlush();</div><div class="code_line">&nbsp;&nbsp; &nbsp;SwapBuffers(app.windowDC);</div><div class="code_line">};</div><div class="code_line">&nbsp;</div><div class="code_line">LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;switch (message)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;case WM_DESTROY:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PostQuitMessage(0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;case WM_PAINT:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DrawScreen();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;default:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return DefWindowProc(hWnd, message, wParam, lParam);</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;return 0;</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">int WinLoop()</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;MSG msg = { 0 };</div><div class="code_line">&nbsp;&nbsp; &nbsp;int iGetOk = 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;while ((iGetOk = GetMessage(&amp;msg, NULL, 0, 0)) != 0)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (iGetOk == -1) return MESSAGENOTGOT;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;TranslateMessage(&amp;msg);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;DispatchMessage(&amp;msg);</div><div class="code_line">&nbsp;&nbsp; &nbsp;};</div><div class="code_line">&nbsp;&nbsp; &nbsp;return msg.wParam;</div><div class="code_line">};</div><div class="code_line">&nbsp;</div><div class="code_line">ATOM RegMyWindowClass()</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;ZeroMemory(&amp;(app.wndclass), sizeof(WNDCLASS));</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;app.wndclass.lpfnWndProc = (WNDPROC)WndProc; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// адрес ф-ции обработки сообщений</div><div class="code_line">&nbsp;&nbsp; &nbsp;app.wndclass.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;// стиль окна</div><div class="code_line">&nbsp;&nbsp; &nbsp;app.wndclass.hInstance = app.hInstance; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // дискриптор экземпляра приложения</div><div class="code_line">&nbsp;&nbsp; &nbsp;app.wndclass.lpszClassName = app.classname; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // название класса</div><div class="code_line">&nbsp;&nbsp; &nbsp;app.wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); &nbsp; &nbsp; // загрузка курсора</div><div class="code_line">&nbsp;&nbsp; &nbsp;app.wndclass.hbrBackground = (HBRUSH)COLOR_APPWORKSPACE;// загрузка цвета окон</div><div class="code_line">&nbsp;&nbsp; &nbsp;return RegisterClass(&amp;app.wndclass); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// регистрация класса</div><div class="code_line">};</div><div class="code_line">&nbsp;</div><div class="code_line">bool SetWindowFormat()</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;PIXELFORMATDESCRIPTOR pfd;</div><div class="code_line">&nbsp;&nbsp; &nbsp;ZeroMemory(&amp;pfd, sizeof(PIXELFORMATDESCRIPTOR));</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;int flags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;/* Specify which pixel format do we opt for... */</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.nVersion = 1;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.dwFlags = flags;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.iPixelType = PFD_TYPE_RGBA;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.cRedBits = 8;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.cGreenBits = 8;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.cBlueBits = 8;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.cAlphaBits = 0;//(fgState.DisplayMode &amp; GLUT_ALPHA) ? 8 : 0</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.cColorBits = 24;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.cRedShift = 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.cGreenShift = 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.cBlueShift = 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.cAlphaShift = 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.cAccumBits = 0;//(fgState.DisplayMode &amp; GLUT_ACCUM) ? 1 : 0</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.cAccumRedBits = 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.cAccumGreenBits = 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.cAccumBlueBits = 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.cAccumAlphaBits = 0;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;/* Hmmm, or 32/0 instead of 24/8? */</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.cDepthBits = 24;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.cStencilBits = 8;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.cAuxBuffers = 0;//(BYTE)fghNumberOfAuxBuffersRequested()</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.iLayerType = 0;//layer_type</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.bReserved = 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.dwLayerMask = 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.dwVisibleMask = 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.dwDamageMask = 0;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.cColorBits = (BYTE)GetDeviceCaps(app.windowDC, BITSPIXEL);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;int nPixelFormat = ChoosePixelFormat(app.windowDC, &amp;pfd);</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (nPixelFormat == 0)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return false;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;SetPixelFormat(app.windowDC, nPixelFormat, &amp;pfd);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;return true;</div><div class="code_line">};</div><div class="code_line">&nbsp;</div><div class="code_line">int WinInit()</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;app.classname = TEXT(&quot;My Window Class!&quot;);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (!RegMyWindowClass())</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return CLASSNOTREGISTERED;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if ((app.hWnd = CreateWindow(app.classname, TEXT(&quot;Dialog Window&quot;), WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 800, 600, NULL, NULL, app.hInstance, NULL)) == 0)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return WINDOWNOTCREATED;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;app.windowDC = GetDC(app.hWnd);</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (!SetWindowFormat())</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return PIXELFORMATNOTSET;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;return 0;</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">int WinOGLInit()</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;app.hglrc = wglCreateContext(app.windowDC);</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (app.hglrc == 0)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return GetLastError();</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (!wglMakeCurrent(app.windowDC, app.hglrc))</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return OGLCONTEXNOTMADECURRENT;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;return 0;</div><div class="code_line">};</div><div class="code_line">&nbsp;</div><div class="code_line">int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;app.hInstance = hInstance;</div><div class="code_line">&nbsp;&nbsp; &nbsp;int initresult;</div><div class="code_line">&nbsp;&nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;initresult = WinInit();</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (initresult != 0)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return initresult;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;initresult = WinOGLInit();</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (initresult != 0)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return initresult;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;return WinLoop(); &nbsp; </div><div class="code_line">}</div></ol></div></div></div></div>]]></description>
        <author>k.sovailo</author>
        <category>C/C++: Прочее</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778111</guid>
        <pubDate>Sun, 16 Sep 2018 18:44:02 +0000</pubDate>
        <title>В чём секрет glut?</title>
        <link>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778111</link>
        <description><![CDATA[k.sovailo: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=413528&view=findpost&p=3778105'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>JoeUser &#064; <time class="tag-quote__quoted-time" datetime="2018-09-16T15:58:05+00:00">16.09.18, 15:58</time></span><div class='quote '></div></div><br>
Действительно, есть упоминание. Всего-то и надо было:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">#define FREEGLUT_STATIC 1</div><div class="code_line">#include &#60;glut.h&#62;</div></ol></div></div></div></div><br>
Теперь буду надеяться, что разберусь, в чём &quot;магия&quot;. Тему пока не закрываю.]]></description>
        <author>k.sovailo</author>
        <category>C/C++: Прочее</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778108</guid>
        <pubDate>Sun, 16 Sep 2018 18:24:34 +0000</pubDate>
        <title>В чём секрет glut?</title>
        <link>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778108</link>
        <description><![CDATA[ЫукпШ: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=413528&view=findpost&p=3778104'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>k.sovailo &#064; <time class="tag-quote__quoted-time" datetime="2018-09-16T14:30:02+00:00">16.09.18, 14:30</time></span><div class='quote '><div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=413528&view=findpost&p=3778103'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>ЫукпШ &#064; <time class="tag-quote__quoted-time" datetime="2018-09-16T14:07:33+00:00">16.09.18, 14:07</time></span><div class='quote '></div></div><br>
Это рисование самого простого треугольника в ответ на сообщение о необходимости перерисовки окна. Очистка буфера, рисование и замена буфера.</div></div><br>
Вот на это я и хотел обратить внимание.<br>
Чтобы с максимальной вероятностью прекратить любые видео-эффекты,<br>
надо отделить операцию рисования от операции вывода.<br>
А у тебя эти операции объединены вместе.<br>
Надо, чтобы из WM_PAINT готовое изображение копировалось в окно.<br>
Тогда такая операция будет производиться максимально быстро.<br>
-----<br>
Ещё рекомендуется обрабатывать сообщение &quot;WM_ERASEBKGND&quot;.]]></description>
        <author>ЫукпШ</author>
        <category>C/C++: Прочее</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778105</guid>
        <pubDate>Sun, 16 Sep 2018 15:58:05 +0000</pubDate>
        <title>В чём секрет glut?</title>
        <link>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778105</link>
        <description><![CDATA[JoeUser: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=413528&view=findpost&p=3778104'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>k.sovailo &#064; <time class="tag-quote__quoted-time" datetime="2018-09-16T14:30:02+00:00">16.09.18, 14:30</time></span><div class='quote '>В то же время в README.Win32 написано: ...If you are using the DLL version of &quot;freeglut&quot;...<br>
То есть можно как-то использовать не-ДЛЛ-версию? Не могу понять, как.<br>
</div></div><br>
<br>
Там есть упоминание о &quot;freeglut_static.lib&quot; - следовательно статик-версия собираться должна...<br>
<br>
1) Читай внимательно README.cmake<br>
2) В одном из проектов есть сборочный файл под все версии, просто посмотри что и как там делают:<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line"># This file is part of MXE. See LICENSE.md for licensing information.</div><div class="code_line">&nbsp;</div><div class="code_line">PKG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; := freeglut</div><div class="code_line">$(PKG)_WEBSITE &nbsp;:= https://freeglut.sourceforge.io/</div><div class="code_line">$(PKG)_IGNORE &nbsp; :=</div><div class="code_line">$(PKG)_VERSION &nbsp;:= 3.0.0</div><div class="code_line">$(PKG)_CHECKSUM := 2a43be8515b01ea82bcfa17d29ae0d40bd128342f0930cd1f375f1ff999f76a2</div><div class="code_line">$(PKG)_SUBDIR &nbsp; := freeglut-$($(PKG)_VERSION)</div><div class="code_line">$(PKG)_FILE &nbsp; &nbsp; := freeglut-$($(PKG)_VERSION).tar.gz</div><div class="code_line">$(PKG)_URL &nbsp; &nbsp; &nbsp;:= https://$(SOURCEFORGE_MIRROR)/project/freeglut/freeglut/$($(PKG)_VERSION)/$($(PKG)_FILE)</div><div class="code_line">$(PKG)_DEPS &nbsp; &nbsp; := cc</div><div class="code_line">&nbsp;</div><div class="code_line">define $(PKG)_UPDATE</div><div class="code_line">&nbsp;&nbsp; &nbsp;$(WGET) -q -O- &#39;https://sourceforge.net/projects/freeglut/files/freeglut/&#39; | \</div><div class="code_line">&nbsp;&nbsp; &nbsp;$(SED) -n &#39;s,.*freeglut-\([0-9][^&#62;]*\)\.tar.*,,p&#39; | \</div><div class="code_line">&nbsp;&nbsp; &nbsp;head -1</div><div class="code_line">endef</div><div class="code_line">&nbsp;</div><div class="code_line">define $(PKG)_BUILD</div><div class="code_line">&nbsp;&nbsp; &nbsp;cd &#39;$(BUILD_DIR)&#39; &amp;&amp; &#39;$(TARGET)-cmake&#39; &#39;$(SOURCE_DIR)&#39; \</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;-DFREEGLUT_GLES=OFF \</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;-DFREEGLUT_BUILD_DEMOS=OFF \</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;-DFREEGLUT_REPLACE_GLUT=ON \</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;-DFREEGLUT_BUILD_STATIC_LIBS=$(CMAKE_STATIC_BOOL) \</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;-DFREEGLUT_BUILD_SHARED_LIBS=$(CMAKE_SHARED_BOOL)</div><div class="code_line">&nbsp;&nbsp; &nbsp;$(MAKE) -C &#39;$(BUILD_DIR)&#39; -j &#39;$(JOBS)&#39; VERBOSE=1</div><div class="code_line">&nbsp;&nbsp; &nbsp;$(MAKE) -C &#39;$(BUILD_DIR)&#39; -j 1 install VERBOSE=1</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#39;$(TARGET)-gcc&#39; \</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;-W -Wall -Werror -ansi -pedantic \</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#39;$(TEST_FILE)&#39; -o &#39;$(PREFIX)/$(TARGET)/bin/test-freeglut.exe&#39; \</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;`&#39;$(TARGET)-pkg-config&#39; glut --cflags --libs`</div><div class="code_line">endef</div></ol></div></div></div></div>]]></description>
        <author>JoeUser</author>
        <category>C/C++: Прочее</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778104</guid>
        <pubDate>Sun, 16 Sep 2018 14:30:02 +0000</pubDate>
        <title>В чём секрет glut?</title>
        <link>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778104</link>
        <description><![CDATA[k.sovailo: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=413528&view=findpost&p=3778103'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>ЫукпШ &#064; <time class="tag-quote__quoted-time" datetime="2018-09-16T14:07:33+00:00">16.09.18, 14:07</time></span><div class='quote '></div></div><br>
Это рисование самого простого треугольника в ответ на сообщение о необходимости перерисовки окна. Очистка буфера, рисование и замена буфера. Наверное, я не понял вопрос. <br>
<br>
<span class="tag-color tag-color-named" data-value="mergepost" style="color: mergepost"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2018-09-16T14:35:48+00:00">16.09.18, 14:35</time></span></span><br>
<strong class='tag-b'>JoeUser</strong>, хотел уже сказать, что проделывал эти шаги, но проверил ещё раз. Всё точно так же, как и в glut, только freeglut собирается только на х64. В результате я подключаю в проект .lib и .h  и получаю &quot;бла-бла-бла нет freeglutd.dll&quot;. Если её положить возле экзешника - никаких проблем, но это не то, чего я хочу. На всякий случай:<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">#include &#60;glut.h&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">void renderScene(void) {</div><div class="code_line">&nbsp;&nbsp; &nbsp;glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;glBegin(GL_TRIANGLES);</div><div class="code_line">&nbsp;&nbsp; &nbsp;glVertex3f(-0.5, -0.5, 0.0);</div><div class="code_line">&nbsp;&nbsp; &nbsp;glVertex3f(0.0, 0.5, 0.0);</div><div class="code_line">&nbsp;&nbsp; &nbsp;glVertex3f(0.5, -0.5, 0.0);</div><div class="code_line">&nbsp;&nbsp; &nbsp;glEnd();</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;glutSwapBuffers();</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">int main(int argc, char **argv) {</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;// инициализация</div><div class="code_line">&nbsp;&nbsp; &nbsp;glutInit(&amp;argc, argv);</div><div class="code_line">&nbsp;&nbsp; &nbsp;glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);</div><div class="code_line">&nbsp;&nbsp; &nbsp;glutInitWindowPosition(100, 100);</div><div class="code_line">&nbsp;&nbsp; &nbsp;glutInitWindowSize(400, 400);</div><div class="code_line">&nbsp;&nbsp; &nbsp;glutCreateWindow(&quot;Урок 1&quot;);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;// регистрация обратных вызовов</div><div class="code_line">&nbsp;&nbsp; &nbsp;glutDisplayFunc(renderScene);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;// Основной цикл GLUT</div><div class="code_line">&nbsp;&nbsp; &nbsp;glutMainLoop();</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;return 0;</div><div class="code_line">}</div></ol></div></div></div></div><br>
<br>
В то же время в README.Win32 написано: ...If you are using the DLL version of &quot;freeglut&quot;...<br>
То есть можно как-то использовать не-ДЛЛ-версию? Не могу понять, как. <br>
<br>
<span class="tag-color tag-color-named" data-value="mergepost" style="color: mergepost"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2018-09-16T14:38:53+00:00">16.09.18, 14:38</time></span></span><br>
<strong class='tag-b'>ЫукпШ</strong>, может Вы про то, что каждый раз вызывается glClearColor? Есть косяк. Убрал - всё точно так же.]]></description>
        <author>k.sovailo</author>
        <category>C/C++: Прочее</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778103</guid>
        <pubDate>Sun, 16 Sep 2018 14:07:33 +0000</pubDate>
        <title>В чём секрет glut?</title>
        <link>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778103</link>
        <description><![CDATA[ЫукпШ: <strong class='tag-b'>k.sovailo</strong>, а вот это - что такое ?<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; case WM_PAINT:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;glClearColor(0.0, 0.0, 0.0, 1.0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;glBegin(GL_TRIANGLES);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;glColor3f(1.0, 0.0, 0.0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;glVertex3f(0.25, 0.25, 0.0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;glColor3f(0.0, 1.0, 0.0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;glVertex3f(0.75, 0.25, 0.0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;glColor3f(0.0, 0.0, 1.0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;glVertex3f(0.75, 0.75, 0.0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;glEnd();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;glFlush();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SwapBuffers(hDc);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div></ol></div></div></div></div>]]></description>
        <author>ЫукпШ</author>
        <category>C/C++: Прочее</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778101</guid>
        <pubDate>Sun, 16 Sep 2018 13:39:20 +0000</pubDate>
        <title>В чём секрет glut?</title>
        <link>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778101</link>
        <description><![CDATA[JoeUser: Я так понимаю, freeglut - хорошая альтернатива glut. В чем тогда проблема? Качаешь исходник freeglut, собираешь либы и подключаешь к своему проекту. В поставке freeglut вроде есть инструкции для всего этого, не?]]></description>
        <author>JoeUser</author>
        <category>C/C++: Прочее</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778100</guid>
        <pubDate>Sun, 16 Sep 2018 12:47:19 +0000</pubDate>
        <title>В чём секрет glut?</title>
        <link>https://forum.sources.ru/index.php?showtopic=413528&amp;view=findpost&amp;p=3778100</link>
        <description><![CDATA[k.sovailo: Всем доброго времени суток, у меня есть очередной вопрос. У меня не получается разобраться, как работает glut. Он был выбран, потому что приложение на glut32.dll корректно работает на всех моих машинах. Я хотел повторить то же самое, но без glut32.dll. Был написан код:<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">#include &#60;windows.h&#62;</div><div class="code_line">#include &#60;gl/GL.h&#62;</div><div class="code_line">#pragma comment(lib, &quot;opengl32.lib&quot;)</div><div class="code_line">&nbsp;</div><div class="code_line">#define CLASSNOTREGISTERED 1</div><div class="code_line">#define WINDOWNOTCREATED 2</div><div class="code_line">#define MESSAGENOTGOT 3</div><div class="code_line">#define OGLCONTEXNOTCREATED 4</div><div class="code_line">#define OGLCONTEXNOTMADECURRENT 5</div><div class="code_line">&nbsp;</div><div class="code_line">HWND hWnd;</div><div class="code_line">HDC hDc;</div><div class="code_line">&nbsp;</div><div class="code_line">LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;switch (message)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;case WM_DESTROY:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PostQuitMessage(0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;case WM_PAINT:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;glClearColor(0.0, 0.0, 0.0, 1.0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;glBegin(GL_TRIANGLES);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;glColor3f(1.0, 0.0, 0.0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;glVertex3f(0.25, 0.25, 0.0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;glColor3f(0.0, 1.0, 0.0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;glVertex3f(0.75, 0.25, 0.0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;glColor3f(0.0, 0.0, 1.0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;glVertex3f(0.75, 0.75, 0.0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;glEnd();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;glFlush();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SwapBuffers(hDc);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;default:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return DefWindowProc(hWnd, message, wParam, lParam);</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;return 0;</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">ATOM RegMyWindowClass(HINSTANCE hInst, LPCTSTR lpzClassName)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;WNDCLASS wcWindowClass = { 0 };</div><div class="code_line">&nbsp;&nbsp; &nbsp;wcWindowClass.lpfnWndProc = (WNDPROC)WndProc; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// адрес ф-ции обработки сообщений</div><div class="code_line">&nbsp;&nbsp; &nbsp;wcWindowClass.style = CS_HREDRAW | CS_VREDRAW; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // стиль окна</div><div class="code_line">&nbsp;&nbsp; &nbsp;wcWindowClass.hInstance = hInst; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // дискриптор экземпляра приложения</div><div class="code_line">&nbsp;&nbsp; &nbsp;wcWindowClass.lpszClassName = lpzClassName; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// название класса</div><div class="code_line">&nbsp;&nbsp; &nbsp;wcWindowClass.hCursor = LoadCursor(NULL, IDC_ARROW); &nbsp; &nbsp; // загрузка курсора</div><div class="code_line">&nbsp;&nbsp; &nbsp;wcWindowClass.hbrBackground = (HBRUSH)COLOR_APPWORKSPACE;// загрузка цвета окон</div><div class="code_line">&nbsp;&nbsp; &nbsp;return RegisterClass(&amp;wcWindowClass); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// регистрация класса</div><div class="code_line">};</div><div class="code_line">&nbsp;</div><div class="code_line">int WinInit(HINSTANCE hInstance)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;LPCTSTR lpzClass = TEXT(&quot;My Window Class!&quot;);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (!RegMyWindowClass(hInstance, lpzClass))</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return CLASSNOTREGISTERED;</div><div class="code_line">&nbsp;&nbsp; &nbsp;};</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;hWnd = CreateWindow(lpzClass, TEXT(&quot;Dialog Window&quot;), WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 800, 600, NULL, NULL, hInstance, NULL);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (!hWnd)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return WINDOWNOTCREATED;</div><div class="code_line">&nbsp;&nbsp; &nbsp;};</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;return 0;</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">int WinLoop()</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;MSG msg = { 0 };</div><div class="code_line">&nbsp;&nbsp; &nbsp;int iGetOk = 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;while ((iGetOk = GetMessage(&amp;msg, NULL, 0, 0)) != 0)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (iGetOk == -1) return MESSAGENOTGOT;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;TranslateMessage(&amp;msg);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;DispatchMessage(&amp;msg);</div><div class="code_line">&nbsp;&nbsp; &nbsp;};</div><div class="code_line">&nbsp;&nbsp; &nbsp;return msg.wParam;</div><div class="code_line">};</div><div class="code_line">&nbsp;</div><div class="code_line">int WinOGLInit()</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;PIXELFORMATDESCRIPTOR pfd;</div><div class="code_line">&nbsp;&nbsp; &nbsp;ZeroMemory(&amp;pfd, sizeof(PIXELFORMATDESCRIPTOR));</div><div class="code_line">&nbsp;&nbsp; &nbsp;//Версия с сайта 1:</div><div class="code_line">&nbsp;&nbsp; &nbsp;/*pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.nVersion = 1;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_TYPE_RGBA;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.iPixelType = 24;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.cDepthBits = 32;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.iLayerType = PFD_MAIN_PLANE;*/</div><div class="code_line">&nbsp;&nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;//Версия с сатйта 2</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.nVersion = 1;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.iPixelType = PFD_TYPE_RGBA;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pfd.cColorBits = 24;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;hDc = GetDC(hWnd);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;int nPixelFormat = ChoosePixelFormat(hDc, &amp;pfd);</div><div class="code_line">&nbsp;&nbsp; &nbsp;SetPixelFormat(hDc, nPixelFormat, &amp;pfd);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;HGLRC hglrc = wglCreateContext(hDc);</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (!hglrc)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return GetLastError();</div><div class="code_line">&nbsp;&nbsp; &nbsp;};</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (!wglMakeCurrent(hDc, hglrc))</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return OGLCONTEXNOTMADECURRENT;</div><div class="code_line">&nbsp;&nbsp; &nbsp;};</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;return 0;</div><div class="code_line">};</div><div class="code_line">&nbsp;</div><div class="code_line">int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;int initresult = WinInit(hInstance);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (initresult != 0)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return initresult;</div><div class="code_line">&nbsp;&nbsp; &nbsp;};</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;initresult = WinOGLInit();</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (initresult != 0)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return initresult;</div><div class="code_line">&nbsp;&nbsp; &nbsp;};</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;return WinLoop(); &nbsp; </div><div class="code_line">}</div></ol></div></div></div></div><br>
<br>
Результат оставляет желать лучшего (обе версии). Во время перерисовок на одной машине (NVidia) окно мограет белым и скорость перерисовок очень низкая, на другой машине (Intel HD) вообще не рисует. Я решил узнать секрет glut. Попробовал прикрутить к проекту glut - но он намертво завязан на glut.dll. Исходный код всех функций вроде как есть, но всё равно требует glut32.lib и glut32.dll. Попробовал пособирать кусочки кода в один файл, чтоб точно скомпилировалось, но через один вечер работы запарился и понял, что что-то я не то делаю. Из ситуации вижу три выхода:<br>
<br>
1) Как-то настроить проект так, чтобы он подключал glut/freeglut и компилировал их, при этом не требовал .lib/.dll. И отлаживать программу.<br>
2) Найти или сделать самому файл, который работает так, как описано в пункте 1. Это у меня не получилось, хотя может нужно больше времени.<br>
3) Отладчиком (таким, который показывает ассемблерные коды, не знаю, как это называется) смотреть, какие функции opengl32.dll и winapi вызываются из glut32.dll. Если честно, не хочется это делать.<br>
<br>
Просто забросить и использовать glut32.dll не очень хочется. Заранее спасибо.]]></description>
        <author>k.sovailo</author>
        <category>C/C++: Прочее</category>
      </item>
	
      </channel>
      </rss>
	