Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

Lesson 1

Lesson1: How to get started.
In this lesson you will learn how to create a window. Everything is pretty well commented so just follow the code. There are very few concepts one should know:
First one is event driven way of interaction for your application. All your application is doing is responding on the events (like drawing, key pressing and so on). Each event has its handler (member function). When you want to do your staff in case of event you override this event. You create one class where you do whatever you want.
Second one is, glut is used by default, so everything is wrapped around glut. The good thing is, you should not care about what is underneath. The concept is to give you ability to put everything you need in your class so you can use it!
The third one, is that you must have one space window class (usually, but not necessary, called CSpcWnd), which will be receiving all events. If you want to process any of them, you override the corresponding event handler (usually, started with OnXXX, like, OnDraw() ). If you need to change the order in which events are processed by child objects you can override event handler directly (in case of drawing example, you could override Draw() method ).
And the last one but not least. To get started easily we will use glut library, to create and transform windows, but you can use anything else, like MFC, or os specific API functions. How it can be done is covered in next tutorials.
See also:
sjgui
// This header includes all resources of the sjgui library
#include <sjgui/sjgui.h>

// This class is used to process all events. But for this lesson, 
// we do not want to process any events, so let's leave it blank.
class CSpcWnd : public sjgui::CWnd
{
}; // end of CSpcWnd class

// This is the way you create window and let it be running.
// Once this is done, all modifications required by sjgui, 
// could be done within space window class CSpcWnd
int main(int argc, char* argv[])
{
    // first thing we should do, is to create 
    // an instance of our space window.
    CSpcWnd SpcWnd;
    // Position the window,
    // Note that we position actuall drawing area, and there is
    // a wondow caption bar on top of it.
    SpcWnd.PosWnd(20,50,320,240);
    // Then we create a window which will be assigned to our
    // space window class.
    // Given parameters are the name of the window
    // (I am using name of the program, which is stored in arv[0])
    // and the class, which will receive all events.
    // Function reruns non zero value in case of the success
    if(sjgui::Create("Just a window!",&SpcWnd))
    {
        // Run it. Now all events are transferred to our class.
        // And when we are done, program will be finished.
        sjgui::GlobalMainLoop();
    }
    else
        // Print error message if something was wrong.
        printf("Could not create opengl window.\n");
    return 0;
} // the end
Forward to Lesson 2.
sjgui logo
Quick Links:

 News
 Description
 Screen Shots
 Projects
 Downloads
 Source Code
 Help/FAQ
 Want to help?
 Credits
 Disclaimer


Documentation:

 Documentation
 Reference
 Lessons


Useful links:

sjcomp logo
sjcomp

opengl logo

nehe logo

SourceForge.net Logo

Last modified:


Started by Alexander Shyrokov. Generated at Wed Apr 28 12:31:05 2004 for the sjgui by doxygen 1.3.1. SourceForge.net Logo