Link to home
Start Free TrialLog in
Avatar of perdoname_
perdoname_

asked on

undeclared identifier ?

Hello,

On the code below i get continually an error 'undeclared identifier' for multiple things, but what it seems strange is that i already have got every identifier declared.

 'ox' : undeclared identifier      
 'num_x' : undeclared identifier
......
......


How can i solve that error ??

Thanks in advance for any help
Avatar of perdoname_
perdoname_

ASKER


#include "display.h"
 
 
SKELETON* gSkel;			/* Holds skeleton data - available to any function */
MOCAP*	  gMo;				/* Hold motion data - available to any function */
int		  gDelay=0;			/* Holds delay information - available to any function */
 
 
//camera
 
static float   camera_yaw = 0.0f;      
static float   camera_pitch = -20.0f;  
static float   camera_distance = 5.0f; 
 
//mouse
 
static int     drag_mouse_r = 0; 
static int     drag_mouse_l = 0;
static int     drag_mouse_m = 0; 
static int     last_mouse_x, last_mouse_y; 
 
 
static int     win_width, win_height;
 
 
/* Entry point from MAIN.C */
void dorender(int argc, char** argv, SKELETON* skel, MOCAP* mo, int delay) {
 
 
	/* Create GLUT window */
   glutInit(&argc, argv);
   glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
   glutInitWindowSize (600, 600);
   glutInitWindowPosition( 0, 0 );
   glutCreateWindow ("Mocap");
 
   /* Setup GLUT callbacks */
   glutReshapeFunc (reshape);
   glutKeyboardFunc (keyboard);
   glutDisplayFunc (display);
   glutMouseFunc( mouse );
   glutMotionFunc( motion );
   glutIdleFunc (idle);
 
   /* Initialise any OpenGL state */
   init();
   initEnvironment();
 
	/* Set global variables */
   gSkel=skel;
   gMo=mo;
   gDelay=delay;
 
   /* Kick off the GLUT main loop */
   glutMainLoop();
   
 
}
 
 
 
void  drawMessage( int line_no, const char * message )
{
	int   i;
	if ( message == NULL )
		return;
 
	glMatrixMode( GL_PROJECTION );
	glPushMatrix();
	glLoadIdentity();
	gluOrtho2D( 0.0, win_width, win_height, 0.0 );
 
	glMatrixMode( GL_MODELVIEW );
	glPushMatrix();
	glLoadIdentity();
 
	
	glDisable( GL_DEPTH_TEST );
	glDisable( GL_LIGHTING );
 
	glColor3f( 1.0, 0.0, 0.0 );
	glRasterPos2i( 8, 24 + 18 * line_no );
	for ( i=0; message[i]!='\0'; i++ )
		glutBitmapCharacter( GLUT_BITMAP_HELVETICA_18, message[i] );
 
 
	glEnable( GL_DEPTH_TEST );
	glEnable( GL_LIGHTING );
	glMatrixMode( GL_PROJECTION );
	glPopMatrix();
	glMatrixMode( GL_MODELVIEW );
	glPopMatrix();
}
 
 
/* Keyboard callback from GLUT */
void keyboard(unsigned char key, int x, int y)
{
 
	/* ESCAPE to exit */
	
 
	switch(key) {
 
			case 0x1b:  
						parser_free_skeleton(gSkel);
						parser_free_mocap(gMo);
						exit(0);
						break;
 
 
	}
 
}
 
 
/* Mouse callback from GLUT */ 
void  mouse( int button, int state, int mx, int my )
{
	
	if ( ( button == GLUT_LEFT_BUTTON ) && ( state == GLUT_DOWN ) )
		drag_mouse_l = 1;
	
	else if ( ( button == GLUT_LEFT_BUTTON ) && ( state == GLUT_UP ) )
		drag_mouse_l = 0;
 
	
	if ( ( button == GLUT_RIGHT_BUTTON ) && ( state == GLUT_DOWN ) )
		drag_mouse_r = 1;
	
	else if ( ( button == GLUT_RIGHT_BUTTON ) && ( state == GLUT_UP ) )
		drag_mouse_r = 0;
 
	
	if ( ( button == GLUT_MIDDLE_BUTTON ) && ( state == GLUT_DOWN ) )
		drag_mouse_m = 1;
	
	else if ( ( button == GLUT_MIDDLE_BUTTON ) && ( state == GLUT_UP ) )
		drag_mouse_m = 0;
 
	
	glutPostRedisplay();
 
	
	last_mouse_x = mx;
	last_mouse_y = my;
}
 
 
void  motion( int mx, int my )
{
	if ( drag_mouse_r )
	{
		camera_yaw -= ( mx - last_mouse_x ) * 1.0;
		if ( camera_yaw < 0.0 )
			camera_yaw += 360.0;
		else if ( camera_yaw > 360.0 )
			camera_yaw -= 360.0;
 
		camera_pitch -= ( my - last_mouse_y ) * 1.0;
		if ( camera_pitch < -90.0 )
			camera_pitch = -90.0;
		else if ( camera_pitch > 90.0 )
			camera_pitch = 90.0;
	}
	
	if ( drag_mouse_l )
	{
		
		camera_distance += ( my - last_mouse_y ) * 0.2;
		if ( camera_distance < 2.0 )
			camera_distance = 2.0;
	}
 
	
	last_mouse_x = mx;
	last_mouse_y = my;
 
	glutPostRedisplay();
}
 
 
/* Called back when GLUT idling */
void idle() {
 
}
 
