Windows 98, CBuilder, wglCreateContext prob

Dear all,

I am using Borland C++ Builder (I’m afraid I don’t have a choice of compiler ( ). If I start Builder and literally in my main file I have the following code:-

#include “gl/gl.h”
#include “gl/glu.h”
#include <windows.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource “*.dfm”
TForm1 Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent
Owner)
: TForm(Owner)
{
HWND hwnd = NULL;
hwnd = Handle;
HDC hdc = NULL;
hdc = GetDeviceContext(hwnd);
HGLRC hglrc = NULL;
hglrc = wglCreateContext(hdc);

then hglrc is NULL!!! What am I doing wrong?

Yours Sincerely,
Matthew Banham

Just an idea: Place your code into the OnCreate event handler of your form. It may be that the form’s handle is still not valid during the constructor’s execution time. And don’t forget to select and set the DC’s pixelformat BEFORE wglCreateContext!

[This message has been edited by Inquisitor (edited 11-09-2000).]

[This message has been edited by Inquisitor (edited 11-09-2000).]