Jump to content
  • Advertisement
Sign in to follow this  
TheMan22

OpenGL array problem with opengl in c#

This topic is 3660 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

float[] diffuseArray = { 1f, 0.5f, 0f }; Gl.glMaterialf(Gl.GL_FRONT_FACE, Gl.GL_DIFFUSE, diffuseArray); It gives error : cannot convert float[] to float I tried float diffuseArray = { 1f, 0.5f, 0f }; but still gives errors like : Error 7 Can only use array initializer expressions to assign to array types. Try using a new expression instead What should i do? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Try: Gl.glMaterialfv(Gl.GL_FRONT_FACE, Gl.GL_DIFFUSE, diffuseArray);

EDIT: Also, use the first syntex (the one with []) to declare diffuseArray.

Share this post


Link to post
Share on other sites
Thanks

But still the material does not show up

float[] diffuseArray = { 0f, 0.5f, 0f };
Gl.glMaterialfv(Gl.GL_FRONT_FACE, Gl.GL_DIFFUSE, diffuseArray);

Gl.glRectf(-1, -1, 1, 1);

The rectangle is still pure white.By the way i have done these things :

Gl.glEnable(Gl.GL_LIGHTING);
Gl.glEnable(Gl.GL_LIGHT0);
Gl.glShadeModel(Gl.GL_SMOOTH);

What is missing ?

Share this post


Link to post
Share on other sites
As far as I know, glRect*() only calls glVertex*(), it doesn't supply normals. Try specifying the vertices yourself with glVertex*() and glNormal*().

I recommend that you have a look here for more info on OpenGL. It's outdated, but still contains a lot of useful information.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!