Click here to Skip to main content
15,905,679 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionSearch Date in Access Database. Pin
Le@rner6-Jun-08 22:20
Le@rner6-Jun-08 22:20 
AnswerRe: Search Date in Access Database. Pin
sudhir_Kumar6-Jun-08 23:03
sudhir_Kumar6-Jun-08 23:03 
GeneralRe: Search Date in Access Database. Pin
Le@rner6-Jun-08 23:22
Le@rner6-Jun-08 23:22 
QuestionVC++ 2005 no exe Pin
rp_suman6-Jun-08 22:01
rp_suman6-Jun-08 22:01 
AnswerRe: VC++ 2005 no exe Pin
ShilpiP6-Jun-08 22:28
ShilpiP6-Jun-08 22:28 
GeneralRe: VC++ 2005 no exe Pin
rp_suman6-Jun-08 22:37
rp_suman6-Jun-08 22:37 
GeneralRe: VC++ 2005 no exe Pin
sudhir_Kumar6-Jun-08 23:01
sudhir_Kumar6-Jun-08 23:01 
QuestionGeting MAX TEXTURE SIZE 1024 for a perticular pixel format? Pin
Soumyadipta6-Jun-08 21:00
Soumyadipta6-Jun-08 21:00 
Different max texture size for PFD_DRAW_TO_BITMAP & PFD_DRAW_TO_WINDOW.

Is there is any solution to get same max texture size?

1. I am using CreateDIBSection() for off screen rendering.
2. Which is working fine in my code as listed below.
3. But i am getting problem with textures as i am getting max texture size is 1024
4. I am getting desired 4096 texture size when i render to application window.
5. Pixel format of main application window and offscreen window is different.
6. The difference of pixel format and returned max texture size is mentioned below.


How can i get 4096 max texture size for off screen window also?

Getting 1024 max texture size
PFD_DRAW_TO_BITMAP |
PFD_SUPPORT_OPENGL |
PFD_STEREO_DONTCARE,
PFD_TYPE_RGBA,

Getting 4096 max texture size
PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL |
PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,

What pixel format should i use to get 4096 max texture size.






bool Create(unsigned int width, unsigned int height)
{	

	// Create a p-buffer for off-screen rendering

	m_uiWidth = width;
	m_uiHeight = height;

	m_hWnd = g_pMainApplicationWindow->GetHWND();		

	m_hMainApplicationWindowDC = g_pMainApplicationWindow->GetHDC();
	m_hMainApplicationWindowRC = g_pMainApplicationWindow->GetHGLRC();			
	
	memset(&m_bmi, 0, sizeof(BITMAPINFO));
	m_bmi.bmiHeader.biSize			= sizeof(BITMAPINFOHEADER);
	m_bmi.bmiHeader.biWidth			= m_uiWidth;
	m_bmi.bmiHeader.biHeight		= m_uiHeight;
	m_bmi.bmiHeader.biPlanes		= 1;
	m_bmi.bmiHeader.biBitCount		= 32;
	m_bmi.bmiHeader.biCompression	= BI_RGB;
	m_bmi.bmiHeader.biSizeImage		= m_uiWidth * m_uiHeight * 4;

	// Create DIB
	HDC	hDC = ::GetDC(m_hWnd);
	m_hDib = ::CreateDIBSection(hDC, &m_bmi, DIB_RGB_COLORS, (void**)&m_pTextureData, NULL, (DWORD)0);
	ReleaseDC(m_hWnd, hDC);
	
	m_hMemDC = ::CreateCompatibleDC(NULL);
	if(!m_hMemDC)
	{
		DeleteObject(m_hDib);
		m_hDib = NULL;
		return (false);
	}

	m_hOldDib = SelectObject(m_hMemDC, m_hDib);

	// Setup memory DC's pixel format.
	if (!SetDCPixelFormat(m_hMemDC, PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL | PFD_STEREO_DONTCARE))
	{
		SelectObject(m_hMemDC, m_hOldDib);
		DeleteObject(m_hDib);
		m_hDib = NULL;
		DeleteDC(m_hMemDC);
		m_hMemDC = NULL;
		return (false);
	}
	
	m_hRC = ::wglCreateContext(m_hMemDC);
	if (!m_hRC)
	{
		SelectObject(m_hMemDC, m_hOldDib);
		DeleteObject(m_hDib);
		m_hDib = NULL;
		DeleteDC(m_hMemDC);
		m_hMemDC = NULL;
		return (false);
	}		
}

