NCBI C++ ToolKit
gldlist.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_OPENGL___GLDLIST__HPP
2 #define GUI_OPENGL___GLDLIST__HPP
3 
4 /* $Id: gldlist.hpp 14562 2007-05-18 11:48:21Z dicuccio $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Mike DiCuccio
30  *
31  * File Description:
32  * CGlDisplayList - manager for a single display list
33  * CGlDisplayListCompile - utility class to permit scoped creation of
34  * display lists.
35  */
36 
37 #include <corelib/ncbiobj.hpp>
38 #include <gui/opengl.h>
39 #include <gui/gui.hpp>
40 
41 /** @addtogroup GUI_OPENGL
42  *
43  * @{
44  */
45 
46 
48 
49 
50 /////////////////////////////////////////////////////////////////////////
51 // CGlDisplayList::
52 // Wrapper for an OpenGL display list. This class maintains (in addition)
53 // flags indicating whether the current display list should be re-created at
54 // the next attempt to render.
55 
57 {
58 public:
59  // Modes for creation
60  // These are straight from OpenGL - one simply remembers the commands, the
61  // other remebers the commands and performs their actions.
62  enum EMode {
63  eCompile = GL_COMPILE,
64  eCompileAndExecute = GL_COMPILE_AND_EXECUTE
65  };
66 
67  // ctor/dtor
69  ~CGlDisplayList();
70 
71  // Draw the display list
72  void Call() const;
73 
74  // Begin/End compilation of the display list
75  void Begin(GLenum mode);
76  void End();
77 
78  // Get/Set the current valid flag. This can be used to mark a display list
79  // for re-creation in a drawing loop.
80  bool IsValid(void) const { return m_IsValid; }
81  void Invalidate(void);
82 
83  // this
84  void Delete();
85 private:
86  GLuint m_DList;
87  bool m_IsValid;
88 
89  // initialize our display list, if it isn't already
90  void x_Init();
91 
92  // copying prohibited
95 };
96 
97 
98 inline
100 {
101  // we simply mark invalid - we can't delete our display list until we have
102  // a valid GL context
103  m_IsValid = false;
104 }
105 
106 
107 /////////////////////////////////////////////////////////////////////////
108 // CGlDisplayListCompile::
109 // This class mediates display list creation and compilation
110 // Creation and compilation can be accomplished via scoping a display list
111 // compiler:
112 //
113 // void Draw()
114 // {
115 // if (m_DList.IsValid()) {
116 // m_DList.Call();
117 // } else {
118 // CGlDisplayListCompile COMPILE(m_DList,
119 // CGlDisplayList::eCompileAndExecute);
120 //
121 // [...rendering commands...]
122 // }
123 // }
124 
126 {
127 public:
129 
130  CGlDisplayListCompile(CGlDisplayList& dlist, GLenum mode = GL_COMPILE);
132 
133 private:
135 };
136 
137 
139 
140 /* @} */
141 
142 #endif // GUI_OPENGL___GLDLIST__HPP
CObject –.
Definition: ncbiobj.hpp:180
CGlDisplayList & m_DList
Definition: gldlist.hpp:134
CGlDisplayList::EMode EMode
Definition: gldlist.hpp:128
GLuint m_DList
Definition: gldlist.hpp:86
bool IsValid(void) const
Definition: gldlist.hpp:80
bool m_IsValid
Definition: gldlist.hpp:87
CGlDisplayList(const CGlDisplayList &)
void Invalidate(void)
Definition: gldlist.hpp:99
CBeginInfo Begin(C &obj)
Get starting point of object hierarchy.
Definition: iterator.hpp:1004
CObject & operator=(const CObject &src) THROWS_NONE
Assignment operator.
Definition: ncbiobj.hpp:482
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_GUIOPENGL_EXPORT
Definition: gui_export.h:514
mdb_mode_t mode
Definition: lmdb++.h:38
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
Standard mechanism to include OpenGL headers for all platforms.
Modified on Wed May 22 11:33:31 2024 by modify_doxy.py rev. 669887