/* Called back by GLUT when the window is resized */
void reshape(int w, int h)
{
 
   glViewport(0, 0, w, h);
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   
   gluPerspective(60,(GLfloat)w/(GLfloat)h,0.01,100.0);
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
 
   win_width = w;
   win_height = h;
 
}
 
/* Called by us in dorender() to init any OpenGL state */
void init(void)
{  
 
   glClearColor (0.0, 0.0, 0.0, 0.0);
 
}
 
 
 
void  initEnvironment( void )
{
 
	float  light0_position[] = { 10.0, 10.0, 10.0, 1.0 };
	float  light0_diffuse[] = { 0.8, 0.8, 0.8, 1.0 };
	float  light0_specular[] = { 1.0, 1.0, 1.0, 1.0 };
	float  light0_ambient[] = { 0.1, 0.1, 0.1, 1.0 };
	glLightfv( GL_LIGHT0, GL_POSITION, light0_position );
	glLightfv( GL_LIGHT0, GL_DIFFUSE, light0_diffuse );
	glLightfv( GL_LIGHT0, GL_SPECULAR, light0_specular );
	glLightfv( GL_LIGHT0, GL_AMBIENT, light0_ambient );
	glEnable( GL_LIGHT0 );
 
	
	glEnable( GL_LIGHTING );
 
	
	glEnable( GL_COLOR_MATERIAL );
 
	
	glEnable( GL_DEPTH_TEST );
 
	
	glCullFace( GL_BACK );
	glEnable( GL_CULL_FACE );
 
	glClearColor( 0.5, 0.5, 0.8, 0.0 );
 
}
 
 
 
 
 
/* Called when GLUT wants to repaint the screen */
void  display( void )
{
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
 
    glMatrixMode( GL_MODELVIEW );
	glLoadIdentity();
	glTranslatef( 0.0, 0.0, - camera_distance );
	glRotatef( - camera_pitch, 1.0, 0.0, 0.0 );
	glRotatef( - camera_yaw, 0.0, 1.0, 0.0 );
	glTranslatef( 0.0, -0.5, 0.0 );
 
	float  light0_position[] = { 10.0, 10.0, 10.0, 1.0 };
	glLightfv( GL_LIGHT0, GL_POSITION, light0_position );
 
	
	float  size = 1.5f;
	int  num_x = 10, num_z = 10;
	double  ox, oz;
	glBegin( GL_QUADS );
		glNormal3d( 0.0, 1.0, 0.0 );
		ox = -(num_x * size) / 2;
		for ( int x=0; x<num_x; x++, ox+=size )
		{
			oz = -(num_z * size) / 2;
			for ( int z=0; z<num_z; z++, oz+=size )
			{
				if ( ((x + z) % 2) == 0 )
					glColor3f( 1.0, 1.0, 1.0 );
				else
					glColor3f( 0.8, 0.8, 0.8 );
				glVertex3d( ox, 0.0, oz );
				glVertex3d( ox, 0.0, oz+size );
				glVertex3d( ox+size, 0.0, oz+size );
				glVertex3d( ox+size, 0.0, oz );
			}
		}
	glEnd();
   /**********
	*	glColor3f( 1.0f, 0.0f, 0.0f );
	*	if ( asf )
	*		asf->RenderFigure( frame_no, 0.02f );
	*
	*	
	*	char  message[ 64 ];
	*	if ( asf )
	*		sprintf( message, "%.2f (%d)", animation_time, frame_no );
	*	else
	*		sprintf( message, "Press 'L' key to Load ASF/AMC file" );
	*	drawMessage( 0, message );
	*
	*********/
	
    glutSwapBuffers();
}
 
 
 
 
 
 
 
 
 
