<?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 und BCB5]]></title><description><![CDATA[<p>Ich weiss, dass dieses Thema eigentlich in die Spieleprogrammierung gehört. Trotzdem bin ich mir in dem Fall nicht sicher obs nicht doch hierhinein gehört.</p>
<p>Quellcode:</p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#include &lt;gl\gl.h&gt;
#include &lt;gl\glu.h&gt;
#pragma hdrstop

#include &quot;Unit1.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
TForm1 *Form1;
bool UseDoubleBuffer = true;
HDC dc, DC;
HGLRC GLContext;

//---------------------------------------------------------------------------

HDC InitOpenGL(HWND Handle, bool UseDoubleBuffer);
void DrawScene();
void CoordinateSystem(GLdouble x, GLdouble y, GLdouble z);

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
  CoordinateSystem(0, 0, 0);
}
//---------------------------------------------------------------------------

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 ChoosePixelFormat&quot;);

  SetPixelFormat(dc, iPF, &amp;pfd);
  GLContext = wglCreateContext(dc);
  if(GLContext)
    wglMakeCurrent(dc, GLContext);
  else
    ShowMessage(&quot;wglMakeCurrent nicht erfolgreich&quot;);

  return dc;
}

void __fastcall TForm1::FormDestroy(TObject *Sender)
{
   ReleaseDC(Handle, dc);
   wglMakeCurrent(dc, NULL);
   wglDeleteContext(GLContext);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormResize(TObject *Sender)
{
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  GLdouble aspect = (double) ClientWidth / ClientHeight;
  gluPerspective(60, aspect, 1, 10);
  glMatrixMode(GL_MODELVIEW);
  DrawScene();
}
//---------------------------------------------------------------------------

void DrawScene()
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  if(UseDoubleBuffer)
    SwapBuffers(dc);
  else
    glFlush();
}

//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  DC = InitOpenGL(Form1-&gt;Handle, UseDoubleBuffer);
  glEnable(GL_DEPTH_TEST);
  glClearColor(1,1,1,1);
  glMatrixMode(GL_MODELVIEW);
  glTranslated(0,0,-2);        
}
//---------------------------------------------------------------------------

void CoordinateSystem(GLdouble x, GLdouble y, GLdouble z)
{
  GLfloat colRed[]   = {1,0,0};
  GLfloat colGreen[] = {0,1,0};
  GLfloat colBlue[]  = {0,0,1};

  glBegin(GL_LINES);
  glColor3fv(colRed);
    glVertex3d(-x,  0,  0);
    glVertex3d( x,  0,  0);
  glColor3fv(colGreen);
    glVertex3d( 0, -y,  0);
    glVertex3d( 0,  y,  0);
  glColor3fv(colBlue);
    glVertex3d( 0,  0, -z);
    glVertex3d( 0,  0,  z);
  glEnd();
  glBegin(GL_TRIANGLES);
    double h = 0.5;
    glColor3fv(colRed);
    glVertex3d(x-h,   h, 0);
    glVertex3d(x  ,   0, 0);
    glVertex3d(x-h,  -h, 0);

  glEnd();
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  exit(1);        
}
//---------------------------------------------------------------------------
</code></pre>
<p>Schönheitsfehler hab ich bis jetzt noch nicht behoben. Aber vlt. kann mir jemand helfen. Hab das erste Mal versucht OpenGl - Komponeten zuverwenden. Mein Compiler meldet auch keine Fehlermeldungen. Jedoch bekomme ich nach dem compilieren nur die &quot;Form&quot; also das Fenster, aber ohne das darzustellende Koordinatensystem. Dieser quellcode stammt nicht von mir sondern damit wollte ich mir nur mal OpenGl in dem zusammenahng angucken.</p>
<p>Hab ich irgendetwas vergessen ???</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/103247/opengl-und-bcb5</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Jul 2026 13:41:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/103247.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 06 Mar 2005 18:00:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to OpenGL und BCB5 on Sun, 06 Mar 2005 18:16:56 GMT]]></title><description><![CDATA[<p>Ich weiss, dass dieses Thema eigentlich in die Spieleprogrammierung gehört. Trotzdem bin ich mir in dem Fall nicht sicher obs nicht doch hierhinein gehört.</p>
<p>Quellcode:</p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#include &lt;gl\gl.h&gt;
#include &lt;gl\glu.h&gt;
#pragma hdrstop

#include &quot;Unit1.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
TForm1 *Form1;
bool UseDoubleBuffer = true;
HDC dc, DC;
HGLRC GLContext;

//---------------------------------------------------------------------------

HDC InitOpenGL(HWND Handle, bool UseDoubleBuffer);
void DrawScene();
void CoordinateSystem(GLdouble x, GLdouble y, GLdouble z);

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
  CoordinateSystem(0, 0, 0);
}
//---------------------------------------------------------------------------

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 ChoosePixelFormat&quot;);

  SetPixelFormat(dc, iPF, &amp;pfd);
  GLContext = wglCreateContext(dc);
  if(GLContext)
    wglMakeCurrent(dc, GLContext);
  else
    ShowMessage(&quot;wglMakeCurrent nicht erfolgreich&quot;);

  return dc;
}

