Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


zxb

Member Since 26 Feb 2013
Offline Last Active Mar 08 2013 12:01 AM

Topics I've Started

Texture not showed when render on memory bitmap

26 February 2013 - 02:34 AM

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

 


PARTNERS