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

MDI rendering problems

Started by Raloth Sep 7, 2003 at 4:34 PM 0 replies 250+ views
Original Post
Raloth
Raloth
Yeah I know...it''s been asked before . I know how to do it but it just won''t work. Here''s the function...
void GraphicsCore::SetRenderWindow(HWND hWnd) {
	hDC = GetDC(hWnd);
	wglMakeCurrent(hDC,hRC);
} 
Here''s where I set up the window...
CREATESTRUCT cs;
	ZeroMemory(&cs, sizeof(CREATESTRUCT));
	
	HWND hChild = CreateWindowEx(WS_EX_MDICHILD,"SolEditChild","",
				   WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW,
				   CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
				   hMDIClient,NULL,hInstance,&cs); 
Passing hChild to my function has no effect. Is there anything obvious I''m missing?
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
Dredge-Master
Dredge-Master

this is the gist of how I do it the way I do it


vector<hDC> dcs; //device context

vector<hRC> rcs; //resource context

vector<hyper> pfs; //matched pixel format

vector<PIXELFORMATDESCRIPTOR> pfds; //pixel format


void AddWindow(HWND hwnd)
{
hyper i=dcs.size();
dcs.resize(i+1);
rcs.resize(i+1);
pfs.resize(i+1);
pfds.resize(i+1);
dcs[i]=GetDC(hwnd);
// your code to create your pixel format for the window etc.

CreatePixelFormat();
// --

SetPixelFormat(dcs[i],pfs[i],&pfds[i]);
rcs[i]=wglCreateContext(dcs[i]);
}

void SetWindow(hyper i)
{
wglMakeCurrent(NULL,NULL);
wglMakeCurrent(dcs[i],rcs[i]);
}


nb: this is off the top of my head. Basically what I use, give or take. Don''t forget about releasing handles etc. if you have too many handles running, the program will stop eventually - then again creating 65000 opengl windows is a bit overkill,

You may want to look into using multiple threads. Since opengl renders to the current context of the current thread, using multiple threads will make it easier as you just have to tell which thread to render what.
You could have your model and control in the parent thread, and each window/control that has an opengl context is a seperate thread. these would just render lets say your textured perspective, and three others for wireframes at different angles etc. for example.
Beer - the love catalystgood ol' homepage

Topic Locked

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

Sign in to reply to this topic.