游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2346|回复: 0

关于一个OPENGL编译的问题

[复制链接]

2

主题

10

帖子

10

积分

新手上路

Rank: 1

积分
10
QQ
发表于 2008-9-9 14:47:00 | 显示全部楼层 |阅读模式
#include <GL/glut.h>
#include <GL/gltools.h>
#include <math.h>

void DrawTorus(GLTMatrix mTransform)
    {
    GLfloat majorRadius = 0.35f;
    GLfloat minorRadius = 0.15f;
    GLint   numMajor = 40;
    GLint   numMinor = 20;
    GLTVector3 objectVertex;        
    GLTVector3 transformedVertex;      
    double majorStep = 2.0f*GLT_PI / numMajor;
    double minorStep = 2.0f*GLT_PI / numMinor;
    int i, j;
   
    for (i=0; i<numMajor; ++i)
        {
        double a0 = i * majorStep;
        double a1 = a0 + majorStep;
        GLfloat x0 = (GLfloat) cos(a0);
        GLfloat y0 = (GLfloat) sin(a0);
        GLfloat x1 = (GLfloat) cos(a1);
        GLfloat y1 = (GLfloat) sin(a1);

        glBegin(GL_TRIANGLE_STRIP);
        for (j=0; j<=numMinor; ++j)
            {
            double b = j * minorStep;
            GLfloat c = (GLfloat) cos(b);
            GLfloat r = minorRadius * c + majorRadius;
            GLfloat z = minorRadius * (GLfloat) sin(b);

            objectVertex[0] = x0*r;
            objectVertex[1] = y0*r;
            objectVertex[2] = z;
            gltTransformPoint(objectVertex, mTransform, transformedVertex);
            glVertex3fv(transformedVertex);

            objectVertex[0] = x1*r;
            objectVertex[1] = y1*r;
            objectVertex[2] = z;
            gltTransformPoint(objectVertex, mTransform, transformedVertex);
            glVertex3fv(transformedVertex);
            }
        glEnd();
        }
    }
        
void RenderScene(void)
    {
    GLTMatrix   transformationMatrix;   // Storeage for rotation matrix
    static GLfloat yRot = 0.0f;         // Rotation angle for animation
    yRot += 0.5f;
        
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        
    gltRotationMatrix(gltDegToRad(yRot), 0.0f, 1.0f, 0.0f, transformationMatrix);
    transformationMatrix[12] = 0.0f;
    transformationMatrix[13] = 0.0f;
    transformationMatrix[14] = -2.5f;
        
    DrawTorus(transformationMatrix);

    glutSwapBuffers();
    }

void SetupRC()
    {
    glClearColor(0.0f, 0.0f, .50f, 1.0f );
    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
    }

void TimerFunction(int value)
    {
    glutPostRedisplay();
    glutTimerFunc(33,TimerFunction, 1);
    }



void ChangeSize(int w, int h)
    {
    GLfloat fAspect;

    if(h == 0)
        h = 1;

    glViewport(0, 0, w, h);
        
    fAspect = (GLfloat)w / (GLfloat)h;

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
       
    gluPerspective(35.0f, fAspect, 1.0f, 50.0f);
        
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    }

void main()
    {
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
    glutInitWindowSize(800,600);
    glutCreateWindow("Manual Transformations Demo");
    glutReshapeFunc(ChangeSize);
    glutDisplayFunc(RenderScene);
    SetupRC();
    glutTimerFunc(33, TimerFunction, 1);

    glutMainLoop();
    }

build该源文件出现如下错误:
Transform.obj : error LNK2001: unresolved external symbol _gltTransformPoint
Transform.obj : error LNK2001: unresolved external symbol _gltRotationMatrix
Debug/Transform.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

其中gltTransformPoint和gltRotationMatrix函数是gltools.h文件中定义的;我自己猜测是lib问题,在这里请教下高手帮忙解决下;
[em1]
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-22 06:16

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表