Geting MAX TEXTURE SIZE 1024 for a perticular pixel format?

Started by
5 comments, last by V-man 15 years, 10 months ago
    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.
<red>How can i get 4096 max texture size for offscreen window also?<red> Getting 1024 max texture size ------------------------------ PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL | PFD_STEREO_DONTCARE, PFD_TYPE_RGBA, Getting 1024 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
	};
}



Advertisement
If you use PFD_DRAW_TO_BITMAP, then you get the standard Microsoft software renderer so they will likely support a different dimension compared to the GPU.
I recommend that you render to FBO instead.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
You are absolutely right and thanks for your advise. But i have no idea about FBO and it may take some time to learn.

It will be really help full if i just run my logic for now. So can you please tell me why i am getting max texture size as 1024.What is the solution to it?

Also can use two opengl windows to draw simultaneously?
I have to display the second window on the second monitor?
Quote:So can you please tell me why i am getting max texture size as 1024.What is the solution to it?


Because MS has programmed their software renderer that way. They set the limit to 1024.
One other solution is to break down your large texture into smaller ones.

Quote:Also can use two opengl windows to draw simultaneously?
I have to display the second window on the second monitor?


Yes, 2 opengl windows is possible.
Secondary monitor : I'm not an expert on this. 1 card with 2 monitors should not be a problem which is what I have.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Thanks for you help.

How to break down my large texture into smaller ones?

Any pseudo code example will be helpful.

Regards,
Soumyadipta De
Why i can't use sub texturing?

1. In current context my max texture size is 1024
2. I can't load larger texture into memory.
3. Then there is no use of texture atlas method.

Options:
---------

1. when i am loading images from disk to memory i have to create 4 buffers for 4 block of the images.
2. I am making my images power two for texturing.
3. Then i have to use this parts for texturing.

Please suggest me if i have miss understood something.

Regards,
Soumyadipta De
I am not sure what you are asking.
Are you saying your image is 2048 x 2048 and you need to break it into 4 textures but you don't know how to write the code?
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement