Could someone take a look? (Win32)

Started by
2 comments, last by trysil 22 years, 2 months ago
Could someone help me? I cant see what goes wrong. This is the main routine:
      
int WINAPI WinMain(	HINSTANCE	hInstance,
					HINSTANCE	hPrevInstance,
					LPSTR		lpCmdLine,
					int			nCmdShow)
	char* sz;
	teEngine* theEngine;

	if (!teGLWindow::registerWindowClass(hInstance))
	{
		MessageBox(NULL,"Could not register window class",0,0);
		return 0;
	}

	theEngine = new teEngine();
	try{
		theEngine->Init();
	}
	catch (char* sz)
	{
		MessageBox(NULL,sz,0,0);
		return 0;
	}

	theEngine -> MessageLoop();

	theEngine->Shutdown();
	return 0;
}
[ /source]

First I register the window class (declared static)

[source]      
bool teGLWindow::registerWindowClass(HINSTANCE hI)
{
//	HINSTANCE hI			= GetModuleHandle(NULL);				

	WNDCLASS wc;
	wc.style			= CS_HREDRAW | CS_VREDRAW | CS_OWNDC;	
	wc.lpfnWndProc		= WndProcGL;					        
	wc.cbClsExtra		= 0;									
	wc.cbWndExtra		= 0;									
	wc.hInstance		= hI;						
	wc.hIcon			= LoadIcon(NULL, IDI_WINLOGO);			
	wc.hCursor			= LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground	= NULL;
	wc.lpszMenuName		= NULL;
	wc.lpszClassName	= "OpenGL";

	if (!RegisterClass(&wc))
	{
		return false;
	}
	return true;
}
  
as this is done I initialize the engine class which calls the constructor for the GLWindow.
        
teGLWindow::teGLWindow(char* name, int width, int height, int b)
{      
	Screen.fullscreen = false;
	Screen.width = width;
	Screen.height = height;
	Screen.aspect = (float)Screen.width/Screen.height;
	Screen.nearClipping = 0.1f;
	Screen.farClipping = 1000.0f;
	Screen.angle = 45.0f;
	Screen.bits = b;

	RECT windowRect;
	DWORD dwStyle;
	DWORD dwExStyle;


	windowRect.left = (long)0;
	windowRect.right = (long)width;
	windowRect.top = (long)0;
	windowRect.bottom = (long)height;

	if (Screen.fullscreen)
	{
		dwExStyle = WS_EX_APPWINDOW;
		dwStyle = WS_POPUP;
	}
	else
	{
		dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
		dwStyle = WS_OVERLAPPEDWINDOW;
	}

	AdjustWindowRectEx(&windowRect, dwStyle, FALSE, dwExStyle);
	
	if (Screen.fullscreen)
	{
		beginFullScreen(width, height, b);
		hWnd = CreateWindowEx(NULL, "Engine", name, dwStyle | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
						  0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
						  NULL, NULL, (HINSTANCE)GetModuleHandle(NULL), (void*)this);
	}
	else
	{

		hWnd = CreateWindowEx(NULL, "Engine", name, dwStyle | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
						  0, 0, width, height, NULL, NULL, (HINSTANCE)GetModuleHandle(NULL),(void*)this);
	}

	if (hWnd == NULL) 
		throw "Creating OpenGL Window!";
		
	ShowWindow(hWnd, SW_SHOW);
	UpdateWindow(hWnd);

	SetForegroundWindow(hWnd);
	SetCapture(hWnd);
	SetFocus(hWnd);
	ShowCursor(FALSE);
}
  
this throws the "Creating OpenGL Window" error message. Someone "A witty and slightly sarcastic quote from an unkown source" -- The generic SIG /trysil Edited by - trysil on February 7, 2002 1:22:01 PM Edited by - trysil on February 7, 2002 1:27:13 PM
"A witty and slightly sarcastic quote from an unkown source"-- The generic SIG/trysil
Advertisement
you''re registering your window class with:

  wc.lpszClassName	= "OpenGL";  


Then you''re calling CreateWindowEx with:

  hWnd = CreateWindowEx(NULL, "Engine", name,...  


"Engine" above should be "OpenGL".
Thanks, i''ve been sitting infront of the PC toooo looong, time to take a break
"A witty and slightly sarcastic quote from an unkown source"-- The generic SIG/trysil
Sometimes it just takes another pair of eyes to look at something.

This topic is closed to new replies.

Advertisement