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  101

#define BITMAP_ID 102

Listing of resource.rc



#include "resource.h"

    

IDI_ICON ICON "icon.ico"

BITMAP_ID BITMAP "splash_screen.bmp"

Listing of main.cpp



// Win32 Tutorial (Splash Screen)

// Alan Baylis 2004



#include <windows.h>

#include "resource.h"



const char ClassName[] = "MainWindowClass";

const char SplashClassName[] = "SplashWindowClass";



HWND hMainWnd;

HBITMAP hSplashBMP;

HDC hSplashDC;

HDC hMemoryDC;

LONG BitmapWidth, BitmapHeight;



LRESULT CALLBACK WndProc( HWND    hWnd,

                          UINT    Msg,

                          WPARAM  wParam,          

                          LPARAM  lParam )

{

    switch (Msg)

    {

        case WM_CLOSE:

            DestroyWindow(hWnd);

        break;



        case WM_DESTROY:

            PostQuitMessage(0);

        break;



        default:

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

    }



    return 0;

}



LRESULT CALLBACK SplashWndProc( HWND    hWnd,

                                UINT    Msg,

                                WPARAM  wParam,          

                                LPARAM  lParam )

{

    switch (Msg)

    {

        case WM_ERASEBKGND:

            BitBlt((HDC)wParam, 0, 0, BitmapWidth, BitmapHeight, hMemoryDC, 0, 0, SRCCOPY); 

        break;



        case WM_CHAR:

        case WM_KILLFOCUS:

        case WM_LBUTTONDOWN:

        case WM_RBUTTONDOWN:

        case WM_MBUTTONDOWN:

            DeleteObject(hSplashBMP);

            ReleaseDC(hWnd, hSplashDC);

            ReleaseDC(hWnd, hMemoryDC);

            DestroyWindow(hWnd);

            ShowWindow(hMainWnd, SW_SHOW);

            UpdateWindow(hMainWnd);

            SetForegroundWindow(hMainWnd);

        break;



        default:

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

    }



    return 0;

}



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;

    }



    WNDCLASSEX    splashwc;



    splashwc.cbSize           = sizeof(WNDCLASSEX);

    splashwc.style            = 0;

    splashwc.lpfnWndProc      = (WNDPROC)SplashWndProc;

    splashwc.cbClsExtra       = 0;

    splashwc.cbWndExtra       = 0;

    splashwc.hInstance        = hInstance;

    splashwc.hIcon            = NULL;

    splashwc.hIconSm          = NULL;

    splashwc.hCursor          = LoadCursor(NULL, IDC_ARROW);

    splashwc.hbrBackground    = NULL;

    splashwc.lpszMenuName     = NULL;

    splashwc.lpszClassName    = SplashClassName;



    if (!RegisterClassEx(&splashwc))

    {

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

        return 0;

    }



    RECT DesktopRect;

    GetWindowRect(GetDesktopWindow(), &DesktopRect);



    hMainWnd = CreateWindowEx(

    WS_EX_CLIENTEDGE,

    ClassName,

    "Splash Screen",

    WS_OVERLAPPEDWINDOW,

    (DesktopRect.right - 340) / 2,

    (DesktopRect.bottom - 200) / 2,

    340,

    200,

    NULL,

    NULL,

    hInstance,

    NULL);



    if (!hMainWnd)

    {

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

        return 0;

    }



    hSplashBMP = LoadBitmap(hInstance, MAKEINTRESOURCE(BITMAP_ID));



    if (!hSplashBMP)

    {

        MessageBox(NULL, "Failed To Load Bitmap", "Error", MB_OK | MB_ICONERROR);

        return 0;

    }



    BITMAP Bitmap;

    GetObject(hSplashBMP, sizeof(BITMAP), &Bitmap);

    BitmapWidth = Bitmap.bmWidth;

    BitmapHeight = Bitmap.bmHeight;



    HWND hSplashWnd = CreateWindowEx(

    0,

    SplashClassName,

    "Splash Screen",

    WS_POPUP,

    (DesktopRect.right - BitmapWidth) / 2,

    (DesktopRect.bottom - BitmapHeight) / 2,

    Bitmap.bmWidth,

    Bitmap.bmHeight,

    NULL,

    NULL,

    hInstance,

    NULL);



    if (!hSplashWnd)

    {

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

        return 0;

    }



    hSplashDC = GetDC(hSplashWnd);

    hMemoryDC = CreateCompatibleDC(hSplashDC);

    SelectObject(hMemoryDC, (HGDIOBJ)hSplashBMP);



    ShowWindow(hSplashWnd, SW_SHOW);

    UpdateWindow(hSplashWnd);



    MSG    Msg;



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

    {

        TranslateMessage(&Msg);

        DispatchMessage(&Msg);

    }



    return Msg.wParam;

}