I have a problem of ripple error from rendering on OpenGL / MFC with texture . render result is like below :
http://vision.csie.n...nShotRipple.jpg
It seems that the bit for each channel is too small to describe smooth color from 0 to 255 , but I don't know which part of setting goes wrong ?
I render one projective texture on a mesh , the loaded image ( 24 bit ) is smooth from Left , White ( 255 255 255 ) to Right , Black ( 0 0 0 ) .
。The Image loading is : RGB , unsigned byte for each channel . I add 4th channel with filling 255 to each pixel to it after loading .
。The texture loading is linear of filter and RGBA 4 channel , like this
glTexParameteri( GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER , GL_LINEAR ) ; glTexParameteri( GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER , GL_LINEAR ) ; glTexImage2D( GL_TEXTURE_2D , 0 , 4 , GetWidth() , GetHeight() , 0 , GL_RGBA , GL_UNSIGNED_BYTE , CaptureImgBuff_RGBA ) ;
。Projective texture setting is linear of filter and GL_REPLACE for glTexEnvi( ... )
。When draw mesh , I use glVertex4d( x , y , z , 1.0 ) , for each vertex . Of course , disable lighting and blending .
。Read out back frame buffer , use glReadPixels ( 0 , 0, w , h , GL_RGBA , GL_UNSIGNED_BYTE , pdata ) , and store pdata to TGA file .
the result is shown at top link , it seems that there are only 16 steps(4bit??) to describe each channel from 0 to 255 .
So I guess the question is about setting rendering device of Windows application( MFC in here ) ?
。At setting device part , PIXELFORMATDESCRIPTOR of SetPixelFormat( ... ) is
static PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // Size of this structure
1, // Version of this structure
PFD_DRAW_TO_WINDOW |// Draw to Window (not to bitmap)
PFD_SUPPORT_OPENGL | // Support OpenGL calls in window
PFD_DOUBLEBUFFER, // Double buffered mode
PFD_TYPE_RGBA, // RGBA Color mode
24, // Want 24bit color
0,0,0,0,0,0, // Not used to select mode
8, // cAlphaBits : Specifies the number of alpha bitplanes in each RGBA color buffer.
0, // Not used to select mode
0,0,0,0,0, // Not used to select mode
32, // Size of depth buffer
8, // cStencilBits
0,
PFD_MAIN_PLANE, // Draw in main plane
0,
0,0,0 };
nPixelFormat = ChoosePixelFormat(m_hDC_3DModel, &pfd) , nPixelFormat return is 51 with cAlphaBits specified , and 7 when cAlphaBits is not specified .
SetPixelFormat(m_hDC_3DModel, nPixelFormat, &pfd)) ;
However , nPixelFormat will fail in render texture , surprisingly , 24 or 32 will ok in rendering texture ( but still have ripple error ) .
Do you have any idea about the solution?
Thanks in advance,
NDark











