2023年2月23日 星期四

Toto week02

 Week02

step01-1

接續上次的GLUT在Codeblock開啟

複製程式碼10行

#include <GL/glut.h>

void display()

{

     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();

}

step01-2

增加一行加入顏色

#include <GL/glut.h>

void display()

{

    glColor3f(0,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();

}

step02-1

製作三角形

#include <GL/glut.h>

void display()

{

    glColor3f(0,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();

}

step02-2
三個頂點不同顏色

#include <GL/glut.h>

void display()

{

    glColor3f(0,1,0);

    glBegin(GL_POLYGON);

        glColor3f(1,0,0);glVertex2f(0,1);

        glColor3f(0,1,0);glVertex2f(-1,-1);

        glColor3f(0,0,1);glVertex2f(+1,-1);

    glEnd();


    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();

}

step03-1
小畫家用吸管吸取顏色,看顏色的數字是多少
在程式上要/255.0



沒有留言:

張貼留言