PDA

View Full Version : Windows 98, CBuilder, wglCreateContext prob



matb
11-08-2000, 11:37 AM
Dear all,

I am using Borland C++ Builder (I'm afraid I don't have a choice of compiler http://www.opengl.org/discussion_boards/ubb/redface.gif( ). 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

Inquisitor
11-09-2000, 04:24 AM
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).]