Jump to content
  • Advertisement
Sign in to follow this  
microwind

OpenGL 3d texture works incorrectly when switch from win32 console to MFC??

This topic is 4549 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I encounter a problem in the volume rendering with 3d-texture mapping and ask for help. In the Win32 console, the rendering result is correct, but when I switched from the Win32 console to MFC Application, the result only display the red component, green and blue component donot work. In the MFC environment, the primary addional step is to set the pixel format, and I change it with many different formats, but the result is still not correct. why? where on earth does the problem exist? How to solve it? //////////////////////////////////////// the following is to set the pixel format: PIXELFORMATDESCRIPTOR pfd; ZeroMemory(&pfd, sizeof(PIXELFORMATDESCRIPTOR)); pfd.nVersion = 1; pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = 32; int pixelIndex = ChoosePixelFormat( hDC, &pfd); if (pixelIndex==0) // Let's choose a default index. { pixelIndex = 1; if (DescribePixelFormat(hDC, pixelIndex,sizeof(PIXELFORMATDESCRIPTOR), &pfd)==0 ) { MessageBox("Choose Pixel Format Failed!"); return FALSE; } } if (SetPixelFormat( hDC, pixelIndex, &pfd)==FALSE) { MessageBox("SetPixelFormat Failed!"); return FALSE; } ////////////////////////// //texture parameters GLubyte m_pTexture[idepth][iheight][iwidth][4]; glGenTextures(1, m_uTextureID); for(int r = 0; r < idepth; ++r) for(int t = 0; t < iheight; ++t) for(int s = 0; s < iwidth; ++s) { m_pTexture[r][t][s][0] = m_pTexture[r][t][s][1] = m_pTexture[r][t][s][2] = m_pTexture[r][t][s][3] = d[s][t][r] * 255; //d is 3d density data, whose value range is [0,1] } glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glBindTexture(GL_TEXTURE_3D, m_uTextureID[0]); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, iwidth,iheight,idepth, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_pTexture); glEnable(GL_TEXTURE_3D);

Share this post


Link to post
Share on other sites
Advertisement
ha, i have solved it.
The reason is that I set red color to draw and didnot reset befor the volume rendering,

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!