Using T&L with OpenGL

I have got an ATI RADEON 8500 LE card with catalyst 4.2 driver, which should be able to use Transform and Lightning. I know the QuakeIII engine has it enabled under OpenGL but I don’t know how.

T&L is used automatically by OpenGL, you dont have to enable it (you cant do that anyway…).

Honk is right, sort of.

If you want to take advantage of HWTnL then you need to know how best to drive OpenGL. For starters, you need to drop immediate mode rendering (glBegin(), glVertex(), glEnd()) and start using glDrawElements() or glDrawArrays(). Once you do that it’s a good idea to look at better ways of getting your vertex data to the driver/card. Compiled Vertex Arrays is a start, but you’re definitely on the right track if you start using VBOs.

Then there’s the matter of vertex formats. This is one area where it isn’t obvious what can cause bad performance, but you basically need to stick to certain formats for certain data. Positions and normals should be float[3], texture coordinates should be floating point values, colors should be unsigned char[4].

There are lots more caveats, but this is a good start to proceedings.

Thank you

Smutmonkey is right, sort of.

Of course you can use glBegin(), glVertex(), glColor(), glEnd() with floats, doubles, integers and so on and still get hardware T&L as long as you put the commands in a displaylist which will be compiled by the driver into a format the driver likes most.

However, I agree the compiled vertex arrays (CVA) or vertex buffer objects (VBO) will mostlikly be faster but you will find that it depends on many factors like for example the GPU vendor (ATI/Nvidia/…), if the card uses AGP or PCI and so forth and even the driver version may have an impact in certain cases.

You need to draw a distinction between dispatching data to the graphics hardware and T&L on the hardware once it receives the data.

Graphics cards that use hardware T&L (i.e. almost all of them) will use hardware T&L no matter whether you’re in immediate mode or not and no matter how your application tries to draw it’s data.

Display lists help because immediate mode is limited by the speed at which data can be sent to the graphics cards, not because they exclusively enable hardware T&L. Display lists store data on the graphics card for high bandwidth on card access or in AGP mapped memory so it can be DMA’d quickly to the card all in an ideal format for the card. Without this the driver will either use PCI transfers or buffer data in client memory before sending it more efficiently to the card.

So, Honk is right, but SmutMonkey has good advice because you’ll only maximize the T&L capability of the card if you can feed it data fast enough to keep it busy.