OSDN Git Service

directx/dx10/shader.hpp: set_primitive_topology(), draw(), draw_primitive() Add.
[roast/roast_ex_windows.git] / roast_ex / include / roast / graphics / directx / dx10 / shader.hpp
1 //      Roast+ License
2
3 #ifndef __SFJP_ROAST_EX__graphics__directx__dx10__shader_HPP__
4 #define __SFJP_ROAST_EX__graphics__directx__dx10__shader_HPP__
5
6 #include "roast/graphics/directx/dx10/device.hpp"
7 #include "roast/graphics/directx/dx10/buffer.hpp"
8
9 namespace roast
10 {
11         namespace directx
12         {
13                 namespace dx10
14                 {
15                         namespace graphics
16                         {
17                                 ///////////////////////////////////////////////////////////////////////////
18
19                                 class shader_device
20                                 {
21                                 public:
22                                         enum exception_codes
23                                         {
24                                                 exception_codes__head = exception_code_root::shader,
25
26                                                 buffer__CreateBuffer_Failed
27                                         };
28                                 protected:
29                                         device& m_dev;
30
31                                 public:
32                                         shader_device(device &d) : m_dev(d)
33                                         {
34                                         }
35
36                                         ///////////////
37
38                                         template <typename VERTEX_TYPE>
39                                         void set_vertex_buffer(const input_vertex_buffer<VERTEX_TYPE> &vb)// const OK...?
40                                         {
41                                                 typename const input_vertex_buffer<VERTEX_TYPE>::_IfType *buffer_ptr = vb.get_buffer_ptr();
42                                                 UINT stride = sizeof(VERTEX_TYPE);
43                                                 UINT offset = 0;
44                                                 m_dev.get_d3ddevice_ptr()->IASetVertexBuffers( 0, 1, (ID3D10Buffer *const *)&buffer_ptr, &stride, &offset );
45                                         }
46
47                                         void set_primitive_topology(::D3D10_PRIMITIVE_TOPOLOGY topology)
48                                         {
49                                                 m_dev.get_d3ddevice_ptr()->IASetPrimitiveTopology(topology);
50                                         }
51
52                                         void draw(UINT vertex_count, UINT vertex_offset=0)
53                                         {
54                                                 m_dev.get_d3ddevice_ptr()->Draw(vertex_count, vertex_offset);
55                                         }
56
57                                         void draw_primitive(::D3D10_PRIMITIVE_TOPOLOGY topology, UINT vertex_count, UINT vertex_offset=0)
58                                         {
59                                                 set_primitive_topology(topology);
60                                                 draw(vertex_count, vertex_offset);
61                                         }
62                                 };
63                                 typedef shader_device render_device, renderer;
64
65                                 ///////////////////////////////////////////////////////////////////////////
66                         }
67                 }
68         }
69 }
70
71 #endif//__SFJP_ROAST_EX__graphics__directx__dx10__shader_HPP__