Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Neosmyle

Strange problem - seems very simple

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

Hello, I'm pretty much a novice to OGL. I have done a few things, but never actually completed a "real" program, just some simple demos and stuff. Now I have decided to try and whip something up for the 4E3 contest, so I set to work making a new OO engine, however, the code I'm using to create an OGL window doesn't work! I just get a regular window, but no OGL viewport/rendering area. Meaning, if I set the clear color to black, the background is still gray like the window, because I don't have a rect for OGL. Basically, the "viewport" isn't being created, and I don't know why! Heres the code I'm using:
    

//CDEMOENGINE class constructor


WNDCLASS wndClass; 
	wndClass.style			= CS_OWNDC | CS_VREDRAW | CS_HREDRAW;// | CS_PARENTDC;

	wndClass.lpfnWndProc	= EngineProcedure;
	wndClass.cbClsExtra		= 0;
	wndClass.cbWndExtra		= 0;
	wndClass.hInstance		= hInstance;
	wndClass.hIcon			= LoadIcon(hInstance, IDI_APPLICATION);
	wndClass.hCursor		= LoadCursor(NULL, IDC_ARROW);
	wndClass.hbrBackground	= HBRUSH(COLOR_BTNFACE+1);
	wndClass.lpszMenuName	= NULL;//MAKEINTRESOURCE(IDR_MENU);

	wndClass.lpszClassName	= strClassName;
	RegisterClass(&wndClass);

	if (bFullscreen)
	{
		vSetFullscreenMode();
		hWnd = CreateWindowEx(WS_EX_APPWINDOW,
							strTitle, 
							strTitle, 
							WS_POPUP |
							WS_CLIPSIBLINGS | 
							WS_CLIPCHILDREN,
							0,
							0, 
							nWidth, 
							nHeight, 
							NULL, 
							NULL, 
							hInstance, 
							(void*)this);
	} else
	{
		hWnd = CreateWindowEx(WS_EX_APPWINDOW | 
							WS_EX_WINDOWEDGE, 
							strTitle, 
							strTitle, 
							WS_OVERLAPPEDWINDOW | 
							WS_CLIPSIBLINGS | 
							WS_CLIPCHILDREN,
							CW_USEDEFAULT, 
							CW_USEDEFAULT, 
							nWidth, 
							nHeight, 
							NULL, 
							NULL, 
							hInstance, 
							(void*)this);
	}
	if (hWnd == NULL) throw "hWnd Create";

	ShowWindow(hWnd, SW_SHOW);
	UpdateWindow(hWnd);

//....


//CDEMOENGINE.bCreate (called later in response to WM_CREATE)


hDC = GetDC(hWnd);
	vSetupPixelFormat();

	if (!(hRC = wglCreateContext(hDC))) throw "wglCreateContext failed";
	if (!(wglMakeCurrent(hDC, hRC))) throw "wglMakeCurrent failed";

	ShowWindow(hWnd, SW_SHOW);
	SetForegroundWindow(hWnd);	// Slightly higher priority

	SetFocus(hWnd); 				// Sets keyboard focus to the window

	vResize(nWidth, nHeight);		// Set up our perspective GL screen


	glShadeModel( GL_SMOOTH );					// Enable Smooth Shading

	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);		// Black Background

	glClearDepth( 1.0f ); 						// Depth Buffer Setup

	glEnable( GL_DEPTH_TEST );					// Enables Depth Testing

	glDepthFunc( GL_LEQUAL ); 					// The Type Of Depth Testing To Do

	glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );	// Really Nice Perspective Calculations

    
If you need/want/desire to see more of the surrounding code, I will, but I'd have to add more comments, etc (ew...) "Dammit! What the friggin hell is the problem????" "Wait a second! I never called [insert function here]/used the variable [insert variable here]/remembered to [insert action here]! Hahaha!" ::fixes mistake:: :resses f7:: ::no errors:: :resses ctrl+f5:: "DOH!" [edited by - neosmyle on May 30, 2002 11:32:37 PM]

Share this post


Link to post
Share on other sites
Advertisement
Ok, imagine you make a window, but with no opengl coding at all. Just registerclass and createwindow. Thats what I get.

Share this post


Link to post
Share on other sites
This''ll sound stupid and you''ve probably done it already, but make sure you are calling SwapBuffers(). Seems like I always forget that when I write new window code and I spend an hour trying to figure out why nothing''s being drawn =]

Share this post


Link to post
Share on other sites
No, I''m calling SwapBuffers(), but thanks for the advice anyway!

"Dammit! What the friggin hell is the problem????"
"Wait a second! I never called [insert function here]/used the variable [insert variable here]/remembered to [insert action here]! Hahaha!"
:: fixes mistake ::
:: presses f7 ::
:: no errors ::
:: presses ctrl+f5 ::
"DOH!"

Share this post


Link to post
Share on other sites
Perhaps what you are drawing is getting overdrawn rather than nothing happening. So for lack of anything better to try I would try setting the window class background brush to null and removing the clip children from the window style. Assuming that isn''t it then I would make sure the routine that does the drawing is actually getting called. Either A) you didn''t draw; B) you drew and got overdrawn; or C) you didn''t swap buffers. If nothing else check the OpenGL calls for errors. Perhaps pointless suggestions, but until you get past this problem you have nothing better to do.

Share this post


Link to post
Share on other sites
Hmmm...maybe this will help...When I set the background to NULL, I get nothing at all in the window. The inside section of the window is transparent.

"Dammit! What the friggin hell is the problem????"
"Wait a second! I never called [insert function here]/used the variable [insert variable here]/remembered to [insert action here]! Hahaha!"
:: fixes mistake ::
:: presses f7 ::
:: no errors ::
:: presses ctrl+f5 ::
"DOH!"

Share this post


Link to post
Share on other sites
have you set the PFD up correctly and assigned it to the window when it's created?

[edited by - _the_phantom_ on May 31, 2002 12:41:22 AM]

Share this post


Link to post
Share on other sites

  • 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!