Jump to content
  • Advertisement
Sign in to follow this  
choffstein

OpenGL glMaterial and glDrawElements

This topic is 4759 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to play around with openGL. Now that I have lighting done and my normals work, I would love to try some materials -- but I can't get them to work. Here is an example of what I am trying to do:
	if(texture)
		glBindTexture(GL_TEXTURE_2D, texture->getID());

	glNormalPointer( GL_FLOAT, 0, normals);
	glColorPointer( 4, GL_FLOAT, 0, colors );
	glTexCoordPointer( 2, GL_FLOAT, 0, textures );
	glVertexPointer( 3, GL_FLOAT, 0, vertices );
	 
        glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,128);

	glDrawElements(GL_TRIANGLES, geometry->getIndices().size(), GL_UNSIGNED_INT, indices);

It looks the exact same as when I don't make the glMaterial call. Any thoughts as to what is going on?

Share this post


Link to post
Share on other sites
Advertisement
I haven't done this in fixed function for a long long time, but I think that you have to do one or two more steps to enable Specular. A simple things to start with would be are you enabling materials? (glEnable(GL_COLOR_MATERIAL);)

Share this post


Link to post
Share on other sites
Quote:
Original post by Toji
I haven't done this in fixed function for a long long time, but I think that you have to do one or two more steps to enable Specular. A simple things to start with would be are you enabling materials? (glEnable(GL_COLOR_MATERIAL);)
Correct, the default specular material color is (0,0,0,1). You need to change this if you want to see specular highlights for a particular material. For more info read the Lighting chapter in the Red Book.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!