Sign in to follow this  
nickme

Opengl:why glEnableClientState(GL_TEXTURE_COORD_ARRAY); generate error?

Recommended Posts

hi

 

I am checking error in my program with the following function:

void errorCheck(char * msg) 
{
	GLenum errCode;
	const GLubyte *errString;
	while ((errCode = glGetError()) != GL_NO_ERROR) {
		errString = gluErrorString(errCode);
		printf(">>===>> %s : %s\n", msg, errString);
		fprintf(file, ">>===>> %s : %s\n", msg, errString);
	}
}


and in my codes:


	glBindBuffer(GL_ARRAY_BUFFER, TexCoordVBOID);
	glBufferData(GL_ARRAY_BUFFER, 8*sizeof(GLfloat), aTexCoord, GL_STATIC_DRAW);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	errorCheck("in init quad");
	glTexCoordPointer(2, GL_FLOAT, 2*sizeof(GLfloat), BUFFER_OFFSET(0));


after the     glEnableClientState(GL_TEXTURE_COORD_ARRAY);  it generated the following error:

 
>>===>> in init quad : invalid operation
 
why would a glEnableClientState() produced such an error?
 
thanks in advance for your help.
 
 

Share this post


Link to post
Share on other sites
From your other thread that I was posting in it sounds like the version of OpenGL that you are using doesn't support fixed function or default vertex attributes (glTexCoord and so on) so that's probably why this is  generating an error, it no longer exists. The brief search I did suggests that it was removed in 3.2 (maybe 3.1). If this is the case then glTexCoordPointer probably doesn't exist either. I read there is a compatibility mode that you can enable that allows these things to work so the function might still exist. I would suggest you take what you have learned from the other thread (where you were using vertex attributes) and use those for your texture coordinates too.
 
I'm not sure why your second post was down voted as moving your check error function around is a reasonable method for narrowing down and finding which function is generating the error.
 
It will be helpful if you can find out which version of OpenGL you are targeting and add that to your OpenGL questions. It'll allow people to quickly help you with your problem.
 
This is the API reference for OpenGL 4.5 https://www.khronos.org/files/opengl45-quick-reference-card.pdf there are others for previous versions also here Edited by Nanoha

Share this post


Link to post
Share on other sites

As the other poster said, you should give more details, mainly which version of OpenGL you are running with (glGet(GL_MAJOR_VERSION) and glGet(GL_MINOR_VERSION)) and what version of OpenGL you are targeting to develop with (if relevant).

 

But as a general answer I would say that if you want to keep using these functions, create a compatibility profile context for OpenGL. How to do this depends on what lower-level API you are using to create your window.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this