Skip to main content
GameDev.net gamedev.net
🔒 Locked

PIXELFORMATDECRIPTOR

Started by Mr Lane Mar 1, 2004 at 9:48 PM 2 replies 300+ views
Original Post
Mr Lane
Mr Lane
Hi I dont understand thise piece of code in NeHe''s tutorial. Is PIXELFORMATDESCRIPTOR a type? Why do we need to do a sizeof? How can you declare stuff in the middle of a fucntion like this? Sorry but I am just a bit confused about this. Have used DevC++ to write my code and now using VC++ on a computer at uni and it does not compile because of this section of code. I just want to know what is actually happening here.
static PIXELFORMATDESCRIPTOR pfd=				// pfd Tells Windows How We Want Things To Be
	{
		sizeof(PIXELFORMATDESCRIPTOR),				// Size Of This Pixel Format Descriptor
		1,											// Version Number
		PFD_DRAW_TO_WINDOW |						// Format Must Support Window
		PFD_SUPPORT_OPENGL |						// Format Must Support OpenGL
		PFD_DOUBLEBUFFER,							// Must Support Double Buffering
		PFD_TYPE_RGBA,								// Request An RGBA Format
		bits,										// Select Our Color Depth
		0, 0, 0, 0, 0, 0,							// Color Bits Ignored
		0,											// No Alpha Buffer
		0,											// Shift Bit Ignored
		0,											// No Accumulation Buffer
		0, 0, 0, 0,									// Accumulation Bits Ignored
		16,											// 16Bit Z-Buffer (Depth Buffer)  
		0,											// No Stencil Buffer
		0,											// No Auxiliary Buffer
		PFD_MAIN_PLANE,								// Main Drawing Layer
		0,											// Reserved
		0, 0, 0										// Layer Masks Ignored
	};
 
Thanks in advance
variant
variant
It would help to have the error. PIXELFORMATDESCRIPTOR is a structure that defines properties of (I think) the rendering context or device context. Like many of Microsoft''s structures, the first element is the size of the structure. I don''t know how dependent things are on that size being correct, but whatever. The code you displayed is the declaration and initilization of the structure. It''s similar to(maybe the same as):

static PIXELFORMATDESCRIPTOR pfd;
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW |PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;

etc.
It''s just the initialization of the structure.
llvllatrix
llvllatrix
try:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/ntopnglr_73jm.asp

for a detailed description of the PIXELFORMATDESCRIPTOR.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.