我要发帖 回复

新手上路

1

主题

12

积分

0

专家分

:

私信
发表时间 : 2008-12-23 21:33:56 | 浏览 : 1287    评论 : 1
这是代码
[cpp]#include "GL/glut.h"
#include <GL/gl.h>
#include <stdio.h>
#include <iostream>
#include <fstream.h>
GLdouble rot_angle;
int vertexSize;
int triangleSize;
float minx, miny, minz;
float maxx, maxy, maxz;
int index0, index1, index2, i;
float vertexTable[10000][3];
int triangleTable[50000][3];

void readfile()
{
// input file stream
ifstream   file;
file.open("I:\\Models\\bunny1972.vt");

int i;
float x,y,z;
int a,b,c;

maxx = maxy = maxz = -10000000;
minx = miny = minz = 100000000;
file >> vertexSize >> triangleSize;
for( i=0; i<vertexSize; i++ )
{
  file >> x >> y >> z ;
  vertexTable[0] = x;
  vertexTable[1] = y;
  vertexTable[2] = z;
  if( x < minx ) minx = x;
  if( y < miny ) miny = y;
  if( z < minz ) minz = z;
  if( x > maxx ) maxx = x;
  if( y > maxy ) maxy = y;
  if( z > maxz ) maxz = z;

}
for( i=0; i<triangleSize; i++)
{
  file >> a >> b >> c;
  triangleTable[0] = a;
  triangleTable[1] = b;
  triangleTable[2] = c;
}
file.close();
}

void render()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotated(rot_angle, 1.0, 0.0, 0.0);
    glRotated(rot_angle, 0.0, 1.0, 0.0);
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_TRIANGLES);
for(i=0; i<triangleSize; i++)
{
  index0=triangleTable[0];
  index1=triangleTable[1];
  index2=triangleTable[2];
  glVertex3f(vertexTable[index0][0]);
  glVertex3f(vertexTable[index1][1]);
  glVertex3f(vertexTable[index2][2]);
}
glEnd();
glPopMatrix();
glFlush();

}
void init()
{
rot_angle = 0.0;
glClearColor(0.0, 0.0, 0.0, 1.0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
}
void idle(void)
{
rot_angle += 0.05;
    if( rot_angle > 360.0 )
        rot_angle -= 360.0;
    glutPostRedisplay();
}

void keyboard (unsigned char key, int x, int y)
{
    switch (key)
    {
        case 27:
        case 'Q':
        case 'q':
            exit(0);
            break;
    }
}
void resize(int w,int h)
{
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//glOrtho(-w/2, w/2, -h/2,h/2, -1.0,1.0);
//glOrtho(-1, 1, -1, 1, -1.0, 1.0);
glOrtho(minx, maxx, miny, maxy, minz, maxz);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(500,500);
glutCreateWindow("3D Tech- GLUT Tutorial");
readfile();
init();
glutReshapeFunc( resize );   
glutKeyboardFunc( keyboard );
glutIdleFunc( idle );

glutDisplayFunc(render);
glutMainLoop();
}

[/cpp]
编译的错误:
Compiling...
reader.cpp
C:\Documents and Settings\Administrator\桌面\新建文件夹\reader.cpp(116) : error C2660: 'glVertex3f' : function does not take 1 parameters
C:\Documents and Settings\Administrator\桌面\新建文件夹\reader.cpp(117) : error C2660: 'glVertex3f' : function does not take 1 parameters
C:\Documents and Settings\Administrator\桌面\新建文件夹\reader.cpp(118) : error C2660: 'glVertex3f' : function does not take 1 parameters
执行 cl.exe 时出错.
reader.exe - 1 error(s), 0 warning(s)

希望有高手尽快帮我解答下~万分感谢啊

[ 本帖最后由 obuil 于 2008-12-24 08:55 AM 编辑 ]

最近VR访客

tan_dunming 评论于2008-12-23 22:12:12
先好好学学英语 或者在金山词霸 或者百度google里翻译一下
“rror C2660: 'glVertex3f' : function does not take 1 parameters”是什么含义

这个函数需要3个参数,你调用的只是一个数组的地址 不错才怪呢

打好基础吧
追求卓越

手机版|VR开发网 统计 津ICP备18009691号
网安备12019202000257

GMT+8, 2021-4-22 11:06 PM

返回顶部