PDA

View Full Version : Using display lists with Borland C++ Builder



08-13-2003, 11:44 PM
For some reason I can't get OpenGL display lists to work with my Borland C++ Builder 5 projects. I made a small test application just to illustrate the problem. It uses the OpenGLPanel component (http://www.cobweb.net/~dplakosh/) to do OpenGL drawing, but that's not causing the problem, the same thing happens when drawing directly to the form.
Here's how I set up my display list (in the form's OnCreate event):



List = glGenLists(1);
glNewList(List, GL_COMPILE);
DrawScene();
glEndList();

DrawScene() looks like this:



void __fastcall TForm1: http://www.opengl.org/discussion_boards/ubb/biggrin.gifrawScene()
{
glBegin(GL_TRIANGLES);
glColor3f(1.0, 0.0, 0.0);
glVertex2f(-1.0, -1.0);
glVertex2f(0.0, 1.0);
glVertex2f(1.0, -1.0);
glEnd();
}

I render everything using this simple code:



void __fastcall TForm1::PanelPaint(TObject *Sender)
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glClear(GL_COLOR_BUFFER_BIT);
glCallList(List);
glFlush();
}

The problem is, nothing shows up on the form. It's completely black. If I replace the glCallList call with DrawScene() it works fine, so there's nothing wrong with the rendering code.
I have this same problem whenever I try to use display lists with BCB. What am I doing wrong? Any Borland gurus out there who could help me?

dbugger
08-13-2003, 11:47 PM
You must have a valid gl context before compiling your display list.

08-13-2003, 11:54 PM
Thanks, that helped. Strange, though...I was almost sure I had tried placing that code in all possible locations.