Re: TDD vs OpenGL
Stanislav Blinov <kerry <at> penza.net>
2004-08-27 20:05:32 GMT
Have you enabled lighting?
>...
>Here's another question - why is my cylinder black?
>
> GLfloat no_mat[] = { 0.0f, 0.0f, 0.0f, 1.0 };
> GLfloat mat_ambient[] = { 0.8f, 0.8f, 0.2f, 1.0 };
> GLfloat mat_diffuse[] = { 0.0f, 0.0f, 1.0f, 1.0 };
>
> ogl.glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
> ogl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
> ogl.glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat);
> ogl.glMaterialf (GL_FRONT, GL_SHININESS, 5.0);
> ogl.glMaterialfv(GL_FRONT, GL_EMISSION, no_mat);
>
> BuildCylinder(20);
>...
>
>double PI = 3.14159265358979323846;
>
>void BuildCylinder(int numEdges)
>{
> int i, top = 1.0, bottom = -1.0;
> float x[100], y[100], angle;
>
> for (i = 0; i <= numEdges; i++) {
> angle = i * 2.0 * PI / numEdges;
> x[i] = cosf(angle);
> y[i] = sinf(angle);
> }
>
> //glNewList(cylinder, GL_COMPILE);
> glBegin(GL_TRIANGLE_STRIP);
>
>
> for (i = 0; i <= numEdges; i++) {
> glNormal3f(x[i], y[i], 0.0);
> glVertex3f(x[i], y[i], bottom);
> glVertex3f(x[i], y[i], top);
> }
> glEnd();
> glBegin(GL_TRIANGLE_FAN);
> glNormal3f(0.0, 0.0, 1.0);
> glVertex3f(0.0, 0.0, top);
> for (i = 0; i <= numEdges; i++) {
> glVertex3f(x[i], -y[i], top);
> }
> glEnd();
> glBegin(GL_TRIANGLE_FAN);
> glNormal3f(0.0, 0.0, -1.0);
> glVertex3f(0.0, 0.0, bottom);
> for (i = 0; i <= numEdges; i++) {
> glVertex3f(x[i], y[i], bottom);
> }
> glEnd();
> //glEndList();
>}
>
>
>=====
>Phlip
> http://industrialxp.org/community/bin/view/Main/TestFirstUserInterfaces
>
>
>
>_______________________________
>Do you Yahoo!?
>Win 1 of 4,000 free domain names from Yahoo! Enter now.
>http://promotions.yahoo.com/goldrush
>-----
>FAQ and OpenGL Resources at:
> http://www.geocities.com/SiliconValley/Hills/9956/OpenGL
>
>--
>Author: Phlip
> INET: phlipcpp <at> yahoo.com
>
>Fat City Hosting, San Diego, California -- http://www.fatcity.com
>---------------------------------------------------------------------
>To REMOVE yourself from this mailing list, send an E-Mail message
>to: ListGuru <at> fatcity.com (note EXACT spelling of 'ListGuru') and in
>the message BODY, include a line containing: UNSUB OPENGL-GAMEDEV-L
>(or the name of mailing list you want to be removed from). You may
>also send the HELP command for other information (like subscribing).
>
-----
FAQ and OpenGL Resources at:
http://www.geocities.com/SiliconValley/Hills/9956/OpenGL
--
--
Author: Stanislav Blinov
INET: kerry <at> penza.net
Fat City Hosting, San Diego, California -- http://www.fatcity.com
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru <at> fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB OPENGL-GAMEDEV-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).