| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 712 人关注过本帖
标题:求助 为什么 VC下OPENGL 控制台编程会出现如下错误!!
取消只看楼主 加入收藏
百惠在心
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2010-11-25
收藏
 问题点数:0 回复次数:3 
求助 为什么 VC下OPENGL 控制台编程会出现如下错误!!
/* Vertex array example by Nutty. (www.)
   Demonstrates the use of vertex arrays for defining geometric primitives.
   Using glut to hide the ugliness of windoze code.

   This source can be distributed freely.
   Nutty.    nutty@
*/
#include "stdlib.h"
#include "windows.h"
#include <GL/glut.h>
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")
#pragma comment(lib, "glaux.lib")

// The Initial size of our window
int window_width = 640;
int window_height = 480;

// Define our vertex structure.
// This holds the position of the vertices. Can also be used for
// anything that requires 3 float elements. i.e. colors.
typedef struct
{
    GLfloat x, y, z;

}Vertex3;

// Our constant. Number of faces per cube.
const GLuint NUMBER_FACES    =    6;
// This is a variable for rotating the cube.
GLfloat angle            =    0.0f;


// Our vertex array! Holds the points for each corner of the cube.
Vertex3 cube_verts[] = {
    {    -2.0f,    2.0f, 2.0f,    },    //Frontface top left.        0
    {     2.0f,    2.0f, 2.0f,    },    //Frontface top right.        1
    {     2.0f, -2.0f, 2.0f,    },    //Frontface bottom right.    2
    {   -2.0f, -2.0f, 2.0f, },  //Frontface bottom left.    3

    {    -2.0f,    2.0f, -2.0f, },    //backface top left.        4
    {     2.0f,    2.0f, -2.0f, },    //backface top right.        5
    {     2.0f, -2.0f, -2.0f, },    //backface bottom right.    6
    {   -2.0f, -2.0f, -2.0f, }    //backface bottom left        7
};

// This is an array of colors. Each color defined by 3 floats. Order will map
// directly to the cornder described in the above array.
Vertex3 vert_colors[] = {
    {    1.0f,    0.0f,   0.0f,    },   
    {    0.0f,    1.0f,   0.0f,    },
    {    0.0f,    0.0f,    1.0f,    },
    {    1.0f,    1.0f,    0.0f,    },

    {    1.0f,    0.0f,    1.0f,    },
    {    0.0f,    1.0f,    1.0f,    },
    {    0.0f,    0.0f,    0.0f,    },
    {    1.0f,    1.0f,    1.0f,    }
};

// These are the indexes into the above arrays to make our cube.
GLuint cube_indexes[NUMBER_FACES * 4] = {
    0, 3, 2, 1,                    //Frontface. In counter clockwise order.
    5, 6, 7, 4,                    //Backface.  In counter clockwise order.
    4, 0, 1, 5,                    //Top face.   
    3, 7, 6, 2,                    //Bottom face.
    4, 0, 3, 7,                    //Left face.
    1, 2, 6, 5,                    //Right face.

};



void Render(void)
{
   
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glTranslatef(0.0f, 0.0f, -5.0f);        //Move the Cube 10 away from us!

    glRotatef(angle, 1.0f, 0.77f, 0.0f);        //Spin the cube in X and Y axis.

   
    //Enable the vertex and color arrays.
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);
   
    //Tell gl, what our arrays look like! 3 floats per vertex, 0 packing, and their addresses.
    glVertexPointer(3, GL_FLOAT, 0, cube_verts);
    glColorPointer(3, GL_FLOAT, 0, vert_colors);

    //Do it! Draw quads. With 6 faces times 4 indexes per face.
    glDrawElements(GL_QUADS, NUMBER_FACES * 4, GL_UNSIGNED_INT, cube_indexes);
        
   
    glutSwapBuffers();
}

void Idle(void)
{   
   

    //Increase angle.
    angle += 0.4f;        

    if(angle >= 360.0f)
    {
        angle -= 360.0f;
    }

    //Re display.
    glutPostRedisplay ();   
}

void Resize(int width, int height)
{
    if(height == 0)
    {
        height = 1;
    }
     
    window_width = width;
    window_height = height;

   
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glViewport(0, 0, window_width, window_height);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    gluPerspective (90, (float)window_width / (float)window_height, 1, 5000);

    glutPostRedisplay();
}

void Keyboard(unsigned char key, int x, int y)
{

    if(key == 27)    //If escape key.
    {
        exit(0);
    }
}

void Mouse(int button, int state, int x, int y)
{
}

void glInit(void)
{
    glEnable(GL_DEPTH_TEST);
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

    glShadeModel(GL_SMOOTH);
}

void main(void)
{
    //Setup the window. RGB double buffered, with a depth buffer.
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutInitWindowSize(window_width, window_height);
    glutCreateWindow("Vertex Array Test - Esc quits");

    //Setup our callbacks.
    glutDisplayFunc(Render);
    glutReshapeFunc(Resize);
    glutIdleFunc(Idle);
    glutKeyboardFunc(Keyboard);
    glutMouseFunc(Mouse);

    glInit();
    glutMainLoop();
}
////////////////////////////////////////////////////////////

Build Log

--------------------Configuration: vertexarrays - Win32 Debug--------------------

Command Lines
Creating temporary file "C:\DOCUME~1\xiaolong\LOCALS~1\Temp\RSP23.tmp" with contents
[
/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"Debug/vertexarrays.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
"D:\新建文件夹 (3)\main.cpp"
]
Creating command line "cl.exe @C:\DOCUME~1\xiaolong\LOCALS~1\Temp\RSP23.tmp"
Creating temporary file "C:\DOCUME~1\xiaolong\LOCALS~1\Temp\RSP24.tmp" with contents
[
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/vertexarrays.pdb" /debug /machine:I386 /out:"Debug/vertexarrays.exe" /pdbtype:sept
".\Debug\main.obj"
]
Creating command line "link.exe @C:\DOCUME~1\xiaolong\LOCALS~1\Temp\RSP24.tmp"
Output Window
Compiling...
main.cpp
Linking...
main.obj : error LNK2001: unresolved external symbol ___glutCreateWindowWithExit@8
Debug/vertexarrays.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.



Results
vertexarrays.exe - 2 error(s), 0 warning(s)


搜索更多相关主题的帖子: 控制台 
2011-03-23 15:59
百惠在心
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2010-11-25
收藏
得分:0 
谢谢
2011-03-31 18:33
百惠在心
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2010-11-25
收藏
得分:0 
可是我安装了glut32.lib 库文件了
2011-03-31 18:34
百惠在心
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2010-11-25
收藏
得分:0 
可是VC++win32 框架下却能编程,还有MFC
2011-04-15 16:14
快速回复:求助 为什么 VC下OPENGL 控制台编程会出现如下错误!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018729 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved