~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

Viewing changes to src/plugins/scriptedwizard/resources/directx/dx9/main.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <d3d9.h>
 
2
#include <strsafe.h>
 
3
 
 
4
LPDIRECT3D9         g_pD3D = NULL; // Used to create the D3DDevice
 
5
LPDIRECT3DDEVICE9   g_pd3dDevice = NULL; // Our rendering device
 
6
 
 
7
HRESULT InitD3D( HWND hWnd )
 
8
{
 
9
    if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
 
10
        return E_FAIL;
 
11
 
 
12
    D3DPRESENT_PARAMETERS d3dpp;
 
13
    ZeroMemory( &d3dpp, sizeof( d3dpp ) );
 
14
    d3dpp.Windowed = TRUE;
 
15
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
 
16
    d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
 
17
 
 
18
    if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
 
19
                                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
 
20
                                      &d3dpp, &g_pd3dDevice ) ) )
 
21
    {
 
22
        return E_FAIL;
 
23
    }
 
24
 
 
25
    return S_OK;
 
26
}
 
27
 
 
28
VOID Cleanup()
 
29
{
 
30
    if( g_pd3dDevice != NULL )
 
31
        g_pd3dDevice->Release();
 
32
 
 
33
    if( g_pD3D != NULL )
 
34
        g_pD3D->Release();
 
35
}
 
36
 
 
37
VOID Render()
 
38
{
 
39
    if( NULL == g_pd3dDevice )
 
40
        return;
 
41
 
 
42
    // Clear the backbuffer to a blue color
 
43
    g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB( 0, 0, 255 ), 1.0f, 0 );
 
44
 
 
45
    // Begin the scene
 
46
    if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
 
47
    {
 
48
        // Rendering of scene objects can happen here
 
49
 
 
50
        // End the scene
 
51
        g_pd3dDevice->EndScene();
 
52
    }
 
53
 
 
54
    // Present the backbuffer contents to the display
 
55
    g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
 
56
}
 
57
 
 
58
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
 
59
{
 
60
    switch( msg )
 
61
    {
 
62
        case WM_DESTROY:
 
63
            Cleanup();
 
64
            PostQuitMessage( 0 );
 
65
            return 0;
 
66
 
 
67
        case WM_PAINT:
 
68
            Render();
 
69
            ValidateRect( hWnd, NULL );
 
70
            return 0;
 
71
    }
 
72
 
 
73
    return DefWindowProc( hWnd, msg, wParam, lParam );
 
74
}
 
75
 
 
76
INT WINAPI wWinMain( HINSTANCE hInst, HINSTANCE, LPWSTR, INT )
 
77
{
 
78
    // Register the window class
 
79
    WNDCLASSEX wc =
 
80
    {
 
81
        sizeof( WNDCLASSEX ), CS_CLASSDC, MsgProc, 0L, 0L,
 
82
        GetModuleHandle( NULL ), NULL, NULL, NULL, NULL,
 
83
        L"D3D Tutorial", NULL
 
84
    };
 
85
    RegisterClassEx( &wc );
 
86
 
 
87
    // Create the application's window
 
88
    HWND hWnd = CreateWindow( L"D3D Tutorial", L"D3D Tutorial 01: CreateDevice",
 
89
                              WS_OVERLAPPEDWINDOW, 100, 100, 300, 300,
 
90
                              NULL, NULL, wc.hInstance, NULL );
 
91
 
 
92
    // Initialize Direct3D
 
93
    if( SUCCEEDED( InitD3D( hWnd ) ) )
 
94
    {
 
95
        // Show the window
 
96
        ShowWindow( hWnd, SW_SHOWDEFAULT );
 
97
        UpdateWindow( hWnd );
 
98
 
 
99
        // Enter the message loop
 
100
        MSG msg;
 
101
        while( GetMessage( &msg, NULL, 0, 0 ) )
 
102
        {
 
103
            TranslateMessage( &msg );
 
104
            DispatchMessage( &msg );
 
105
        }
 
106
    }
 
107
 
 
108
    UnregisterClass( L"D3D Tutorial", wc.hInstance );
 
109
    return 0;
 
110
}