2019年4月11日 星期四

06161091蔡萓芹,week08

主題:貼圖Texture

glTexCoord2f(tx,ty); //貼圖座標
Texture 貼圖
Coordinate 座標

範例:Texture.exe
實作:OpenCV
            OpenCV+OpenGL貼圖
期中考:10行OpenGL程式

1.把[data] [window62] [glut32.dll] 下載
2.把data window32 解壓縮
3.把data跟glut32.dll丟進window32資料夾
4.開啟Texture
貼圖Texture實作
程式碼:
#include <GL/glut.h>
#include <opencv/highgui.h>
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    glutSolidTeapot(0.3);
    glutSwapBuffers();
}
int main (int argc,char**argv)
{
    IplImage*img=cvLoadImage("4.jpg");
    cvShowImage("opencv Window",img);
    cvWaitKey(0);

    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("Week08");

    glutDisplayFunc(display);
    glutMainLoop();
}

程式執行結果如下:


沒有留言:

張貼留言