Problem in Design MFC/ OpenGL
Hello,
this text adresses to those of you that are common with MFC and OpenGL.
I've a problem in the design of my program.
I have paintable objects that can be modified by the user. Because they are data I've stored them in CDocument. The user should be allowed to change these objects, and with that to change if they are a source of light, and if they have a user defined bmp file as texture.
No here lies the problem. If the user changes the name of the texture, it is necessary to delete the old texture, and to create the new one, based on the given filename. The problem is that, as far as I know, for this action the Rendering Context must be active. But if the Doc class handle this event (or even if the View class does) the RC isn't active. It is only active in the draw routine.
One thing I've done is to make the RC permanent active, means not making it Inactive in the Draw Routine. But then I've still a problem with function OnNewDocument(). There I want to init some default objects, and some of them should be textured or a source of light. But at this time the RC isn't set yet.
My solution of this problem, is to carry a flag for every of these settings. This flag is set to true if some of these properties shall be changed. Then in the draw routine these flags are checked, and if they are set the needed action is done (Loading the Texture or enabling the LIGHTi). This way my program works, but it is very dirty, and becomes difficult to control, because some things depends on each other. I slowly loose control about all these flags, and I'm still in the hot phase of programming. Imagine what this will mean if I look at the code after half a year pause.
If anyone of you has an Idea about a better design please let me know.
My program is an MDI, but this causes some conflicts I think, because of different rendering contexts and static variables.
If anyone can explain a little bit how static variables and the RC take to effect in a MDI application please let me know.
Thanks for reading until now.
Ben
Edited by - Ben_ on February 22, 2001 2:58:54 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement