Based on VC + + WIN32+CUDA+OPENGL combination and VC + + MFC SDI+CUDA+OPENGL combination of two scenarios of remote sensing image display: The important conclusions obtained!

Source: Internet
Author: User

1, based on VC + + WIN32+CUDA+OPENGL combination of remote sensing image display

In this combination scenario, OpenGL is set to the following two ways when initialized, with the same effect

// setting mode 1glutinitdisplaymode (glut_double |  GLUT_RGBA); // setting Mode 2glutinitdisplaymode (glut_double | GLUT_RGB);

Extracting the pixel data from the remote sensing image data, the R, G, and b three channels can be assigned to the pixel buffer objects (pbo,pixel buffer object) specified in the memory of the pixels of the R, B, three channels. The following is the test code for the production of pixel data, the actual remote sensing image display in the code will be replaced by Cuda kernel function, for extracting real pixel data from the remote sensing image data file.

//Create a red texture pixel datavoidCrsquicklookview::createtexturepixel () {intaswathlengthdownsampled =1024x768*3* +; Ppixeldata =NewUnsignedChar[aswathlengthdownsampled];ZeroMemory (ppixeldata,aswathlengthdownsampled);  for(inti =0; I < +; i++)    {         for(intj =0; J <1024x768; J + +)        {            intoffset=i*1024x768*3+j*3; Ppixeldata[offset]=255;//RedPpixeldata[offset +1] =0; Ppixeldata[offset+2] =0; }    }}

Code at the time of drawing:

0 0, Gl_rgb, Gl_unsigned_byte, NULL);

  The Gl_rgb setting in function glteximage2d () must be strictly consistent with the pixel field in the Createtexturepixel () function, otherwise the displayed image will be rendered in a blocky pattern.

2, based on VC + + MFC SDI+CUDA+OPENGL combination of remote sensing image display

In this combination scenario, the settings for the OpenGL parameter are completed as follows when initializing:

StaticPixelformatdescriptor PFD = {        sizeof(pixelformatdescriptor),1, Pfd_draw_to_window| Pfd_support_opengl | Pfd_doublebuffer,//logoPfd_type_rgba,//Color Mode         -,//number of color bits        0,0,0,0,0,0,        0,0,0,0,0,0,0,         +,//depth of position        0,        0, Pfd_main_plane,0,        0,0,0    };

  It turns out that the field ipixeltype in the struct Pixelformatdescriptor in MFC SDI is set to Pfd_type_rgba, contains an alpha channel, and the pixel field of the specified texture is Gl_rgba or GL_RGB when the texture is subsequently drawn, Can get the same drawing result, regardless of whether it contains an alpha channel or not, regardless of the setting value of the Ipixeltype field in the previous struct, that is, the following two code forms are used to draw the texture, all of which can get the same effect. The only requirement is that the GL_RGB setting in function glteximage2d () must be strictly consistent with the pixel field in the Createtexturepixel () function, otherwise the displayed image will be rendered in a blocky pattern.

// Mode 1 0 0 , Gl_rgba, Gl_unsigned_byte, NULL); // Mode 2 0 0, Gl_rgb, Gl_unsigned_byte, NULL);

Based on VC + + WIN32+CUDA+OPENGL combination and VC + + MFC SDI+CUDA+OPENGL combination of two scenarios of remote sensing image display: The important conclusions obtained!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.