I use the following code with Borland C++ Builder 6. It works fine and does the following: When I press the button (Button1Click) it creates a separate OpenGL window, with background color blue. Now: When I want to close the window (no matter which) I get the following error : “access violation at 0x40009729: write of address 0x00030c0c. Process stopped” and the Compiler hangs up. Why is this and what`s wrong? When I run the .exe file of this Programm, I do not get a problem, when I quit it.
#include <vcl.h>
#pragma hdrstop
#include “Basic_U.h”
#include <GL/glut.h>
//-----------------------------------------------
#pragma package(smart_init)
#pragma resource “*.dfm”
TForm1 Form1;
//-----------------------------------------------
__fastcall TForm1::TForm1(TComponent Owner)
: TForm(Owner)
{
}
//-----------------------------------------------
void RenderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
}
void SetupRC(void)
{
glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
}
//-----------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutCreateWindow(“This is a OpenGL window”);
glutDisplayFunc(RenderScene);
SetupRC();
glutMainLoop();
}
//-----------------------------------------------