Thread: Why WHY WHYYYY?! Please Help...

  1. #1
    Registered User minime6696's Avatar
    Join Date
    Aug 2001
    Posts
    267

    Exclamation Why WHY WHYYYY?! Please Help...

    I've had so many crazy errors with this code its almost unbeleivable... This one sort of pushes it over the edge. Here is the code, "GetLastError()" returns something about not having the correct DLL (?This code has Worked before?)...

    Code:
    	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
    		16,										// 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
    	};
    	
    	GLuint		PixelFormat;			// Holds The Results After Searching For A Match
    
    	if (!(PixelFormat=ChoosePixelFormat(hdc,&pfd)))	// Did Windows Find A Matching Pixel Format?
    	{
    		KillGL(hdc,hRC);								// Reset The Display
    		MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
    		return FALSE;								// Return FALSE
    	}
    
    	if(!SetPixelFormat(hdc,PixelFormat,&pfd))		// Are We Able To Set The Pixel Format?
    	{
    		DWORD i = GetLastError();
    		KillGL(hdc,hRC);								// Reset The Display
    		MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
    		return FALSE;								// Return FALSE
    	}
    
    	if (!(hRC=wglCreateContext(hdc)))				// Are We Able To Get A Rendering Context?
    	{
    		KillGL(hdc,hRC);								// Reset The Display
    		MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
    		return FALSE;								// Return FALSE
    	}
    
    	if(!wglMakeCurrent(hdc,hRC))					// Try To Activate The Rendering Context
    	{
    		KillGL(hdc,hRC);								// Reset The Display
    		MessageBox(NULL,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
    		return FALSE;								// Return FALSE
    	}
    
    	return TRUE;
    Thanks, SPH

  2. #2
    Registered User johnnie2's Avatar
    Join Date
    Aug 2001
    Posts
    186
    We love NeHe base code don't we?

    So the code fails...where? And just to make sure, you're certain you've already fetched the DC by this time?
    "Optimal decisions, once made, do not need to be changed." - Robert Sedgewick, Algorithms in C

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Yup, and...

    >>> (?This code has Worked before?)...

    ... what did you do to make it break?
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #4
    Registered User minime6696's Avatar
    Join Date
    Aug 2001
    Posts
    267

    Arrow heh...

    Well that just the thing... I didnt do anything to break it and its NeHe originated yeah, cuz why re-write the allready written? hdc has of course been fetched. I think its a bit more than a careless error .

    It says something about impropor dlls... any ideas?

    SPH

Popular pages Recent additions subscribe to a feed