顯示具有 99160921_許雅茹 標籤的文章。 顯示所有文章
顯示具有 99160921_許雅茹 標籤的文章。 顯示所有文章

2013年5月3日 星期五

第十一次上課


#include <GL/glut.h>
#include "CMP3_MCI.h"
CMP3_MCI myMP3;

float rot=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(rot, 0,1,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void timer(int t)
{
glutTimerFunc(10, timer, t+1);
rot++;
glutPostRedisplay();
}
int main()
{
myMP3.Load("333.mp3");
myMP3.Play();
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("99160921");
glutDisplayFunc(display);
glutTimerFunc(2000,timer, 0);
glutMainLoop();
return 0;
}


#include<windows.h>
#include<GL/glut.h>
#include "CMP3_MCI.h"
CMP3_MCI myMP3;
float rot=0;

void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(rot,0,1,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void timer(int t)
{
glutTimerFunc(10,timer,t+1);
rot++;
glutPostRedisplay();
}
void oioi(int t)
{
glutTimerFunc(6000,oioi,0);
//PlaySound("o.wav",NULL,SND_ASYNC);

}
void keyboard(unsigned char key,int x,int y)
{
if(key=='1')PlaySound("do.wav",NULL,SND_ASYNC);
if(key=='2')PlaySound("re.wav",NULL,SND_ASYNC);
if(key=='3')PlaySound("mi.wav",NULL,SND_ASYNC);
if(key=='4')PlaySound("fa.wav",NULL,SND_ASYNC);
if(key=='5')PlaySound("sol.wav",NULL,SND_ASYNC);
if(key=='6')PlaySound("la.wav",NULL,SND_ASYNC);
if(key=='7')PlaySound("ti.wav",NULL,SND_ASYNC);
if(key=='8')PlaySound("doHigh.wav",NULL,SND_ASYNC);
}
int main()
{
//myMP3.Load("333.mp3");
//myMP3.Play();
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("0016108");
glutDisplayFunc(display);
glutTimerFunc(2000,timer,0);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;

}



2013年4月26日 星期五

第十次上課


#include "glm.h"

GLMmodel *pmodel=NULL;
void display()
{
     glPushMatrix();
     glmDraw(pmodel,GLM_SMOOTH|GLM_MATERIAL);
     glPopMatrix();
     glutSwapBuffers();
}
int main()
{
     glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
     glutCreateWindow("99160921");
     glutDisplayFunc(display);
     pmodel=glmReadOBJ("data/Al.obj");
     glmUnitize(pmodel);
     glmFacetNormals(pmodel);
     glmVertexNormals(pmodel,90.0); 
     glutMainLoop();
     return 0;
}  



#include <GL/glut.h>
#include "glm.h"
GLMmodel* myrobot;
float rot=0;//!!!!
void init(){

myrobot = glmReadOBJ("dargon posing.obj");
glmUnitize(myrobot);
glmFacetNormals(myrobot);
glmVertexNormals(myrobot, 90.0);

}
void display(void){
    GLfloat light_pos[] = { 3.0, 0.0, -4.0, 0.0 };

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glLightfv(GL_LIGHT0, GL_POSITION, light_pos);
    glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);

glPushMatrix();
glRotatef(180+rot, 0,1,0);//!!!!
glmDraw(myrobot,GLM_SMOOTH );//| GLM_MATERIAL);
glPopMatrix();
glDisable(GL_LIGHTING);

glFlush();
}
void idle()//!!!!
{
rot+=0.5;
glutPostRedisplay();
}
int main(int argc, char** argv){
    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH);

glutCreateWindow("simple");
init();
glutDisplayFunc(display);
glutIdleFunc(idle);//!!!!
glutMainLoop();
}


2013年4月12日 星期五

第八次上課




#include <GL/glu.h>
#include <GL/glut.h>
#include <opencv/highgui.h>
#include <opencv/cv.h>
GLUquadric * quad=NULL;
GLuint id;
float rot=0;
void display()
{
    glEnable(GL_DEPTH_TEST);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glEnable(GL_TEXTURE_2D);
 glBindTexture(GL_TEXTURE_2D,id);
    glPushMatrix();
        glRotated(90,1,0,0);
        glRotated(rot,0,0,1);
        gluQuadricTexture (quad, true);
        gluSphere(quad, 1, 30,30);    
    glPopMatrix();
 glDisable(GL_TEXTURE_2D);
    glutSwapBuffers();
}
void idle()
{
    rot+=0.3;
    glutPostRedisplay();
}
int main()
{
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("99160921");
    glutDisplayFunc(display);
    glutIdleFunc(idle);
//Texture image file by OpenCV
 IplImage * img = cvLoadImage("earth.jpg");
 cvCvtColor(img,img,CV_BGR2RGB);
//Texture image file by OpenGL
 glEnable(GL_TEXTURE_2D);
 glGenTextures(1,&id);
 glBindTexture(GL_TEXTURE_2D,id);
 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_LINEAR);
 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_LINEAR);
 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,img->width,img->height,0,GL_RGB,GL_UNSIGNED_BYTE,img->imageData);
//Texture End
    quad = gluNewQuadric();
    glutMainLoop();
    return 0;
}

2013年2月22日 星期五

第一次上課




 

tium(R) Dual-Core  CPU      E5400  @ 2.70GHz
Operating System: Windows 7 家用進階版 64-bit
Card name: NVIDIA GeForce G210
C : 186G
D : 271G
網路 : cable3M