Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

glEnableClientState and glDisableClientState of OpenGL

Tags:

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.

like image 639
Quazi Irfan Avatar asked Jun 13 '11 21:06

Quazi Irfan


2 Answers

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.

like image 134
datenwolf Avatar answered Sep 30 '22 19:09

datenwolf


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.

like image 45
Chris Mennie Avatar answered Sep 30 '22 19:09

Chris Mennie