Week2
1.開New Project 專案名week02_GLUT_first
codeBlocks中開啟Project的Sources下拉main.cpp
開啟notepad++
寫出程式碼
#include <GL/glut.h>
void display()
{
glutSolidTeapot(0.3);
glutSwapBuffers();
}
int main(int argc, char *argv[])
{ ///上面是特別的main函式,有很多參數
glutInit(&argc, argv);///把GLUT開起來 (GLUT初始化)
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("GLUT Shapes");
glutDisplayFunc(display);
glutMainLoop();
}
貼回Codeblocks
第二個程式碼(會有一個黃色的茶壺)
#include <GL/glut.h>
void display()
{
glColor3f(1,1,0);///黃色
glutSolidTeapot(0.3);3
glutSwapBuffers();
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("GLUT Shapes");
glutDisplayFunc(display);
glutMainLoop();
}
第三個程式(加上一個綠色的茶壺)
include <GL/glut.h>
void display()
{
glColor3f(0,1,0);///綠色
glutSolidTeapot(0.5);
glColor3f(1,1,0);///黃色
glutSolidTeapot(0.3);
glutSwapBuffers();
}
int main(int argc, char *argv[])
{ /
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);/
glutCreateWindow("GLUT Shapes");
glutDisplayFunc(display);
glutMainLoop();
}
#include <GL/glut.h>
void display()
{
///glColor3f(0,1,0);///綠色
///glutSolidTeapot(0.5);///畫出一個實心的茶壺,它的大小是0.5
glBegin(GL_POLYGON);///開始畫出多邊形
glVertex2f( 0, 1);///頂點 Vertex
glVertex2f(-1,-1);///頂點 Vertex
glVertex2f(+1,-1);///頂點 Vertex
glEnd();///結束畫
glColor3f(1,1,0);///黃色
glutSolidTeapot(0.3);///畫出一個實心的茶壺,它的大小是0.3
glutSwapBuffers();///請GLUT把畫面swap送到顯示的地方
}
int main(int argc, char *argv[])
{ ///上面是特別的main函式,有很多參數
glutInit(&argc, argv);///把GLUT開起來
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);///把顯示的模式設定好
glutCreateWindow("GLUT Shapes");///要開視窗
glutDisplayFunc(display);///要顯示的對應函式
glutMainLoop();///最後用main迴圈,壓在最後面
}
沒有留言:
張貼留言