本文介绍了OpenGL功能绘图仪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,我正在尝试构建函数绘图仪,到目前为止,这是我的代码....我在第72行"glutInit(& argc; argc,argv);"中遇到错误.


1> c:\ users \ alb \ documents \ projects \ laba8 \ eeee \ eeee \ ee.cpp(72):错误C2065:"amp":未声明的标识符
1> c:\ users \ alb \ documents \ projects \ laba8 \ eeee \ eeee \ ee.cpp(72):错误C2143:语法错误:'';''之前缺少'')'';''
1> c:\ users \ alb \ documents \ projects \ laba8 \ eeee \ eeee \ ee.cpp(72):错误C2059:语法错误:'')''
第72行:glutInit(& argc,argv);

知道如何解决吗?到目前为止,这是我的代码!

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;
}

推荐答案



这篇关于OpenGL功能绘图仪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 12:52