Page 1 of 1
[Ques] How to design GFX usiing OOPS?
Posted: Thu Jan 18, 2007 1:41 am
by codemastersnake
Well I am designing my OS using C++ with OOPS features.
I have crerated a class for handling the graphics of my OS including textmode, VGA and VESA.
According to my thaughts:
* I have created a base class 'ABC' (won't disclose the name
).
* Created three derived classes VGA, Console, VESA.
* Each is derived in public mode from 'ABC'.
Now my question is that how should I implement the desired functions in the classes. I am not talking about the code. I am talking about the implementation of function in a modularized way. i.e.
* Which class should have the function for mode changing.
* Which class should contain the information about the current state.
* Whether I should not include text mode driver in this implementation and use it solely for graphics mode.
Suggestions are welcome.
Re: [Ques] How to design GFX usiing OOPS?
Posted: Thu Jan 18, 2007 2:39 am
by Solar
Snake wrote:
* Created three derived classes VGA, Console, VESA.
* Each is derived in public mode from 'ABC'.
[...]
* Which class should have the function for mode changing.
I'm not sure that model is a good one. OOD (OO design) is a bit more involved than having a base class and inheriting from it. I suggest you model the
whole concept, down to GUI and 3D API. You don't have to
implement them, but having an idea of what they will do (and require) will help you getting your design questions right.
Posted: Thu Jan 18, 2007 3:25 am
by codemastersnake
Thnks for the suggestions but I have done that on a paper. I just want to know from you people how would you design graphics syatem for your OS if you have to use C++.
I have plotted mine and want to know what r your ideas. also if you can suggest me on my idea....
By the way I'll be creating an object for every deriver class that can access static members of base class. whenever a app wants something from GFX system it will call appropriate function from the desired object. Base class will be the ultimate resource center for all derived driver classes
Posted: Thu Jan 18, 2007 4:05 am
by Solar
I didn't do what I just suggested to you (plotting the whole design first), so I can only give you a "gut opinion". But I would probably set it up like this:
- A "graphics interface" object that takes commands from the graphics API, and forwards those to a "driver" object. That "driver" object must be passed to the "graphics interface" during creation, obviously.
- A "driver" base class that declares all the members used by the "graphics interface".
- A set of classes derived from "driver" that provide support for VESA, VGA, nVidia cards, ATI cards, ...
Your design, as far as I understood it, mixes graphics functionality and driver functionality into the same class (ABC), which feels odd to me.
That being said, there is no "right" way to design something. If it's flexible, extensible, and not least of all simple and elegant, it's probably "right".
Posted: Thu Jan 18, 2007 7:16 am
by codemastersnake
Ok let me give you a biref intro of my OS Design, Tell me if it's good...
+--------------+ +--------------+ +--------------+
| VGA | | VESA | | Console |
+--------------+ +--------------+ +--------------+
\ | /
\ | /
\ | /
+--------------+
| ABC |
+--------------+
|
+----------------------------------------------------------+
| Hardware |
+----------------------------------------------------------+
* VGA, VESA, Console are global objects that I have created.
* ABC is only a class from which above are derived. ABC do not have any object
Purpose of global objects is to let any body use there functions acc to the need. Now the problem that I am facing is that how to manage the 'things' so that every object (VGA, VESA .. ) can have information so that they do not mess.
Hope I am clear...
Posted: Thu Jan 18, 2007 7:18 am
by codemastersnake
Sorry every thing above messed up... seems like phpbb has ommited the spaces..
Posted: Thu Jan 18, 2007 8:12 am
by Brynet-Inc
Use the [code] [/code] tags..
Posted: Thu Jan 18, 2007 8:17 am
by codemastersnake
OK