• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
封........
博客园    首页    新随笔    联系   管理    订阅  订阅
Opengl绘制点

这两次一直编写出来的opengl点就是显示不了,总是搞不懂。今天才发现一个很细微的错误。

一下是我一开始写的:

 1 #include <GL/glut.h>
2
3 void Display(void)
4 {
5 glClear(GL_COLOR_BUFFER_BIT);
6 glPointSize(2.0f);
7 glBegin(GL_POINT);//必须是加上s,要不然显示不了
8 glVertex2f(0.0f,0.0f);
9 glVertex2f(0.5f,0.8f);
10 glEnd();
11 glFlush();
12 }
13 int main(int argc,char* argv[])
14 {
15 glutInit(&argc,argv);
16 glutInitDisplayMode(GLUT_RGB);
17 glutInitWindowPosition(200,200);
18 glutInitWindowSize(400,400);
19 glutCreateWindow("Three Window");
20 glutDisplayFunc(&Display);
21 glutMainLoop();
22 return 0;
23 }

在第7行glBegin里面的参数是GL_POINT,就因为没有加一个S,叫我怎么改变点的坐标都无法显示出点来,让我可折腾了。后来再一看别人的代码,才发现这个问题。

View Code
 1 #include <GL/glut.h>
2
3 void Display(void)
4 {
5 glClear(GL_COLOR_BUFFER_BIT);
6 glPointSize(2.0f);
7 glBegin(GL_POINTS);//必须是加上s,要不然显示不了
8 glVertex2f(0.0f,0.0f);
9 glVertex2f(0.5f,0.8f);
10 glEnd();
11 glFlush();
12 }
13 int main(int argc,char* argv[])
14 {
15 glutInit(&argc,argv);
16 glutInitDisplayMode(GLUT_RGB);
17 glutInitWindowPosition(200,200);
18 glutInitWindowSize(400,400);
19 glutCreateWindow("Three Window");
20 glutDisplayFunc(&Display);
21 glutMainLoop();
22 return 0;
23 }

先记下,一点点的小错误。


posted on 2012-03-30 14:02  琴&天  阅读(12542)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3