//header :
 
#ifndef MOCAP_DISPLAY_INCLUDED
#define MOCAP_DISPLAY_INCLUDED
 
 
#ifdef WIN32
	#include "windows.h"
	#define strcasecmp stricmp
#endif
 
#include "GL/gl.h"
#include "GL/glut.h"
 
#include <math.h>
 
#include "parser.h"
 
void dorender(int argc, char** argv, SKELETON* skel, MOCAP* mo, int delay);
 
/* GLUT callbacks */
void keyboard(unsigned char key, int x, int y);
void reshape(int w, int h);
void init(void);
void initEnvironment(void);
void display(void);
void idle(void);
void mouse(int button, int state, int mx, int my );
void motion(int mx, int my);
 
#endif

Open in new window

Avatar of ikework
hey perdoname_

can you post the real compiler-error here as well as the line-number it refers to?

ike
If you are compiling this as a C program, then C requires all declarations to be at the beginning of a code block which is not the case here
ok is in the code snippet

thanks
Error	2	error C2065: 'light0_position' : undeclared identifier		262
Error	9	error C2065: 'num_x' : undeclared identifier		270	
Error	16	error C2065: 'num_x' : undeclared identifier		271	
Error	24	error C2065: 'num_z' : undeclared identifier		273	
Error	31	error C2065: 'num_z' : undeclared identifier		274	
Error	8	error C2065: 'ox' : undeclared identifier		270	
Error	19	error C2065: 'ox' : undeclared identifier		271	
Error	40	error C2065: 'ox' : undeclared identifier		280	
Error	42	error C2065: 'ox' : undeclared identifier		281	
Error	45	error C2065: 'ox' : undeclared identifier		282	
Error	49	error C2065: 'ox' : undeclared identifier		283	
Error	23	error C2065: 'oz' : undeclared identifier		273	
Error	34	error C2065: 'oz' : undeclared identifier		274	
Error	41	error C2065: 'oz' : undeclared identifier		280	
Error	43	error C2065: 'oz' : undeclared identifier		281	
Error	47	error C2065: 'oz' : undeclared identifier		282	
Error	51	error C2065: 'oz' : undeclared identifier		283	
Error	10	error C2065: 'size' : undeclared identifier		270	
Error	21	error C2065: 'size' : undeclared identifier		272	
Error	25	error C2065: 'size' : undeclared identifier		273	
Error	36	error C2065: 'size' : undeclared identifier		275	
Error	44	error C2065: 'size' : undeclared identifier		281	
Error	46	error C2065: 'size' : undeclared identifier		282	
Error	48	error C2065: 'size' : undeclared identifier		282	
Error	50	error C2065: 'size' : undeclared identifier		283	
Error	15	error C2065: 'x' : undeclared identifier		271	
Error	18	error C2065: 'x' : undeclared identifier		271	
Error	38	error C2065: 'x' : undeclared identifier		276	
Error	30	error C2065: 'z' : undeclared identifier		274	
Error	33	error C2065: 'z' : undeclared identifier		274	
Error	39	error C2065: 'z' : undeclared identifier		276	

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of jgordos
jgordos
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial