| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1117 人关注过本帖
标题:画个多边形
只看楼主 加入收藏
qq1023569223
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:湖南科技大学
等 级:贵宾
威 望:26
帖 子:2753
专家分:13404
注 册:2010-12-22
结帖率:100%
收藏
 问题点数:0 回复次数:14 
画个多边形
程序代码:
#include <GL/glut.h>

void Draw_Polygon(void)
{
    glColor3f(1.0,0.0,0.0);

    glBegin(GL_POLYGON);
    glVertex2i(0,250);
    glVertex2i(250,0);
    glVertex2i(500,250);
    glVertex2i(250,500);
    glEnd();

    glFlush();
}

void main(int argc,char** argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
    glutInitWindowPosition(100,100);
    glutInitWindowSize(600,600);
    glutCreateWindow("0810050225");

    glClearColor(0.0,0.0,0.0,0.0);
    glClear(GL_COLOR_BUFFER_BIT);
    glMatrixMode(GL_PROJECTION);
    gluOrtho2D(0.0,500.0,0.0,500.0);

    glutDisplayFunc(Draw_Polygon);
    glutMainLoop();
}
图片附件: 游客没有浏览图片的权限,请 登录注册
2011-04-21 08:45
qq1023569223
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:湖南科技大学
等 级:贵宾
威 望:26
帖 子:2753
专家分:13404
注 册:2010-12-22
收藏
得分:0 
对于刚开始学OpenGL的同学来说,上面的程序是一个模板,main函数部分是一个通式!

   唯实惟新 至诚致志
2011-04-21 19:05
songkun123
Rank: 2
等 级:论坛游民
帖 子:19
专家分:15
注 册:2011-4-16
收藏
得分:0 
#include <GL/glut.h>
怎么弄呀?
2011-04-29 17:14
qq1023569223
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:湖南科技大学
等 级:贵宾
威 望:26
帖 子:2753
专家分:13404
注 册:2010-12-22
收藏
得分:0 
下个软件包,然后再装啊!

   唯实惟新 至诚致志
2011-04-29 19:19
qq1023569223
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:湖南科技大学
等 级:贵宾
威 望:26
帖 子:2753
专家分:13404
注 册:2010-12-22
收藏
得分:0 
With thanks to Kamil Saykali of the EdCenter:

This part will show how to install the glut libraries and dll's (to download it go to http://reality. )

1. After you have downloaded the glut.zip file (you should get the latest ver 3.7) unzip it into a folder

2. Inside the folder you should have:

glut.dll

glut32.dll

glut.h

glut.lib

glut32.lib

3. Copy both glut.dll and glut32.dll into your windows directory (windows or winnt, depends on if you are using Windows95/98 or Windows NT)

4. Copy your glut.h to:

<drive>:\<VC++ path>\include\GL\glut.h

*** put the drive where you installed VC++ instead of the <drive> ***

*** put the directory where you installed VC++ instead of the <VC++ path>

5. Copy your glut.lib and glut32.lib to:

<drive>:\<VC++ path>\lib\glut.lib

<drive>:\<VC++ path>\lib\glut32.lib

*** put the drive where you installed VC++ instead of the <drive> ***

*** put the directory where you installed VC++ instead of the <VC++ path>

6. That should be it for installed the glut libraries. The rest of this letter shows you how to setup VC++ so that you can use the glut libraries.

This will show you how to start up an opengl project and setup the setting so that you will be able to compile and run the program. This is assuming that you have already downloaded the appropriate files and installed them in the directories that there documentation tell you to. If you have not done that you need to do it before you can run or write an opengl program.

1. Start VC++ and create a new project.

2. The project has to be a "Win32 Console Application"

3. Type in the name of the project and where it will be on your hard drive.

4. Chose an empty project and click next or finish

5. First thing you need to do when the project opens up is to click on the "Project" menu item from the top.

6. Chose "Settings" (a window will come up)

7. On the left side of the window there are tabs, chose the "Link" tab

8. The string field labeled "Object/library modules" has a few lib files already set in it

9. Go to the end of this string field and enter:

opengl32.lib glut32.lib glu32.lib

10. Chose "OK" and that will include all the opengl libraries that you need

11. Now all you need to do is include <gl\glut.h> and you are ready to go
glutdlls37beta.zip (145.95 KB)

   唯实惟新 至诚致志
2011-04-29 19:20
mybluedesky
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2011-5-14
收藏
得分:0 
,就是这个
2011-05-14 10:25
mybluedesky
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2011-5-14
收藏
得分:0 
画出来了,
2011-05-16 11:43
qq1023569223
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:湖南科技大学
等 级:贵宾
威 望:26
帖 子:2753
专家分:13404
注 册:2010-12-22
收藏
得分:0 
那就好呵!

   唯实惟新 至诚致志
2011-05-16 11:45
墨竹
Rank: 2
等 级:论坛游民
帖 子:29
专家分:39
注 册:2011-5-16
收藏
得分:0 
Linking...
LINK : fatal error LNK1104: cannot open file "glut32.lib"
Error executing link.exe.
怎么回事?
2011-05-17 11:05
墨竹
Rank: 2
等 级:论坛游民
帖 子:29
专家分:39
注 册:2011-5-16
收藏
得分:0 
呃...
没问题了,路径放错了
2011-05-17 11:08
快速回复:画个多边形
数据加载中...
 
   



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

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