2022年4月18日 星期一

week09

1-1.    Using glTexCoord2f

    glTexCoord2f(x,y); x,y 貼圖的座標位置

1-2.    Install openCV

    Add to C directory

2-1. Trying OpenCV

The picture and the program must be placed in the same directory

#include <opencv/highgui.h>
main(){
    IplImage*img=cvLoadImage("01.png");//
    cvShowImage("week09",img);//show
    cvWaitKey(0);

}







2-2 glut texture

#include <GL/glut.h>
#include <opencv/highgui.h>
void myTexture(){
    IplImage*img = cvLoadImage("map.jpg");
    cvShowImage("img",img);
    cvWaitKey(0);
}
void display(){
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glColor3f(1,0,0);
        glutSolidTeapot(0.3);
    glutSwapBuffers();
}
int main(int argc, char *argv[]){
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("week09");
    glutDisplayFunc(display);
    myTexture();
    glutMainLoop();
    return 0;
}




沒有留言:

張貼留言