I need to display opengl texture on 2 sides of window creating a twin view in MFC. How to do this.
What I have tried:
I tried the below code but only one is appearing
void OverlayDisplayDlg :: DrawTwinView()
{
glClear( GL_COLOR_BUFFER_BIT ); // Clear the color buffer
glMatrixMode( GL_MODELVIEW ); // To operate on Model-View matrix
glLoadIdentity(); // Reset the model-view matrix
glEnable( GL_TEXTURE_2D );
glGenTextures( 5, &m_glTexture[4] );
glBindTexture( GL_TEXTURE_2D, m_glTexture[4] );
glPushMatrix();
m_glTexture[0] = ApplyTexture();
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, m_glTexture[0] );
glBegin( GL_QUADS );
glTexCoord2d(0.0,0.0);
glVertex2f( -1.0f, -1.0f );
glTexCoord2d( 1.0,0.0 );
glVertex2f( 0.0f, -1.0f );
glTexCoord2d( 1.0,1.0 );
glVertex2f( 0.0f, 1.0f );
glTexCoord2d( 0.0,1.0 );
glVertex2f( -1.0f, 1.0f );
glEnd();
glDisable( GL_TEXTURE_2D );
glPopMatrix();
glPushMatrix();
GLuint glTexture;
glTexture = ApplyTexture();
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, glTexture );
glBegin( GL_QUADS );
glTexCoord2d(0.0,0.0);
glVertex2f( 0.2f, -1.0f );
glTexCoord2d( 1.0,0.0 );
glVertex2f( 1.0f, -1.0f );
glTexCoord2d( 1.0,1.0 );
glVertex2f( 1.0f, 1.0f );
glTexCoord2d( 0.0,1.0 );
glVertex2f( 0.2f, 1.0f );
glEnd();
glDisable( GL_TEXTURE_2D );
glPopMatrix();
SwapBuffers( m_hDeviceContextDC );
}
GLuint OverlayDisplayDlg :: ApplyTexture()
{
GLuint glTexture;
ReadData( _T( "D:\\Bin Files\\InputData_1280_690.bin" ), WIDTH, HEIGHT, PIXEL, m_pbyImageData);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glEnable( GL_TEXTURE_2D );
glEnable(GL_COLOR_MATERIAL);
glGenTextures( 1, &glTexture );
glBindTexture( GL_TEXTURE_2D, glTexture );
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); // Select modulate to mix texture with color for shading
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); // When texture area is small, bilinear filter the closest mipmap
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); // When texture area is large, bilinear filter the original
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); // The texture wraps over at the edges (repeat)
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
glColor4f( 1.0f, 1.0f, 1.0f, 1.0f);
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, WIDTH, HEIGHT, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, m_pbyImageData ); // To dislay texture applied image to screen
glDisable( GL_TEXTURE_2D );
glDisable( GL_COLOR_MATERIAL );
return glTexture;
}
Please help me