Thanks to visit codestin.com
Credit goes to Github.com

Skip to content
This repository was archived by the owner on Sep 11, 2019. It is now read-only.
G. S. H edited this page Feb 8, 2017 · 16 revisions

libGH

providing lowlevel procedural abstractions for consistent implementation of multiplatform windowed user interfaces.

Introducing the newest libGH, completely reworked laterally and forward implemented int the heaviest hitting development systems using the most up-to-date and hardest hitting tools available.

Why?

For the cred.

So there are two flavours of development available with libGH...

  • C-style, using the lowlevel procedural interfaces.

  • C++ style, using a whole new slew of hierarchical objects architected especially for RAD.

C Style Strats

Getting Started

Getting started with C Style libGH strats assumes you know your way around your own dev system a bit insofar as you know how to create a new project setup.

In your entry point function, main, try the following:

ghWINDOW* pWMain;
ghInit();

pWMain = ghWindowShow( ghWindowInit( ghWindowCreate() ) );

return ghRun();

Obviously this lacks quite a bit of initialisation and error checking, but it should be enough to get a window up on the screen.

Hello World!

Next, it would be nice to have a simple windowed "Hello World!" application, so we will build to that, and then maybe add some error checking.

Let's start from the top. We'll include our header first, and create just a basic skeleton with main.

#include "gh/GH.h"

int main( int argc, char**  argv ) {

    return 0;
}

For this simple app, we'll simply want to create a window and output a simple string of text.

We now use a more expansive form of the window Create/Init process, starting with a variable to hold the window:

ghWINDOW* pwMain;

pwMain = ghWindowCreate();

Creating the window in a separate step allows us to initialise some window settings prior to actually instantiating the window through the platform.

We can set a few simple properties that will give us enough room to work.

We can start by sizing the window. The _SetExtent functions allow us to set the width and height of the window. These values are of course, unsigned.


ghWindowSetExtent( pwMain, 300, 100 );

We can title our window to allow it to stand out from other windows on our desktop with the following:

ghWindowSetTitle( pwMain, "Hello Window" );

Now that the window is set up, we can go ahead and forward our settings to the platform.

ghWindowInit( pwMain );

We now have a window that is created and initialised on our platform, and is ready to show.

So let's go ahead and do just that:

ghWindowShow( pwMain );

So our window will be visible on screen.

To keep our program alive, we will need an event loop which we will take care of shortly.

We'll quickly take care of displaying some familiar text:

ghWindowDrawString( pwMain, "Hello World!", 20, 20 );

And we'll keep our window alive until it's closed with the following:

ghRun();

Now, the text should display, however, you may quickly notice that if the window is redrawn in any way, our output will disappear.

In other words, the graphics we place on the window will not persist.

In order to keep something on our window, we'll want to place this drawing code within an event handler, more specifically, the ON_DRAW handler.

We'll continue this shortly.

C Type Reference

C Function Reference

C++ Style Strats

C++ Scalar Type Reference

C++ Object Type Reference

Clone this wiki locally