Texture not showed when render on memory bitmap

Started by
0 comments, last by zxb 11 years, 1 month ago

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();

Advertisement

I found another solution that dont need render on memory bitmap. Thanks.

This topic is closed to new replies.

Advertisement