用于空中立体图像的OpenGL 3d立体观看(左,右图像)

时间:2008-11-27 06:17:39

标签: visual-c++ opengl

我的目的: - 显示整个左右卫星或航拍图像的重叠区域

        - rotate image using roll, pitch yaw angles
        -image format is Tiff image

现在我正在为空中立体声图像(左,右立体声对)进行OpengGL 3d立体观看。我使用以下代码显示了我的左图:

glDrawBuffer (GL_BACK_LEFT);
LeftBuf = new unsigned char [LeftCol * LeftRow *3];

for (int i = 0; i < LeftRow; i++){
    for (int j = 0; j< LeftCol; j++){

        LeftBuf [(i*LeftCol + j)*3] = tiff.LnBuf [i*LeftCol + LeftCol-(j-1)];
        LeftBuf [(i*LeftCol + j)*3+1] = tiff.LnBuf [i*LeftCol + LeftCol-(j-1)];
        LeftBuf [(i*LeftCol + j)*3+2] = tiff.LnBuf [i*LeftCol + LeftCol-(j-1)];

    }
}

glRasterPos2f(-1,-1);
glDrawPixels(LeftCol, LeftRow, GL_RGB, GL_UNSIGNED_BYTE, LeftBuf);

glDrawBuffer (GL_BACK_RIGHT);
RightBuf = new unsigned char [RightCol *RightRow *3];

for (int r = 0; r < RightRow; r++){
    for (int c = 0; c< RightCol; c++){

        RightBuf [(r*RightCol + c)*3] = tiff.RnBuf [r*RightCol + RightCol-(c-1)];
        RightBuf [(r*RightCol + c)*3+1] = tiff.RnBuf [r*RightCol + RightCol-(c-1)];
        RightBuf [(r*RightCol + c)*3+2] = tiff.RnBuf [r*RightCol + RightCol-(c-1)];

    }
}

glRasterPos2f(-1,-0.45);
glDrawPixels(RightCol, RightRow, GL_RGB, GL_UNSIGNED_BYTE, RightBuf);

现在我需要使用Opengl跟随功能3D旋转我的右图像:         glRotatef(rightphoto.omega * 180 / PI,1.0F,0.0F,0.0F);     glRotatef(rightphoto.phi * 180 / PI,0.0F,1.0F,0.0F);     glRotatef(rightphoto.kappa * 180 / PI,0.0F,0.0F,1.0F);但我不能旋转我的形象。

请帮我如何旋转我的形象!!!!! 另外我想用3d旋转显示左右图像的相同部分的左重叠整个图像。我不知道如何计算整个左右图像的重叠区域坐标。抱歉我的英语很差。

1 个答案:

答案 0 :(得分:4)

使用glDrawPixels()读取或写入的像素不会被模型视图矩阵转换,这是glRotatef()更改的内容。它们是像素,是比实际模型更低级的原语。

要解决此问题,请考虑使用以下方法绘制内容:纹理映射的基元,例如quad。