I'm just starting out with OpenGL, and I've got some code here that's giving me some trouble. I've got the proper .dlls for OpenGL and GLUT, so I'm sure that's not the problem. What happens is that I get an exception (access violation, etc) when I try to run it. I'm pretty sure the problem lies in the initialization of the window:

Code:
unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OpenGL, Glut;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  w,h: GLint;

implementation

{$R *.dfm}

procedure SetRenderContext;
begin
  glClearColor(0.9,0.4,0.2,1.0);
end;

procedure RenderIt; cdecl;
begin
  glClear(GL_COLOR_BUFFER_BIT);
  glutSwapBuffers;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  w := 640;
  h := 480;
  glutInitDisplayMode(GLUT_DOUBLE or GLUT_RGBA);
  glutInitWindowSize(w,h);
  glutInitWindowPosition((Screen.Width-Form1.Width) div 2,(Screen.Height-Form1.Height) div 2);
  glutCreateWindow('Generic Window');
  glutDisplayFunc(RenderIt);
end;

procedure TForm1.FormActivate(Sender: TObject);
begin
  SetRenderContext;
  glutMainLoop;
end;

end.
I'm sure not all of that is needed, but I thought that I should post it all for completeness.

Thanks in advance!