2021年3月24日 星期三

嵐的QQ_WEEK05

 1.transformation

程式講解


glTranslatef();搬到右邊的
    glRotatef();旋轉的
        glScalef();變胖的
        glBegin();藍色的車子

glTranslatef();
    glRotatef();
調換
2.旋轉程式碼
5.旋轉
程式碼:
#include <GL/glut.h>
int N=0,vx[3000],vy[3000];
float angle=0;
void display()
{

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glPushMatrix();
        glRotatef(angle,0,0,1);
        glBegin(GL_LINE_LOOP);
        for(int i=0;i<N;i++){
            glVertex2f((vx[i]-150)/150.0,-(vy[i]-150)/150.0);
        }
        glEnd();
    glPopMatrix();
    glutSwapBuffers();
}
void keyboard(unsigned char key,int x,int y)
{
    angle++;
    display();
}
void motion(int x, int y)
{
    vx[N]=x;vy[N]=y;
    N++;
    display();
}


int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("08160864");

    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutMotionFunc(motion);
    glutMainLoop();


}

3.120.125.80.50/GL/
opengl教學資源




    

沒有留言:

張貼留言

距地表面160 Week11

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