Sign in to follow this  
zxb

Texture not showed when render on memory bitmap

Recommended Posts

In Windows system, Texture show ok when render on window dc, but Texture not showed when render on memory bitmap?

I need generate a memory bitmap for ::UpdateLayerWindow, with WS_EX_LAYERED syte window.

Thank you!

 

	HDC hDC = ::GetDC(m_hWnd);
#if 0 // Texture show ok.
	if(SetWindowPixelFormat(hDC)==FALSE)
	{
		return 0;
	}
	if(CreateViewGLContext(hDC)==FALSE)
	{
		return 0;
	}

	//::ReleaseDC(m_hWnd, hDC);
#else // Texture not showed.
	m_hDCMem = ::CreateCompatibleDC(hDC);

	CRect rcWnd;
	GetWindowRect(&rcWnd);
	LPBYTE pbits = NULL;
	m_hbmpMem = CreateDIBSection(rcWnd.Width(), rcWnd.Height(), 32, (LPVOID *)&pbits);
	HGDIOBJ hbmpOld = ::SelectObject(m_hDCMem, m_hbmpMem);

	if(SetWindowPixelFormat(m_hDCMem)==FALSE)
	{
		return 0;
	}

	if(CreateViewGLContext(m_hDCMem)==FALSE)
	{
		return 0;
	}

	::ReleaseDC(m_hWnd, hDC);
#endif

...

// some paint code
glBindTexture(GL_TEXTURE_2D, texName);

		glBegin(GL_POLYGON);
			//glColor4f(1.0f,0.0f,0.0f,1.0f);
			glTexCoord2f(0.0, 0.0);
			glVertex3f(-8.0f,-8.0f, 0.0);
			//glColor4f(0.0f,0.0f,1.0f,1.0f);
			glTexCoord2f(1.0, 0.0);
			glVertex3f(8.0f,-8.0f,0.0);
			//glColor4f(0.0f,1.0f,0.0f,1.0f);
			glTexCoord2f(1.0, 1.0);
			glVertex3f(8.0f,8.0f, 0.0);
			//glColor4f(0.0f,0.0f,1.0f,1.0f);
			glTexCoord2f(0.0, 1.0);
			glVertex3f(-8.0f,8.0f,0.0);
		glEnd();

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this