Ok! here is the entire file:
GLfloat ambientLight[]… is the line 33.
I really don’t understand, i can compile funcion.c and trackball.c without errors and many others glut examples.
#include <windows.h>
#include <GL/glut.h>
#include “funcion.h”
#include “trackball.h”
#define ZOOM -3.5
/* mesh_list = glGenLists(1);
glNewList(mesh_list, GL_COMPILE);
glBegin(GL_QUADS);
glEnd();
glEndList();
*/
/* -------------------------------------------------------- /
/ This function does any needed initialization on the rendering
context. /
void SetupRC()
{
glEnable( GL_DEPTH_TEST ); / Hidden surface removal /
glEnable( GL_POLYGON_SMOOTH );
glFrontFace(GL_CCW); / Counter clock-wise polygons face out */
/* Light values and coordinates */
GLfloat ambientLight[] = { 0.3f, 0.3f, 0.3f, 1.0f };
GLfloat diffuseLight[] = { 0.9f, 0.9f, 0.9f, 1.0f };
GLfloat specular[] = { 1.0f, 1.0f, 1.0f, 1.0f};
GLfloat lightPos[] = { 10.0f, 10.0f, 10.0f, 1.0f };
GLfloat specref[] = { 1.0f, 1.0f, 1.0f, 1.0f };
/* Enable lighting */
glEnable(GL_LIGHTING);
/* Setup and enable light 0 */
glLightfv(GL_LIGHT0,GL_AMBIENT,ambientLight);
glLightfv(GL_LIGHT0,GL_DIFFUSE,diffuseLight);
glLightfv(GL_LIGHT0,GL_SPECULAR,specular);
glLightfv(GL_LIGHT0,GL_POSITION,lightPos);
glEnable(GL_LIGHT0);
/* Enable color tracking */
glEnable(GL_COLOR_MATERIAL);
/* Set Material properties to follow glColor values */
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
/* All materials hereafter have full specular reflectivity
with a high shine */
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR,specref);
glMateriali(GL_FRONT,GL_SHININESS,128);
/* Black background */
glClearColor(0.0f, 0.0f, 0.0f, 1.0f );
glNewList( AXES, GL_COMPILE );
draw_axes();
glEndList();
glNewList( FUNCTION, GL_COMPILE );
draw_function();
glEndList();
tbInit(GLUT_RIGHT_BUTTON);
}
void display(void)
{
/* Esto seria mi renderscene.
*/
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* Clear the window with current clearing color */
glPushMatrix();
glTranslatef( 0.0f, 0.0f, ZOOM );
tbMatrix();
glCallList( AXES );
glCallList( FUNCTION );
glPopMatrix();
glFlush();
glutSwapBuffers();
}
/* -------------------------------------------------------- /
/ Change viewing volume and viewport. Called when window is resized /
void reshape (GLsizei w, GLsizei h)
{
/ Prevent a divide by zero /
if(h == 0) h = 1;
tbReshape(w, h);
/ Set Viewport to window dimensions */
glViewport(0, 0, w, h);
/* Reset projection matrix stack /
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
/ Produce the perspective projection */
gluPerspective(60.0f, (GLfloat)w/(GLfloat)h, 1.0f, 20.0f);
/* Reset Model view matrix stack */
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
}
void keyboard(unsigned char key, int x, int y)
{
switch (key)
{
case 'f':glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glutPostRedisplay();
break;
case 'w':glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glutPostRedisplay();
break;
case 27: exit(0);
break;
}
}
void mouse(int button, int state, int x, int y)
{
tbMouse(button, state, x, y);
glutPostRedisplay();
}
void motion(int x, int y)
{
tbMotion(x, y);
glutPostRedisplay();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize (400, 400);
glutInitWindowPosition (0, 0);
glutCreateWindow (“Superficie 3D”);
SetupRC();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutMouseFunc(mouse);
glutMotionFunc(motion);
glutMainLoop();
return 0;
}