Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


Texture not showed when render on memory bitmap


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 zxb   Members   -  Reputation: 104

Like
0Likes
Like

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

 



Sponsor:

#2 zxb   Members   -  Reputation: 104

Like
0Likes
Like

Posted 27 February 2013 - 03:52 AM

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






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS