Lots of RCs

I’m developing a MDI application for windows (using just the API, no MFC or VCL stuff) in C, it has 4 child windows, each one with its own OpenGL animation.

I needed to draw something like a square with a line passing through it. I have made an OpenGL code that works nicely in a single window application, but when I use this same code in one of my MDI child windows, i can’t see the part of the line that should be drawn within the boundaries of the square polygon.

Since I didn’t see any difference in the OpenGL code of both applications, maybe there’s something I don´t know about using multiple rendering contexts in one single application. After all, I’m just remrebering to do wglMakeCurrent before drawing to each one of the windows, and nothing else.

Any clue on what should I do ?

PS.: Sorry for any english errors, I’m from Brazil !

I am doing the same thing,I guess you’ve got to have collection set(like vector) to store all the HDC and HGLRC for the every HWND of the child window. And in the message loop ,render the opengl on the corresponding HGLRC for the every available HWND.

Well, in fact, every HWND, HRC and HGLRC for each one of my child windows is a global, and in the WM_PAINT message of each of them I always set its RC as current before drawing the scene. Actually, the scene is being drawn (quite oddly, but at least it is on the screen ! =P )

I didn’t understand very well what you’ve said, but maybe you’re telling me to render the scenes of each window in the message loop of the frame (main) window ?

Has anyone thought to clean up the animation. Maybe the problem is with the buffering. You should be able to have one snippet of code run in multiple windows.

Yes,you’ve got my point .But i am afraid that if you make every thing global, the code would look rather messy.

Right now, i have solved this problem thoroughly.I have created a class specifically to manager all the rendering context.
The class is like this:

class RcManager
	vector<GLBase*> container;										
	void start(HWND hwnd);
	void process();
	BOOL resizeGL(HWND ,int ,int);
	void createGLWindow(HWND hwnd);
	void destroy(HWND);
	void addRC(GLBase *rc);		

The container is collection set i mentioned yestaday.
Every created RC ,dc and hwnd are stored in one GLBase object and then i would add this GLBase object into the <container> of the RcManager.

The GLBase class is like this:
class GLBase
HGLRC hrc;
HDC hdc;
BOOL created;
GLRENDER glRender;
void init();


HWND hwnd;
BOOL createGLWindow(HWND);
void process();		
void destroy(HWND);	
void start(HWND);
BOOL resizeGL(HWND hWnd,int width,int height);
BOOL makeCurrent();
void bindFunc(GLRENDER);
BOOL isCreated()
	return created;


If you have any problem,please feel free to ask. Do you need my source code? Just drop me a Email to my address(you can find the address in my profile.)

Good Luck

[This message has been edited by RunningRabbit (edited 07-31-2003).]

[This message has been edited by RunningRabbit (edited 07-31-2003).]

Hello,morning ,

I am called, and the package are delivered BThe code is not heavied commented.But Please notice the Mdi proc , rcManager is created as global and its functions are intervened in the WM_CREATE, WM_SIZE,WM_DESTROY message of Mdi proc. the GLdrawScene function is binded when createGLWindow and called in winmain message loop.

if my mail or the attachment are not delivered.please notify .