bool SetDCPixelFormat(HDC hDC, DWORD dwFlags)
{
	HDC NewHdc = hDC;	

	static PIXELFORMATDESCRIPTOR pixelDesc =
	{
		sizeof(PIXELFORMATDESCRIPTOR),
		1,
		PFD_DRAW_TO_BITMAP |
		PFD_SUPPORT_OPENGL |
		PFD_STEREO_DONTCARE,		
		PFD_TYPE_RGBA,
		32,
		0, 0, 0, 0, 0, 0,
		0,
		0,
		0,
		0, 0, 0, 0,
		16,  
		1, // Use stencil buffer
		0,
		PFD_MAIN_PLANE,
		0,
		0, 0, 0
	};	
		
	GLuint PixelFormat;
	
	int nPixelIndex = ::ChoosePixelFormat(NewHdc, &pixelDesc);
	if (nPixelIndex == 0) // Choose default
	{		
		nPixelIndex = 1;
		if (::DescribePixelFormat(hDC, nPixelIndex, 
			sizeof(PIXELFORMATDESCRIPTOR), &pixelDesc) == 0)
			return false;
	}

	if (!::SetPixelFormat(hDC, nPixelIndex, &pixelDesc))
		return false;

	return true;
}

bool DIBBuffer::StartRendering(void)
{	
	wglMakeCurrent(m_hMemDC, m_hRC);
	BitBlt();

	GLint  texSize;
	glGetIntegerv( GL_MAX_TEXTURE_SIZE, &texSize );

	//i am getting max texture size 1024
	//but when i use the below format i am getting 4096 max texture size

	static PIXELFORMATDESCRIPTOR pfd =
	{
		sizeof(PIXELFORMATDESCRIPTOR),
		1,
		PFD_DRAW_TO_WINDOW |
		PFD_SUPPORT_OPENGL |
		PFD_DOUBLEBUFFER,
		PFD_TYPE_RGBA,
		MAIN_APPLICATION_WINDOW_BITS_PER_PIXEL,
		0, 0, 0, 0, 0, 0,
		0,
		0,
		0,
		0, 0, 0, 0,
		16,  
		1, // Use stencil buffer
		0,
		PFD_MAIN_PLANE,
		0,
		0, 0, 0
	};
}

Questionuse of Validation for controls? Pin
Le@rner6-Jun-08 20:36
Le@rner6-Jun-08 20:36 
AnswerRe: use of Validation for controls? Pin
rp_suman6-Jun-08 20:59
rp_suman6-Jun-08 20:59 
QuestionThe application has failed to start because its side-by-side configuration is incorrect [Solved] Pin
ShilpiP6-Jun-08 19:42
ShilpiP6-Jun-08 19:42 
AnswerRe: The application has failed to start because its side-by-side configuration is incorrect Pin
rp_suman6-Jun-08 20:07
rp_suman6-Jun-08 20:07 
GeneralRe: The application has failed to start because its side-by-side configuration is incorrect Pin
ShilpiP6-Jun-08 21:09
ShilpiP6-Jun-08 21:09 
GeneralRe: The application has failed to start because its side-by-side configuration is incorrect Pin
rp_suman6-Jun-08 21:47
rp_suman6-Jun-08 21:47 
QuestionList of Nationality in VC++ Pin
rp_suman6-Jun-08 19:03
rp_suman6-Jun-08 19:03 
AnswerRe: List of Nationality in VC++ Pin
ShilpiP6-Jun-08 19:23
ShilpiP6-Jun-08 19:23 
AnswerRe: List of Nationality in VC++ Pin
sudhir_Kumar6-Jun-08 21:29
sudhir_Kumar6-Jun-08 21:29 
QuestionTabstop with Enter Key? Pin
Le@rner6-Jun-08 18:29
Le@rner6-Jun-08 18:29 
AnswerRe: Tabstop with Enter Key? Pin
Jijo.Raj6-Jun-08 22:25
Jijo.Raj6-Jun-08 22:25 
GeneralRe: Tabstop with Enter Key? Pin
Le@rner6-Jun-08 23:09
Le@rner6-Jun-08 23:09 
GeneralRe: Tabstop with Enter Key? Pin
Jijo.Raj7-Jun-08 1:25
Jijo.Raj7-Jun-08 1:25 
GeneralRe: Tabstop with Enter Key? Pin
Le@rner7-Jun-08 1:52
Le@rner7-Jun-08 1:52 
QuestionDate in VC++ Pin
rp_suman6-Jun-08 18:25
rp_suman6-Jun-08 18:25 
AnswerRe: Date in VC++ Pin
Le@rner6-Jun-08 18:40
Le@rner6-Jun-08 18:40 
GeneralRe: Date in VC++ Pin
rp_suman6-Jun-08 18:58
rp_suman6-Jun-08 18:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.