2016年3月8日 星期二

Week3_CLASSWORK

WEEK 3_01370984 黃昱鳴

Class work 01

User can change each values to adjust color and shape.

POINT:



LINE:



LINE_LOOP:



LINE_STRIP:



TRIANGLES:



TRIANGLE_FAN:



TRIANGLE_STRIP:



QUADS:



QUAD_STRIP:



POLYGON:



class work 02



source code:

#include<GL/glut.h>

void disply()
{
    glBegin(GL_POLYGON);
          glColor3f(0.8, 0.2, 0.6);
          glVertex3f(0.0, 0.0, 0.0);
          glVertex3f(1.0, 0.0, 0.0);
          glVertex3f(1.0, 1.0, 0.0);
    glEnd();

    glutSwapBuffers();
}

int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("01370984_WEEK3");
    glutDisplayFunc(disply);

    glutMainLoop();
}


class work 03


source code:

#include<GL/glut.h>

void disply()
{
    glClearColor(191/255.0, 239/255.0, 255/255.0, 1);
    glClear(GL_COLOR_BUFFER_BIT);

    glBegin(GL_POLYGON);
          glColor3ub(255, 130, 171);
          glVertex3f(1.0, 0.0, 0.0);
          glVertex3f(0.0, 1.0, 0.0);
          glVertex3f(0.0, 0.0, 1.0);
          glVertex3f(1.0, 1.0, 1.0);
    
    glEnd();

    glutSwapBuffers();
}

int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("01370984_WEEK3");
    glutDisplayFunc(disply);

    glutMainLoop();
}

For this picture, you can search color's RGB values by using mspaint. 



Also can check coordinate using mspaint.



class work 04



source code:

#include <GL/glut.h>
#include <stdio.h>
void mouse(int button, int state, int x, int y)
{
    if(state==GLUT_DOWN)
        printf("        glvertex3f(%d-150)/150.0, -(%d-150/150.0, 0.0);\n", x,y);
}
void display()
{
        glClearColor(191/255.0, 239/255.0, 255/255.0, 1);
        glClear(GL_COLOR_BUFFER_BIT);

        glBegin(GL_POLYGON);
        glColor3ub(255, 130, 171);
        glVertex3f(1.0, 0.0, 0.0);
        glVertex3f(0.0, 1.0, 0.0);
        glVertex3f(0.0, 0.0, 1.0);
        glVertex3f(1.0, 1.0, 1.0);

    glEnd();

    glutSwapBuffers();
}

int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("01370984_WEEK3");
    glutDisplayFunc(display);
    glutMouseFunc(mouse);
    glutMainLoop();
}



沒有留言:

張貼留言