Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


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