Jump to content
  • Advertisement
Sign in to follow this  
soumya_iiitc

OpenGL Geting MAX TEXTURE SIZE 1024 for a perticular pixel format?

This topic is 3670 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

    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
	};
}



Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Thanks for you help.

How to break down my large texture into smaller ones?

Any pseudo code example will be helpful.

Regards,
Soumyadipta De

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!