2021年3月3日 星期三

張昆詳week02

  1.打開 codeBlocks,File-New-Project,openGl








2.在moodle下載freeglut,ru,解壓縮後,複製libfreeglut.a檔,將複製檔檔名改成libglut32.a,在codeBlocks,File-New-Project,Glut project 開啟freeglut
3.開啟codeBlocks,File-New-Project,Glut project
    茶壺
                                            
將程式碼改成
#include <GL/glut.h>
static void display(void)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glutSolidTeapot(0.3);
    glutSwapBuffers();
}

int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("我是08161026");
    glutDisplayFunc(display);
    glutMainLoop();
}


4.參數


5.茶壺變色
 增加程式碼 glColor3f(1,0,0);
4.加入三角形
    glBegin(GL_TRIANGLES);
    glColor3f(1.0f,0.0f,0.0f);glVertex2f(0.0f,1.0f);
    glColor3f(0.0f,1.0f,0.0f);glVertex2f(0.87f,-0.5f);
    glColor3f(0.0f,0.0f,1.0f);glVertex2f(-0.87f,-0.5f);
    glEnd();
#include <GL/glut.h>
#include <math.h>
static void display(void)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glBegin(GL_POLYGON);
    glColor3f(1.0f,0.0f,1.0f);
    for(float angle=0;angle<3.14159265358979*2;angle+=0.01){
        glVertex2f(0.5*cos(angle),0.5*sin(angle));
    }
    glEnd();
    glColor3f(0.5,1,0.2);
    glutSolidTeapot(0.3);
    glutSwapBuffers();
}










沒有留言:

張貼留言

距地表面160 Week11

 #include "glm.h" GLMmodel* pmodel = NULL; void drawmodel(void) {     if (!pmodel) { pmodel = glmReadOBJ("data/porsche.obj...