Quazi Irfan
Quazi Irfan

Reputation: 2589

glEnableClientState and glDisableClientState of OpenGL

What is the meaning of glEnableClientState and glDisableClientState in OpenGL? So far I've found that these functions are to enable or disable some client side capabilities.

Well, what exactly is the client or server here? I am running my OpenGL program on a PC, so what is this referring to? Why do we even need to disable certain capabilities? ...and more intriguing it's about some sort of an array related thing?

The whole picture is very gray to me.

Upvotes: 18

Views: 8987

Answers (4)

datenwolf
datenwolf

Reputation: 162164

The original terminology stems from the X11 notation, where the server is the actual graphics display system:

  • A server program providing access to some kind of display device

and

  • Clients connecting to the server to draw on the display device provided by it

glEnableClientState and glDisableClientState set state of the client side part. Vertex Arrays used to be located in the client process memory, so drawing using vertex arrays was a client local process.

Today we have Buffer Objects, that place the data in server memory, rendering the whole client side terminology of vertex arrays counterintuitive. It would make sense to discard client states and enable/disable vertex arrays through the usual glEnable/glDisable functions, like we do with framebuffer objects and textures.

Upvotes: 15

Christian Rau
Christian Rau

Reputation: 45948

In OpenGL terminology, the client is your application, whereas the server is the graphics card (or the driver), I think. The only client-side capabilities are the vertex arrays, as these are stored in CPU memory and therefore on the client-side or more specifically, they are controlled (allocated and freed) by your application and not by the driver.

Vertex buffer objects are a different story. They can be used as vertex arrays, but are controlled by the driver, so the word "client state" doesn't make so much sense anymore when working with buffers.

Upvotes: 4

Chris Mennie
Chris Mennie

Reputation: 674

If you draw your graphics by passing buffers to OpenGL (glVertexPointer(), etc) instead of direct calls (glVertex3f()), you need to tell OpenGL which buffers to use.

So instead of calling glVertex and glNormal, you'd create buffers, bind them, and use glVertexPointer and glNormalPointer to point OpenGL at your data. Afterwards a call to glDrawElements (or the like) will use those buffers to do the drawing. However, one other required step is to tell the OpenGL driver which buffers you actually want to use, which is there glEnableClientState() comes in.

This is all very hand-wavy. You need to read up on vertex buffer objects and try them out.

Upvotes: 8

tibur
tibur

Reputation: 11636

glEnableClientState and glDisableClientState are mainly used to manage Vertex Arrays and Vertex Buffer Objects.

Upvotes: 2

Related Questions