關於openGL 三角網格的問題 |
尚未結案
|
3358
一般會員 發表:4 回覆:0 積分:0 註冊:2005-09-21 發送簡訊給我 |
在寫取程式的時候,發現無法讀取STL的檔案,請問有沒有高手可以指證一下我的宣告到底是哪裡出了問題,
應該要怎麼樣宣告才能夠順利讀取
Compiling...
test.cpp
Linking...
test.obj : error LNK2001: unresolved external symbol "struct STriangle * __cdecl LoadStlASCII(char const *,int &)" (?LoadStlASCII@@YAPAUSTriangle@@PBDAAH@Z)
Debug/test.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe. test.exe - 2 error(s), 0 warning(s) 下面是原始程式碼
#include
#include
#include
#include #include "inputStl.h" // Rotation amounts
static GLfloat xRot = 0.0f;
static GLfloat yRot = 0.0f; //triangles
STriangle * triArray = NULL;
int nTriangles = 0; // Called to draw scene
void RenderScene()
{
// Clear the window
glClear(GL_COLOR_BUFFER_BIT); // Save matrix state and do the rotation
glPushMatrix();
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
glRotatef(yRot, 0.0f, 1.0f, 0.0f); for (int i=0; i {
glBegin(GL_TRIANGLES);
glVertex3f(triArray[i].a[0], triArray[i].a[1], triArray[i].a[2]);
glVertex3f(triArray[i].b[0], triArray[i].b[1], triArray[i].b[2]);
glVertex3f(triArray[i].c[0], triArray[i].c[1], triArray[i].c[2]);
glEnd();
}
// Restore transformations
glPopMatrix(); // Flush drawing commands
glutSwapBuffers();
} void SetupRC()
{
// Black background
glClearColor(0.0f, 0.0f, 0.0f, 1.0f ); // Set drawing color to blue
glColor3ub(0, 0, 255);
} void SpecialKeys(int key, int x, int y)
{
if(key == GLUT_KEY_UP)
xRot-= 5.0f; if(key == GLUT_KEY_DOWN)
xRot = 5.0f; if(key == GLUT_KEY_LEFT)
yRot -= 5.0f; if(key == GLUT_KEY_RIGHT)
yRot = 5.0f; if(xRot > 356.0f)
xRot = 0.0f; if(xRot < -1.0f)
xRot = 355.0f; if(yRot > 356.0f)
yRot = 0.0f; if(yRot < -1.0f)
yRot = 355.0f; // Refresh the Window
glutPostRedisplay();
} void ChangeSize(int w, int h)
{
//GLfloat nRange = 1.9f;
GLfloat nRange = 500.0f; // Prevent a divide by zero
if(h == 0)
h = 1; // Set Viewport to window dimensions
glViewport(0, 0, w, h); // Reset projection matrix stack
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); // Establish clipping volume (left, right, bottom, top, near, far)
if (w <= h)
glOrtho (-nRange, nRange, -nRange*h/w, nRange*h/w, -nRange*100, nRange*100);
else
glOrtho (-nRange*w/h, nRange*w/h, -nRange, nRange, -nRange*100, nRange*100); // Reset Model view matrix stack
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
} void main()
{
triArray = LoadStlASCII("Sammy1_ascii.stl", nTriangles);
//triArray = LoadStlBinary("Sammy1_binary.stl", nTriangles); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutCreateWindow("STL Loading Sample");
glutReshapeFunc(ChangeSize);
glutSpecialFunc(SpecialKeys);
glutDisplayFunc(RenderScene);
SetupRC();
glutMainLoop();
}
|
yangkissktop
一般會員 發表:13 回覆:29 積分:8 註冊:2003-10-25 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |