Line | |
---|
1 | #include "Screen.h" |
---|
2 | #include "screen/ScreenShape.h" |
---|
3 | |
---|
4 | using namespace projection; |
---|
5 | |
---|
6 | /** |
---|
7 | * Constructor. |
---|
8 | * |
---|
9 | * @param pScreen Screen data. |
---|
10 | */ |
---|
11 | ScreenShape::ScreenShape(Screen* pScreen) |
---|
12 | { |
---|
13 | m_pScreen = pScreen; |
---|
14 | |
---|
15 | m_dlIndex = 0; |
---|
16 | m_bDirty = true; |
---|
17 | } |
---|
18 | |
---|
19 | /** |
---|
20 | * Destructor. |
---|
21 | */ |
---|
22 | ScreenShape::~ScreenShape() |
---|
23 | { |
---|
24 | if (glIsList(m_dlIndex)) |
---|
25 | glDeleteLists(m_dlIndex, 2); |
---|
26 | } |
---|
27 | |
---|
28 | /** |
---|
29 | * Draw the shape model in inherited class. |
---|
30 | * |
---|
31 | * @param bFrame True to draw a wire frame mesh. False to draw as a polygon model. |
---|
32 | */ |
---|
33 | void ScreenShape::draw(bool bFrame) |
---|
34 | { |
---|
35 | // cache the model in display lists. |
---|
36 | |
---|
37 | // update screen shape model, if modified |
---|
38 | if (m_bDirty) |
---|
39 | { |
---|
40 | if (glIsList(m_dlIndex)) |
---|
41 | glDeleteLists(m_dlIndex, 2); |
---|
42 | |
---|
43 | m_dlIndex = glGenLists(2); |
---|
44 | |
---|
45 | glNewList(m_dlIndex, GL_COMPILE); |
---|
46 | drawShape(false); |
---|
47 | glEndList(); |
---|
48 | |
---|
49 | glNewList(m_dlIndex+1, GL_COMPILE); |
---|
50 | drawShape(true); |
---|
51 | glEndList(); |
---|
52 | |
---|
53 | m_bDirty = false; |
---|
54 | } |
---|
55 | |
---|
56 | if (!bFrame) |
---|
57 | glCallList(m_dlIndex); |
---|
58 | else |
---|
59 | glCallList(m_dlIndex+1); |
---|
60 | } |
---|
61 | |
---|
62 | /** |
---|
63 | * Notify to redraw the screen shape. |
---|
64 | */ |
---|
65 | void ScreenShape::notifyRedraw() |
---|
66 | { |
---|
67 | m_bDirty = true; |
---|
68 | |
---|
69 | m_pScreen->notifyRedraw(); |
---|
70 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.