aboutsummaryrefslogtreecommitdiffstats
path: root/src/native/jawtrenderer/windows/d3d_device.h
blob: 61a191cf32689fde255b5876432effe52d49ca63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
 * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

/**
 * \file d3d_device.h
 * \brief Direct3D device.
 * \author Sebastien Vincent
 * \date 2010
 */

#ifndef D3D_DEVICE_H
#define D3D_DEVICE_H

#include <cstdlib>

#include <d3d9.h>
#include <d3dx9.h>

#include "d3d_surface.h"

/**
 * \class D3DDevice
 * \brief Direct3D device.
 *
 * It is used to render contents on screen.
 */
class D3DDevice
{
    public:
        /**
         * \brief Constructor.
         * \param hwnd Handle of the Window
         * \param d3d raw Direct3D context
         * \param width width of the future device
         * \param height height of the future device
         * \param fullscreen create device for fullscreen mode
         */
        D3DDevice(HWND hwnd, LPDIRECT3D9 d3d, size_t width, size_t height, bool fullscreen);

        /**
         * \brief Destructor.
         */
        ~D3DDevice();

        /**
         * \brief Get raw Direct3D device pointer.
         * \return Direct3D device pointer
         */
        LPDIRECT3DDEVICE9 getDevice() const;

        /**
         * \brief Validate the device.
         * \return true if validation succeed, false otherwise
         */
        bool validate();

        /**
         * \brief Create a surface.
         * \param width width of the surface
         * \param height height of the surface
         * \return surface or NULL if problem
         */
        D3DSurface* createSurface(size_t width, size_t height);

        /**
         * \brief Render a surface on the screen.
         * \param surface surface to render on the screen
         */
        void render(D3DSurface* surface);

    private:
        /**
         * \brief Raw Direct3D device.
         */
        LPDIRECT3DDEVICE9 m_device;

        /**
         * \brief Settings of the device.
         */
        D3DPRESENT_PARAMETERS m_settings;

        /**
         * \brief Back surface.
         */
        LPDIRECT3DSURFACE9 m_backSurface;

        /**
         * \brief Width of the device.
         */
        size_t m_width;

        /**
         * \brief Height of the device.
         */
        size_t m_height;
};

#endif /* D3D_DEVICE_H */