代码如下,挺简单的一个
#include<gl/glut.h>
void myinit()
{
glClearColor(1.0,1.0,1.0,1.0);
glColor3f(1.0,0.0,0.0);
glMatrixMode(GL_MODELVIEW);
}
void display()
{
GLfloat vertices[3][2]={{0,0},{25,50},{50,0}};
int i,j,k;
int rand();
GLfloat p[2]={7.5,5.0};
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POINTS);
for(k=0;k<5000;k++)
{
j=rand()%3;
p[0]=(p[0]+vertices[j][0])/2.0;
p[1]=(p[1]+vertices[j][1])/2.0;
glVertex2fv(p);
}
glEnd();
glFlush();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(0,0);
glutCreateWindow("sdddd");
glutDisplayFunc(display);
myinit();
glutMainLoop();
}编译错误:
正在链接...
1>src.obj : error LNK2028: 无法解析的标记(0A000001) "int __cdecl rand(void)" (?rand@@$$FYAHXZ),该标记在函数 "void __cdecl display(void)" (?display@@$$FYAXXZ) 中被引用
1>src.obj : error LNK2019: 无法解析的外部符号 "int __cdecl rand(void)" (?rand@@$$FYAHXZ),该符号在函数 "void __cdecl display(void)" (?display@@$$FYAXXZ) 中被引用
1>G:\编程\图形学\Debug\图形学.exe : fatal error LNK1120: 2 个无法解析的外部命令
这时为什么?为什么?
解决方案 »
- MFC中分割视图切换成普通视图后不显示,需要移动窗口才显示普通视图
- VC2005下怎么对对话框资源进行工程间的复制
- 关于串口通信
- 托盘程序问题延伸???????
- 请高手指点迷津,很急,谢谢!
- 在线求救,请问如何根据一个盘符,判断该盘符所在的磁盘连接IDE的位置信息??
- CListCtrl如何实现大图标居中对齐?(急急急,高手请进100分)
- activex控件和activex容器编程的问题(给我当前的最高分!)
- 推荐一个考高程的网站?
- 关于用API函数SHGetDesktopFolder得到桌面的目录
- 求助!随机生成一个字符串的问题。
- 请问有没有搞过触摸板开发的?我想做这方面的课程设计,求思路经验,谢谢先~
#include <stdlib.h>
#include "stdlib.h"然后,main 函数要返回一个整型数值。