void __fastcall TForm1::FormDestroy(TObject *Sender)
{
   ReleaseDC(Handle, dc);
   wglMakeCurrent(dc, NULL);
   wglDeleteContext(GLContext);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormResize(TObject *Sender)
{
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  GLdouble aspect = (double) ClientWidth / ClientHeight;
  gluPerspective(60, aspect, 1, 10);
  glMatrixMode(GL_MODELVIEW);
  DrawScene();
}
//---------------------------------------------------------------------------

void DrawScene()
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  if(UseDoubleBuffer)
    SwapBuffers(dc);
  else
    glFlush();
}

//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  DC = InitOpenGL(Form1-&gt;Handle, UseDoubleBuffer);
  glEnable(GL_DEPTH_TEST);
  glClearColor(1,1,1,1);
  glMatrixMode(GL_MODELVIEW);
  glTranslated(0,0,-2);        
}
//---------------------------------------------------------------------------

void CoordinateSystem(GLdouble x, GLdouble y, GLdouble z)
{
  GLfloat colRed[]   = {1,0,0};
  GLfloat colGreen[] = {0,1,0};
  GLfloat colBlue[]  = {0,0,1};

  glBegin(GL_LINES);
  glColor3fv(colRed);
    glVertex3d(-x,  0,  0);
    glVertex3d( x,  0,  0);
  glColor3fv(colGreen);
    glVertex3d( 0, -y,  0);
    glVertex3d( 0,  y,  0);
  glColor3fv(colBlue);
    glVertex3d( 0,  0, -z);
    glVertex3d( 0,  0,  z);
  glEnd();
  glBegin(GL_TRIANGLES);
    double h = 0.5;
    glColor3fv(colRed);
    glVertex3d(x-h,   h, 0);
    glVertex3d(x  ,   0, 0);
    glVertex3d(x-h,  -h, 0);

  glEnd();
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  exit(1);        
}
//---------------------------------------------------------------------------
</code></pre>
<p>Schönheitsfehler hab ich bis jetzt noch nicht behoben. Aber vlt. kann mir jemand helfen. Hab das erste Mal versucht OpenGl - Komponeten zuverwenden. Mein Compiler meldet auch keine Fehlermeldungen. Jedoch bekomme ich nach dem compilieren nur die &quot;Form&quot; also das Fenster, aber ohne das darzustellende Koordinatensystem. Dieser quellcode stammt nicht von mir sondern damit wollte ich mir nur mal OpenGl in dem zusammenahng angucken.</p>
<p>Hab ich irgendetwas vergessen ???</p>
]]></description><link>https://www.c-plusplus.net/forum/post/738928</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/738928</guid><dc:creator><![CDATA[nortan]]></dc:creator><pubDate>Sun, 06 Mar 2005 18:16:56 GMT</pubDate></item><item><title><![CDATA[Reply to OpenGL und BCB5 on Sun, 06 Mar 2005 18:12:43 GMT]]></title><description><![CDATA[<p>Im examples-Verzeichnis deiner BCB-Installation finden sich auch zwei lauffähige OpenGL-Beispiele, an denen du dich orientieren kannst.</p>
<p>Und nächste Mal bitte die <strong>&quot;C++&quot;</strong>-CodeTags verwenden! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/738939</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/738939</guid><dc:creator><![CDATA[Jansen]]></dc:creator><pubDate>Sun, 06 Mar 2005 18:12:43 GMT</pubDate></item><item><title><![CDATA[Reply to OpenGL und BCB5 on Sun, 06 Mar 2005 18:17:31 GMT]]></title><description><![CDATA[<p>So hab cpp tags verwendet</p>
<p>Öhm also ist das obige Beispiel total falsch ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/738944</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/738944</guid><dc:creator><![CDATA[nortan]]></dc:creator><pubDate>Sun, 06 Mar 2005 18:17:31 GMT</pubDate></item><item><title><![CDATA[Reply to OpenGL und BCB5 on Sun, 06 Mar 2005 22:26:16 GMT]]></title><description><![CDATA[<p>Sieht so aus als ob dein handle nicht funktioniert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/739164</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/739164</guid><dc:creator><![CDATA[helfer 23]]></dc:creator><pubDate>Sun, 06 Mar 2005 22:26:16 GMT</pubDate></item><item><title><![CDATA[Reply to OpenGL und BCB5 on Mon, 07 Mar 2005 09:42:52 GMT]]></title><description><![CDATA[<p>Hm. So in der Art hab ich mir das auch gedacht. Kannste mir evtl. bissel helfen. Ich hab echt kA von OpenGl und BCB 5</p>
]]></description><link>https://www.c-plusplus.net/forum/post/739312</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/739312</guid><dc:creator><![CDATA[badboy]]></dc:creator><pubDate>Mon, 07 Mar 2005 09:42:52 GMT</pubDate></item><item><title><![CDATA[Reply to OpenGL und BCB5 on Mon, 07 Mar 2005 11:37:13 GMT]]></title><description><![CDATA[<p>Ich habe es so gelöst. Datei--&gt;Neuer Frame dann: oben in der Komponentenleiste auf: Standard--&gt;Frames und den Frame ins Form einfügen. Bei den OpenGL Sachen sich dann auf dieses Frame beziehen. Vielleicht hilft es dir.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/739407</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/739407</guid><dc:creator><![CDATA[helfer 23]]></dc:creator><pubDate>Mon, 07 Mar 2005 11:37:13 GMT</pubDate></item><item><title><![CDATA[Reply to OpenGL und BCB5 on Mon, 07 Mar 2005 12:01:49 GMT]]></title><description><![CDATA[<p>unter <a href="http://www.rkaiser.de" rel="nofollow">www.rkaiser.de</a> kannst du dir die Lösungen der Aufgaben aus dem Buch &quot;C++ mit dem Borland Builder&quot; herunterladen. Dort sind ein paar Lösungen dabei.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/739442</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/739442</guid><dc:creator><![CDATA[helfer 23]]></dc:creator><pubDate>Mon, 07 Mar 2005 12:01:49 GMT</pubDate></item><item><title><![CDATA[Reply to OpenGL und BCB5 on Mon, 07 Mar 2005 12:14:05 GMT]]></title><description><![CDATA[<p>sorry, war quatsch was ich geschrieben habe. genau die lösungen stehn da nicht drin. im netz geistern aber ein paar nette opengl anleitungen für bcb herum. man hat auch schon pdf´s von rkaisers buch gesehen. dort steht definitiv etwas über die opengl-fenster-initialisierung drin. irgendwo habe ich auch mal eine freeware-opengl-komponente gesehen und auch benutzt. allerdings war diese nur für den bcb 4 und 5 geeignet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/739462</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/739462</guid><dc:creator><![CDATA[helfer 23]]></dc:creator><pubDate>Mon, 07 Mar 2005 12:14:05 GMT</pubDate></item><item><title><![CDATA[Reply to OpenGL und BCB5 on Mon, 07 Mar 2005 14:21:51 GMT]]></title><description><![CDATA[<p>jo. hab das buch hier liegen und daher kommen auch die bespiele. Trotzdem ist das hier nur abgetippt aus dem buch und irgendwie geht es nicht. Die pdf von dem buch is sogar auf der cd mitbeigefügt. Irgendwie schoin komisch das mit der pdf. Werd mir mal die Lödsung zu der aufgabe reinziehen.</p>
<p>Würd mich trotzdem freuen wenn mir jemand sagen kann wo der fehler liegt, weil es ist nur abgetippt. Die aufgabe geht zwar in dem buch noch etwas weiter. Aber im Grunde sollte es doch funktionieren</p>
]]></description><link>https://www.c-plusplus.net/forum/post/739588</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/739588</guid><dc:creator><![CDATA[nortan]]></dc:creator><pubDate>Mon, 07 Mar 2005 14:21:51 GMT</pubDate></item><item><title><![CDATA[Reply to OpenGL und BCB5 on Mon, 07 Mar 2005 16:02:42 GMT]]></title><description><![CDATA[<p>hast du denn die sache mit dem frame auch so wie beschrieben gemacht? Das war bei mir der fehler.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/739693</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/739693</guid><dc:creator><![CDATA[helfer 23]]></dc:creator><pubDate>Mon, 07 Mar 2005 16:02:42 GMT</pubDate></item><item><title><![CDATA[Reply to OpenGL und BCB5 on Mon, 07 Mar 2005 16:51:29 GMT]]></title><description><![CDATA[<p>ui sry das hab ich total überlesen werde es gleich mal ausprobieren mit den frames</p>
]]></description><link>https://www.c-plusplus.net/forum/post/739732</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/739732</guid><dc:creator><![CDATA[nortan]]></dc:creator><pubDate>Mon, 07 Mar 2005 16:51:29 GMT</pubDate></item></channel></rss>