These tutorials focus mainly on OpenGL, Win32 programming and the ODE physics engine. OpenGL has moved on to great heights and I don't cover the newest features but cover all of the basic concepts you will need with working example programs.

 

Working with the Win32 API is a great way to get to the heart of Windows and is just as relevant today as ever before. Whereas ODE has been marginalized as hardware accelerated physics becomes more common.

 

Games and graphics utilities can be made quickly and easily using game engines like Unity so this and Linux development in general will be the focus of my next tutorials.    

  

 

Listing of resource.h



#define IDI_ICON         100

#define IDC_DLG_TEXT     101

#define IDC_EDITBOX_TEXT 102

Listing of resource.rc



#include <windows.h>

#include "resource.h"



IDI_ICON ICON "icon.ico"



DIALOG_NAME DIALOG 0, 0, 179, 61

STYLE DS_SYSMODAL

| DS_MODALFRAME

| WS_POPUP | WS_VISIBLE

| WS_CAPTION

| WS_SYSMENU

CAPTION "Dialog Box"

LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL

FONT 8, "MS Sans Serif"

      

{

   CONTROL "Enter some text in the edit control to test.",

       -1,

      "STATIC", SS_CENTER

       | WS_CHILD

       | WS_VISIBLE, 8,

      6,

      129, 11

 

   CONTROL "Default", IDC_DLG_TEXT,

      "EDIT", ES_LEFT

       | ES_AUTOHSCROLL

       | WS_CHILD

       | WS_VISIBLE

       | WS_BORDER

       | WS_TABSTOP,

      10,

      20,

      158, 12



   CONTROL "&Ok", IDOK,

      "BUTTON", BS_PUSHBUTTON

       | BS_CENTER

       | WS_CHILD

       | WS_VISIBLE

       | WS_TABSTOP, 37,

      39,

      50, 14

 

   CONTROL "&Cancel", IDCANCEL,

      "BUTTON", BS_PUSHBUTTON

       | BS_CENTER

       | WS_CHILD

       | WS_VISIBLE

       | WS_TABSTOP, 92,

      39,

      50, 14     

}

Listing of main.cpp



// Win32 Tutorial (Initialization Dialog Box)

// Alan Baylis 2004



#include <windows.h>

#include "resource.h"



#define BUFFER_SIZE 256



const char ClassName[] = "MainWindowClass";

char szText[BUFFER_SIZE];

HWND hWndEditBox;



LRESULT CALLBACK WndProc( HWND    hWnd,

                          UINT    Msg,

                          WPARAM  wParam,          

                          LPARAM  lParam )

{

    switch (Msg)

    {

        case WM_CREATE:

        {

            hWndEditBox = CreateWindow(

            "EDIT", 

            "Default Text", 

            WS_VISIBLE | WS_CHILD, 

            10, 

            10, 

            100, 

            50, 

            hWnd, 

            (HMENU)IDC_EDITBOX_TEXT, 

            (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), 

            NULL);



            if (!hWndEditBox)

                MessageBox(NULL, "Edit Box Failed.", "Error", MB_OK | MB_ICONERROR);

        }

        break;



        case WM_CLOSE:

            DestroyWindow(hWnd);

        break;



        case WM_DESTROY:

            PostQuitMessage(0);

        break;



        default:

            return (DefWindowProc(hWnd, Msg, wParam, lParam));

    }



    return 0;

}



BOOL CALLBACK InitProc( HWND   hDlgWnd,

                        UINT   Message, 

                        WPARAM wParam, 

                        LPARAM lParam )

{

    switch(Message)

    {

        case WM_INITDIALOG:

            SendDlgItemMessage(hDlgWnd, IDC_DLG_TEXT, EM_SETLIMITTEXT, (WPARAM)BUFFER_SIZE - 1, (LPARAM)0);

            SetDlgItemText(hDlgWnd, IDC_DLG_TEXT, "Enter Text");

            return TRUE;

        break;



        case WM_COMMAND:

            switch(LOWORD(wParam))

            {

                case IDCANCEL:

                    EndDialog(hDlgWnd, IDCANCEL);

                    return TRUE;

                break;



                case IDOK:

                    GetDlgItemText(hDlgWnd, IDC_DLG_TEXT, szText, BUFFER_SIZE);

                    EndDialog(hDlgWnd, IDOK);

                    return TRUE;

                break;

            }

        break;

    }

    return FALSE;

}



INT WINAPI WinMain( HINSTANCE  hInstance,

                    HINSTANCE  hPrevInstance,

                    LPSTR      lpCmdLine,

                    INT        nCmdShow )

{

    WNDCLASSEX    wc;



    wc.cbSize           = sizeof(WNDCLASSEX);

    wc.style            = 0;

    wc.lpfnWndProc      = (WNDPROC)WndProc;

    wc.cbClsExtra       = 0;

    wc.cbWndExtra       = 0;

    wc.hInstance        = hInstance;

    wc.hIcon            = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON));

    wc.hIconSm          = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON));

    wc.hCursor          = LoadCursor(NULL, IDC_ARROW);

    wc.hbrBackground    = (HBRUSH)(COLOR_WINDOW + 1);

    wc.lpszMenuName     = NULL;

    wc.lpszClassName    = ClassName;



    if (!RegisterClassEx(&wc))

    {

        MessageBox(NULL, "Failed To Register The Window Class.", "Error", MB_OK | MB_ICONERROR);

        return 0;

    }



    HWND    hWnd;



    hWnd = CreateWindowEx(

    WS_EX_CLIENTEDGE,

    ClassName,

    "Initialization Dialog",

    WS_OVERLAPPEDWINDOW,

    CW_USEDEFAULT,

    CW_USEDEFAULT,

    240,

    120,

    NULL,

    NULL,

    hInstance,

    NULL);



    if (!hWnd)

    {

        MessageBox(NULL, "Window Creation Failed.", "Error", MB_OK | MB_ICONERROR);

        return 0;

    }



    ShowWindow(hWnd, SW_HIDE);



    if (DialogBox(hInstance, "DIALOG_NAME", hWnd, (DLGPROC)InitProc) != IDCANCEL)

    {

        SetDlgItemText(hWnd, IDC_EDITBOX_TEXT, szText);

        ShowWindow(hWnd, SW_SHOW);

        UpdateWindow(hWnd);

        SetFocus(hWnd);

        UpdateWindow(hWnd);

    }

    else

        PostQuitMessage(0);



    MSG    Msg;



    while (GetMessage(&Msg, NULL, 0, 0))

    {

        TranslateMessage(&Msg);

        DispatchMessage(&Msg);

    }



    return Msg.wParam;

}