Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ OpenGL VisualStudio
Hey guys i trying to build a function plotter and here it is my code so far....Iam geting an error in line 72 "glutInit(&argc;argc, argv);"
 

1>c:\users\alb\documents\projects\laba8\eeee\eeee\ee.cpp(72): error C2065: 'amp' : undeclared identifier
1>c:\users\alb\documents\projects\laba8\eeee\eeee\ee.cpp(72): error C2143: syntax error : missing ')' before ';'
1>c:\users\alb\documents\projects\laba8\eeee\eeee\ee.cpp(72): error C2059: syntax error : ')'
line 72:glutInit(&argc, argv);
 
Any idea how to fix it? this is my code so far!!
 
 
#include <stdlib.h>
#include <math.h>
#include <GL/glut.h>

/* Sample func itself */
float func(float x)
{
	return x*x;
}
 
/* Function plotting func */
void draw(float (* func)(float x), float x1, float x2, float y1, float y2, int N)
{
	float x, dx = 1.0/N;
 
	glPushMatrix(); /* GL_MODELVIEW is default */
 
	glScalef(1.0 / (x2 - x1), 1.0 / (y2 - y1), 1.0);
	glTranslatef(-x1, -y1, 0.0);
	glColor3f(1.0, 1.0, 1.0);
 
	glBegin(GL_LINE_STRIP);
 
	for(x = x1; x < x2; x += dx)
	{
		glVertex2f(x, func(x));
	}
 
	glEnd();
 
	glPopMatrix();
};
 
/* Redrawing func */
void redraw(void)
{
	glClearColor(0, 0, 0, 0);
	glClear(GL_COLOR_BUFFER_BIT);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	
	draw(func, -3, 3, 0, 10, 10);
 
	glutSwapBuffers();
};
 
/* Idle proc. Redisplays, if called. */
void idle(void)
{
	glutPostRedisplay();
};
 
/* Key press processing */
void key(unsigned char c, int x, int y)
{
	if(c == 27) exit(0);
};
 
/* Window reashape */
void reshape(int w, int h)
{
	glViewport(0, 0, w, h);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0, 1, 0, 1, -1, 1);
	glMatrixMode(GL_MODELVIEW);
};
 
/* Main function */
int main(int argc, char **argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
	glutCreateWindow("Graph plotter");
 
	/* Register GLUT callbacks. */
	glutDisplayFunc(redraw);
	glutKeyboardFunc(key);
	glutReshapeFunc(reshape);
	glutIdleFunc(idle);
 
	/* Init the GL state */
	glLineWidth(1.0);
  
	/* Main loop */
	glutMainLoop();
	return 0;
}
 
Posted 4-May-12 6:35am
Edited 4-May-12 7:20am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I don't see a call to glutInit_ATEXIT_HACK() anywhere and I have no intention of counting up to 72 to find out what is on that line. Are you certain this is the actual code you passed in to your compiler?
  Permalink  
Comments
Erison Veshi at 4-May-12 12:19pm
   
yep ur were right i just copied an error from a different program. here it is the original error
 
1>c:\users\alb\documents\projects\laba8\eeee\eeee\ee.cpp(72): error C2065: 'amp' : undeclared identifier
1>c:\users\alb\documents\projects\laba8\eeee\eeee\ee.cpp(72): error C2143: syntax error : missing ')' before ';'
1>c:\users\alb\documents\projects\laba8\eeee\eeee\ee.cpp(72): error C2059: syntax error : ')'
line 72:glutInit(&argc, argv);
Richard MacCutchan at 4-May-12 12:32pm
   
Well unless you give us a clue as to the exact line where the error occurs we cannot help. Once again I cannot find any reference to the symbol amp in the above source listing.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Ok just solved it! i have added "amp" by mistake to the code (just a typo)that`s why it gave the error. Thanks Richard for pointing it out.
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 George Jonsson 215
1 Kornfeld Eliyahu Peter 169
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 4 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100