Hello,
A GUI is just an interface that uses graphics rendering to display the interface. So, in order to create a GUI, you must have some way to render graphics first.
Graphics, of any sort, is pure mathematics and data management. For an example, in a video mode, where video memory is mapped to a
linear address, where each pixel is 1 byte, this will render a rectangle (Taken from an old game of mine):
Code: Select all
void DrawFilledRect (int x, int y, int width, int height, int col) {
byte_t far* p=0;
int i=width;
p = GetDisplay () + y * VID_WIDTH +x;
while (height>=0) {
for (i=width; i>=0; i--)
p[i] = col;
p+=VID_WIDTH;
height--;
}
}
The above code may be found within a graphics driver.
GetDisplay() may be implemented by your video driver. All it does in this case is return the base address of the mapped region of video display.
---
After all of the needed graphics routines are implemented, such as our above routine, you need to have the GUI manage this information somehow.
...Such as, a window?
All a GUI (should) do is manage data. In this case, we might create a basic Window object defining properties of a window. Mabey:
Code: Select all
class Window {
unsigned int std::string m_strName;
RECT m_rcRect;
//...other properties of the window...//
public:
void Render ();
}
void Render () {
// render the window at its new location
// This may be done by a system call, which will
// provoke our graphics driver and calls our
// DrawFilledRect() and associated routines
}
^The above should be implemented by your GUI library code.
Notice that we have yet to touch an input--which is the most important part, and why creating a Kernel Shell first is important.
The kernel shell is just text based--not graphical. This allows you to build on your input manager and C++ library code before the graphics. This will fix our above problem.
Because the GUI and graphics shell rely on alot of different parts of your system, it is highly recommended to develop a text based shell first.
Your GUI relies on the System API. The System API will then invoke the current Graphics Driver. The Graphics Driver will invoke the current Video Driver.
You must do everything in the proper order, even if it is bare minimum code.
I hope this gives you an idea of how everything works on the graphics side of things, and show you what your next steps should be
