<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[OpenGL in Bitmap&#x2F;Canvas]]></title><description><![CDATA[<p>ALso ich habe eine Funktion zum Initialisieren von OpenGL:</p>
<pre><code class="language-cpp">bool UseDoubleBuffer = true;
HDC dc;
HGLRC GLContext;

HDC InitOpenGL(HWND Handle,bool UseDoubleBuffer)
{
        PIXELFORMATDESCRIPTOR pfd;

        memset(&amp;pfd,0,sizeof(pfd));
        pfd.nSize       = sizeof(PIXELFORMATDESCRIPTOR);
        pfd.nVersion    = 1;
        pfd.dwFlags     = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
        if(UseDoubleBuffer)
                pfd.dwFlags |= PFD_DOUBLEBUFFER;
        pfd.iPixelType  = PFD_TYPE_RGBA;
        pfd.cColorBits  = 24;
        pfd.cDepthBits  = 32;
        pfd.iLayerType  = PFD_MAIN_PLANE;

        HDC dc = GetDC(Handle);

        int iPF = ChoosePixelFormat(dc, &amp;pfd);
        if(iPF == 0) ShowMessage(&quot;Fehler bei PixelFormat!&quot;);

        SetPixelFormat(dc, iPF, &amp;pfd );
        GLContext = wglCreateContext(dc);
        if(GLContext) wglMakeCurrent(dc, GLContext);
        else ShowMessage(&quot;MakeCurrent geht nich!&quot;);
        return dc;
}
</code></pre>
<p>Und beim Erstellen:</p>
<pre><code class="language-cpp">dc = InitOpenGL(Form1-&gt;Handle,UseDoubleBuffer);
        glEnable(GL_DEPTH_TEST);
        glDepthFunc(GL_LEQUAL);
        glClearColor(1,1,1,1);

        glMatrixMode(GL_MODELVIEW);
</code></pre>
<p>Das ganze funktioniert ja prima, jedoch möchte ich gerne auch nur auf eine Paintbox oder Bitmap zeichnen!<br />
Wenn ich PaintBox-&gt;Canvas-&gt;Hande verwende, erscheinen jedoch beide Fehlermeldungen(&quot;Fehler bei PixelFormat!&quot; und &quot;MakeCurrent geht nich!&quot;), nutze ch TBitmap-&gt;Handle kommt immerhin nur noch die zweite Meldung (&quot;MakeCurrent geht nich!&quot;).<br />
Was muss ich anpassen, damit beides oder zumindest eins von beidem funktioniert?<br />
Danke schonmal!</p>
<p>EDit: Bei den BCB Examples sind leider keine OGL Sachen dabei</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/209339/opengl-in-bitmap-canvas</link><generator>RSS for Node</generator><lastBuildDate>Thu, 20 Aug 2026 14:40:47 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/209339.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 29 Mar 2008 13:53:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to OpenGL in Bitmap&#x2F;Canvas on Sat, 29 Mar 2008 13:54:12 GMT]]></title><description><![CDATA[<p>ALso ich habe eine Funktion zum Initialisieren von OpenGL:</p>
<pre><code class="language-cpp">bool UseDoubleBuffer = true;
HDC dc;
HGLRC GLContext;

HDC InitOpenGL(HWND Handle,bool UseDoubleBuffer)
{
        PIXELFORMATDESCRIPTOR pfd;

        memset(&amp;pfd,0,sizeof(pfd));
        pfd.nSize       = sizeof(PIXELFORMATDESCRIPTOR);
        pfd.nVersion    = 1;
        pfd.dwFlags     = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
        if(UseDoubleBuffer)
                pfd.dwFlags |= PFD_DOUBLEBUFFER;
        pfd.iPixelType  = PFD_TYPE_RGBA;
        pfd.cColorBits  = 24;
        pfd.cDepthBits  = 32;
        pfd.iLayerType  = PFD_MAIN_PLANE;

        HDC dc = GetDC(Handle);

        int iPF = ChoosePixelFormat(dc, &amp;pfd);
        if(iPF == 0) ShowMessage(&quot;Fehler bei PixelFormat!&quot;);

        SetPixelFormat(dc, iPF, &amp;pfd );
        GLContext = wglCreateContext(dc);
        if(GLContext) wglMakeCurrent(dc, GLContext);
        else ShowMessage(&quot;MakeCurrent geht nich!&quot;);
        return dc;
}
</code></pre>
<p>Und beim Erstellen:</p>
<pre><code class="language-cpp">dc = InitOpenGL(Form1-&gt;Handle,UseDoubleBuffer);
        glEnable(GL_DEPTH_TEST);
        glDepthFunc(GL_LEQUAL);
        glClearColor(1,1,1,1);

        glMatrixMode(GL_MODELVIEW);
</code></pre>
<p>Das ganze funktioniert ja prima, jedoch möchte ich gerne auch nur auf eine Paintbox oder Bitmap zeichnen!<br />
Wenn ich PaintBox-&gt;Canvas-&gt;Hande verwende, erscheinen jedoch beide Fehlermeldungen(&quot;Fehler bei PixelFormat!&quot; und &quot;MakeCurrent geht nich!&quot;), nutze ch TBitmap-&gt;Handle kommt immerhin nur noch die zweite Meldung (&quot;MakeCurrent geht nich!&quot;).<br />
Was muss ich anpassen, damit beides oder zumindest eins von beidem funktioniert?<br />
Danke schonmal!</p>
<p>EDit: Bei den BCB Examples sind leider keine OGL Sachen dabei</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1482674</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1482674</guid><dc:creator><![CDATA[Powerpaule]]></dc:creator><pubDate>Sat, 29 Mar 2008 13:54:12 GMT</pubDate></item><item><title><![CDATA[Reply to OpenGL in Bitmap&#x2F;Canvas on Sat, 29 Mar 2008 15:05:49 GMT]]></title><description><![CDATA[<p>Bei meinem BCB 5 sind Beispiele im Ordner &quot;.../Examples/Open GL&quot;:<br />
- Drawing<br />
- Rotate<br />
Beide benutzten jedoch auch nur das Form-&gt;Handle.</p>
<p>Ich denke, die Fehlermeldungen kommen daher, daß nur ein Formular ein eigenständiges Canvas besitzt (eine Paintbox benutzt auch nur das Formular-Canvas) und eine Bitmap nur eine Offline-Komponente darstellt (bin mir jedoch nicht sicher -)</p>
<p>Evtl. bietet OpenGL ja selbständig eine Clipping-Methode an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1482701</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1482701</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Sat, 29 Mar 2008 15:05:49 GMT</pubDate></item><item><title><![CDATA[Reply to OpenGL in Bitmap&#x2F;Canvas on Sat, 29 Mar 2008 15:18:20 GMT]]></title><description><![CDATA[<p>Hm komisch, ich hab BCB6, aber es nur Beispiele zu DirectDraw dabei...</p>
<p>Also ich hab mal die Funktion etwas verändert, und zwar so:</p>
<pre><code class="language-cpp">bool UseDoubleBuffer = true;
HDC dc;
HGLRC GLContext;

HDC InitOpenGL(HDC Handle,bool UseDoubleBuffer)
{
        PIXELFORMATDESCRIPTOR pfd;

        memset(&amp;pfd,0,sizeof(pfd));
        pfd.nSize       = sizeof(PIXELFORMATDESCRIPTOR);
        pfd.nVersion    = 1;
        pfd.dwFlags     = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
        if(UseDoubleBuffer)
                pfd.dwFlags |= PFD_DOUBLEBUFFER;
        pfd.iPixelType  = PFD_TYPE_RGBA;
        pfd.cColorBits  = 24;
        pfd.cDepthBits  = 32;
        pfd.iLayerType  = PFD_MAIN_PLANE;

        HDC dc = GetDC(Handle);

        int iPF = ChoosePixelFormat(Handle, &amp;pfd);
        if(iPF == 0) ShowMessage(&quot;Fehler bei PixelFormat!&quot;);

        SetPixelFormat(Handle, iPF, &amp;pfd );
        GLContext = wglCreateContext(Handle);
        if(GLContext) wglMakeCurrent(Handle, GLContext);
        else ShowMessage(&quot;MakeCurrent geht nich!&quot;);
        return dc;
}
</code></pre>
<p>Wenn ich sie jetzt mit</p>
<pre><code class="language-cpp">dc = InitOpenGL(Form1-&gt;Canvas-&gt;Handle,UseDoubleBuffer);
</code></pre>
<p>aufrufe, klappt auch alles, auch das Zeichnen.</p>
<p>Nehme ich aber das Handle der PaintBox:</p>
<pre><code class="language-cpp">dc = InitOpenGL(Form1-&gt;PaintBox1-&gt;Canvas-&gt;Handle,UseDoubleBuffer);
</code></pre>
<p>kommt zwar keine Fehlermeldung, aber man sieht auch nichts...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1482708</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1482708</guid><dc:creator><![CDATA[Powerpaule]]></dc:creator><pubDate>Sat, 29 Mar 2008 15:18:20 GMT</pubDate></item><item><title><![CDATA[Reply to OpenGL in Bitmap&#x2F;Canvas on Sat, 29 Mar 2008 16:37:02 GMT]]></title><description><![CDATA[<p>I habe noch nicht viel mit OpenGL gemacht, aber ich hatte ein Beispiel, wo das Bild in einem Panel war, auf jeden Fall funktioniert es auch wo anderes als in einer Form (soweit ein pixelformat und eine color palette existiert). Auf jeden Fall mußt Du SwapBuffers(dc) in ScreenDraw benutzen und zuvor evtl. das Pixelformat und Color Palette für das Handl anpassen.<br />
Da dies aber nicht unbedingt BCB spezifisch ist, würde ich mal im Forum Spiele Programmierung fragen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1482750</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1482750</guid><dc:creator><![CDATA[OldMan00]]></dc:creator><pubDate>Sat, 29 Mar 2008 16:37:02 GMT</pubDate></item><item><title><![CDATA[Reply to OpenGL in Bitmap&#x2F;Canvas on Sat, 29 Mar 2008 17:00:36 GMT]]></title><description><![CDATA[<p>Ey cool, wenn ich ein Panel nehme, klappt's! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /><br />
danke für den tipp!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1482764</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1482764</guid><dc:creator><![CDATA[Powerpaule]]></dc:creator><pubDate>Sat, 29 Mar 2008 17:00:36 GMT</pubDate></item><item><title><![CDATA[Reply to OpenGL in Bitmap&#x2F;Canvas on Sat, 29 Mar 2008 18:32:45 GMT]]></title><description><![CDATA[<p>Powerpaule schrieb:</p>
<blockquote>
<p>Hm komisch, ich hab BCB6, aber es nur Beispiele zu DirectDraw dabei...</p>
</blockquote>
<p>...\CBuilder6\Examples\OpenGL</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1482809</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1482809</guid><dc:creator><![CDATA[Jansen]]></dc:creator><pubDate>Sat, 29 Mar 2008 18:32:45 GMT</pubDate></item><item><title><![CDATA[Reply to OpenGL in Bitmap&#x2F;Canvas on Sat, 29 Mar 2008 22:52:30 GMT]]></title><description><![CDATA[<p>Jansen schrieb:</p>
<blockquote>
<p>Powerpaule schrieb:</p>
<blockquote>
<p>Hm komisch, ich hab BCB6, aber es nur Beispiele zu DirectDraw dabei...</p>
</blockquote>
<p>...\CBuilder6\Examples\OpenGL</p>
</blockquote>
<p>Gibt's bei mir nicht, hab auch nur Personal Edition, oder ich hab nicht alle Beispiele installieren lassen, wer weiß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1482944</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1482944</guid><dc:creator><![CDATA[Powerpaule]]></dc:creator><pubDate>Sat, 29 Mar 2008 22:52:30 GMT</pubDate></item></channel></rss>