Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Error creating dummy window for OpenGL 3.x Content

This topic is 2122 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

Hi all,


Trying to get my code to use an OpenGL 3.x Core Context. 


Previously my code has been working fine on Windows using just a 1.2 Context, but now that I've prototyped out the design I need to get a more recent context to do some of the more exciting things.


The issue I'm having is that my CreateWindow() call is return a null HWND, and GetLastError() is returning 0 - which is less than helpful!


Bit of background info. This code is called in a child thread of the main application thread (I've tried calling it in the main thread, with the same results) and there is already a Window that has been successfully created (but not created a GL Context yet).


Any thoughts what I might be doing wrong?

WNDCLASS wndClass;
HINSTANCE hInstance = 0;

ZeroMemory(&wndClass, sizeof(WNDCLASS));

wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;			
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndClass.hInstance = hInstance;
wndClass.lpfnWndProc = WndProc;
wndClass.lpszClassName = TEXT("Dummy Window");
wndClass.lpszMenuName = 0;
wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;

DWORD err = GetLastError();
err = GetLastError();

err = GetLastError();
if (hWnd == NULL)
	return false;

return true;

Share this post

Link to post
Share on other sites

Right, fixed this - I was being stupid.


In the WndProc method I was passing to Register class I was just returning 0 (as the method wouldn't be used). Changing that to 


static LRESULT CALLBACK WndProc(HWND hwnd, cxuint message, WPARAM wparam, LPARAM lparam)
return DefWindowProc(hwnd, message, wparam, lparam);
Worked perfectly...

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!