[fixed]Bug in class COpenGLDriver

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Jesus.Net
Posts: 31
Joined: Sat Apr 15, 2006 6:14 pm
Contact:

[fixed]Bug in class COpenGLDriver

Post by Jesus.Net »

Hi guys.
I do not know if anyone has seen, if so, I said nothing.
Within "COpenGLDriver.cpp" file in "initDriver" we see the following piece of code:

Code: Select all

	GLuint PixelFormat;

	for (u32 i=0; i<5; ++i)
	{
		if (i == 1)
		{
			if (params.Stencilbuffer)
			{
				os::Printer::log("Cannot create a GL device with stencil buffer, disabling stencil shadows.", ELL_WARNING);
				params.Stencilbuffer = false;
				pfd.cStencilBits = 0;
			}
			else
				continue;
		}
		else
		if (i == 2)
		{
			pfd.cDepthBits = 24;
		}
		if (i == 3)
		{
			if (params.Bits!=16)
				pfd.cDepthBits = 16;
			else
				continue;
		}
		else
		if (i == 4)
		{
			// try single buffer
			if (params.Doublebuffer)
				pfd.dwFlags &= ~PFD_DOUBLEBUFFER;
			else
				continue;
		}
		else
		if (i == 5)
		{
			os::Printer::log("Cannot create a GL device context", "No suitable format for temporary window.", ELL_ERROR);
			ReleaseDC(temporary_wnd, HDc);
			DestroyWindow(temporary_wnd);
			return false;
		}

		// choose pixelformat
		PixelFormat = ChoosePixelFormat(HDc, &pfd);
		if (PixelFormat)
			break;
	}
Notice that the following condition is never fulfilled:

Code: Select all

		if (i == 5)
		{
			os::Printer::log("Cannot create a GL device context", "No suitable format for temporary window.", ELL_ERROR);
			ReleaseDC(temporary_wnd, HDc);
			DestroyWindow(temporary_wnd);
			return false;
		}
Not fulfill this condition by the last cycle of the loop is 4 (the loop condition is i <5).

Hope this helps . :wink:
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yeah, you're right. Might also introduce some more problems with incorrectly set up windows. I'll add some better code in Irrlicht 1.8. For the 1.7 branch I simply changed the check to 6.
Post Reply