Open gl and c++ builder 5

I try these code but thy don’t work, could you thake a look and sey me what i have forgot?
Tanks for your help.

Unit1.cpp
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include “Unit1.h”
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource “*.dfm”
TForm1 Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent
Owner)
: TForm(Owner)
{

}
//---------------------------------------------------------------------------
void __fastcall TForm1::RenderGLScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glFlush();

}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
hdc = GetDC(Form1->Handle);
SetPixelFormatDescriptor();
hrc = wglCreateContext(hdc);
wglMakeCurrent(hdc, hrc);
SetupRC();

}
//---------------------------------------------------------------------------
void __fastcall TForm1::SetupRC()
{
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
RenderGLScene();
SwapBuffers(hdc);

}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
ReleaseDC(hwnd,hdc);
wglMakeCurrent(hdc, NULL);
wglDeleteContext(hrc);

}
//---------------------------------------------------------------------------
void __fastcall TForm1::SetPixelFormatDescriptor()
{
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL |
PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
24,
0,0,0,0,0,0,
0,
0,
0,
0,0,0,0,
32,
0,
0,
PFD_MAIN_PLANE,
0,
0,0,0

};
PixelFormat = ChoosePixelFormat(hdc, &pfd);
SetPixelFormat(hdc, PixelFormat, &pfd);

}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormResize(TObject *Sender)
{
GLfloat nRange = 200.f;

if(ClientHeight == 0)
ClientHeight = 1;

glViewport(0,0,ClientWidth,ClientHeight);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

if(ClientWidth <= ClientHeight)
glOrtho(-nRange, nRange, -nRangeClientHeight/ClientWidth,
nRange
ClientHeight/ClientWidth, -nRange, nRange);
else
glOrtho(-nRangeClientWidth/ClientHeight, nRangeClientWidth/ClientHeight,
-nRange, nRange, -nRange, nRange);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

}
//---------------------------------------------------------------------------

Unit1.h

#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <gl\gl.h>
#include <gl\glu.h>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
void __fastcall FormCreate(TObject *Sender);
void __fastcall FormDestroy(TObject *Sender);
void __fastcall FormResize(TObject Sender);
private: // User declarations
HDC hdc;
HGLRC hrc;
int PixelFormat;
HWND hwnd;
public: // User declarations
__fastcall TForm1(TComponent
Owner);
void __fastcall RenderGLScene();
void __fastcall SetPixelFormatDescriptor();
void __fastcall SetupRC();
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif

www.bytamin-c.com has an article on how to set up OpenGL in C++Builder.

try using
hDC = GetDC(Handle);
instead of
hDC = GetDC(Form1->Handle);

See if your SetPixelFormatDescriptor is working properly it may not.

See if your SetPixelFormatDescriptor is working properly it may not.

use this function to initialize OpenGL and
PixelDescriptor is below.

GLvoid initializeGL()
{
/*
int width,height;
GLfloat aspect;
ghWnd=Form1->Handle;
ghDC = GetDC(ghWnd);
if (!bSetupPixelFormat(ghDC))
PostQuitMessage (0);
ghRC = wglCreateContext(ghDC);
wglMakeCurrent(ghDC, ghRC);
GetClientRect(ghWnd, &rect);
glClearIndex( (GLfloat)WHITE_INDEX);
glClearDepth( 1.0 );
glEnable(GL_DEPTH_TEST);
glMatrixMode( GL_PROJECTION );
width=rect.right;
height=rect.bottom;
aspect = (GLfloat) width / height;
gluPerspective( 45.0, aspect, 3.0, 7.0 );
glMatrixMode( GL_MODELVIEW );
*/
INITIALIZED =1111;
int width,height;
ghWnd=Form1->Handle;
ghDC = GetDC(ghWnd);
if (!bSetupPixelFormat(ghDC))
PostQuitMessage (0);
ghRC = wglCreateContext(ghDC);
wglMakeCurrent(ghDC, ghRC);
GetWindowRect(ghWnd,&rect);
width=rect.right;
height=rect.bottom;
glClearColor(1.0,1.0,1.0,1.0);
glClearIndex((GLfloat)WHITE_INDEX);
glEnable(GL_DEPTH_TEST);
glClearDepth(1.0f);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
GLfloat aspect;
glMatrixMode( GL_PROJECTION );
aspect = (GLfloat) width / (GLfloat)height;
vangle=1.0;
gluPerspective( vangle, aspect, -10.0, 10.0 );
glMatrixMode( GL_MODELVIEW );
glPushMatrix();
}

HWND ghWnd;
HDC ghDC;
HGLRC ghRC;
RECT rect;
CScene m_Scene;
float m_newMatrix[16];
float vangle;

BOOL bSetupPixelFormat(HDC hdc)
{
PIXELFORMATDESCRIPTOR pfd, *ppfd;
int pixelformat;

ppfd = &pfd;

ppfd-&gt;nSize = sizeof(PIXELFORMATDESCRIPTOR);
ppfd-&gt;nVersion = 1;
ppfd-&gt;dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | 

PFD_DOUBLEBUFFER;
ppfd->dwLayerMask = PFD_MAIN_PLANE;
ppfd->iPixelType = PFD_TYPE_COLORINDEX;
ppfd->cColorBits = 8;
ppfd->cDepthBits = 16;
ppfd->cAccumBits = 0;
ppfd->cStencilBits = 0;

pixelformat = ChoosePixelFormat(hdc, ppfd);

if ( (pixelformat = ChoosePixelFormat(hdc, ppfd)) == 0 )
{
    MessageBox(NULL, "ChoosePixelFormat failed", "Error", MB_OK);
    return FALSE;
}

if (SetPixelFormat(hdc, pixelformat, ppfd) == FALSE)

{
    MessageBox(NULL, "SetPixelFormat failed", "Error", MB_OK);
    return FALSE;
}

return TRUE;

}

Above codes are from my project so ignore some lines.Sorry I have no time to arrange them for you.

Good luck!